HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ParabolicFunctionNC1Stage.c File Reference

Evaluate the parabolic term using a 1-stage finite-difference discretization. More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int ParabolicFunctionNC1Stage (double *par, double *u, void *s, void *m, double t)
 

Detailed Description

Evaluate the parabolic term using a 1-stage finite-difference discretization.

Author
Debojyoti Ghosh

Definition in file ParabolicFunctionNC1Stage.c.

Function Documentation

int ParabolicFunctionNC1Stage ( double *  par,
double *  u,
void *  s,
void *  m,
double  t 
)

Evaluate the parabolic term using a conservative finite-difference spatial discretization: The parabolic term is assumed to be of the form:

\begin{equation} {\bf P}\left({\bf u}\right) = \sum_{d=0}^{D-1} \frac {\partial^2 {\bf g}_d\left(\bf u\right)} {\partial x_d^2}, \end{equation}

which is discretized at a grid point as:

\begin{equation} \left.{\bf P}\left({\bf u}\right)\right|_j = \sum_{d=0}^{D-1} \frac { \mathcal{L}_d \left[ {\bf g}_d \right] } {\Delta x_d^2}, \end{equation}

where \(d\) is the spatial dimension index, \(D\) is the total number of spatial dimensions (HyPar::ndims), and \(j\) is the grid index along \(d\). \(\mathcal{L}_d\) represents the finite-difference approximation to the Laplacian along the \(d\) spatial dimension, computed using HyPar::SecondDerivativePar.

Note: this form of the parabolic term does not allow for cross-derivatives.

To use this form of the parabolic term:

Parameters
pararray to hold the computed parabolic term
usolution
sSolver object of type HyPar
mMPI object of type MPIVariables
tCurrent simulation time

Definition at line 31 of file ParabolicFunctionNC1Stage.c.

38 {
39  HyPar *solver = (HyPar*) s;
40  MPIVariables *mpi = (MPIVariables*) m;
41  double *Func = solver->fluxC;
42  double *Deriv2 = solver->Deriv2;
43  int d, v, i, done;
45 
46  int ndims = solver->ndims;
47  int nvars = solver->nvars;
48  int ghosts = solver->ghosts;
49  int *dim = solver->dim_local;
50  double *dxinv = solver->dxinv;
51  int size = solver->npoints_local_wghosts;
52 
53  if (!solver->GFunction) return(0); /* zero parabolic terms */
54  solver->count_par++;
55 
56  int index[ndims];
57  _ArraySetValue_(par,size*nvars,0.0);
58 
59  int offset = 0;
60  for (d = 0; d < ndims; d++) {
61  int size_deriv = 1; for (i=0; i<ndims; i++) size_deriv *= dim[i];
62 
63  /* calculate the diffusion function */
64  IERR solver->GFunction(Func,u,d,solver,t); CHECKERR(ierr);
65  IERR solver->SecondDerivativePar(Deriv2,Func,d,solver,mpi); CHECKERR(ierr);
66 
67  /* calculate the final term - second derivative of the diffusion function */
68  done = 0; _ArraySetValue_(index,ndims,0);
69  int p;
70  while (!done) {
71  _ArrayIndex1D_(ndims,dim,index,ghosts,p);
72  for (v=0; v<nvars; v++)
73  par[nvars*p+v] += ( dxinv[offset+ghosts+index[d]]*dxinv[offset+ghosts+index[d]]
74  * Deriv2[nvars*p+v] );
75  _ArrayIncrementIndex_(ndims,dim,index,done);
76  }
77 
78  offset += dim[d] + 2*ghosts;
79  }
80 
81  if (solver->flag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars);
82  return(0);
83 }
int npoints_local_wghosts
Definition: hypar.h:42
#define _ArraySetValue_(x, size, value)
double * iblank
Definition: hypar.h:436
#define _ArrayIncrementIndex_(N, imax, i, done)
double * Deriv2
Definition: hypar.h:151
int flag_ib
Definition: hypar.h:441
int * dim_local
Definition: hypar.h:37
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int count_par
Definition: hypar.h:418
#define _ArrayBlockMultiply_(x, a, n, bs)
double * fluxC
Definition: hypar.h:128
int nvars
Definition: hypar.h:29
#define CHECKERR(ierr)
Definition: basic.h:18
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
int(* SecondDerivativePar)(double *, double *, int, void *, void *)
Definition: hypar.h:247
#define IERR
Definition: basic.h:16
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int(* GFunction)(double *, double *, int, void *, double)
Definition: hypar.h:310
#define _DECLARE_IERR_
Definition: basic.h:17