135 MatStencil &ghost, MatStencil &target);
148inline PetscErrorCode
stretchGrid(
const PetscReal &bg,
const PetscReal &ed,
149 const PetscInt &n,
const PetscReal &r,
152 PetscFunctionBeginUser;
157 dL[0] = (ed - bg) * (r - 1.0) / (std::pow(r, n) - 1.0);
160 for (
auto it = dL.begin() + 1; it < dL.end(); ++it) *it = *(it - 1) * r;
162 PetscFunctionReturn(0);
186 const std::function<PetscErrorCode(
const PetscInt &,
const PetscInt &)> &f)
190 PetscFunctionBeginUser;
192 for (PetscInt i = bound1.
bg; i < bound1.
ed; i++)
193 for (PetscInt j = bound2.
bg; j < bound2.
ed; j++)
195 ierr = f(i, j); CHKERRQ(ierr);
198 PetscFunctionReturn(0);
213 const std::function<PetscErrorCode(
const PetscInt &,
const PetscInt &,
214 const PetscInt &)> &f)
216 using namespace std::placeholders;
220 PetscFunctionBeginUser;
222 for (PetscInt i = bound1.
bg; i < bound1.
ed; ++i)
224 ierr =
doubleLoops(bound2, bound3, std::bind(f, i, _1, _2));
228 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 doubleLoops(const LoopBound &bound1, const LoopBound &bound2, const std::function< PetscErrorCode(const PetscInt &, const PetscInt &)> &f)
A helper function to carry out a double loop on a given function.
PetscErrorCode tripleLoops(const LoopBound &bound1, const LoopBound &bound2, const LoopBound &bound3, const std::function< PetscErrorCode(const PetscInt &, const PetscInt &, const PetscInt &)> &f)
A helper function to carry out a triple loop on a given function.
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 stretchGrid(const PetscReal &bg, const PetscReal &ed, const PetscInt &n, const PetscReal &r, type::RealVec1D &dL)
Calculate and return cell sizes of stretched grid in one direction.
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::vector< BoolVec1D > BoolVec2D
2D std::vector holding PetscBool.
std::map< MatStencil, GhostPointInfo > GhostPointsList
A map between MatStencil and GhostPointInfo.
std::vector< PetscInt > IntVec1D
1D std::vector holding PetscInt.
BCLoc
Location of a boundary.
std::vector< PetscReal > RealVec1D
1D std::vector holding PetscReal.
Prototype of mesh::MeshBase, type::Mesh, and factory function.
A toolbox for building flow solvers.
A helper struct to make looping function easier.
Definition of user-defined types for convenience.