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/parser.h>
14
15#include "navierstokes.h"
16
45int main(int argc, char **argv)
46{
47 PetscErrorCode ierr;
48 YAML::Node config;
49 NavierStokesSolver solver;
50
51 ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr);
52 ierr = PetscLogDefaultBegin(); CHKERRQ(ierr);
53
54 // parse configuration files; store info in YAML node
55 ierr = petibm::parser::getSettings(config); CHKERRQ(ierr);
56
57 // initialize the Navier-Stokes solver
58 ierr = solver.init(PETSC_COMM_WORLD, config); CHKERRQ(ierr);
59 ierr = solver.ioInitialData(); CHKERRQ(ierr);
60 ierr = PetscPrintf(PETSC_COMM_WORLD,
61 "Completed initialization stage\n"); CHKERRQ(ierr);
62
63 // integrate the solution in time
64 while (!solver.finished())
65 {
66 // compute the solution at the next time step
67 ierr = solver.advance(); CHKERRQ(ierr);
68 // output data to files
69 ierr = solver.write(); CHKERRQ(ierr);
70 }
71
72 // destroy the Navier-Stokes solver
73 ierr = solver.destroy(); CHKERRQ(ierr);
74
75 ierr = PetscFinalize(); CHKERRQ(ierr);
76
77 return 0;
78} // main
int main(int argc, char **argv)
Definition: main.cpp:48
Solve the incompressible Navier-Stokes equations with a projection method (Perot 1993).
Definition: navierstokes.h:30
PetscErrorCode ioInitialData()
Read or write initial data.
PetscErrorCode advance()
Advance the solution by one time step.
bool finished()
Evaluate if the simulation is finished.
PetscErrorCode write()
Write solution and solver info to files.
PetscErrorCode init(const MPI_Comm &world, const YAML::Node &node)
Initialize the Navier-Stokes solver.
PetscErrorCode destroy()
Manually destroy data.
PetscErrorCode getSettings(YAML::Node &node)
Get configuration settings.
Definition: parser.cpp:175
Definition of the class NavierStokesSolver.
Prototypes of parser functions.