Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
navier_stokes_solve.icc
Go to the documentation of this file.
1
25using namespace std;
27 Float Re, Float delta_t, field l0h, field& uh, field& ph,
28 size_t& max_iter, Float& tol, odiststream *p_derr=0) {
29 const space& Xh = uh.get_space();
30 const space& Qh = ph.get_space();
31 string label = "navier-stokes-" + Xh.get_geo().name();
32 integrate_option iopt;
33 iopt.set_family(integrate_option::gauss_lobatto);
34 iopt.set_order(Xh.degree());
35 trial u (Xh), p (Qh);
36 test v (Xh), q (Qh);
37 form m = integrate (dot(u,v), iopt);
38 form a = integrate (2*ddot(D(u),D(v)) + 1.5*(Re/delta_t)*dot(u,v), iopt);
39 form b = integrate (-div(u)*q, iopt);
40 problem_mixed stokes (a, b);
41 if (p_derr != 0) *p_derr << "[" << label << "] #n |du/dt|" << endl;
42 field uh1 = uh;
43 for (size_t n = 0; true; n++) {
44 field uh2 = uh1;
45 uh1 = uh;
46 field uh_star = 2.0*uh1 - uh2;
47 characteristic X1 ( -delta_t*uh_star);
48 characteristic X2 (-2.0*delta_t*uh_star);
49 field l1h = integrate (dot(compose(uh1,X1),v), iopt);
50 field l2h = integrate (dot(compose(uh2,X2),v), iopt);
51 field lh = l0h + (Re/delta_t)*(2*l1h - 0.5*l2h);
52 stokes.solve (lh, field(Qh,0), uh, ph);
53 field duh_dt = (3*uh - 4*uh1 + uh2)/(2*delta_t);
54 Float residual = sqrt(m(duh_dt,duh_dt));
55 if (p_derr != 0) *p_derr << "[" << label << "] "<< n << " " << residual << endl;
56 if (residual < tol) {
57 tol = residual;
58 max_iter = n;
59 return 0;
60 }
61 if (n == max_iter-1) {
62 tol = residual;
63 return 1;
64 }
65 }
66}
field lh(Float epsilon, Float t, const test &v)
see the Float page for the full documentation
see the characteristic page for the full documentation
see the field page for the full documentation
see the form page for the full documentation
see the problem_mixed page for the full documentation
see the space page for the full documentation
see the test page for the full documentation
see the test page for the full documentation
STL namespace.
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 sphere.icc:25
Definition leveque.h:25