HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Structures and function definitions for immersed boundaries. More...
#include <basic.h>
Go to the source code of this file.
Data Structures | |
struct | Facet3D |
Structure defining a facet. More... | |
struct | FacetMap |
Structure defining a facet map. More... | |
struct | Body3D |
Structure defining a body. More... | |
struct | IBNode |
Structure defining an immersed boundary node. More... | |
struct | ImmersedBoundary |
Structure containing variables for immersed boundary implementation. More... | |
Macros | |
#define | _IB_NDIMS_ 3 |
#define | _IB_NNODES_ 8 |
#define | _IB_XY_ "2d (xy)" |
#define | _IB_XZ_ "2d (xz)" |
#define | _IB_YZ_ "2d (yz)" |
#define | _IB_3D_ "3d" |
Functions | |
int | IBReadBodySTL (Body3D **, char *, void *, int *) |
int | IBWriteBodySTL (Body3D *, char *, void *, int, int *) |
int | IBCleanup (void *) |
int | IBComputeBoundingBox (Body3D *) |
int | IBCreateFacetMapping (void *, void *, double *, int *, int) |
int | IBIdentifyBody (void *, int *, int *, int, void *, double *, double *) |
int | IBIdentifyBoundary (void *, void *, int *, int, double *) |
int | IBIdentifyMode (double *, int *, void *) |
int | IBNearestFacetNormal (void *, void *, double *, double, int *, int) |
int | IBInterpCoeffs (void *, void *, double *, int *, int, double *) |
int | IBAssembleGlobalFacetData (void *, void *, const double *const, double **const, int) |
int | IBComputeNormalGradient (void *, void *, const double *const, int, double **const) |
int | IBComputeFacetVar (void *, void *, const double *const, int, double **const) |
Structures and function definitions for immersed boundaries.
Definition in file immersedboundaries.h.
struct Facet3D |
Structure defining a facet.
A "facet" is the basic unit of a tessellated surface in 3D: It is a triangle in an unstructured triangulated surface, defined by its vertices and surface normal.
Definition at line 39 of file immersedboundaries.h.
struct FacetMap |
Structure defining a facet map.
A facet map contains information for facets that lie within the local computational domain of this MPI rank.
Definition at line 67 of file immersedboundaries.h.
Data Fields | ||
---|---|---|
Facet3D * | facet |
pointer to the facet |
int | index |
index of this facet in the array Body3D::surface |
int | interp_nodes[_IB_NNODES_] |
indices of grid points surrounding the facet centroid |
double | interp_coeffs[_IB_NNODES_] |
interpolation coefficients corresponding to FacetMap::interp_nodes |
int | interp_nodes_ns[_IB_NNODES_] |
indices of grid points surrounding the "near-surface" point near the centroid |
double | interp_coeffs_ns[_IB_NNODES_] |
interpolation coefficients corresponding to FacetMap::interp_nodes_ns |
double | xc |
x-coordinate of centroid of FacetMap::facet |
double | yc |
y-coordinate of centroid of FacetMap::facet |
double | zc |
z-coordinate of centroid of FacetMap::facet |
double | xns |
x-coordinate of "near surface" point of FacetMap::facet |
double | yns |
y-coordinate of "near surface" point of FacetMap::facet |
double | zns |
z-coordinate of "near surface" point of FacetMap::facet |
double | dx | |
double | dy | |
double | dz |
struct Body3D |
Structure defining a body.
A 3D body whose surface is represented as a collection of faces of type Facet3D.
Definition at line 100 of file immersedboundaries.h.
Data Fields | ||
---|---|---|
int | nfacets |
number of surface facets |
Facet3D * | surface |
array of surface facets |
double | xmin |
x-coordinate of lower end of bounding box |
double | xmax |
x-coordinate of higher end of bounding box |
double | ymin |
y-coordinate of lower end of bounding box |
double | ymax |
y-coordinate of higher end of bounding box |
double | zmin |
z-coordinate of lower end of bounding box |
double | zmax |
z-coordinate of higher end of bounding box |
struct IBNode |
Structure defining an immersed boundary node.
An immersed boundary node is a grid point inside the immersed body but within stencil-width-distance of a point outside the body.
Definition at line 125 of file immersedboundaries.h.
Data Fields | ||
---|---|---|
int | i |
grid index along x |
int | j |
grid index along y |
int | k |
grid index along z |
int | p |
array index of this point |
double | x |
x-coordinate of the boundary node |
double | y |
y-coordinate of the boundary node |
double | z |
z-coordinate of the boundary node |
Facet3D * | face |
the nearest facet of ImmersedBoundary::body |
int | interp_nodes[_IB_NNODES_] |
indices of interior nodes from which to extrapolate |
double | interp_coeffs[_IB_NNODES_] |
interpolation coefficients corresponding to IBNode::interp_nodes |
double | interp_node_distance |
Distance from the immersed body surface to the interior node from which to extrapolate |
double | surface_distance |
Distance from this node to the immersed body surface |
struct ImmersedBoundary |
Structure containing variables for immersed boundary implementation.
This structure contains all the variables needed to implement immersed boundaries.
Definition at line 153 of file immersedboundaries.h.
Data Fields | ||
---|---|---|
Body3D * | body |
immersed body |
IBNode * | boundary |
immersed boundary nodes |
FacetMap * | fmap |
list of "local" facets |
double | tolerance |
zero tolerance |
double | delta |
small number |
int | itr_max |
maximum intersections in ray-tracing method |
int | n_boundary_nodes |
number of immersed boundary nodes |
int | nfacets_local |
number of "local" facets |
char | mode[_MAX_STRING_SIZE_] |
identifies if the simulation is 2D along a plane or truly 3D.
|
#define _IB_NDIMS_ 3 |
Immersed boundaries are implemented only for 3-dimensional simulations.
Definition at line 10 of file immersedboundaries.h.
#define _IB_NNODES_ 8 |
Number of grid points surrounding a random point in space, i.e., number of corners of a cube.
Definition at line 13 of file immersedboundaries.h.
#define _IB_XY_ "2d (xy)" |
"Pseudo-2D" simulation in the x-y plane
Definition at line 16 of file immersedboundaries.h.
#define _IB_XZ_ "2d (xz)" |
"Pseudo-2D" simulation in the x-z plane
Definition at line 18 of file immersedboundaries.h.
#define _IB_YZ_ "2d (yz)" |
"Pseudo-2D" simulation in the y-z plane
Definition at line 20 of file immersedboundaries.h.
#define _IB_3D_ "3d" |
3D simulation
Definition at line 22 of file immersedboundaries.h.
int IBReadBodySTL | ( | Body3D ** | body, |
char * | filename, | ||
void * | m, | ||
int * | stat | ||
) |
Function to read a 3D surface from a STL file. See https://en.wikipedia.org/wiki/STL_(file_format) for details of the STL file format. Notes:
body | 3D body to be allocated and read from file |
filename | Filename |
m | MPI object of type MPIVariables |
stat | Status (0: success; non-0: failure) |
Definition at line 21 of file IBReadBodySTL.c.
int IBWriteBodySTL | ( | Body3D * | body, |
char * | filename, | ||
void * | m, | ||
int | rank, | ||
int * | stat | ||
) |
Function to write a 3D surface from a STL file. See https://en.wikipedia.org/wiki/STL_(file_format) for details of the STL file format. Notes:
It is assumed that all MPI ranks have the body data. The MPI rank specified as the input rank will actually write the file.
body | 3D body to write to file |
filename | Filename |
m | MPI object of type MPIVariables |
rank | MPI rank that does the writing |
stat | Status (0: success; non-0: failure) |
Definition at line 23 of file IBWriteBodySTL.c.
int IBCleanup | ( | void * | ) |
Definition at line 11 of file IBCleanup.c.
int IBComputeBoundingBox | ( | Body3D * | b | ) |
Compute the bounding box for a given body.
b | The body |
Definition at line 9 of file IBComputeBoundingBox.c.
int IBCreateFacetMapping | ( | void * | ib, |
void * | m, | ||
double * | X, | ||
int * | dim, | ||
int | ghosts | ||
) |
This function creates a "facet map", i.e., on each MPI rank, it does the following:
Note: each MPI rank has a copy of the entire immersed body, i.e., all the facets.
ib | Immersed boundary object of type ImmersedBoundary |
m | MPI object of type MPIVariables |
X | Array of local spatial coordinates |
dim | Local dimensions |
ghosts | Number of ghost points |
Definition at line 143 of file IBCreateFacetMapping.c.
int IBIdentifyBody | ( | void * | ib, |
int * | dim_g, | ||
int * | dim_l, | ||
int | ghosts, | ||
void * | m, | ||
double * | X, | ||
double * | blank | ||
) |
Identify the grid points of the given grid that are inside a given body whose surface is defined as an unstructured triangulation. This function uses the ray-tracing method and is a copy of a FORTRAN function originally written by Dr. Jay Sitaraman.
ib | Immersed boundary object of type ImmersedBoundary |
dim_g | global dimensions |
dim_l | local dimensions |
ghosts | number of ghost points |
m | MPI object of type MPIVariables |
X | Array of global spatial coordinates |
blank | Blanking array: for grid points within the body, this value will be set to 0 |
Definition at line 20 of file IBIdentifyBody.c.
int IBIdentifyBoundary | ( | void * | ib, |
void * | m, | ||
int * | dim_l, | ||
int | ghosts, | ||
double * | blank | ||
) |
Identify the immersed boundary points: an immersed boundary point is any grid point inside the immersed body that is within stencil-width-distance of a grid point outside the immersed body. This function does the following:
ib | Immersed boundary object of type ImmersedBoundary |
m | MPI object of type MPIVariables |
dim_l | local dimensions |
ghosts | number of ghost points |
blank | Blanking array: for grid points within the immersed body, this value will be set to 0 |
Definition at line 158 of file IBIdentifyBoundary.c.
int IBIdentifyMode | ( | double * | X, |
int * | dim, | ||
void * | ib | ||
) |
Identify the "mode", i.e., whether the simulation is a true 3D simulation, or a 2D simulation being run in 3D. If extent of the immersed body is larger than the grid along a particular axis (say, x), then we assume that the intention is to simulate a 2D case around a 2D body in the plane normal to that axis ( y-z plane ).
For example, to simulate a 2D cylinder in the x-y plane, we consider a cylinder whose extent along z is larger than the extent of the grid along z, i.e., it sticks out of the computational domain at both ends.
If the immersed body is completely contained within the computational domain, or sticks out only on one end along a particular dimension, we assume it's a 3D simulation.
X | Array of global spatial coordinates |
dim | global dimensions |
ib | Immersed boundary object of type ImmersedBoundary |
Definition at line 24 of file IBIdentifyMode.c.
int IBNearestFacetNormal | ( | void * | ib, |
void * | m, | ||
double * | X, | ||
double | large_distance, | ||
int * | dim_l, | ||
int | ghosts | ||
) |
For each immersed boundary point, find the nearest facet (Facet3D) of the immersed body (ImmersedBoundary::body). The "nearest" facet is the one which is closest to the boundary point in terms of the distance along the normal defined for that facet.
Note: This function is sensitive to the fact that the normals defined for the immersed body are the outward normals, i.e., pointing away from the body. If this function returns an error, make sure this is true in the STL file the body is defined in.
ib | Immersed boundary object of type ImmersedBoundary |
m | MPI object of type MPIVariables |
X | Array of (local) spatial coordinates |
large_distance | A large distance |
dim_l | Integer array of local grid size in each spatial dimension |
ghosts | Number of ghost points |
Definition at line 25 of file IBNearestFacetNormal.c.
int IBInterpCoeffs | ( | void * | ib, |
void * | m, | ||
double * | X, | ||
int * | dim_l, | ||
int | ghosts, | ||
double * | blank | ||
) |
Compute the interpolation nodes and coefficients for immersed boundary points: For each immersed boundary point, do the following:
ib | Immersed boundary object of type ImmersedBoundary |
m | MPI object of type MPIVariables |
X | Array of (local) spatial coordinates |
dim_l | Integer array of local grid size in each spatial dimension |
ghosts | Number of ghost points |
blank | Blanking array: for grid points within the body, this value will be set to 0 |
Definition at line 22 of file IBInterpCoeffs.c.
int IBAssembleGlobalFacetData | ( | void * | m, |
void * | ib, | ||
const double *const | local_var, | ||
double **const | global_var, | ||
int | nvars | ||
) |
Assemble any local data computed at immersed body surface (facet centroids) into a global array.
The local array must be of length (ImmersedBoundary::nfacets_local X nvars).
The global array must be NULL at input; it will have the size (Body3D::nfacets X nvars) at output on rank 0; it will remain NULL on other ranks.
m | MPI object of type MPIVariables |
ib | Immersed boundary object of type ImmersedBoundary |
local_var | Local array |
global_var | Array to store the gradient; must be NULL at input |
nvars | Number of components in var |
Definition at line 22 of file IBAssembleGlobalFacetData.c.
int IBComputeNormalGradient | ( | void * | s, |
void * | m, | ||
const double *const | var, | ||
int | nvars, | ||
double **const | grad_var | ||
) |
Calculate the normal gradient 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 normal gradient.
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 normal gradient 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 normal gradient at each local facet. If there are no local facets, it will remain NULL.
The gradient calculation is currently first-order.
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
var | Variable to compute the gradient of |
nvars | Number of components in var |
grad_var | Array to store the gradient; must be NULL at input |
Definition at line 33 of file IBComputeNormalGradient.c.
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).
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
var | Variable to compute the interpolated value of |
nvars | Number of components in var |
face_var | Array to store the interpolated value; must be NULL at input |
Definition at line 33 of file IBComputeFacetVar.c.