PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
boundarysimple.cpp
Go to the documentation of this file.
1
8// here goes headers from our PetIBM
10#include <petibm/parser.h>
11
12namespace petibm
13{
14namespace boundary
15{
16using namespace type;
17
18// constructor
19BoundarySimple::BoundarySimple(const type::Mesh &inMesh, const YAML::Node &node)
20{
21 init(inMesh, node);
22} // BoundarySimple
23
24// underlying initialization function
25PetscErrorCode BoundarySimple::init(const type::Mesh &inMesh,
26 const YAML::Node &node)
27{
28 PetscFunctionBeginUser;
29
30 PetscErrorCode ierr;
31
32 // make a shared pointer pointing to associated mesh
33 mesh = inMesh;
34
35 // obtain MPI information from CartesianMesh object
36 comm = mesh->comm;
37 mpiSize = mesh->mpiSize;
38 mpiRank = mesh->mpiRank;
39
40 // set dim
41 dim = mesh->dim;
42
43 // initialize the size of bds (Question: is barrier necessary?)
44 bds.resize(dim);
45
46 type::IntVec2D bcTypes;
47 type::RealVec2D bcValues;
48 ierr = parser::parseBCs(node, bcTypes, bcValues); CHKERRQ(ierr);
49
50 for (PetscInt f = 0; f < dim; ++f)
51 {
52 bds[f].resize(dim * 2);
53
54 for (PetscInt b = 0; b < dim * 2; ++b)
55 {
57 bcValues[f][b],
58 type::BCType(bcTypes[f][b]), bds[f][b]);
59 CHKERRQ(ierr);
60 }
61 }
62
63 PetscFunctionReturn(0);
64} // init
65
66// set initial values to ghost points
68{
69 PetscFunctionBeginUser;
70
71 PetscErrorCode ierr;
72
73 for (auto &fbd : bds)
74 {
75 for (auto &bd : fbd)
76 {
77 ierr = bd->setGhostICs(soln->UGlobal); CHKERRQ(ierr);
78 }
79 }
80
81 ierr = MPI_Barrier(comm); CHKERRQ(ierr);
82
83 PetscFunctionReturn(0);
84} // setGhostICs
85
86// update the equations between boundary and ghost points
87PetscErrorCode BoundarySimple::updateEqs(const type::Solution &soln,
88 const PetscReal &dt)
89{
90 PetscFunctionBeginUser;
91
92 PetscErrorCode ierr;
93
94 for (auto &fbd : bds)
95 {
96 for (auto &bd : fbd)
97 {
98 ierr = bd->updateEqs(soln->UGlobal, dt); CHKERRQ(ierr);
99 }
100 }
101
102 ierr = MPI_Barrier(comm); CHKERRQ(ierr);
103
104 PetscFunctionReturn(0);
105} // updateEqs
106
107// update values of ghost points
109{
110 PetscFunctionBeginUser;
111
112 PetscErrorCode ierr;
113
114 for (auto &fbd : bds)
115 {
116 for (auto &bd : fbd)
117 {
118 ierr = bd->updateGhostValues(soln->UGlobal); CHKERRQ(ierr);
119 }
120 }
121
122 ierr = MPI_Barrier(comm); CHKERRQ(ierr);
123
124 PetscFunctionReturn(0);
125} // updateGhostValues
126
127// copy values of ghost points to local PETSc Vecs
129 std::vector<Vec> &lclVecs) const
130{
131 PetscFunctionBeginUser;
132
133 PetscErrorCode ierr;
134
135 for (PetscInt f = 0; f < dim; ++f)
136 {
137 for (auto &bd : bds[f])
138 {
139 ierr = bd->copyValues2LocalVec(lclVecs[f]); CHKERRQ(ierr);
140 }
141 }
142
143 ierr = MPI_Barrier(comm); CHKERRQ(ierr);
144
145 PetscFunctionReturn(0);
146} // copyValues2LocalVecs
147
148} // end of namespace boundary
149} // end of namespace petibm
Definition of boundary::BoundarySimple.
PetscMPIInt mpiSize
Size of MPI communicator.
Definition: boundary.h:153
MPI_Comm comm
MPI communicator.
Definition: boundary.h:150
type::Mesh mesh
A shared_ptr to underlying mesh.
Definition: boundary.h:159
PetscInt dim
Dimension.
Definition: boundary.h:82
std::vector< std::vector< type::SingleBoundary > > bds
A 2D vector holding all single boundaries.
Definition: boundary.h:85
PetscMPIInt mpiRank
The rank of this process.
Definition: boundary.h:156
BoundarySimple(const type::Mesh &mesh, const YAML::Node &node)
Construct a boundary object based on a given mesh object.
virtual PetscErrorCode copyValues2LocalVecs(std::vector< Vec > &lclVecs) const
Copy values of ghost points to a vector of local PETSc Vec objects.
virtual PetscErrorCode init(const type::Mesh &mesh, const YAML::Node &node)
Underlying initialization function.
virtual PetscErrorCode updateGhostValues(const type::Solution &soln)
Update the values of ghost points.
virtual PetscErrorCode setGhostICs(const type::Solution &soln)
Set the initial values of ghost points.
virtual PetscErrorCode updateEqs(const type::Solution &soln, const PetscReal &dt)
Update the equations between ghost and boundary points.
PetscErrorCode createSingleBoundary(const type::Mesh &mesh, const type::BCLoc &loc, const type::Field &field, const PetscReal &value, const type::BCType &bcType, type::SingleBoundary &singleBd)
Factory function for creating a SingleBoundary object.
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
Definition: mesh.h:348
PetscErrorCode parseBCs(const YAML::Node &node, type::IntVec2D &bcTypes, type::RealVec2D &bcValues)
Parse boundary conditions from a YAML node.
Definition: parser.cpp:359
std::shared_ptr< solution::SolutionBase > Solution
Type definition of solution object.
Definition: solution.h:210
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
Definition: type.h:135
Field
Legal fields.
Definition: type.h:80
BCType
Type of boundary conditions.
Definition: type.h:94
std::vector< RealVec1D > RealVec2D
2D std::vector holding PetscReal.
Definition: type.h:142
BCLoc
Location of a boundary.
Definition: type.h:108
A toolbox for building flow solvers.
Definition: bodypack.h:52
Prototypes of parser functions.