HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
TimeGLMGEE.c File Reference

General Linear Methods with Global Error Estimators. More...

#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <simulation_object.h>
#include <timeintegration.h>

Go to the source code of this file.

Functions

int TimeGLMGEE (void *ts)
 

Detailed Description

General Linear Methods with Global Error Estimators.

Author
Debojyoti Ghosh

Definition in file TimeGLMGEE.c.

Function Documentation

◆ TimeGLMGEE()

int TimeGLMGEE ( void *  ts)

Advance the ODE given by

\begin{equation} \frac{d{\bf u}}{dt} = {\bf F} \left({\bf u}\right) \end{equation}

by one time step of size HyPar::dt using the \(s\)-stage General Linear Method with Global Error Estimation (GLM-GEE), given by

\begin{align} {\bf U}^{\left(i\right)} &= c_{i0}{\bf u}_n + \sum_{j=1}^{r-1} c_{ij} \tilde{\bf u}_n^j + \Delta t \sum_{j=1}^{i-1} a_{ij} {\bf F}\left({\bf U}^{\left(j\right)}\right), i=1,\cdots,s\\ {\bf u}_{n+1} &= d_{00} {\bf u}_n + \sum_{j=1}^{r-1} d_{0j} \tilde{\bf u}_n^j + \Delta t \sum_{j=1}^s b_{0j} {\bf F}\left({\bf U}^{\left(j\right)}\right), \\ \tilde{\bf u}_{n+1}^i &= d_{i0} {\bf u}_n + \sum_{j=1}^{r-1} d_{ij} \tilde{\bf u}_n^j + \Delta t \sum_{j=1}^s b_{ij} {\bf F}\left({\bf U}^{\left(j\right)}\right), i=1,\cdots,r-1 \end{align}

where the superscripts in parentheses represent stages, the subscripts represent the time level, the superscripts without parentheses represent auxiliary solutions, \(\Delta t\) is the time step size HyPar::dt, \(\tilde{\bf u}^i, i=1,\cdots,r-1\) are the auxiliary solutions, and \({\bf F}\left({\bf u}\right)\) is computed by TimeIntegration::RHSFunction. The coefficients defining this methods are:

where \(s\) is the number of stages (GLMGEEParameters::nstages) and \(r\) is the number of auxiliary solutions propagated with the solution (GLMGEEParameters::r).

Note: In the code TimeIntegration::Udot is equivalent to \({\bf F}\left({\bf u}\right)\).

References:

Parameters
tsObject of type TimeIntegration

Definition at line 45 of file TimeGLMGEE.c.

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],
138  sim[ns].solver.StepBoundaryIntegral,
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 }
Structure of variables/parameters and function pointers for time integration.
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
Structure defining a simulation.
int(* RHSFunction)(double *, double *, void *, void *, double)
#define _ArrayScaleCopy1D_(x, a, y, size)
#define _ArrayAXPY_(x, a, y, size)
#define _ArraySetValue_(x, size, value)
int(* PostStage)(double *, void *, void *, double)
Definition: hypar.h:336
void * msti
Definition: hypar.h:366
Structure containing the parameters for the General Linear Methods with Global Error Estimators (GLM-...
#define _DECLARE_IERR_
Definition: basic.h:17
#define _ArrayCopy1D_(x, y, size)