Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
navier_stokes_cavity.cc
Go to the documentation of this file.
1
25#include "rheolef.h"
26using namespace rheolef;
27using namespace std;
30#include "cavity.h"
31int 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}
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.
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:179
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