Actual source code: petsc-characteristicimpl.h

petsc-3.4.5 2014-06-29
  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 PetscLogEvent CHARACTERISTIC_SetUp, CHARACTERISTIC_Solve, CHARACTERISTIC_QueueSetup, CHARACTERISTIC_DAUpdate;
 11: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_HalfTimeLocal, CHARACTERISTIC_HalfTimeRemote, CHARACTERISTIC_HalfTimeExchange;
 12: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_FullTimeLocal, CHARACTERISTIC_FullTimeRemote, CHARACTERISTIC_FullTimeExchange;

 14: #define MAX_COMPONENTS 10

 16: typedef struct _p_Item {
 17:   int           proc; /* Relative processor from which data is required (mapped to absolute by neighbors) */
 18:   int           i, j; /* The vertex for which we need field values */
 19:   PassiveScalar x, y; /* Coordinates of a point on the characteristic */
 20:   PassiveScalar u, v; /* Velocity of a point on the characteristic */
 21:   PassiveScalar field[MAX_COMPONENTS]; /* Field being advected */
 22: } CharacteristicPointDA2D;

 24: typedef CharacteristicPointDA2D *Queue;

 26: struct _CharacteristicOps {
 27:   PetscErrorCode (*view)(Characteristic, PetscViewer);
 28:   PetscErrorCode (*destroy)(Characteristic);
 29:   PetscErrorCode (*setup)(Characteristic);
 30: };

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

 77: PETSC_EXTERN PetscErrorCode CharacteristicSetNeighbors(Characteristic, PetscInt, PetscMPIInt []);
 78: PETSC_EXTERN PetscErrorCode CharacteristicAddPoint(Characteristic, CharacteristicPointDA2D *);
 79: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesBegin(Characteristic);
 80: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesEnd(Characteristic);
 81: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesBegin(Characteristic);
 82: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesEnd(Characteristic);

 84: #endif /*__CHARACTERISTICIMPL_H*/