https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
20 "Uses a parsed expression to determine the subdomain ids of included elements.");
21
22 return params;
23}
24
29
30void
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}
registerMooseObject("MooseApp", ParsedSubdomainIDsGenerator)
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 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 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:457
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 to use a parsed expression to determine the subdomain ids of included elements.
void assignElemSubdomainID(Elem *elem) override
Assign the subdomain id to the element based on the parsed expression.
ParsedSubdomainIDsGenerator(const InputParameters &parameters)