Actual source code: characteristicimpl.h
petsc-3.12.4 2020-02-04
Report Typos and Errors

      2: #ifndef __CHARACTERISTICIMPL_H

      5:  #include <petsccharacteristic.h>
      6:  #include <petsc/private/petscimpl.h>

      8: /* Logging support */
      9: PETSC_EXTERN PetscClassId CHARACTERISTIC_CLASSID;
     10: PETSC_EXTERN PetscBool        CharacteristicRegisterAllCalled;
     11: PETSC_EXTERN PetscErrorCode   CharacteristicRegisterAll(void);
     12: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_SetUp;
     13: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_Solve;
     14: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_QueueSetup;
     15: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_DAUpdate;
     16: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_HalfTimeLocal;
     17: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_HalfTimeRemote;
     18: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_HalfTimeExchange;
     19: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_FullTimeLocal;
     20: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_FullTimeRemote;
     21: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_FullTimeExchange;

     23: #define MAX_COMPONENTS 10

     25: typedef struct _p_Item {
     26:   int           proc; /* Relative processor from which data is required (mapped to absolute by neighbors) */
     27:   int           i, j; /* The vertex for which we need field values */
     28:   PetscScalar   x, y; /* Coordinates of a point on the characteristic */
     29:   PetscScalar   u, v; /* Velocity of a point on the characteristic */
     30:   PetscScalar   field[MAX_COMPONENTS]; /* Field being advected */
     31: } CharacteristicPointDA2D;

     33: typedef CharacteristicPointDA2D *Queue;

     35: struct _CharacteristicOps {
     36:   PetscErrorCode (*view)(Characteristic, PetscViewer);
     37:   PetscErrorCode (*destroy)(Characteristic);
     38:   PetscErrorCode (*setup)(Characteristic);
     39: };

     41: struct _p_Characteristic {
     42:   PETSCHEADER(struct _CharacteristicOps);
     43:   PetscInt     setupcalled;
     44:   PetscBool    structured;      /* Flag for mesh type */
     45:   PetscInt     numIds;          /* Number of integers necessary to identify a mesh element */
     46:   /* Velocity interpolation structures */
     47:   DM           velocityDA;      /* DM for the velocity field */
     48:   Vec          velocity;        /* Velocity field at t_n */
     49:   Vec          velocityOld;     /* Velocity field at t_n-1 */
     50:   PetscInt     numVelocityComp; /* Number of velocity components (should be the mesh dimension) */
     51:   PetscInt    *velocityComp;    /* Components of the velocity in the DM */
     52:   PetscErrorCode (*velocityInterp)(Vec, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
     53:   PetscErrorCode (*velocityInterpLocal)(void *, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
     54:   void        *velocityCtx;     /* User context for velocity inteprolation */
     55:   /* Field interpolation structures */
     56:   DM           fieldDA;         /* DM for the field field */
     57:   Vec          field;           /* Field field at t_n */
     58:   Vec          fieldOld;        /* Field field at t_n-1 */
     59:   PetscInt     numFieldComp;    /* Number of field components (should be the mesh dimension) */
     60:   PetscInt    *fieldComp;       /* Components of the field in the DM */
     61:   PetscErrorCode (*fieldInterp)(Vec, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
     62:   PetscErrorCode (*fieldInterpLocal)(void *, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
     63:   void        *fieldCtx;        /* User context for field inteprolation */
     64:   /* Communication structures*/
     65:   MPI_Datatype itemType;        /* Type corresponding to the item struct */
     66:   Queue        queue;
     67:   PetscInt     queueSize;
     68:   PetscInt     queueMax;
     69:   Queue        queueLocal;      /* Queue of Items to receive from other processes */
     70:   PetscInt     queueLocalSize;
     71:   PetscInt     queueLocalMax;
     72:   Queue        queueRemote;     /* Queue of Items to send to other processes */
     73:   PetscInt     queueRemoteSize;
     74:   PetscInt     queueRemoteMax;
     75:   PetscInt     numNeighbors;    /* Number of neighboring processes */
     76:   PetscMPIInt *neighbors;       /* Ranks of neighbors */
     77:   PetscInt    *needCount;       /* Number of Items requested from other processes */
     78:   PetscInt    *localOffsets;    /* Offset into queue for each process (Prefix sums of need_count) */
     79:   PetscInt    *fillCount;       /* Number of Items requested by other processes */
     80:   PetscInt    *remoteOffsets;   /* Offset into remote queue for each process (Prefix sums of fill_count) */
     81:   MPI_Request *request;         /* Requests for sizes/velocities/fields from other processes */
     82:   MPI_Status  *status;          /* Status structues for the persistent requests */
     83:   void        *data;            /* Holder for implementation class */
     84: };

     86: PETSC_EXTERN PetscErrorCode CharacteristicSetNeighbors(Characteristic, PetscInt, PetscMPIInt []);
     87: PETSC_EXTERN PetscErrorCode CharacteristicAddPoint(Characteristic, CharacteristicPointDA2D *);
     88: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesBegin(Characteristic);
     89: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesEnd(Characteristic);
     90: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesBegin(Characteristic);
     91: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesEnd(Characteristic);

     93: #endif /*__CHARACTERISTICIMPL_H*/