HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
IBComputeFacetVar.c
Go to the documentation of this file.
1 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <arrayfunctions.h>
9 #include <immersedboundaries.h>
10 #include <mpivars.h>
11 #include <hypar.h>
12 
33 int IBComputeFacetVar(void* s,
34  void* m,
35  const double* const var,
36  int nvars,
37  double** const face_var
39  )
40 {
41  HyPar *solver = (HyPar*) s;
42  MPIVariables *mpi = (MPIVariables*) m;
43  ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib;
44 
45  if (!solver->flag_ib) return(0);
46 
47  if ((*face_var) != NULL) {
48  fprintf(stderr,"Error in IBComputeFacetVar()\n");
49  fprintf(stderr," face_var is not NULL on rank %d\n",
50  mpi->rank );
51  return 1;
52  }
53 
54  int nfacets_local = IB->nfacets_local;
55  FacetMap *fmap = IB->fmap;
56 
57  if (nfacets_local > 0) {
58  (*face_var) = (double*) calloc (nvars*nfacets_local, sizeof(double));
59 
60  for (int n = 0; n < nfacets_local; n++) {
61 
62  double *alpha;
63  int *nodes, j, k;
64 
65  double *v_c = (*face_var) + n*nvars;
66  alpha = &(fmap[n].interp_coeffs[0]);
67  nodes = &(fmap[n].interp_nodes[0]);
68  _ArraySetValue_(v_c,nvars,0.0);
69  for (j=0; j<_IB_NNODES_; j++) {
70  for (k=0; k<nvars; k++) {
71  v_c[k] += ( alpha[j] * var[nvars*nodes[j]+k] );
72  }
73  }
74  }
75 
76  }
77 
78  return(0);
79 }
double interp_coeffs[_IB_NNODES_]
Structure defining a facet map.
#define _IB_NNODES_
Structure containing variables for immersed boundary implementation.
MPI related function definitions.
int IBComputeFacetVar(void *s, void *m, const double *const var, int nvars, double **const face_var)
void * ib
Definition: hypar.h:443
int interp_nodes[_IB_NNODES_]
int flag_ib
Definition: hypar.h:441
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
#define _ArraySetValue_(x, size, value)
Structures and function definitions for immersed boundaries.
Structure of MPI-related variables.
Contains macros and function definitions for common array operations.