12 #include "libmesh/face_quad4.h"
13 #include "libmesh/face_tri3.h"
14 #include "libmesh/mesh_modification.h"
28 "How many points to discretize the range q = (0.5, k) into.");
30 "How many 'extra' points should be inserted in the final element"
31 " *in addition to* the equispaced q points.");
32 params.
addRequiredParam<
int>(
"num_k_pts",
"How many points in the range k=(kmin, kmax).");
33 params.
addParam<boundary_id_type>(
"inflow_bid", 1,
"The boundary id to use for the inflow");
35 "inner_wall_bid", 2,
"The boundary id to use for the inner wall");
36 params.
addParam<boundary_id_type>(
"outflow_bid", 3,
"The boundary id to use for the outflow");
38 "outer_wall_bid", 4,
"The boundary id to use for the outer wall");
40 "triangles",
false,
"If true, all the quadrilateral elements will be split into triangles");
48 _gamma(getParam<Real>(
"gamma")),
49 _kmax(getParam<Real>(
"kmax")),
50 _kmin(getParam<Real>(
"kmin")),
51 _num_q_pts(getParam<int>(
"num_q_pts")),
52 _n_extra_q_pts(getParam<int>(
"n_extra_q_pts")),
53 _num_k_pts(getParam<int>(
"num_k_pts")),
54 _inflow_bid(getParam<boundary_id_type>(
"inflow_bid")),
55 _outflow_bid(getParam<boundary_id_type>(
"outflow_bid")),
56 _inner_wall_bid(getParam<boundary_id_type>(
"inner_wall_bid")),
57 _outer_wall_bid(getParam<boundary_id_type>(
"outer_wall_bid")),
58 _triangles(getParam<bool>(
"triangles"))
63 mooseError(
"RinglebMesh: kmax must be greater than kmin");
66 std::unique_ptr<MooseMesh>
69 return libmesh_make_unique<RinglebMesh>(*
this);
75 std::vector<Real> values(4);
76 Real a = std::sqrt(1 - ((gamma - 1) / 2.) *
std::pow(q[index], 2));
77 Real rho =
std::pow(a, 2. / (gamma - 1));
78 Real p = (1. / gamma) *
std::pow(a, 2 * gamma / (gamma - 1));
80 0.5 * std::log((1 + a) / (1 - a));
81 values = {a, rho, p, J};
89 const std::vector<Real> & ks,
90 const std::vector<Real> & q)
92 std::vector<Real> xy(2);
95 xy[0] = 0.5 / values[1] * (2. / ks[i] / ks[i] - 1. / q[index] / q[index]) - 0.5 * values[3];
99 Real sqrt_term = 1. - q[index] * q[index] / ks[i] / ks[i];
100 sqrt_term = std::max(sqrt_term, 0.);
103 xy[1] = 1. / (ks[i] * values[1] * q[index]) * std::sqrt(sqrt_term);
114 std::vector<std::vector<Node *>> stream_nodes(
_num_k_pts);
117 int current_node_id = 0;
123 ks[i] =
_kmin + i * diff;
131 Real diffq = (ks[i] - 0.5) / (
_num_q_pts - 1);
133 q[j] = 0.5 + j * diffq;
138 std::vector<Real>::iterator it = q.end();
139 q.insert(--it, 0.3 * q[j - 2] + 0.7 * q[j - 1]);
142 std::vector<Real> vals(4);
143 std::vector<Real> xy(2);
155 stream_nodes[i][j] = mesh.add_point(Point(xy[0], xy[1]), current_node_id++);
169 stream_nodes[i][j] = mesh.add_point(Point(xy[0], -xy[1]), current_node_id++);
181 Elem *
elem = mesh.add_elem(
new Quad4);
182 elem->set_node(0) = stream_nodes[i][j];
183 elem->set_node(1) = stream_nodes[i][j + 1];
184 elem->set_node(2) = stream_nodes[i + 1][j + 1];
185 elem->set_node(3) = stream_nodes[i + 1][j];
198 Elem *
elem = mesh.add_elem(
new Quad4);
199 elem->set_node(0) = stream_nodes[i][j];
200 elem->set_node(1) = stream_nodes[i][j + 2];
201 elem->set_node(2) = stream_nodes[i + 1][j + 2];
202 elem->set_node(3) = stream_nodes[i + 1][j];
213 mesh.prepare_for_use();
217 MeshTools::Modification::all_tri(mesh);
220 mesh.boundary_info->sideset_name(
_inflow_bid) =
"inflow";
221 mesh.boundary_info->sideset_name(
_outflow_bid) =
"outflow";