PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
solution.cpp
Go to the documentation of this file.
1
9#include <petibm/io.h>
10#include <petibm/solution.h>
12
13namespace petibm
14{
15namespace solution
16{
17// Destructor.
19{
20 PetscErrorCode ierr;
21 PetscBool finalized;
22
23 PetscFunctionBeginUser;
24
25 ierr = PetscFinalized(&finalized); CHKERRV(ierr);
26 if (finalized) return;
27
28 ierr = VecDestroy(&UGlobal); CHKERRV(ierr);
29 ierr = VecDestroy(&pGlobal); CHKERRV(ierr);
30 comm = MPI_COMM_NULL;
31} // ~SolutionBase
32
33// Manually destroy data.
34PetscErrorCode SolutionBase::destroy()
35{
36 PetscErrorCode ierr;
37
38 PetscFunctionBeginUser;
39
40 dim = -1;
41 ierr = VecDestroy(&UGlobal); CHKERRQ(ierr);
42 ierr = VecDestroy(&pGlobal); CHKERRQ(ierr);
43 info = "";
44
45 comm = MPI_COMM_NULL;
46 mpiRank = mpiSize = 0;
47 mesh.reset();
48
49 PetscFunctionReturn(0);
50} // destroy
51
52// Print information about the solution to standard output.
53PetscErrorCode SolutionBase::printInfo() const
54{
55 PetscErrorCode ierr;
56
57 PetscFunctionBeginUser;
58
59 ierr = io::print(info); CHKERRQ(ierr);
60
61 PetscFunctionReturn(0);
62} // printInfo
63
64// Factory function to create a petibm::solution::Solution object.
65PetscErrorCode createSolution(const type::Mesh &mesh, type::Solution &solution)
66{
67 PetscFunctionBeginUser;
68
69 solution = std::make_shared<SolutionSimple>(mesh);
70
71 PetscFunctionReturn(0);
72} // createSolution
73
74} // end of namespace solution
75} // end of namespace petibm
PetscMPIInt mpiRank
Rank of the local process.
Definition: solution.h:173
MPI_Comm comm
MPI communicator.
Definition: solution.h:167
PetscMPIInt mpiSize
Size of MPI communicator.
Definition: solution.h:170
std::string info
String containing information about the solution.
Definition: solution.h:72
virtual PetscErrorCode destroy()
Manually destroy data.
Definition: solution.cpp:34
virtual ~SolutionBase()
Default destructor.
Definition: solution.cpp:18
Vec UGlobal
Packed PETSc Vec object for the velocity vector field.
Definition: solution.h:66
type::Mesh mesh
Shared pointer to the underlying Cartesian mesh object.
Definition: solution.h:176
PetscErrorCode printInfo() const
Print information about the solution to standard output.
Definition: solution.cpp:53
Vec pGlobal
PETSc Vec for the pressure scalar field.
Definition: solution.h:69
PetscInt dim
Number of dimensions.
Definition: solution.h:63
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
Definition: mesh.h:348
PetscErrorCode print(const std::string &info)
Print information of a parallel object to standard output.
Definition: io.cpp:120
std::shared_ptr< solution::SolutionBase > Solution
Type definition of solution object.
Definition: solution.h:210
PetscErrorCode createSolution(const type::Mesh &mesh, type::Solution &solution)
Factory function to create a petibm::solution::Solution object.
Definition: solution.cpp:65
Prototypes of I/O functions.
A toolbox for building flow solvers.
Definition: bodypack.h:52
Definition of the class petibm::solution::SolutionBase, the type definition petibm::type::Solution,...
Definition of class petibm::solution::SolutionSimple.