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

Base (abstract) class of mesh. More...

#include <mesh.h>

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

Public Member Functions

 MeshBase ()=default
 Default constructor. More...
 
 MeshBase (const MPI_Comm &world, const YAML::Node &node)
 Constructor. More...
 
virtual ~MeshBase ()
 Default destructor. More...
 
virtual PetscErrorCode destroy ()
 Manually destroy data. More...
 
PetscErrorCode printInfo () const
 Print information to standard output. More...
 
virtual PetscErrorCode write (const std::string &filePath) const =0
 Write the mesh object into a HDF5 file. More...
 
virtual PetscBool isPointOnLocalProc (const type::RealVec1D &point, const type::Field &field)=0
 
virtual PetscErrorCode getLocalIndex (const PetscInt &f, const MatStencil &s, PetscInt &idx) const =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 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 =0
 Get the global index of a point in packed DM by providing i, j, and k. 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

virtual PetscErrorCode init (const MPI_Comm &world, const YAML::Node &node)=0
 Initialization. More...
 

Detailed Description

Base (abstract) class of mesh.

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

Definition at line 64 of file mesh.h.

Constructor & Destructor Documentation

◆ MeshBase() [1/2]

petibm::mesh::MeshBase::MeshBase ( )
default

Default constructor.

◆ MeshBase() [2/2]

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

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 150 of file mesh.h.

◆ ~MeshBase()

petibm::mesh::MeshBase::~MeshBase ( )
virtual

Default destructor.

Definition at line 17 of file mesh.cpp.

Member Function Documentation

◆ destroy()

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

Manually destroy data.

Reimplemented in petibm::mesh::CartesianMesh.

Definition at line 38 of file mesh.cpp.

◆ getGlobalIndex() [1/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getGlobalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getGlobalIndex() [2/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getGlobalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getLocalIndex() [1/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getLocalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getLocalIndex() [2/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getLocalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getNaturalIndex() [1/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getNaturalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getNaturalIndex() [2/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getNaturalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getPackedGlobalIndex() [1/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getPackedGlobalIndex ( const PetscInt &  f,
const MatStencil &  s,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ getPackedGlobalIndex() [2/2]

virtual PetscErrorCode petibm::mesh::MeshBase::getPackedGlobalIndex ( const PetscInt &  f,
const PetscInt &  i,
const PetscInt &  j,
const PetscInt &  k,
PetscInt &  idx 
) const
pure 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.

Implemented in petibm::mesh::CartesianMesh.

◆ init()

virtual PetscErrorCode petibm::mesh::MeshBase::init ( const MPI_Comm &  world,
const YAML::Node &  node 
)
protectedpure virtual

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

Implemented in petibm::mesh::CartesianMesh.

◆ isPointOnLocalProc()

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

Implemented in petibm::mesh::CartesianMesh.

◆ printInfo()

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

Print information to standard output.

Definition at line 75 of file mesh.cpp.

◆ write()

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

Write the mesh object into a HDF5 file.

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

Implemented in petibm::mesh::CartesianMesh.

Member Data Documentation

◆ bg

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

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

Communicator.

Definition at line 128 of file mesh.h.

◆ coord

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

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

Definition at line 84 of file mesh.h.

◆ da

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

A vector of DMs of all fields.

Definition at line 100 of file mesh.h.

◆ dim

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

Dimension.

Definition at line 68 of file mesh.h.

◆ dL

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

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

Definition at line 87 of file mesh.h.

◆ ed

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

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

A string for printing information.

Definition at line 96 of file mesh.h.

◆ m

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

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

Maximum coordinates of boundaries in all directions.

Definition at line 74 of file mesh.h.

◆ min

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

Minimum coordinates of boundaries in all directions.

Definition at line 71 of file mesh.h.

◆ mpiRank

PetscMPIInt petibm::mesh::MeshBase::mpiRank

Rank of this process.

Definition at line 134 of file mesh.h.

◆ mpiSize

PetscMPIInt petibm::mesh::MeshBase::mpiSize

Total number of processes.

Definition at line 131 of file mesh.h.

◆ n

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

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

Number of processes in all directions.

Definition at line 103 of file mesh.h.

◆ periodic

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

Bools indicating if any direction is periodic.

Definition at line 80 of file mesh.h.

◆ pN

PetscInt petibm::mesh::MeshBase::pN

Total number of pressure points.

Definition at line 93 of file mesh.h.

◆ pNLocal

PetscInt petibm::mesh::MeshBase::pNLocal

Total number of pressure points local to this process.

Definition at line 121 of file mesh.h.

◆ UN

PetscInt petibm::mesh::MeshBase::UN

Total number of velocity points.

Definition at line 90 of file mesh.h.

◆ UNLocal

PetscInt petibm::mesh::MeshBase::UNLocal

Total number of velocity points local to this process.

Definition at line 118 of file mesh.h.

◆ UPack

DM petibm::mesh::MeshBase::UPack

DMComposte of velocity DMs.

Definition at line 124 of file mesh.h.


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