HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LinearADRDiffusion.c
Go to the documentation of this file.
1 
7 #include <stdlib.h>
8 #include <basic.h>
9 #include <arrayfunctions.h>
11 #include <mpivars.h>
12 #include <hypar.h>
13 
26 int LinearADRDiffusionG( double *f,
27  double *u,
28  int dir,
29  void *s,
30  double t
31  )
32 {
33  HyPar *solver = (HyPar*) s;
34  LinearADR *param = (LinearADR*) solver->physics;
35  int i, v;
36 
37  int *dim = solver->dim_local;
38  int ghosts = solver->ghosts;
39  int ndims = solver->ndims;
40  int nvars = solver->nvars;
41  int index[ndims], bounds[ndims], offset[ndims];
42 
43  /* set bounds for array index to include ghost points */
44  _ArrayCopy1D_(dim,bounds,ndims);
45  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
46 
47  /* set offset such that index is compatible with ghost point arrangement */
48  _ArraySetValue_(offset,ndims,-ghosts);
49 
50  int done = 0; _ArraySetValue_(index,ndims,0);
51  while (!done) {
52  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
53  for (v = 0; v < nvars; v++) f[nvars*p+v] = param->d[nvars*dir+v] * u[nvars*p+v];
54  _ArrayIncrementIndex_(ndims,bounds,index,done);
55  }
56 
57  return(0);
58 }
59 
74 int LinearADRDiffusionH( double *f,
75  double *u,
76  int dir1,
77  int dir2,
78  void *s,
79  double t
80  )
81 {
82  HyPar *solver = (HyPar*) s;
83  LinearADR *param = (LinearADR*) solver->physics;
84  int i, v;
85 
86  int *dim = solver->dim_local;
87  int ghosts = solver->ghosts;
88  int ndims = solver->ndims;
89  int nvars = solver->nvars;
90  int index[ndims], bounds[ndims], offset[ndims];
91 
92  if (dir1 == dir2) {
93 
94  int dir = dir1;
95 
96  /* set bounds for array index to include ghost points */
97  _ArrayCopy1D_(dim,bounds,ndims);
98  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
99 
100  /* set offset such that index is compatible with ghost point arrangement */
101  _ArraySetValue_(offset,ndims,-ghosts);
102 
103  int done = 0; _ArraySetValue_(index,ndims,0);
104  while (!done) {
105  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
106  for (v = 0; v < nvars; v++) f[nvars*p+v] = param->d[nvars*dir+v] * u[nvars*p+v];
107  _ArrayIncrementIndex_(ndims,bounds,index,done);
108  }
109 
110  } else _ArraySetValue_(f,solver->npoints_local_wghosts*nvars,0.0);
111 
112 
113  return(0);
114 }
int npoints_local_wghosts
Definition: hypar.h:42
#define _ArraySetValue_(x, size, value)
double * d
Definition: linearadr.h:53
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
Structure containing variables and parameters specific to the linear advection-diffusion-reaction mod...
Definition: linearadr.h:37
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
Linear Advection-Diffusion-Reaction model.
int ghosts
Definition: hypar.h:52
int LinearADRDiffusionG(double *f, double *u, int dir, void *s, double t)
int LinearADRDiffusionH(double *f, double *u, int dir1, int dir2, void *s, double t)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArrayCopy1D_(x, y, size)
int nvars
Definition: hypar.h:29
Contains structure definition for hypar.
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23