navier_stokes_solve.icc

The Navier-Stokes equations with the method of characteristics – solver function

using namespace std;
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) {
const space& Xh = uh.get_space();
const space& Qh = ph.get_space();
string label = "navier-stokes-" + Xh.get_geo().name();
integrate_option iopt;
iopt.set_family(integrate_option::gauss_lobatto);
iopt.set_order(Xh.degree());
trial u (Xh), p (Qh);
test v (Xh), q (Qh);
form m = integrate (dot(u,v), iopt);
form a = integrate (2*ddot(D(u),D(v)) + 1.5*(Re/delta_t)*dot(u,v), iopt);
form b = integrate (-div(u)*q, iopt);
problem_mixed stokes (a, b);
if (p_derr != 0) *p_derr << "[" << label << "] #n |du/dt|" << endl;
field uh1 = uh;
for (size_t n = 0; true; n++) {
field uh2 = uh1;
uh1 = uh;
field uh_star = 2.0*uh1 - uh2;
characteristic X1 ( -delta_t*uh_star);
characteristic X2 (-2.0*delta_t*uh_star);
field l1h = integrate (dot(compose(uh1,X1),v), iopt);
field l2h = integrate (dot(compose(uh2,X2),v), iopt);
field lh = l0h + (Re/delta_t)*(2*l1h - 0.5*l2h);
stokes.solve (lh, field(Qh,0), uh, ph);
field duh_dt = (3*uh - 4*uh1 + uh2)/(2*delta_t);
Float residual = sqrt(m(duh_dt,duh_dt));
if (p_derr != 0) *p_derr << "[" << label << "] "<< n << " " << residual << endl;
if (residual < tol) {
tol = residual;
max_iter = n;
return 0;
}
if (n == max_iter-1) {
tol = residual;
return 1;
}
}
}
lh
field lh(Float epsilon, Float t, const test &v)
Definition: burgers_diffusion_operators.icc:25
Float
see the Float page for the full documentation
characteristic
see the characteristic page for the full documentation
field
see the field page for the full documentation
form
see the form page for the full documentation
problem_mixed
see the problem_mixed page for the full documentation
space
see the space page for the full documentation
test
see the test page for the full documentation
trial
see the test page for the full documentation
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_ball.n
int n
Definition: mkgeo_ball.sh:150
mkgeo_sector.m
m
Definition: mkgeo_sector.sh:118
rheolef::details::compose
class rheolef::details::field_expr_v2_nonlinear_node_unary compose
rheolef::details::dot
rheolef::details::is_vec dot
rheolef::integrate
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&! is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const integrate_option &iopt, Result dummy=Result())
see the integrate page for the full documentation
Definition: integrate.h:202
rheolef::ddot
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
Definition: tensor.cc:278
rheolef::D
std::enable_if< details::is_field_convertible< Expr >::value,details::field_expr_v2_nonlinear_terminal_field< typename Expr::scalar_type,typename Expr::memory_type,details::differentiate_option::gradient >>::type D(const Expr &expr)
D(uh): see the expression page for the full documentation.
Definition: field_expr_terminal.h:969
rheolef::div
std::enable_if< details::is_field_convertible< Expr >::value,details::field_expr_v2_nonlinear_terminal_field< typename Expr::scalar_type,typename Expr::memory_type,details::differentiate_option::divergence >>::type div(const Expr &expr)
div(uh): see the expression page for the full documentation
Definition: field_expr_terminal.h:1031
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
a
Definition: diffusion_isotropic.h:25
p
Definition: sphere.icc:25
u
Definition: leveque.h:25
u
Float u(const point &x)
Definition: transmission_error.cc:26