https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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");
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
40void
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
55void
56ParsedSubdomainMeshGenerator::setBlockName(std::unique_ptr<MeshBase> & mesh)
57{
58 if (isParamValid("block_name"))
59 mesh->set_subdomain_name(getParam<subdomain_id_type>("block_id"),
60 getParam<SubdomainName>("block_name"));
61}
registerMooseObject("MooseApp", ParsedSubdomainMeshGenerator)
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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.
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...
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.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
A base class for mesh generators that Use a parsed expression to assign new subdomain id(s)
std::vector< unsigned int > _eeid_indices
Indices of the extra element ids used in the parsed expression.
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...
SymFunctionPtr _func_F
function parser object describing the combinatorial geometry
MeshGenerator for defining a Subdomain inside or outside of combinatorial geometry.
const subdomain_id_type _block_id
Block ID to assign to the region.
void setBlockName(std::unique_ptr< MeshBase > &mesh) override
Set block name for the block with new id if applicable.
void assignElemSubdomainID(Elem *elem) override
Assign the subdomain id to the element based on the parsed expression.
ParsedSubdomainMeshGenerator(const InputParameters &parameters)
MeshBase & mesh