https://mooseframework.inl.gov
ParsedSubdomainMeshGenerator.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 
16 {
18 
19  params.renameParam("expression",
20  "combinatorial_geometry",
21  "Function expression encoding a combinatorial geometry");
22  params.addRequiredParam<subdomain_id_type>("block_id",
23  "Subdomain id to set for inside of the combinatorial");
24  params.addParam<SubdomainName>("block_name",
25  "Subdomain name to set for inside of the combinatorial");
26  params.addClassDescription(
27  "Uses a parsed expression (`combinatorial_geometry`) to determine if an "
28  "element (via its centroid) is inside the region defined by the expression and "
29  "assigns a new block ID.");
30 
31  return params;
32 }
33 
35  : ParsedSubdomainGeneratorBase(parameters),
36  _block_id(parameters.get<subdomain_id_type>("block_id"))
37 {
38 }
39 
40 void
42 {
43  _func_params[0] = elem->vertex_average()(0);
44  _func_params[1] = elem->vertex_average()(1);
45  _func_params[2] = elem->vertex_average()(2);
46  for (const auto i : index_range(_eeid_indices))
47  _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]);
48  bool contains = evaluate(_func_F);
49 
50  if (contains && std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) ==
51  _excluded_ids.end())
52  elem->subdomain_id() = _block_id;
53 }
54 
55 void
56 ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh)
57 {
58  if (isParamValid("block_name"))
59  mesh->subdomain_name(getParam<subdomain_id_type>("block_id")) =
60  getParam<SubdomainName>("block_name");
61 }
void setBlockName(std::unique_ptr< MeshBase > &mesh) override
Set block name for the block with new id if applicable.
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a parameter and provide a new documentation string.
std::vector< unsigned int > _eeid_indices
Indices of the extra element ids used in the parsed expression.
registerMooseObject("MooseApp", ParsedSubdomainMeshGenerator)
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
MeshBase & mesh
std::vector< subdomain_id_type > _excluded_ids
A list of excluded subdomain ids that will not be changed even if they are in the combinatorial geome...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
A base class for mesh generators that Use a parsed expression to assign new subdomain id(s) ...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
void assignElemSubdomainID(Elem *elem) override
Assign the subdomain id to the element based on the parsed expression.
SymFunctionPtr _func_F
function parser object describing the combinatorial geometry
ParsedSubdomainMeshGenerator(const InputParameters &parameters)
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
MeshGenerator for defining a Subdomain inside or outside of combinatorial geometry.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const subdomain_id_type _block_id
Block ID to assign to the region.
auto index_range(const T &sizable)