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

Right-hand-side computation for explicit time integration. More...

#include <basic.h>
#include <arrayfunctions_gpu.h>
#include <mpivars.h>
#include <hypar.h>
#include <time.h>

Go to the source code of this file.

Functions

int TimeRHSFunctionExplicit (double *rhs, double *u, void *s, void *m, double t)
 

Detailed Description

Right-hand-side computation for explicit time integration.

Author
Debojyoti Ghosh, Youngdae Kim

Definition in file TimeRHSFunctionExplicit.c.

Function Documentation

int TimeRHSFunctionExplicit ( double *  rhs,
double *  u,
void *  s,
void *  m,
double  t 
)

This function computes the right-hand-side of the ODE given by

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

for explicit time integration methods, i.e., where

\begin{equation} {\bf F}\left({\bf u}\right) = - {\bf F}_{\rm hyperbolic}\left({\bf u}\right) + {\bf F}_{\rm parabolic} \left({\bf u}\right) + {\bf F}_{\rm source} \left({\bf u}\right), \end{equation}

given the solution \({\bf u}\) and the current simulation time.

Parameters
rhsArray to hold the computed right-hand-side
uArray holding the solution
sSolver object of type HyPar
mMPI object of type MPIVariables
tCurrent simulation time

Definition at line 30 of file TimeRHSFunctionExplicit.c.

37 {
38  HyPar *solver = (HyPar*) s;
39  MPIVariables *mpi = (MPIVariables*) m;
40  int d;
41 
42  int size = 1;
43  for (d=0; d<solver->ndims; d++) size *= (solver->dim_local[d]+2*solver->ghosts);
44 
45  /* apply boundary conditions and exchange data over MPI interfaces */
46  solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t);
47  solver->ApplyIBConditions(solver,mpi,u,t);
48 
49  /* Evaluate hyperbolic, parabolic and source terms and the RHS */
50 #if defined(HAVE_CUDA)
51  if (solver->use_gpu) {
53  solver->nvars,
54  solver->gpu_dim_local,
55  solver->ghosts,
56  mpi,
57  u );
58  } else {
59 #endif
61  solver->nvars,
62  solver->dim_local,
63  solver->ghosts,
64  mpi,
65  u);
66 #if defined(HAVE_CUDA)
67  }
68 #endif
69 
70  solver->HyperbolicFunction( solver->hyp,
71  u,
72  solver,
73  mpi,
74  t,
75  1,
76  solver->FFunction,
77  solver->Upwind );
78  solver->ParabolicFunction(solver->par,u,solver,mpi,t);
79  solver->SourceFunction(solver->source,u,solver,mpi,t);
80 
81 #if defined(HAVE_CUDA)
82  if (solver->use_gpu) {
83  gpuArraySetValue(rhs, size*solver->nvars, 0.0);
84  gpuArrayAXPY(solver->hyp, -1.0, rhs, size*solver->nvars);
85  gpuArrayAXPY(solver->par, 1.0, rhs, size*solver->nvars);
86  gpuArrayAXPY(solver->source, 1.0, rhs, size*solver->nvars);
87  } else {
88 #endif
89  _ArraySetValue_(rhs,size*solver->nvars,0.0);
90  _ArrayAXPY_(solver->hyp ,-1.0,rhs,size*solver->nvars);
91  _ArrayAXPY_(solver->par , 1.0,rhs,size*solver->nvars);
92  _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars);
93 #if defined(HAVE_CUDA)
94  }
95 #endif
96 
97  return(0);
98 }
double * hyp
Definition: hypar.h:119
void gpuArrayAXPY(const double *, double, double *, int)
#define _ArraySetValue_(x, size, value)
int(* Upwind)(double *, double *, double *, double *, double *, double *, int, void *, double)
Definition: hypar.h:295
int * dim_local
Definition: hypar.h:37
int(* FFunction)(double *, double *, int, void *, double)
Definition: hypar.h:276
void gpuArraySetValue(double *, int, double)
int(* ParabolicFunction)(double *, double *, void *, void *, double)
Definition: hypar.h:256
int ghosts
Definition: hypar.h:52
double * par
Definition: hypar.h:122
int * gpu_dim_local
Definition: hypar.h:455
double * source
Definition: hypar.h:125
int(* SourceFunction)(double *, double *, void *, void *, double)
Definition: hypar.h:259
int(* HyperbolicFunction)(double *, double *, void *, void *, double, int, int(*)(double *, double *, int, void *, double), int(*)(double *, double *, double *, double *, double *, double *, int, void *, double))
Definition: hypar.h:250
int nvars
Definition: hypar.h:29
int gpuMPIExchangeBoundariesnD(int, int, const int *, int, void *, double *)
int use_gpu
Definition: hypar.h:449
int ndims
Definition: hypar.h:26
int(* ApplyBoundaryConditions)(void *, void *, double *, double *, double)
Definition: hypar.h:214
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
Structure of MPI-related variables.
#define _ArrayAXPY_(x, a, y, size)
int(* ApplyIBConditions)(void *, void *, double *, double)
Definition: hypar.h:217
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23