https://mooseframework.inl.gov
ParsedSubdomainIDsGenerator.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.addClassDescription(
20  "Uses a parsed expression to determine the subdomain ids of included elements.");
21 
22  return params;
23 }
24 
26  : ParsedSubdomainGeneratorBase(parameters)
27 {
28 }
29 
30 void
32 {
33  _func_params[0] = elem->vertex_average()(0);
34  _func_params[1] = elem->vertex_average()(1);
35  _func_params[2] = elem->vertex_average()(2);
36  for (const auto i : index_range(_eeid_indices))
37  _func_params[3 + i] = elem->get_extra_integer(_eeid_indices[i]);
38 
39  if (std::find(_excluded_ids.begin(), _excluded_ids.end(), elem->subdomain_id()) ==
40  _excluded_ids.end())
41  {
42  const Real func_val = evaluate(_func_F);
43  if (func_val < 0.0)
44  paramError("expression",
45  "the value of the function is negative at the element with ID " +
46  std::to_string(elem->id()) +
47  ". The function must be non-negative. Consider using the absolute value of "
48  "the function.");
49  elem->subdomain_id() = std::round(func_val);
50  }
51 }
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
Evaluate FParser object and check EvalError.
std::vector< unsigned int > _eeid_indices
Indices of the extra element ids used in the parsed expression.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
ParsedSubdomainIDsGenerator(const InputParameters &parameters)
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) ...
T round(T x)
Definition: MathUtils.h:77
static InputParameters validParams()
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
MeshGenerator to use a parsed expression to determine the subdomain ids of included elements...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< GenericReal< is_ad > > _func_params
Array to stage the parameters passed to the functions when calling Eval.
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...
registerMooseObject("MooseApp", ParsedSubdomainIDsGenerator)
auto index_range(const T &sizable)