PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures

Objects for meshes and domain decompositions. More...

Collaboration diagram for Mesh objects:

Namespaces

namespace  petibm::mesh
 Collection of classes and utilities regarding mesh.
 

Classes

class  petibm::mesh::CartesianMesh
 Class of composite staggered Cartesian mesh. More...
 
class  petibm::mesh::MeshBase
 Base (abstract) class of mesh. More...
 

Typedefs

typedef std::shared_ptr< mesh::MeshBasepetibm::type::Mesh
 Type definition of Mesh. More...
 

Functions

PetscErrorCode petibm::mesh::createMesh (const MPI_Comm &comm, const YAML::Node &node, type::Mesh &mesh)
 Factory function for creating a Mesh object. More...
 

Detailed Description

Objects for meshes and domain decompositions.

So far, we only have stretched Cartesian mesh in our code. However, in order to consider future extension of different kinds of mesh, we still design a base (abstract) class, MeshBase, to unify the interfaces of potential mesh classes. Currently, there is only a child derived from the base class: CartesianMesh.

The design of PetIBM is to use std::shared_ptr to hold the base class for instances of different kinds of derived classes, so that we can call the public APIs regardless the types of the derived classes. Mesh is defined as a shared pointer to MeshBase. Users should use Mesh instead of using classes directly. And users should also initialize mesh instances with the factory function, createMesh, instead of initializing the instances directly.

The domain decomposition is done with PETSc DMDA objects. And the information of sub-domains are retrieved into mesh classes.

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

Typedef Documentation

◆ Mesh

typedef std::shared_ptr<mesh::MeshBase> petibm::type::Mesh

Type definition of Mesh.

Please use petibm::mesh::createMesh to create a Mesh object.

Example usage:

PetscErrorCode ierr;
// create Mesh with petibm::mesh::createMesh
ierr = mesh->printInfo(); CHKERRQ(ierr);
ierr = mesh->write("./grid"); CHKERRQ(ierr);
PetscInt idx;
ierr = mesh->getNaturalIndex(0, 1, 1, 1, idx); CHKERRQ(ierr);
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
Definition: mesh.h:348
See also
Mesh objects, petibm::mesh::createMesh, petibm::mesh::MeshBase

Definition at line 348 of file mesh.h.

Function Documentation

◆ createMesh()

PetscErrorCode petibm::mesh::createMesh ( const MPI_Comm &  comm,
const YAML::Node &  node,
type::Mesh mesh 
)

Factory function for creating a Mesh object.

Parameters
comm[in] MPI Communicator.
node[in] YAML configuration node.
mesh[out] Structured Cartesian mesh object.

This function will look into the key mesh in node for mesh settings. An example of 2D stretched Cartesian mesh settings in the YAML node is shown as the following:

YAML::Node node;
node["mesh"][0]["direction"] = "x";
node["mesh"][0]["start"] = 0.0;
node["mesh"][0]["subDomains"][0]["end"] = 0.5;
node["mesh"][0]["subDomains"][0]["cells"] = 64;
node["mesh"][0]["subDomains"][0]["stretchRatio"] = 1.01;
node["mesh"][0]["subDomains"][1]["end"] = 1.0;
node["mesh"][0]["subDomains"][1]["cells"] = 64;
node["mesh"][0]["subDomains"][1]["stretchRatio"] = 0.9900990099001;
node["mesh"][1]["direction"] = "y";
node["mesh"][1]["start"] = 0.0;
node["mesh"][1]["subDomains"][0]["end"] = 0.5;
node["mesh"][1]["subDomains"][0]["cells"] = 64;
node["mesh"][1]["subDomains"][0]["stretchRatio"] = 1.01;
node["mesh"][1]["subDomains"][1]["end"] = 1.0;
node["mesh"][1]["subDomains"][1]["cells"] = 64;
node["mesh"][1]["subDomains"][1]["stretchRatio"] = 0.9900990099001;

Or in an ASCII YAML file:

mesh:
- direction: x
start: 0.0
subDomains:
- end: 0.5
cells: 64
stretchRatio: 1.01
- end: 1.0
cells: 64
stretchRatio: 0.9900990099001
- direction: y
start: 0.0
subDomains:
- end: 0.5
cells: 64
stretchRatio: 1.01
- end: 1.0
cells: 64
stretchRatio: 0.9900990099001

We then pass this YAML node into the factory function:

PetscErrorCode ierr;
petibm::type::mesh mesh;
ierr = petibm::mesh::createMesh(PETSC_COMM_WORLD, node, mesh); CHKERRQ(ierr);
PetscErrorCode createMesh(const MPI_Comm &comm, const YAML::Node &node, type::Mesh &mesh)
Factory function for creating a Mesh object.
Definition: mesh.cpp:86
See also
Mesh objects, petibm::type::Mesh

Definition at line 86 of file mesh.cpp.