PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
cartesianmesh.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <string>
11#include <vector>
12
13#include <petscao.h>
14#include <petscdmcomposite.h>
15#include <petscdmda.h>
16#include <petscsys.h>
17#include <yaml-cpp/yaml.h>
18
19#include <petibm/mesh.h>
20#include <petibm/type.h>
21
22namespace petibm
23{
24namespace mesh
25{
31class CartesianMesh : public MeshBase
32{
33public:
35 CartesianMesh(const MPI_Comm &world, const YAML::Node &node);
36
38 virtual ~CartesianMesh();
39
40 // doc is the same as MeshBase::destroy
41 virtual PetscErrorCode destroy();
42
43 virtual PetscBool isPointOnLocalProc(const type::RealVec1D &point,
44 const type::Field &field);
45
46 // doc is the same as MeshBase::write
47 virtual PetscErrorCode write(const std::string &filePath) const;
48
49 // doc is the same as MeshBase::getLocalIndex
50 virtual PetscErrorCode getLocalIndex(const PetscInt &f, const MatStencil &s,
51 PetscInt &idx) const;
52
53 // doc is the same as MeshBase::getLocalIndex
54 virtual PetscErrorCode getLocalIndex(const PetscInt &f, const PetscInt &i,
55 const PetscInt &j, const PetscInt &k,
56 PetscInt &idx) const;
57
58 // doc is the same as MeshBase::getNaturalIndex
59 virtual PetscErrorCode getNaturalIndex(const PetscInt &f,
60 const MatStencil &s,
61 PetscInt &idx) const;
62
63 // doc is the same as MeshBase::getNaturalIndex
64 virtual PetscErrorCode getNaturalIndex(const PetscInt &f, const PetscInt &i,
65 const PetscInt &j, const PetscInt &k,
66 PetscInt &idx) const;
67
68 // doc is the same as MeshBase::getGlobalIndex
69 virtual PetscErrorCode getGlobalIndex(const PetscInt &f,
70 const MatStencil &s,
71 PetscInt &idx) const;
72
73 // doc is the same as MeshBase::getGlobalIndex
74 virtual PetscErrorCode getGlobalIndex(const PetscInt &f, const PetscInt &i,
75 const PetscInt &j, const PetscInt &k,
76 PetscInt &idx) const;
77
78 // doc is the same as MeshBase::getPackedGlobalIndex
79 virtual PetscErrorCode getPackedGlobalIndex(const PetscInt &f,
80 const MatStencil &s,
81 PetscInt &idx) const;
82
83 // doc is the same as MeshBase::getPackedGlobalIndex
84 virtual PetscErrorCode getPackedGlobalIndex(const PetscInt &f,
85 const PetscInt &i,
86 const PetscInt &j,
87 const PetscInt &k,
88 PetscInt &idx) const;
89
90protected:
91 // doc is the same as MeshBase::init
92 PetscErrorCode init(const MPI_Comm &world, const YAML::Node &node);
93
96
99
101 std::vector<AO> ao;
102
106
110
114
117
119 PetscErrorCode createVertexMesh();
120
122 PetscErrorCode createPressureMesh();
123
125 PetscErrorCode createVelocityMesh();
126
128 PetscErrorCode createInfoString();
129
131 PetscErrorCode addLocalInfoString(std::stringstream &ss);
132
134 PetscErrorCode initDMDA();
135
142 PetscErrorCode createSingleDMDA(const PetscInt &i);
143
145 PetscErrorCode createPressureDMDA();
146
148 PetscErrorCode createVelocityPack();
149
150}; // CartesianMesh
151
152} // end of namespace mesh
153
154} // end of namespace petibm
Class of composite staggered Cartesian mesh.
Definition: cartesianmesh.h:32
type::IntVec1D UPackNLocalAllProcs
Number of local packed velocity points (without ghost points) for all processes.
virtual PetscErrorCode getNaturalIndex(const PetscInt &f, const MatStencil &s, PetscInt &idx) const
Get the natural index of a point by providing MatStencil.
type::RealVec3D dLTrue
Underlying data for mesh point spacing.
Definition: cartesianmesh.h:95
PetscErrorCode createSingleDMDA(const PetscInt &i)
Function for creating a single DMDA.
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.
virtual PetscErrorCode write(const std::string &filePath) const
Write the mesh object into a HDF5 file.
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.
PetscErrorCode initDMDA()
Initialize DMDAs.
type::RealVec3D coordTrue
Underlying data for mesh point coordinates.
Definition: cartesianmesh.h:98
type::IntVec1D offsetsPackAllProcs
Offsets of packed velocity points in packed DM.
PetscErrorCode addLocalInfoString(std::stringstream &ss)
Gather info of parallel distribution and add to info string.
virtual ~CartesianMesh()
Default destructor.
PetscErrorCode createVelocityMesh()
Create velocity mesh information.
std::vector< AO > ao
References to underlying AO objects of velocity DMs.
PetscErrorCode createPressureDMDA()
Create DMDA for pressure.
virtual PetscErrorCode getLocalIndex(const PetscInt &f, const MatStencil &s, PetscInt &idx) const
Get the local index of a point by providing MatStencil.
type::IntVec2D UNLocalAllProcs
Number of local velocity points (without ghost points) for all processes and all velocity fields.
virtual PetscErrorCode destroy()
Manually destroy data.
PetscErrorCode init(const MPI_Comm &world, const YAML::Node &node)
Initialization.
PetscErrorCode createPressureMesh()
Create pressure mesh information.
PetscErrorCode createVertexMesh()
Create vertex information.
PetscErrorCode createInfoString()
Create a string of information.
virtual PetscBool isPointOnLocalProc(const type::RealVec1D &point, const type::Field &field)
CartesianMesh(const MPI_Comm &world, const YAML::Node &node)
Constructor.
type::IntVec2D offsetsAllProcs
Offsets of velocity points in unpacked DMs for all processes and all velocity field.
PetscErrorCode createVelocityPack()
Create DMDAs for velocity fields and make a DMComposite.
Base (abstract) class of mesh.
Definition: mesh.h:65
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
Definition: type.h:135
Field
Legal fields.
Definition: type.h:80
std::vector< PetscInt > IntVec1D
1D std::vector holding PetscInt.
Definition: type.h:133
std::vector< PetscReal > RealVec1D
1D std::vector holding PetscReal.
Definition: type.h:140
std::vector< RealVec2D > RealVec3D
3D std::vector holding PetscReal.
Definition: type.h:144
Prototype of mesh::MeshBase, type::Mesh, and factory function.
A toolbox for building flow solvers.
Definition: bodypack.h:52
Definition of user-defined types for convenience.