13#include "libmesh/replicated_mesh.h"
14#include "libmesh/mesh_modification.h"
15#include "libmesh/face_quad4.h"
16#include "libmesh/face_tri3.h"
29 "How many points to discretize the range q = (0.5, k) into.");
31 "How many 'extra' points should be inserted in the final element"
32 " *in addition to* the equispaced q points.");
33 params.
addRequiredParam<
int>(
"num_k_pts",
"How many points in the range k=(kmin, kmax).");
34 params.
addParam<boundary_id_type>(
"inflow_bid", 1,
"The boundary id to use for the inflow");
36 "inner_wall_bid", 2,
"The boundary id to use for the inner wall");
37 params.
addParam<boundary_id_type>(
"outflow_bid", 3,
"The boundary id to use for the outflow");
39 "outer_wall_bid", 4,
"The boundary id to use for the outer wall");
41 "triangles",
false,
"If true, all the quadrilateral elements will be split into triangles");
49 _gamma(getParam<Real>(
"gamma")),
50 _kmax(getParam<Real>(
"kmax")),
51 _kmin(getParam<Real>(
"kmin")),
52 _num_q_pts(getParam<
int>(
"num_q_pts")),
53 _n_extra_q_pts(getParam<
int>(
"n_extra_q_pts")),
54 _num_k_pts(getParam<
int>(
"num_k_pts")),
55 _inflow_bid(getParam<boundary_id_type>(
"inflow_bid")),
56 _outflow_bid(getParam<boundary_id_type>(
"outflow_bid")),
57 _inner_wall_bid(getParam<boundary_id_type>(
"inner_wall_bid")),
58 _outer_wall_bid(getParam<boundary_id_type>(
"outer_wall_bid")),
59 _triangles(getParam<bool>(
"triangles"))
65 mooseError(
"RinglebMesh: kmax must be greater than kmin");
71 std::vector<Real>
values(4);
72 Real a = std::sqrt(1 - ((gamma - 1) / 2.) *
std::pow(q[index], 2));
73 Real rho =
std::pow(a, 2. / (gamma - 1));
74 Real p = (1. / gamma) *
std::pow(a, 2 * gamma / (gamma - 1));
76 0.5 * std::log((1 + a) / (1 - a));
85 const std::vector<Real> & ks,
86 const std::vector<Real> & q)
88 std::vector<Real> xy(2);
91 xy[0] = 0.5 /
values[1] * (2. / ks[i] / ks[i] - 1. / q[index] / q[index]) - 0.5 *
values[3];
95 Real sqrt_term = 1. - q[index] * q[index] / ks[i] / ks[i];
96 sqrt_term = std::max(sqrt_term, 0.);
99 xy[1] = 1. / (ks[i] *
values[1] * q[index]) * std::sqrt(sqrt_term);
104std::unique_ptr<MeshBase>
108 BoundaryInfo & boundary_info =
mesh->get_boundary_info();
111 std::vector<std::vector<Node *>> stream_nodes(
_num_k_pts);
114 int current_node_id = 0;
120 ks[i] =
_kmin + i * diff;
128 Real diffq = (ks[i] - 0.5) / (
_num_q_pts - 1);
130 q[j] = 0.5 + j * diffq;
135 std::vector<Real>::iterator it = q.end();
136 q.insert(--it, 0.3 * q[j - 2] + 0.7 * q[j - 1]);
139 std::vector<Real> vals(4);
140 std::vector<Real> xy(2);
152 stream_nodes[i][j] =
mesh->add_point(Point(xy[0], xy[1]), current_node_id++);
166 stream_nodes[i][j] =
mesh->add_point(Point(xy[0], -xy[1]), current_node_id++);
178 Elem * elem =
mesh->add_elem(
new Quad4);
179 elem->set_node(0, stream_nodes[i][j]);
180 elem->set_node(1, stream_nodes[i][j + 1]);
181 elem->set_node(2, stream_nodes[i + 1][j + 1]);
182 elem->set_node(3, stream_nodes[i + 1][j]);
187 boundary_info.add_side(elem->id(), 3,
_inflow_bid);
195 Elem * elem =
mesh->add_elem(
new Quad4);
196 elem->set_node(0, stream_nodes[i][j]);
197 elem->set_node(1, stream_nodes[i][j + 2]);
198 elem->set_node(2, stream_nodes[i + 1][j + 2]);
199 elem->set_node(3, stream_nodes[i + 1][j]);
210 mesh->prepare_for_use();
214 MeshTools::Modification::all_tri(*
mesh);
217 boundary_info.sideset_name(
_inflow_bid) =
"inflow";
222 return dynamic_pointer_cast<MeshBase>(
mesh);
std::array< Real, 2 > values
registerMooseObject("MooseApp", RinglebMeshGenerator)
void ErrorVector unsigned int
MeshGenerators are objects that can modify or add to an existing mesh.
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
static InputParameters validParams()
T & declareMeshProperty(const std::string &data_name, Args &&... args)
Methods for writing out attributes to the mesh meta-data store, which can be retrieved from most othe...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Generates a mesh given all the parameters.
std::vector< Real > computexy(const std::vector< Real > values, const int &i, const int &index, const std::vector< Real > &ks, const std::vector< Real > &q)
RinglebMeshGenerator(const InputParameters ¶meters)
const int & _n_extra_q_pts
how many "extra" points should be inserted in the nearest element from the horizontal in additi /// o...
const bool & _triangles
This parameter, if true, allows to split the quadrilateral elements into triangular elements.
const Real & _gamma
Gamma.
const boundary_id_type _outer_wall_bid
const Real & _kmax
k is a streamline parameter, i.e.
const boundary_id_type _inner_wall_bid
std::vector< Real > arhopj(const Real &gamma, const std::vector< Real > &q, const int &index)
const boundary_id_type _inflow_bid
The boundary ids to use for the ringleb mesh.
const Real & _kmin
kmin corresponds to the outer wall
const boundary_id_type _outflow_bid
const int & _num_k_pts
how many points in the range k=(kmin, kmax).
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const int & _num_q_pts
How many points to discretize the range q = (0.5, k) into.
static InputParameters validParams()
MooseUnits pow(const MooseUnits &, int)