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

Extrapolation boundary condition. More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>

Go to the source code of this file.

Functions

int BCExtrapolateU (void *b, void *m, int ndims, int nvars, int *size, int ghosts, double *phi, double waqt)
 

Detailed Description

Extrapolation boundary condition.

Author
Debojyoti Ghosh

Definition in file BCExtrapolate.c.

Function Documentation

◆ BCExtrapolateU()

int BCExtrapolateU ( void *  b,
void *  m,
int  ndims,
int  nvars,
int *  size,
int  ghosts,
double *  phi,
double  waqt 
)

Apply the extrapolative boundary condition: Values at the physical boundary ghost points are extrapolated from the interior points adjacent to the boundary

Parameters
bBoundary object of type DomainBoundary
mMPI object of type MPIVariables
ndimsNumber of spatial dimensions
nvarsNumber of variables/DoFs per grid point
sizeInteger array with the number of grid points in each spatial dimension
ghostsNumber of ghost points
phiThe solution array on which to apply the boundary condition
waqtCurrent solution time

Definition at line 13 of file BCExtrapolate.c.

23 {
24  DomainBoundary *boundary = (DomainBoundary*) b;
25 
26  int dim = boundary->dim;
27  int face = boundary->face;
28 
29  if (boundary->on_this_proc) {
30  int bounds[ndims], indexb[ndims], indexi[ndims];
31  _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims);
32  _ArraySetValue_(indexb,ndims,0);
33  int done = 0;
34  while (!done) {
35  _ArrayCopy1D_(indexb,indexi,ndims);
36  _ArrayAdd1D_(indexi,indexi,boundary->is,ndims);
37  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
38  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
39  else return(1);
40  int p1,p2;
41  _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1);
42  _ArrayIndex1D_(ndims,size,indexi,ghosts,p2);
43  _ArrayCopy1D_((phi+nvars*p2),(phi+nvars*p1),nvars);
44  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
45  }
46  }
47  return(0);
48 }
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayAdd1D_(x, a, b, size)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _ArrayCopy1D_(x, y, size)