PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
main.cpp
Go to the documentation of this file.
1
10#include <petscsys.h>
11#include <yaml-cpp/yaml.h>
12
13#include <petibm/mesh.h>
14#include <petibm/parser.h>
15
24int main(int argc, char **argv)
25{
26 PetscErrorCode ierr;
27 YAML::Node config;
29
30 ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr);
31 ierr = PetscLogDefaultBegin(); CHKERRQ(ierr);
32
33 // parse configuration files; store info in YAML node
34 ierr = petibm::parser::getSettings(config); CHKERRQ(ierr);
35
36 // create mesh
37 ierr = petibm::mesh::createMesh(PETSC_COMM_WORLD, config, mesh);
38 CHKERRQ(ierr);
39
40 // write grid data into HDF5 file
41 std::string filePath = config["output"].as<std::string>() + "/grid.h5";
42 char s[PETSC_MAX_PATH_LEN];
43 PetscBool flag = PETSC_FALSE;
44 ierr = PetscOptionsGetString(nullptr, nullptr, "-file", s, sizeof(s),
45 &flag); CHKERRQ(ierr);
46 if (flag) filePath = s;
47 ierr = mesh->write(filePath); CHKERRQ(ierr);
48
49 ierr = mesh->destroy(); CHKERRQ(ierr);
50 ierr = PetscFinalize(); CHKERRQ(ierr);
51
52 return 0;
53} // main
int main(int argc, char **argv)
Definition: main.cpp:48
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 getSettings(YAML::Node &node)
Get configuration settings.
Definition: parser.cpp:175
Prototype of mesh::MeshBase, type::Mesh, and factory function.
Prototypes of parser functions.