navier_stokes_cavity.cc

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

#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "navier_stokes_solve.icc"
#include "navier_stokes_criterion.icc"
#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;
field ch = navier_stokes_criterion (Re,uh);
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);
}
}
cavity.h
The driven cavity benchmark: 2D boundary conditions.
Float
see the Float page for the full documentation
field
see the field page for the full documentation
geo
see the geo page for the full documentation
rheolef::space
space_basic< Float > space
Definition: space.h:356
rheolef::field
field_basic< Float > field
see the field page for the full documentation
Definition: field.h:419
rheolef::derr
odiststream derr(cerr)
see the diststream page for the full documentation
Definition: diststream.h:436
space
see the space page for the full documentation
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::adapt
geo_basic< T, M > adapt(const field_basic< T, M > &uh, const adapt_option &opts)
adapt(uh,opts): see the adapt page for the full documentation
Definition: adapt.cc:172
main
int main(int argc, char **argv)
Definition: navier_stokes_cavity.cc:31
navier_stokes_criterion.icc
The Navier-Stokes equations – adaptive mesh criterion.
navier_stokes_criterion
field navier_stokes_criterion(Float Re, const field &uh)
Definition: navier_stokes_criterion.icc:25
navier_stokes_solve.icc
The Navier-Stokes equations with the method of characteristics – solver function.
navier_stokes_solve
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)
Definition: navier_stokes_solve.icc:26
rheolef.h
rheolef - reference manual
cavity::velocity_space
static space velocity_space(const geo &omega, string approx)
Definition: cavity.h:26
cavity::velocity_field
static field velocity_field(const space &Xh, Float alpha=1)
Definition: cavity.h:37