Rheolef  7.2
an efficient C++ finite element environment
contraction.h
Go to the documentation of this file.
1
26 struct base {
27 base (geo omega) : c(0), umax(0), cartesian(true) {
28 c = omega.xmax()[1];
29 string sys_coord = omega.coordinate_system_name();
30 cartesian = (sys_coord == "cartesian");
31 umax = cartesian ? 3/(2*c) : 4/sqr(c);
32 }
35 };
36 struct u_upstream: base {
37 u_upstream (geo omega) : base(omega) {}
38 Float operator() (const point& x) const {
39 return base::umax*(1-sqr(x[1]/base::c)); }
40 };
41 static space velocity_space (geo omega, string approx) {
42 space Xh (omega, approx, "vector");
43 Xh.block ("wall");
44 Xh.block ("upstream");
45 Xh[1].block ("axis");
46 Xh[1].block ("downstream");
47 return Xh;
48 }
50 geo omega = Xh.get_geo();
51 string approx = "P" + to_string(Xh.degree());
52 space Wh (omega["upstream"], approx);
53 field uh (Xh, 0.);
54 uh[0]["upstream"] = lazy_interpolate (Wh, u_upstream(omega));
55 return uh;
56 }
57 static space streamf_space (geo omega, string approx) {
58 space Ph (omega, approx);
59 Ph.block("upstream");
60 Ph.block("wall");
61 Ph.block("axis");
62 return Ph;
63 }
65 psi_upstream (geo omega) : base(omega) {}
66 Float operator() (const point& x) const {
67 Float y = (x[1]/base::c);
68 if (base::cartesian) {
69 return (base::umax*base::c)*(y*(1-sqr(y)/3) - 2./3);
70 } else {
71 return 0.5*(base::umax*sqr(base::c))*(sqr(y)*(1-sqr(y)/2) - 0.5);
72 }
73 }
74 };
76 geo omega = Ph.get_geo();
77 space Wh (omega["upstream"], Ph.get_approx());
78 field psi_h (Ph, 0);
79 psi_upstream psi_up (omega);
80 psi_h["upstream"] = lazy_interpolate (Wh, psi_up);
81 psi_h["wall"] = 0;
82 psi_h["axis"] = -1;
83 return psi_h;
84 }
85};
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 point page for the full documentation
see the space page for the full documentation
string sys_coord
Definition: mkgeo_grid.sh:171
field_basic< T, M > lazy_interpolate(const space_basic< T, M > &X2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
Definition: field.h:871
base(geo omega)
Definition: contraction.h:27
Float operator()(const point &x) const
Definition: contraction.h:66
Float operator()(const point &x) const
Definition: contraction.h:38
static field streamf_field(space Ph)
Definition: contraction.h:75
static space velocity_space(geo omega, string approx)
Definition: contraction.h:41
static space streamf_space(geo omega, string approx)
Definition: contraction.h:57
static field velocity_field(space Xh)
Definition: contraction.h:49