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

No-flux boundary condition (specific to Numa2D and Numa3D). More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <boundaryconditions.h>
#include <physicalmodels/numa2d.h>
#include <physicalmodels/numa3d.h>

Go to the source code of this file.

Functions

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

Detailed Description

No-flux boundary condition (specific to Numa2D and Numa3D).

Author
Debojyoti Ghosh

Definition in file BCNoFlux.c.

Function Documentation

◆ BCNoFluxU()

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

Applies the no-flux boundary conditions: This boundary condition is specific to the NUMA 2D/3D (Numa2D, Numa3D). Used for simulating inviscid walls or symmetry boundaries. It's equivalent to the slip-wall BC of the Euler/Navier- Stokes system.

The density, potential temperature, and tangential velocity are extrapolated, while the normal velocity at the ghost point is set to the negative of that in the interior (to enforce zero-normal velocity at the boundary face).

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 22 of file BCNoFlux.c.

32 {
33  DomainBoundary *boundary = (DomainBoundary*) b;
34 
35  int dim = boundary->dim;
36  int face = boundary->face;
37 
38  if (boundary->on_this_proc) {
39  int bounds[ndims], indexb[ndims], indexi[ndims];
40  _ArraySubtract1D_ (bounds,boundary->ie,boundary->is,ndims);
41  _ArraySetValue_ (indexb,ndims,0);
42  int done = 0;
43  while (!done) {
44  int p1, p2;
45  _ArrayCopy1D_ (indexb,indexi,ndims);
46  _ArrayAdd1D_ (indexi,indexi,boundary->is,ndims);
47  if (face == 1) indexi[dim] = ghosts-1-indexb[dim];
48  else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1;
49  else return(1);
50  _ArrayIndex1DWO_ (ndims,size,indexb,boundary->is,ghosts,p1);
51  _ArrayIndex1D_ (ndims,size,indexi,ghosts,p2);
52 
53  if (nvars == 4) {
54  phi[nvars*p1+0] = phi[nvars*p2+0];
55  phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] );
56  phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] );
57  phi[nvars*p1+3] = phi[nvars*p2+3];
58  } else if (nvars == 5) {
59  phi[nvars*p1+0] = phi[nvars*p2+0];
60  phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] );
61  phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] );
62  phi[nvars*p1+3] = (dim == _ZDIR_ ? -phi[nvars*p2+3] : phi[nvars*p2+3] );
63  phi[nvars*p1+4] = phi[nvars*p2+4];
64  }
65 
66  _ArrayIncrementIndex_(ndims,bounds,indexb,done);
67  }
68  }
69  return(0);
70 }
#define _ZDIR_
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
#define _ArrayAdd1D_(x, a, b, size)
#define _YDIR_
Definition: euler2d.h:41
#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 _XDIR_
Definition: euler1d.h:75
#define _ArrayCopy1D_(x, y, size)