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

Compute the interpolated value of a provided variable on immersed body surface. More...

#include <stdio.h>
#include <stdlib.h>
#include <arrayfunctions.h>
#include <immersedboundaries.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int IBComputeFacetVar (void *s, void *m, const double *const var, int nvars, double **const face_var)
 

Detailed Description

Compute the interpolated value of a provided variable on immersed body surface.

Author
Debojyoti Ghosh

Definition in file IBComputeFacetVar.c.

Function Documentation

◆ IBComputeFacetVar()

int IBComputeFacetVar ( void *  s,
void *  m,
const double *const  var,
int  nvars,
double **const  face_var 
)

Calculate the interpolated value of a provided variables on the immersed body surface: for each "local facet", i.e., facets (of the immersed body surface) that lie within the local computational domain of this MPI rank, compute the interpolated value.

The variable should be a grid variable with size/layout the same as the solution variable (HyPar::u) with the appropriate number of ghost points.

If the incoming variable has multiple components, this function will calculate interpolated value of each component.

The grad var array should be NULL at input; at output, it will point to an array of size (ImmersedBoundary::nfacets_local X nvars) that contains the interpolated value at each local facet. If there are no local facets, it will remain NULL.

The interpolation is bi/tri-linear (second-order).

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables
varVariable to compute the interpolated value of
nvarsNumber of components in var
face_varArray to store the interpolated value; must be NULL at input

Definition at line 33 of file IBComputeFacetVar.c.

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.
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
#define _ArraySetValue_(x, size, value)
Structure of MPI-related variables.