Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
navier_stokes_cavity.cc

The Navier-Stokes equations on the driven cavity benchmark with the method of characteristics.

The Navier-Stokes equations on the driven cavity benchmark with the method of characteristics

#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "cavity.h"
int main (int argc, char**argv) {
environment rheolef (argc, argv);
if (argc < 2) {
cerr << "usage: " << argv[0] << " <geo> <Re> <err> <n_adapt>" << endl;
exit (1);
}
geo omega (argv[1]);
adapt_option options;
Float Re = (argc > 2) ? atof(argv[2]) : 100;
options.err = (argc > 3) ? atof(argv[3]) : 1e-2;
size_t n_adapt = (argc > 4) ? atoi(argv[4]) : 5;
Float delta_t = 0.05;
options.hmin = 0.004;
options.hmax = 0.1;
space Xh = cavity::velocity_space (omega, "P2");
space Qh (omega, "P1");
field uh = cavity::velocity_field (Xh, 1.0);
field ph (Qh, 0);
field fh (Xh, 0);
for (size_t i = 0; true; i++) {
size_t max_iter = 1000;
Float tol = 1e-5;
navier_stokes_solve (Re, delta_t, fh, uh, ph, max_iter, tol, &derr);
odiststream o (omega.name(), "field");
o << catchmark("Re") << Re << endl
<< catchmark("delta_t") << delta_t << endl
<< catchmark("u") << uh
<< catchmark("p") << ph;
o.close();
if (i >= n_adapt) break;
omega = adapt (ch, options);
o.open (omega.name(), "geo");
o << omega;
o.close();
Xh = cavity::velocity_space (omega, "P2");
Qh = space (omega, "P1");
uh = cavity::velocity_field (Xh, 1.0);
ph = field (Qh, 0);
fh = field (Xh, 0);
}
}
The driven cavity benchmark: 2D boundary conditions.
see the Float page for the full documentation
see the field page for the full documentation
see the geo page for the full documentation
see the catchmark page for the full documentation
Definition catchmark.h:67
see the environment page for the full documentation
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
void open(std::string filename, std::string suffix="", io::mode_type mode=io::out, const communicator &comm=communicator())
This routine opens a physical output file.
see the space page for the full documentation
int main()
Definition field2bb.cc:58
This file is part of Rheolef.
STL namespace.
The Navier-Stokes equations – adaptive mesh criterion.
field navier_stokes_criterion(Float Re, const field &uh)
The Navier-Stokes equations with the method of characteristics – solver function.
int navier_stokes_solve(Float Re, Float delta_t, field l0h, field &uh, field &ph, size_t &max_iter, Float &tol, odiststream *p_derr=0)
rheolef - reference manual
static space velocity_space(const geo &omega, string approx)
Definition cavity.h:26
static field velocity_field(const space &Xh, Float alpha=1)
Definition cavity.h:37
adapt_option: see the adapt page for the full documentation
Definition adapt.h:147