PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
petibm::mesh::CartesianMesh Class Reference

Class of composite staggered Cartesian mesh. More...

#include <cartesianmesh.h>

Inheritance diagram for petibm::mesh::CartesianMesh:
[legend]

Public Member Functions

 CartesianMesh (const MPI_Comm &world, const YAML::Node &node)
 Constructor. More...
 
virtual ~CartesianMesh ()
 Default destructor. More...
 
virtual PetscErrorCode destroy ()
 Manually destroy data. More...
 
virtual PetscBool isPointOnLocalProc (const type::RealVec1D &point, const type::Field &field)
 
virtual PetscErrorCode write (const std::string &filePath) const
 Write the mesh object into a HDF5 file. More...
 
virtual PetscErrorCode getLocalIndex (const PetscInt &f, const MatStencil &s, PetscInt &idx) const
 Get the local index of a point by providing MatStencil. More...
 
virtual PetscErrorCode getLocalIndex (const PetscInt &f, const PetscInt &i, const PetscInt &j, const PetscInt &k, PetscInt &idx) const
 Get the local index of a point by providing i, j, and k. More...
 
virtual PetscErrorCode getNaturalIndex (const PetscInt &f, const MatStencil &s, PetscInt &idx) const
 Get the natural index of a point by providing MatStencil. More...
 
virtual PetscErrorCode getNaturalIndex (const PetscInt &f, const PetscInt &i, const PetscInt &j, const PetscInt &k, PetscInt &idx) const
 Get the natural index of a point by providing i, j, and k. More...
 
virtual PetscErrorCode getGlobalIndex (const PetscInt &f, const MatStencil &s, PetscInt &idx) const
 Get the global index of a point in unpacked DM by providing MatStencil. More...
 
virtual PetscErrorCode getGlobalIndex (const PetscInt &f, const PetscInt &i, const PetscInt &j, const PetscInt &k, PetscInt &idx) const
 Get the global index of a point in unpacked DM by providing i, j, and k. More...
 
virtual PetscErrorCode getPackedGlobalIndex (const PetscInt &f, const MatStencil &s, PetscInt &idx) const
 Get the global index of a point in packed DM by providing MatStencil. More...
 
virtual PetscErrorCode getPackedGlobalIndex (const PetscInt &f, const PetscInt &i, const PetscInt &j, const PetscInt &k, PetscInt &idx) const
 Get the global index of a point in packed DM by providing i, j, and k. More...
 
PetscErrorCode printInfo () const
 Print information to standard output. More...
 

Public Attributes

PetscInt dim = -1
 Dimension. More...
 
type::RealVec1D min
 Minimum coordinates of boundaries in all directions. More...
 
type::RealVec1D max
 Maximum coordinates of boundaries in all directions. More...
 
type::IntVec2D n
 Total number of points of all fields and in all directions. More...
 
type::BoolVec2D periodic
 Bools indicating if any direction is periodic. More...
 
type::GhostedVec3D coord
 Coordinates of mesh points of all fields and in all directions. More...
 
type::GhostedVec3D dL
 Spacings of mesh points of all fields and in all directions. More...
 
PetscInt UN
 Total number of velocity points. More...
 
PetscInt pN
 Total number of pressure points. More...
 
std::string info
 A string for printing information. More...
 
std::vector< DM > da
 A vector of DMs of all fields. More...
 
type::IntVec1D nProc
 Number of processes in all directions. More...
 
type::IntVec2D bg
 The beginning index of all fields in all directions of this process. More...
 
type::IntVec2D ed
 The ending index of all fields in all directions of this process. More...
 
type::IntVec2D m
 The number of points of all fields in all directions of this process. More...
 
PetscInt UNLocal
 Total number of velocity points local to this process. More...
 
PetscInt pNLocal
 Total number of pressure points local to this process. More...
 
DM UPack
 DMComposte of velocity DMs. More...
 
MPI_Comm comm
 Communicator. More...
 
PetscMPIInt mpiSize
 Total number of processes. More...
 
PetscMPIInt mpiRank
 Rank of this process. More...
 

Protected Member Functions

PetscErrorCode init (const MPI_Comm &world, const YAML::Node &node)
 Initialization. More...
 
PetscErrorCode createVertexMesh ()
 Create vertex information. More...
 
PetscErrorCode createPressureMesh ()
 Create pressure mesh information. More...
 
PetscErrorCode createVelocityMesh ()
 Create velocity mesh information. More...
 
PetscErrorCode createInfoString ()
 Create a string of information. More...
 
PetscErrorCode addLocalInfoString (std::stringstream &ss)
 Gather info of parallel distribution and add to info string. More...
 
PetscErrorCode initDMDA ()
 Initialize DMDAs. More...
 
