13#include "../private/private.h"
24 PetscFunctionBeginUser;
33 for (
int f = 0; f < 3; f++)
35 for (
int d = 0; d < 3; d++)
42 SETERRQ3(PETSC_COMM_WORLD, PETSC_ERR_ARG_INCOMP,
43 "Boundary %s for velocity field %s is periodic BC, "
44 "but its counterpart, %s, is not!\n",
51 SETERRQ3(PETSC_COMM_WORLD, PETSC_ERR_ARG_INCOMP,
52 "Boundary %s for velocity field %s is periodic BC, "
53 "but its counterpart, %s, is not!\n",
59 if (p1 && p2) periodic[f][d] = PETSC_TRUE;
64 if (std::all_of(bcTypes[2].begin(), bcTypes[2].end(),
69 for (
int d = 0; d < 3; d++)
72 for (
int f = 0; f < 3; f++)
74 if (periodic[f][d]) c += 1;
76 if ((c != 0) && (c != dim))
77 SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_ARG_INCOMP,
78 "Not all velocity fields in direction %s are periodic!",
82 PetscFunctionReturn(0);
88 PetscFunctionBeginUser;
97 ierr = DMDAGetProcessorSubset(da, DM_X, 0, &bcMPI);
101 ierr = DMDAGetProcessorSubset(da, DM_X, n[0] - 1, &bcMPI);
105 ierr = DMDAGetProcessorSubset(da, DM_Y, 0, &bcMPI);
109 ierr = DMDAGetProcessorSubset(da, DM_Y, n[1] - 1, &bcMPI);
113 ierr = DMDAGetProcessorSubset(da, DM_Z, 0, &bcMPI);
117 ierr = DMDAGetProcessorSubset(da, DM_Z, n[2] - 1, &bcMPI);
122 if (bcMPI != MPI_COMM_NULL)
123 onThisProc = PETSC_TRUE;
125 onThisProc = PETSC_FALSE;
126 PetscFunctionReturn(0);
134 PetscFunctionBeginUser;
139 PetscInt axis = int(loc) / 2;
154 for (PetscInt b = bg[pAxes[1]]; b < ed[pAxes[1]]; ++b)
156 for (PetscInt a = bg[pAxes[0]]; a < ed[pAxes[0]]; ++a)
175 ierr = mesh->getPackedGlobalIndex(field, target, targetId);
179 ierr = mesh->getLocalIndex(field, ghost, ghostId); CHKERRQ(ierr);
185 area = dL[pAxes[0]][a] * dL[pAxes[1]][b];
187 if ((
int(loc) == 1) || (
int(loc) == 3) || (
int(loc) == 5))
188 d = coord[axis][n[axis]] - coord[axis][n[axis] - 1];
189 else if ((
int(loc) == 0) || (
int(loc) == 2) || (
int(loc) == 4))
190 d = coord[axis][0] - coord[axis][-1];
192 points[ghost] = {ghostId, target, targetId, area, d, 0.0, 0.0, 0.0};
196 PetscFunctionReturn(0);
201 PetscFunctionBeginUser;
217 SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
218 "Can not recongnize axis %d in the function "
223 PetscFunctionReturn(0);
229 MatStencil &ghost, MatStencil &target)
231 PetscFunctionBeginUser;
236 target = {pIdx[1], pIdx[0], 0, 0};
237 ghost = {pIdx[1], pIdx[0], -1, 0};
240 target = {pIdx[1], pIdx[0], n[0] - 1, 0};
241 ghost = {pIdx[1], pIdx[0], n[0], 0};
244 target = {pIdx[1], 0, pIdx[0], 0};
245 ghost = {pIdx[1], -1, pIdx[0], 0};
248 target = {pIdx[1], n[1] - 1, pIdx[0], 0};
249 ghost = {pIdx[1], n[1], pIdx[0], 0};
252 target = {0, pIdx[1], pIdx[0], 0};
253 ghost = {-1, pIdx[1], pIdx[0], 0};
256 target = {n[2] - 1, pIdx[1], pIdx[0], 0};
257 ghost = {n[2], pIdx[1], pIdx[0], 0};
260 SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
261 "Can not recongnize BC location %s in the function "
262 "getGhostTargetStencil!",
266 PetscFunctionReturn(0);
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
PetscErrorCode getGhostTargetStencil(const type::IntVec1D &n, const type::BCLoc &loc, const type::IntVec1D &pIdx, MatStencil &ghost, MatStencil &target)
Get the stencils of a desired ghost point and its corresponding boundary point.
PetscErrorCode checkBoundaryProc(const DM &da, const type::IntVec1D &n, const type::BCLoc &loc, PetscBool &onThisProc)
Check if a boundary is on this process.
PetscErrorCode getPerpendAxes(const PetscInt &self, type::IntVec1D &pAxes)
An utility to get the perpendicular axes of a desired axis.
PetscErrorCode getGhostPointList(const type::Mesh &mesh, const type::Field &field, const type::BCLoc &loc, type::GhostPointsList &points)
Get a list of ghost points on a desired boundary.
PetscErrorCode checkPeriodicBC(const type::IntVec2D &bcTypes, type::BoolVec2D &periodic)
Check if there is any periodic boundary condition and if these periodic BCs make sense.
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
std::map< BCLoc, std::string > bl2str
Mapping between BCLoc and std::string.
std::vector< PetscBool > BoolVec1D
1D std::vector holding PetscBool.
std::vector< PetscReal * > GhostedVec2D
a vector of pointers to mimic ghosted 1D vectors.
Dir
Legal physical directions.
std::vector< BoolVec1D > BoolVec2D
2D std::vector holding PetscBool.
std::map< MatStencil, GhostPointInfo > GhostPointsList
A map between MatStencil and GhostPointInfo.
std::map< Field, std::string > fd2str
Mapping between Field and std::string.
std::vector< PetscInt > IntVec1D
1D std::vector holding PetscInt.
BCLoc
Location of a boundary.
std::map< Dir, std::string > dir2str
Mapping between Dir and std::string.
Prototype of mesh::MeshBase, type::Mesh, and factory function.
Prototypes of some miscellaneous functions.
Frequently used types, structures, and enums.
A toolbox for building flow solvers.