Rheolef  7.1
an efficient C++ finite element environment
navier_stokes_cavity.cc
Go to the documentation of this file.
1 #include "rheolef.h"
26 using namespace rheolef;
27 using namespace std;
28 #include "navier_stokes_solve.icc"
30 #include "cavity.h"
31 int main (int argc, char**argv) {
32  environment rheolef (argc, argv);
33  if (argc < 2) {
34  cerr << "usage: " << argv[0] << " <geo> <Re> <err> <n_adapt>" << endl;
35  exit (1);
36  }
37  geo omega (argv[1]);
38  adapt_option options;
39  Float Re = (argc > 2) ? atof(argv[2]) : 100;
40  options.err = (argc > 3) ? atof(argv[3]) : 1e-2;
41  size_t n_adapt = (argc > 4) ? atoi(argv[4]) : 5;
42  Float delta_t = 0.05;
43  options.hmin = 0.004;
44  options.hmax = 0.1;
45  space Xh = cavity::velocity_space (omega, "P2");
46  space Qh (omega, "P1");
47  field uh = cavity::velocity_field (Xh, 1.0);
48  field ph (Qh, 0);
49  field fh (Xh, 0);
50  for (size_t i = 0; true; i++) {
51  size_t max_iter = 1000;
52  Float tol = 1e-5;
53  navier_stokes_solve (Re, delta_t, fh, uh, ph, max_iter, tol, &derr);
54  odiststream o (omega.name(), "field");
55  o << catchmark("Re") << Re << endl
56  << catchmark("delta_t") << delta_t << endl
57  << catchmark("u") << uh
58  << catchmark("p") << ph;
59  o.close();
60  if (i >= n_adapt) break;
61  field ch = navier_stokes_criterion (Re,uh);
62  omega = adapt (ch, options);
63  o.open (omega.name(), "geo");
64  o << omega;
65  o.close();
66  Xh = cavity::velocity_space (omega, "P2");
67  Qh = space (omega, "P1");
68  uh = cavity::velocity_field (Xh, 1.0);
69  ph = field (Qh, 0);
70  fh = field (Xh, 0);
71  }
72 }
rheolef::odiststream::open
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.
Definition: diststream.cc:143
main
int main(int argc, char **argv)
Definition: navier_stokes_cavity.cc:31
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
rheolef::catchmark
see the catchmark page for the full documentation
Definition: catchmark.h:67
field
see the field page for the full documentation
rheolef::field
field_basic< Float > field
see the field page for the full documentation
Definition: field.h:419
rheolef::adapt_option
adapt_option: see the adapt page for the full documentation
Definition: adapt.h:147
space
see the space page for the full documentation
rheolef.h
rheolef - reference manual
rheolef::adapt_option::hmin
Float hmin
Definition: adapt.h:154
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::space
space_basic< Float > space
Definition: space.h:356
rheolef::odiststream::close
void close()
Definition: diststream.cc:164
rheolef::environment
see the environment page for the full documentation
Definition: environment.h:115
navier_stokes_criterion.icc
The Navier-Stokes equations – adaptive mesh criterion.
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::adapt_option::err
Float err
Definition: adapt.h:151
navier_stokes_solve.icc
The Navier-Stokes equations with the method of characteristics – solver function.
rheolef::derr
odiststream derr(cerr)
see the diststream page for the full documentation
Definition: diststream.h:436
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
Float
see the Float page for the full documentation
cavity.h
The driven cavity benchmark: 2D boundary conditions.
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
navier_stokes_criterion
field navier_stokes_criterion(Float Re, const field &uh)
Definition: navier_stokes_criterion.icc:25
rheolef::std
Definition: vec_expr_v2.h:402
geo
see the geo page for the full documentation
rheolef::adapt_option::hmax
Float hmax
Definition: adapt.h:155