PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
mesh.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/type.h>
20
48namespace petibm
49{
56namespace mesh
57{
65{
66public:
68 PetscInt dim = -1;
69
72
75
78
81
85
88
90 PetscInt UN;
91
93 PetscInt pN;
94
96 std::string info;
97
98 // PETSc stuffs
100 std::vector<DM> da;
101
104
108
112
116
118 PetscInt UNLocal;
119
121 PetscInt pNLocal;
122
125
126 // MPI stuffs
128 MPI_Comm comm;
129
131 PetscMPIInt mpiSize;
132
134 PetscMPIInt mpiRank;
135
137 MeshBase() = default;
138
150 MeshBase(const MPI_Comm &world, const YAML::Node &node){};
151
153 virtual ~MeshBase();
154
156 virtual PetscErrorCode destroy();
157
159 PetscErrorCode printInfo() const;
160
166 virtual PetscErrorCode write(const std::string &filePath) const = 0;
167
168 virtual PetscBool isPointOnLocalProc(const type::RealVec1D &point,
169 const type::Field &field) = 0;
170
180 virtual PetscErrorCode getLocalIndex(const PetscInt &f, const MatStencil &s,
181 PetscInt &idx) const = 0;
182
195 virtual PetscErrorCode getLocalIndex(const PetscInt &f, const PetscInt &i,
196 const PetscInt &j, const PetscInt &k,
197 PetscInt &idx) const = 0;
198
209 virtual PetscErrorCode getNaturalIndex(const PetscInt &f,
210 const MatStencil &s,
211 PetscInt &idx) const = 0;
212
227 virtual PetscErrorCode getNaturalIndex(const PetscInt &f, const PetscInt &i,
228 const PetscInt &j, const PetscInt &k,
229 PetscInt &idx) const = 0;
230
242 virtual PetscErrorCode getGlobalIndex(const PetscInt &f,
243 const MatStencil &s,
244 PetscInt &idx) const = 0;
245
261 virtual PetscErrorCode getGlobalIndex(const PetscInt &f, const PetscInt &i,
262 const PetscInt &j, const PetscInt &k,
263 PetscInt &idx) const = 0;
264
278 virtual PetscErrorCode getPackedGlobalIndex(const PetscInt &f,
279 const MatStencil &s,
280 PetscInt &idx) const = 0;
281
298 virtual PetscErrorCode getPackedGlobalIndex(const PetscInt &f,
299 const PetscInt &i,
300 const PetscInt &j,
301 const PetscInt &k,
302 PetscInt &idx) const = 0;
303
304protected:
317 virtual PetscErrorCode init(const MPI_Comm &world,
318 const YAML::Node &node) = 0;
319
320}; // MeshBase
321
322} // end of namespace mesh
323
324namespace type
325{
348typedef std::shared_ptr<mesh::MeshBase> Mesh;
349
350} // end of namespace type
351
352namespace mesh
353{
420PetscErrorCode createMesh(const MPI_Comm &comm, const YAML::Node &node,
421 type::Mesh &mesh);
422
423} // end of namespace mesh
424
425} // end of namespace petibm
Base (abstract) class of mesh.
Definition: mesh.h:65
type::RealVec1D max
Maximum coordinates of boundaries in all directions.
Definition: mesh.h:74
type::IntVec2D n
Total number of points of all fields and in all directions.
Definition: mesh.h:77
virtual PetscErrorCode destroy()
Manually destroy data.
Definition: mesh.cpp:38
DM UPack
DMComposte of velocity DMs.
Definition: mesh.h:124
MPI_Comm comm
Communicator.
Definition: mesh.h:128
virtual PetscErrorCode write(const std::string &filePath) const =0
Write the mesh object into a HDF5 file.
type::IntVec2D ed
The ending index of all fields in all directions of this process.
Definition: mesh.h:111
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.
std::string info
A string for printing information.
Definition: mesh.h:96
PetscMPIInt mpiRank
Rank of this process.
Definition: mesh.h:134
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.
type::IntVec2D bg
The beginning index of all fields in all directions of this process.
Definition: mesh.h:107
virtual PetscBool isPointOnLocalProc(const type::RealVec1D &point, const type::Field &field)=0
PetscInt UNLocal
Total number of velocity points local to this process.
Definition: mesh.h:118
virtual PetscErrorCode getNaturalIndex(const PetscInt &f, const MatStencil &s, PetscInt &idx) const =0
Get the natural index of a point by providing MatStencil.
type::IntVec1D nProc
Number of processes in all directions.
Definition: mesh.h:103
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.
type::GhostedVec3D coord
Coordinates of mesh points of all fields and in all directions.
Definition: mesh.h:84
virtual ~MeshBase()
Default destructor.
Definition: mesh.cpp:17
PetscErrorCode printInfo() const
Print information to standard output.
Definition: mesh.cpp:75
MeshBase()=default
Default constructor.
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.
PetscInt UN
Total number of velocity points.
Definition: mesh.h:90
MeshBase(const MPI_Comm &world, const YAML::Node &node)
Constructor.
Definition: mesh.h:150
type::GhostedVec3D dL
Spacings of mesh points of all fields and in all directions.
Definition: mesh.h:87
PetscMPIInt mpiSize
Total number of processes.
Definition: mesh.h:131
PetscInt pNLocal
Total number of pressure points local to this process.
Definition: mesh.h:121
virtual PetscErrorCode getLocalIndex(const PetscInt &f, const MatStencil &s, PetscInt &idx) const =0
Get the local index of a point by providing MatStencil.
virtual PetscErrorCode init(const MPI_Comm &world, const YAML::Node &node)=0
Initialization.
PetscInt dim
Dimension.
Definition: mesh.h:68
std::vector< DM > da
A vector of DMs of all fields.
Definition: mesh.h:100
type::RealVec1D min
Minimum coordinates of boundaries in all directions.
Definition: mesh.h:71
type::BoolVec2D periodic
Bools indicating if any direction is periodic.
Definition: mesh.h:80
PetscInt pN
Total number of pressure points.
Definition: mesh.h:93
type::IntVec2D m
The number of points of all fields in all directions of this process.
Definition: mesh.h:115
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.
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.
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
Definition: mesh.h:348
PetscErrorCode createMesh(const MPI_Comm &comm, const YAML::Node &node, type::Mesh &mesh)
Factory function for creating a Mesh object.
Definition: mesh.cpp:86
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
Definition: type.h:135
Field
Legal fields.
Definition: type.h:80
std::vector< BoolVec1D > BoolVec2D
2D std::vector holding PetscBool.
Definition: type.h:149
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< GhostedVec2D > GhostedVec3D
a vector of vector pointers to mimic ghosted 2D vectors. type
Definition: type.h:157
A toolbox for building flow solvers.
Definition: bodypack.h:52
Definition of user-defined types for convenience.