15 #include "libmesh/fparser_ad.hh" 16 #include "libmesh/distributed_mesh.h" 17 #include "libmesh/elem.h" 18 #include "libmesh/fe_base.h" 31 "Function expression encoding a combinatorial geometry");
32 params.
addRequiredParam<BoundaryName>(
"new_sideset_name",
"The name of the new sideset");
34 params.
addParam<std::vector<std::string>>(
35 "constant_names", {},
"Vector of constants used in the parsed function");
36 params.
addParam<std::vector<std::string>>(
37 "constant_expressions",
39 "Vector of values for the constants in constant_names (can be an FParser expression)");
46 "centroid satisfies the `combinatorial_geometry` expression. " 47 "Optionally, element sides are also added if they are included in " 48 "`included_subdomains` and if they feature the designated normal.");
56 _function(parameters.
get<
std::string>(
"combinatorial_geometry"))
61 _func_F = std::make_shared<SymFunction>();
68 getParam<std::vector<std::string>>(
"constant_names"),
69 getParam<std::vector<std::string>>(
"constant_expressions"));
75 "\nin ParsedAddSideset ",
83 std::unique_ptr<MeshBase>
86 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
87 if (!
mesh->is_replicated())
89 "ParsedGenerateSideset is not implemented for distributed meshes. Make sure the " 90 "parsed sideset does NOT cross any mesh distribution boundaries, using the ProcessorAux");
95 BoundaryInfo & boundary_info =
mesh->get_boundary_info();
98 std::vector<boundary_id_type> boundary_ids =
100 mooseAssert(boundary_ids.size() == 1,
"Length of boundary_ids should be one");
102 for (
const auto & elem :
mesh->active_element_ptr_range())
108 for (
const auto side :
make_range(elem->n_sides()))
112 const Point & face_normal =
_fe_face->get_normals()[0];
118 std::unique_ptr<Elem> curr_side = elem->side_ptr(side);
125 boundary_info.remove_side(elem, side);
126 boundary_info.add_side(elem, side, boundary_ids[0]);
134 mesh->set_isnt_prepared();
bool elementSubdomainIdInList(const Elem *const elem, const std::vector< subdomain_id_type > &subdomain_id_list) const
Determines whether the given element's subdomain id is in the given subdomain_id_list.
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
SymFunctionPtr _func_F
function parser object describing the combinatorial geometry
bool elemSideSatisfiesRequirements(const Elem *const elem, const unsigned int side, const MeshBase &mesh, const Point &normal, const Point &face_normal)
Determines whether the given element's side satisfies the following parameters: include_only_external...
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::unique_ptr< MeshBase > & _input
the mesh to add the sidesets to
ParsedGenerateSideset(const InputParameters ¶meters)
std::string _function
function expression
Point _normal
if specified, then faces are only added if their normal is close to this
static InputParameters validParams()
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
const bool _replace
Whether or not to remove the old sidesets (all of them, if any) when adding sidesets.
std::vector< BoundaryName > _boundary_names
The list of new boundary names.
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.
MeshGenerator for defining a Sideset by a parsed expression and optionally by looking at the subdomai...
void addFParserConstants(SymFunctionPtr &parser, const std::vector< std::string > &constant_names, const std::vector< std::string > &constant_expressions)
add constants (which can be complex expressions) to the parser object
virtual const std::string & name() const
Get the name of the class.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
std::vector< subdomain_id_type > _included_subdomain_ids
A list of included subdomain ids that the side has to be part of, extracted from the included_subdoma...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
std::unique_ptr< FEBase > _fe_face
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
void finalize()
This method finalizes the object, setting names back in the boundary_info object and releasing memory...
static InputParameters validParams()
const bool _check_subdomains
whether to check subdomain ids of the element in the (element, side, boundary id) tuple when adding s...
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
static InputParameters validParams()
registerMooseObject("MooseApp", ParsedGenerateSideset)
void setup(MeshBase &mesh)
This method is used to construct the FE object so we can compute normals of faces.
void setParserFeatureFlags(SymFunctionPtr &)
apply input paramters to internal feature flags of the parser object