Actual source code: pipe.h

  1: #ifndef PIPE_H
  2: #define PIPE_H

  4: #define GRAV                9.806
  5: #define PIPE_CHARACTERISTIC 10000000.0

  7: #include <petsc.h>

  9: typedef struct {
 10:   PetscScalar q; /* flow rate */
 11:   PetscScalar h; /* pressure */
 12: } PipeField;

 14: typedef struct {
 15:   PetscScalar Q0, H0; /* boundary values in upstream */
 16:   PetscScalar QL, HL; /* boundary values in downstream */
 17: } PipeBoundary;

 19: /* pipe                 */
 20: /*----------------------*/
 21: struct _p_Pipe {
 22:   /* identification variables */
 23:   PetscInt id;
 24:   PetscInt networkid; /* which network this pipe belongs */

 26:   /* solver objects */
 27:   Vec        x;
 28:   PipeField *xold;
 29:   PetscReal  dt;
 30:   DM         da;
 31:   PetscInt   nnodes; /* number of nodes in da discretization */
 32:   Mat       *jacobian;

 34:   /* physics */
 35:   PetscReal    length; /* pipe length */
 36:   PetscReal    a;      /* natural flow speed */
 37:   PetscReal    fric;   /* friction */
 38:   PetscReal    D;      /* diameter */
 39:   PetscReal    A;      /* area of cross section */
 40:   PetscReal    R;
 41:   PetscReal    rad;
 42:   PipeBoundary boundary; /* boundary conditions for H and Q */
 43: } PETSC_ATTRIBUTEALIGNED(PetscMax(sizeof(double), sizeof(PetscScalar)));

 45: typedef struct _p_Pipe *Pipe;

 47: extern PetscErrorCode PipeCreate(MPI_Comm, Pipe *);
 48: extern PetscErrorCode PipeDestroy(Pipe *);
 49: extern PetscErrorCode PipeSetParameters(Pipe, PetscReal, PetscReal, PetscReal, PetscReal);
 50: extern PetscErrorCode PipeSetUp(Pipe);
 51: extern PetscErrorCode PipeCreateJacobian(Pipe, Mat *, Mat *[]);
 52: extern PetscErrorCode PipeDestroyJacobian(Pipe);

 54: extern PetscErrorCode PipeComputeSteadyState(Pipe, PetscScalar, PetscScalar);
 55: extern PetscErrorCode PipeIFunctionLocal(DMDALocalInfo *, PetscReal, PipeField *, PipeField *, PipeField *, Pipe);
 56: extern PetscErrorCode PipeIFunctionLocal_Lax(DMDALocalInfo *, PetscReal, PipeField *, PipeField *, PetscScalar *, Pipe);
 57: extern PetscErrorCode PipeRHSFunctionLocal(DMDALocalInfo *, PetscReal, PipeField *, PetscScalar *, Pipe);
 58: extern PetscErrorCode PipeMonitor(TS, PetscInt, PetscReal, Vec, void *);

 60: extern PetscErrorCode PipeCreateJacobian(Pipe, Mat *, Mat *[]);
 61: extern PetscErrorCode PipeDestroyJacobian(Pipe);
 62: #endif