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).");
36 "inner_wall_bid", 2,
"The boundary id to use for the inner wall");
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")),
59 _triangles(getParam<bool>(
"triangles"))
65 mooseError(
"RinglebMesh: kmax must be greater than kmin");
71 std::vector<Real> values(4);
74 Real p = (1. / gamma) *
std::pow(a, 2 * gamma / (gamma - 1));
77 values = {a, rho, p, J};
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];
99 xy[1] = 1. / (ks[i] * values[1] * q[index]) *
std::sqrt(sqrt_term);
104 std::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;
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";
const Real & _kmax
k is a streamline parameter, i.e.
const Real & _kmin
kmin corresponds to the outer wall
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
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)
const int & _n_extra_q_pts
how many "extra" points should be inserted in the nearest element from the horizontal in additi /// o...
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
const boundary_id_type _outflow_bid
const boundary_id_type _inflow_bid
The boundary ids to use for the ringleb mesh.
static InputParameters validParams()
Generates a mesh given all the parameters.
const boundary_id_type _inner_wall_bid
auto max(const L &left, const R &right)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::vector< Real > arhopj(const Real &gamma, const std::vector< Real > &q, const int &index)
const Real & _gamma
Gamma.
const boundary_id_type _outer_wall_bid
const bool & _triangles
This parameter, if true, allows to split the quadrilateral elements into triangular elements...
static InputParameters validParams()
registerMooseObject("MooseApp", RinglebMeshGenerator)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const int & _num_q_pts
How many points to discretize the range q = (0.5, k) into.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const int & _num_k_pts
how many points in the range k=(kmin, kmax).
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...
RinglebMeshGenerator(const InputParameters ¶meters)
MooseUnits pow(const MooseUnits &, int)
MeshGenerators are objects that can modify or add to an existing mesh.
void ErrorVector unsigned int