HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TimeGLMGEE.c
Go to the documentation of this file.
1 
6 #include <string.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
9 #include <simulation_object.h>
10 #include <timeintegration.h>
11 
45 int TimeGLMGEE(void *ts )
46 {
47  TimeIntegration* TS = (TimeIntegration*) ts;
49  GLMGEEParameters* params = (GLMGEEParameters*) sim[0].solver.msti;
50  int ns, stage, i, j, nsims = TS->nsims;
52 
53  int s = params->nstages;
54  int r = params->r;
55  double dt = TS->dt;
56  double *A =params->A,
57  *B =params->B,
58  *C=params->C,
59  *D=params->D,
60  *c=params->c,
61  **U = TS->U,
62  **Udot = TS->Udot,
63  **Uaux = &TS->U[r];
64 
65  /* Calculate stage values */
66  for (j=0; j<s; j++) {
67 
68  double stagetime = TS->waqt + c[j]*dt;
69 
70  for (ns = 0; ns < nsims; ns++) {
71  _ArrayScaleCopy1D_( sim[ns].solver.u,
72  C[j*r+0],
73  (U[0] + TS->u_offsets[ns]),
74  (TS->u_sizes[ns]) );
75  }
76 
77  for (i=1;i<r;i++) _ArrayAXPY_(Uaux[i-1], C[j*r+i] , U[0], TS->u_size_total);
78  for (i=0;i<j;i++) _ArrayAXPY_(Udot[i] , dt*A[j*s+i], U[0], TS->u_size_total);
79 
80  for (ns = 0; ns < nsims; ns++) {
81  if (sim[ns].solver.PreStage) {
82  fprintf(stderr,"Call to solver->PreStage() commented out in TimeGLMGEE()!\n");
83  return 1;
84 // IERR sim[ns].solver.PreStage( stage,
85 // (U),
86 // &(sim[ns].solver),
87 // &(sim[ns].mpi),
88 // stagetime ); CHECKERR(ierr);
89  }
90  }
91 
92  for (ns = 0; ns < nsims; ns++) {
93  IERR TS->RHSFunction( (Udot[j] + TS->u_offsets[ns]),
94  (U[0] + TS->u_offsets[ns]),
95  &(sim[ns].solver),
96  &(sim[ns].mpi),
97  stagetime);
98  }
99 
100  for (ns = 0; ns < nsims; ns++) {
101  if (sim[ns].solver.PostStage) {
102  IERR sim[ns].solver.PostStage( (U[j] + TS->u_offsets[ns]),
103  &(sim[ns].solver),
104  &(sim[ns].mpi),
105  stagetime); CHECKERR(ierr);
106  }
107  }
108 
109  _ArraySetValue_(TS->BoundaryFlux[j], TS->bf_size_total, 0.0);
110  for (ns = 0; ns < nsims; ns++) {
111  _ArrayCopy1D_( sim[ns].solver.StageBoundaryIntegral,
112  (TS->BoundaryFlux[j] + TS->bf_offsets[ns]),
113  TS->bf_sizes[ns] );
114  }
115  }
116 
117  /* Step completion */
118  for (j=0; j<r; j++) {
119 
120  for (ns = 0; ns < nsims; ns++) {
121 
122  _ArrayScaleCopy1D_( sim[ns].solver.u,
123  D[j*r+0],
124  (U[j]+TS->u_offsets[ns]),
125  (TS->u_sizes[ns]) );
126 
127  }
128 
129  for (i=1; i<r; i++) _ArrayAXPY_(Uaux[i-1], D[j*r+i] , U[j], TS->u_size_total);
130  for (i=0; i<s; i++) _ArrayAXPY_(Udot[i] , dt*B[j*s+i], U[j], TS->u_size_total);
131 
132  }
133 
134  for (ns = 0; ns < nsims; ns++) {
135  for (i=0; i<s; i++) {
136  _ArrayAXPY_( (TS->BoundaryFlux[i] + TS->bf_offsets[ns]),
137  dt*B[0*s+i],
139  TS->bf_sizes[ns] );
140  }
141 
142  }
143 
144  for (ns = 0; ns < nsims; ns++) {
145  _ArrayCopy1D_( (U[0] + TS->u_offsets[ns]),
146  sim[ns].solver.u,
147  TS->u_sizes[ns] );
148  }
149  for (i=1; i<r; i++) {
150  _ArrayCopy1D_(U[i],Uaux[i-1],TS->u_size_total);
151  }
152 
153  return(0);
154 }
155 
int(* RHSFunction)(double *, double *, void *, void *, double)
#define _ArraySetValue_(x, size, value)
double * u
Definition: hypar.h:116
#define _ArrayScaleCopy1D_(x, a, y, size)
Structure of variables/parameters and function pointers for time integration.
int(* PostStage)(double *, void *, void *, double)
Definition: hypar.h:336
double * StepBoundaryIntegral
Definition: hypar.h:384
int TimeGLMGEE(void *)
Definition: TimeGLMGEE.c:45
Structure containing the parameters for the General Linear Methods with Global Error Estimators (GLM-...
Simulation object.
#define _ArrayCopy1D_(x, y, size)
#define CHECKERR(ierr)
Definition: basic.h:18
Contains function declarations for time integration.
void * msti
Definition: hypar.h:366
Structure defining a simulation.
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
#define IERR
Definition: basic.h:16
#define _ArrayAXPY_(x, a, y, size)
#define _DECLARE_IERR_
Definition: basic.h:17