PetscErrorCode createSingleDMDA (const PetscInt &i)
 Function for creating a single DMDA. More...
 
PetscErrorCode createPressureDMDA ()
 Create DMDA for pressure. More...
 
PetscErrorCode createVelocityPack ()
 Create DMDAs for velocity fields and make a DMComposite. More...
 

Protected Attributes

type::RealVec3D dLTrue
 Underlying data for mesh point spacing. More...
 
type::RealVec3D coordTrue
 Underlying data for mesh point coordinates. More...
 
std::vector< AO > ao
 References to underlying AO objects of velocity DMs. More...
 
type::IntVec2D UNLocalAllProcs
 Number of local velocity points (without ghost points) for all processes and all velocity fields. More...
 
type::IntVec1D UPackNLocalAllProcs
 Number of local packed velocity points (without ghost points) for all processes. More...
 
type::IntVec2D offsetsAllProcs
 Offsets of velocity points in unpacked DMs for all processes and all velocity field. More...
 
type::IntVec1D offsetsPackAllProcs
 Offsets of packed velocity points in packed DM. More...
 

Detailed Description

Class of composite staggered Cartesian mesh.

See also
Mesh objects, petibm::type::Mesh, petibm::mesh::createMesh

Definition at line 31 of file cartesianmesh.h.

Constructor & Destructor Documentation

◆ CartesianMesh()

petibm::mesh::CartesianMesh::CartesianMesh ( const MPI_Comm &  world,
const YAML::Node &  node 
)

Constructor.

Parameters
world[in] MPI communicator.
node[in] YAML configuration node.

Users are not encouraged to use constructor to initialize instances directly. Please use the factory function.

See also
petibm::mesh::createMesh

Definition at line 30 of file cartesianmesh.cpp.

◆ ~CartesianMesh()

petibm::mesh::CartesianMesh::~CartesianMesh ( )
virtual

Default destructor.

Definition at line 36 of file cartesianmesh.cpp.

Member Function Documentation

◆ addLocalInfoString()

PetscErrorCode petibm::mesh::CartesianMesh::addLocalInfoString ( std::stringstream &  ss)
protected

Gather info of parallel distribution and add to info string.

Definition at line 412 of file cartesianmesh.cpp.

◆ createInfoString()

PetscErrorCode petibm::mesh::CartesianMesh::createInfoString ( )
protected

Create a string of information.

Definition at line 358 of file cartesianmesh.cpp.

◆ createPressureDMDA()

PetscErrorCode petibm::mesh::CartesianMesh::createPressureDMDA ( )
protected

Create DMDA for pressure.

Definition at line 541 of file cartesianmesh.cpp.

◆ createPressureMesh()

PetscErrorCode petibm::mesh::CartesianMesh::createPressureMesh ( )
protected

Create pressure mesh information.

Definition at line 136 of file cartesianmesh.cpp.

◆ createSingleDMDA()

PetscErrorCode petibm::mesh::CartesianMesh::createSingleDMDA ( const PetscInt &  i)
protected

Function for creating a single DMDA.

Parameters
i[in] The index of the targeting field (0 ~ 4 represents u, v, w, pressure, and vertex respectively).

Definition at line 492 of file cartesianmesh.cpp.

◆ createVelocityMesh()

PetscErrorCode petibm::mesh::CartesianMesh::createVelocityMesh ( )
protected

Create velocity mesh information.

Definition at line 209 of file cartesianmesh.cpp.

◆ createVelocityPack()

PetscErrorCode petibm::mesh::CartesianMesh::createVelocityPack ( )
protected

Create DMDAs for velocity fields and make a DMComposite.

Definition at line 559 of file cartesianmesh.cpp.

◆ createVertexMesh()

PetscErrorCode petibm::mesh::CartesianMesh::createVertexMesh ( )
protected

Create vertex information.

Definition at line 177 of file cartesianmesh.cpp.

◆ destroy()

PetscErrorCode petibm::mesh::CartesianMesh::destroy ( )
virtual

Manually destroy data.

Reimplemented from petibm::mesh::MeshBase.

Definition at line 50 of file cartesianmesh.cpp.

◆ getGlobalIndex() [1/2]

PetscErrorCode petibm::mesh::CartesianMesh::getGlobalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
virtual

Get the global index of a point in unpacked DM by providing MatStencil.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
s[in] MatStencil object of target point.
idx[out] Global index in unpacked DM object.

If the provided MatStencil is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 709 of file cartesianmesh.cpp.

◆ getGlobalIndex() [2/2]

PetscErrorCode petibm::mesh::CartesianMesh::getGlobalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
virtual

Get the global index of a point in unpacked DM by providing i, j, and k.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
i[in] i-index.
j[in] j-index.
k[in] k-index.
idx[out] Global index in unpacked DM.

