PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
mesh.cpp
Go to the documentation of this file.
1
9#include <petibm/io.h>
10#include <petibm/mesh.h>
11
12namespace petibm
13{
14namespace mesh
15{
16// implement MeshBase::~MeshBase
18{
19 PetscFunctionBeginUser;
20
21 PetscErrorCode ierr;
22 PetscBool finalized;
23
24 ierr = PetscFinalized(&finalized); CHKERRV(ierr);
25 if (finalized) return;
26
27 for (int f = 0; f < dim; ++f)
28 {
29 ierr = DMDestroy(&da[f]); CHKERRV(ierr);
30 }
31 ierr = DMDestroy(&da[3]); CHKERRV(ierr);
32 ierr = DMDestroy(&da[4]); CHKERRV(ierr);
33 ierr = DMDestroy(&UPack); CHKERRV(ierr);
34 comm = MPI_COMM_NULL;
35} // ~MeshBase
36
37// implement MeshBase::destroy
38PetscErrorCode MeshBase::destroy()
39{
40 PetscFunctionBeginUser;
41
42 PetscErrorCode ierr;
43
44 for (int f = 0; f < dim; ++f)
45 {
46 ierr = DMDestroy(&da[f]); CHKERRQ(ierr);
47 }
48 ierr = DMDestroy(&da[3]); CHKERRQ(ierr);
49 ierr = DMDestroy(&da[4]); CHKERRQ(ierr);
50 ierr = DMDestroy(&UPack); CHKERRQ(ierr);
51
52 dim = -1;
53 type::RealVec1D().swap(min);
54 type::RealVec1D().swap(max);
55 type::IntVec2D().swap(n);
58 type::GhostedVec3D().swap(dL);
59 UN = pN = 0;
60 info = std::string();
61
62 type::IntVec1D().swap(nProc);
63 type::IntVec2D().swap(bg);
64 type::IntVec2D().swap(ed);
65 type::IntVec2D().swap(m);
66 UNLocal = pNLocal = 0;
67
68 comm = MPI_COMM_NULL;
69 mpiSize = mpiRank = 0;
70
71 PetscFunctionReturn(0);
72} // destroy
73
74// implement MeshBase::printInfo
75PetscErrorCode MeshBase::printInfo() const
76{
77 PetscFunctionBeginUser;
78
79 PetscErrorCode ierr;
80 ierr = io::print(info); CHKERRQ(ierr);
81
82 PetscFunctionReturn(0);
83} // printInfo
84
85// implement petibm::mesh::createMesh
86PetscErrorCode createMesh(const MPI_Comm &comm, const YAML::Node &node,
87 type::Mesh &mesh)
88{
89 PetscFunctionBeginUser;
90
91 mesh = std::make_shared<CartesianMesh>(comm, node);
92
93 PetscFunctionReturn(0);
94} // createMesh
95
96} // namespace mesh
97} // namespace petibm
Definition of class mesh::CartesianMesh.
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
type::IntVec2D ed
The ending index of all fields in all directions of this process.
Definition: mesh.h:111
std::string info
A string for printing information.
Definition: mesh.h:96
PetscMPIInt mpiRank
Rank of this process.
Definition: mesh.h:134
type::IntVec2D bg
The beginning index of all fields in all directions of this process.
Definition: mesh.h:107
PetscInt UNLocal
Total number of velocity points local to this process.
Definition: mesh.h:118
type::IntVec1D nProc
Number of processes in all directions.
Definition: mesh.h:103
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
PetscInt UN
Total number of velocity points.
Definition: mesh.h:90
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
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
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
PetscErrorCode print(const std::string &info)
Print information of a parallel object to standard output.
Definition: io.cpp:120
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
Definition: type.h:135
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
Prototypes of I/O functions.
Prototype of mesh::MeshBase, type::Mesh, and factory function.
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