Actual source code: petsc-characteristicimpl.h
petsc-3.3-p3 2012-08-29
2: #ifndef __CHARACTERISTICIMPL_H
5: #include <petsccharacteristic.h>
7: /* Logging support */
8: PETSC_EXTERN PetscClassId CHARACTERISTIC_CLASSID;
9: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_SetUp, CHARACTERISTIC_Solve, CHARACTERISTIC_QueueSetup, CHARACTERISTIC_DAUpdate;
10: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_HalfTimeLocal, CHARACTERISTIC_HalfTimeRemote, CHARACTERISTIC_HalfTimeExchange;
11: PETSC_EXTERN PetscLogEvent CHARACTERISTIC_FullTimeLocal, CHARACTERISTIC_FullTimeRemote, CHARACTERISTIC_FullTimeExchange;
13: #define MAX_COMPONENTS 10
15: typedef struct _p_Item {
16: int proc; /* Relative processor from which data is required (mapped to absolute by neighbors) */
17: int i, j; /* The vertex for which we need field values */
18: PassiveScalar x, y; /* Coordinates of a point on the characteristic */
19: PassiveScalar u, v; /* Velocity of a point on the characteristic */
20: PassiveScalar field[MAX_COMPONENTS]; /* Field being advected */
21: } CharacteristicPointDA2D;
23: typedef CharacteristicPointDA2D *Queue;
25: struct _CharacteristicOps {
26: PetscErrorCode (*view)(Characteristic, PetscViewer);
27: PetscErrorCode (*destroy)(Characteristic);
28: PetscErrorCode (*setup)(Characteristic);
29: };
31: struct _p_Characteristic {
32: PETSCHEADER(struct _CharacteristicOps);
33: PetscInt setupcalled;
34: PetscBool structured; /* Flag for mesh type */
35: PetscInt numIds; /* Number of integers necessary to identify a mesh element */
36: /* Velocity interpolation structures */
37: DM velocityDA; /* DM for the velocity field */
38: Vec velocity; /* Velocity field at t_n */
39: Vec velocityOld; /* Velocity field at t_n-1 */
40: PetscInt numVelocityComp; /* Number of velocity components (should be the mesh dimension) */
41: PetscInt *velocityComp; /* Components of the velocity in the DM */
42: PetscErrorCode (*velocityInterp)(Vec, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
43: PetscErrorCode (*velocityInterpLocal)(void *, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
44: void *velocityCtx; /* User context for velocity inteprolation */
45: /* Field interpolation structures */
46: DM fieldDA; /* DM for the field field */
47: Vec field; /* Field field at t_n */
48: Vec fieldOld; /* Field field at t_n-1 */
49: PetscInt numFieldComp; /* Number of field components (should be the mesh dimension) */
50: PetscInt *fieldComp; /* Components of the field in the DM */
51: PetscErrorCode (*fieldInterp)(Vec, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
52: PetscErrorCode (*fieldInterpLocal)(void *, PetscReal [], PetscInt, PetscInt [], PetscScalar [], void *);
53: void *fieldCtx; /* User context for field inteprolation */
54: /* Communication structures*/
55: MPI_Datatype itemType; /* Type corresponding to the item struct */
56: Queue queue;
57: PetscInt queueSize;
58: PetscInt queueMax;
59: Queue queueLocal; /* Queue of Items to receive from other processes */
60: PetscInt queueLocalSize;
61: PetscInt queueLocalMax;
62: Queue queueRemote; /* Queue of Items to send to other processes */
63: PetscInt queueRemoteSize;
64: PetscInt queueRemoteMax;
65: PetscInt numNeighbors; /* Number of neighboring processes */
66: PetscMPIInt *neighbors; /* Ranks of neighbors */
67: PetscInt *needCount; /* Number of Items requested from other processes */
68: PetscInt *localOffsets; /* Offset into queue for each process (Prefix sums of need_count) */
69: PetscInt *fillCount; /* Number of Items requested by other processes */
70: PetscInt *remoteOffsets; /* Offset into remote queue for each process (Prefix sums of fill_count) */
71: MPI_Request *request; /* Requests for sizes/velocities/fields from other processes */
72: MPI_Status *status; /* Status structues for the persistent requests */
73: void *data; /* Holder for implementation class */
74: };
76: PETSC_EXTERN PetscErrorCode CharacteristicSetNeighbors(Characteristic, PetscInt, PetscMPIInt []);
77: PETSC_EXTERN PetscErrorCode CharacteristicAddPoint(Characteristic, CharacteristicPointDA2D *);
78: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesBegin(Characteristic);
79: PETSC_EXTERN PetscErrorCode CharacteristicSendCoordinatesEnd(Characteristic);
80: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesBegin(Characteristic);
81: PETSC_EXTERN PetscErrorCode CharacteristicGetValuesEnd(Characteristic);
83: PETSC_EXTERN PetscBool CharacteristicRegisterAllCalled;
84: PETSC_EXTERN PetscFList CharacteristicList;
86: #endif /*__CHARACTERISTICIMPL_H*/