For 2D mesh, the value of k-index will be ignored.

If the provided (i, j, k) is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 724 of file cartesianmesh.cpp.

◆ getLocalIndex() [1/2]

PetscErrorCode petibm::mesh::CartesianMesh::getLocalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
virtual

Get the local index of a point by providing MatStencil.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
s[in] MatStencil object of target point.
idx[out] Local index.

Note that the stencil must belong to this process.

Implements petibm::mesh::MeshBase.

Definition at line 679 of file cartesianmesh.cpp.

◆ getLocalIndex() [2/2]

PetscErrorCode petibm::mesh::CartesianMesh::getLocalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
virtual

Get the local index of a point by providing i, j, and k.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
i[in] i-index.
j[in] j-index.
k[in] k-index.
idx[out] Local index.

Note that the stencil must belong to this process. For 2D mesh, the value of k-index will be ignored.

Implements petibm::mesh::MeshBase.

Definition at line 693 of file cartesianmesh.cpp.

◆ getNaturalIndex() [1/2]

PetscErrorCode petibm::mesh::CartesianMesh::getNaturalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
virtual

Get the natural index of a point by providing MatStencil.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
s[in] MatStencil object of target point.
idx[out] Natural index.

If the provided MatStencil is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 578 of file cartesianmesh.cpp.

◆ getNaturalIndex() [2/2]

PetscErrorCode petibm::mesh::CartesianMesh::getNaturalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
virtual

Get the natural index of a point by providing i, j, and k.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
i[in] i-index.
j[in] j-index.
k[in] k-index.
idx[out] Natural index.

For 2D mesh, the value of k-index will be ignored.

If the provided (i, j, k) is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 592 of file cartesianmesh.cpp.

◆ getPackedGlobalIndex() [1/2]

PetscErrorCode petibm::mesh::CartesianMesh::getPackedGlobalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
virtual

Get the global index of a point in packed DM by providing MatStencil.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
s[in] MatStencil object of target point.
idx[out] Global index in packed DM.

For pressure field (f=3), packed ID will be equal to unpacked ID.

If the provided MatStencil is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 740 of file cartesianmesh.cpp.

◆ getPackedGlobalIndex() [2/2]

PetscErrorCode petibm::mesh::CartesianMesh::getPackedGlobalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
virtual

Get the global index of a point in packed DM by providing i, j, and k.

Parameters
f[in] Target field (u=0, v=1, w=2, p=3).
i[in] i-index.
j[in] j-index.
k[in] k-index.
idx[out] Global index in packed DM.

For 2D mesh, the value of k-index will be ignored. For pressure field (f=3), packed ID will be equal to unpacked ID.

If the provided (i, j, k) is not valid or is a ghost point, the idx will be -1.

Implements petibm::mesh::MeshBase.

Definition at line 782 of file cartesianmesh.cpp.

◆ init()

PetscErrorCode petibm::mesh::CartesianMesh::init ( const MPI_Comm &  world,
const YAML::Node &  node 
)
protectedvirtual

Initialization.

Parameters
world[in] MPI communicator.
node[in] YAML configuration node.

Given the design of PetIBM is to use factory function to create shared pointers of instances, it seems not necessary to make this function public.

See also
petibm::mesh::createMesh

Implements petibm::mesh::MeshBase.

Definition at line 69 of file cartesianmesh.cpp.

◆ initDMDA()

PetscErrorCode petibm::mesh::CartesianMesh::initDMDA ( )
protected

Initialize DMDAs.

Definition at line 438 of file cartesianmesh.cpp.

◆ isPointOnLocalProc()

PetscBool petibm::mesh::CartesianMesh::isPointOnLocalProc ( const type::RealVec1D point,
const type::Field field 
)
virtual

Implements petibm::mesh::MeshBase.

Definition at line 825 of file cartesianmesh.cpp.

◆ printInfo()

PetscErrorCode petibm::mesh::MeshBase::printInfo ( ) const
inherited

Print information to standard output.

Definition at line 75 of file mesh.cpp.

◆ write()

PetscErrorCode petibm::mesh::CartesianMesh::write ( const std::string &  filePath) const
virtual

Write the mesh object into a HDF5 file.

Parameters
filePath[in] Path of the file to write in.

Implements petibm::mesh::MeshBase.

Definition at line 798 of file cartesianmesh.cpp.

Member Data Documentation

◆ ao

std::vector<AO> petibm::mesh::CartesianMesh::ao
protected

References to underlying AO objects of velocity DMs.

Definition at line 101 of file cartesianmesh.h.

◆ bg

type::IntVec2D petibm::mesh::MeshBase::bg
inherited

The beginning index of all fields in all directions of this process.

Definition at line 107 of file mesh.h.

◆ comm

MPI_Comm petibm::mesh::MeshBase::comm
inherited

Communicator.

Definition at line 128 of file mesh.h.

◆ coord

type::GhostedVec3D petibm::mesh::MeshBase::coord
inherited

Coordinates of mesh points of all fields and in all directions.

Definition at line 84 of file mesh.h.

◆ coordTrue

type::RealVec3D petibm::mesh::CartesianMesh::coordTrue
protected

Underlying data for mesh point coordinates.

Definition at line 98 of file cartesianmesh.h.

◆ da

std::vector<DM> petibm::mesh::MeshBase::da
inherited

A vector of DMs of all fields.

Definition at line 100 of file mesh.h.

◆ dim

PetscInt petibm::mesh::MeshBase::dim = -1
inherited

Dimension.

Definition at line 68 of file mesh.h.

◆ dL

type::GhostedVec3D petibm::mesh::MeshBase::dL
inherited

Spacings of mesh points of all fields and in all directions.

Definition at line 87 of file mesh.h.

◆ dLTrue

type::RealVec3D petibm::mesh::CartesianMesh::dLTrue
protected

Underlying data for mesh point spacing.

Definition at line 95 of file cartesianmesh.h.

◆ ed

type::IntVec2D petibm::mesh::MeshBase::ed
inherited

The ending index of all fields in all directions of this process.

Definition at line 111 of file mesh.h.

◆ info

std::string petibm::mesh::MeshBase::info
inherited

A string for printing information.

Definition at line 96 of file mesh.h.

◆ m

type::IntVec2D petibm::mesh::MeshBase::m
inherited

The number of points of all fields in all directions of this process.

Definition at line 115 of file mesh.h.

◆ max

type::RealVec1D petibm::mesh::MeshBase::max
inherited

Maximum coordinates of boundaries in all directions.

Definition at line 74 of file mesh.h.

◆ min

type::RealVec1D petibm::mesh::MeshBase::min
inherited

Minimum coordinates of boundaries in all directions.

Definition at line 71 of file mesh.h.

◆ mpiRank

PetscMPIInt petibm::mesh::MeshBase::mpiRank
inherited

Rank of this process.

Definition at line 134 of file mesh.h.

◆ mpiSize

PetscMPIInt petibm::mesh::MeshBase::mpiSize
inherited

Total number of processes.

Definition at line 131 of file mesh.h.

◆ n

type::IntVec2D petibm::mesh::MeshBase::n
inherited

Total number of points of all fields and in all directions.

Definition at line 77 of file mesh.h.

◆ nProc

type::IntVec1D petibm::mesh::MeshBase::nProc
inherited

Number of processes in all directions.

Definition at line 103 of file mesh.h.

◆ offsetsAllProcs

type::IntVec2D petibm::mesh::CartesianMesh::offsetsAllProcs
protected

Offsets of velocity points in unpacked DMs for all processes and all velocity field.

Definition at line 113 of file cartesianmesh.h.

◆ offsetsPackAllProcs

type::IntVec1D petibm::mesh::CartesianMesh::offsetsPackAllProcs
protected

Offsets of packed velocity points in packed DM.

Definition at line 116 of file cartesianmesh.h.

◆ periodic

type::BoolVec2D petibm::mesh::MeshBase::periodic
inherited

Bools indicating if any direction is periodic.

Definition at line 80 of file mesh.h.

◆ pN

PetscInt petibm::mesh::MeshBase::pN
inherited

Total number of pressure points.

Definition at line 93 of file mesh.h.

◆ pNLocal

PetscInt petibm::mesh::MeshBase::pNLocal
inherited

Total number of pressure points local to this process.

Definition at line 121 of file mesh.h.

◆ UN

PetscInt petibm::mesh::MeshBase::UN
inherited

Total number of velocity points.

Definition at line 90 of file mesh.h.

◆ UNLocal

PetscInt petibm::mesh::MeshBase::UNLocal
inherited

Total number of velocity points local to this process.

Definition at line 118 of file mesh.h.

◆ UNLocalAllProcs

type::IntVec2D petibm::mesh::CartesianMesh::UNLocalAllProcs
protected

Number of local velocity points (without ghost points) for all processes and all velocity fields.

Definition at line 105 of file cartesianmesh.h.

◆ UPack

DM petibm::mesh::MeshBase::UPack
inherited

DMComposte of velocity DMs.

Definition at line 124 of file mesh.h.

◆ UPackNLocalAllProcs

type::IntVec1D petibm::mesh::CartesianMesh::UPackNLocalAllProcs
protected

Number of local packed velocity points (without ghost points) for all processes.

Definition at line 109 of file cartesianmesh.h.


The documentation for this class was generated from the following files: