https://mooseframework.inl.gov
MFEMParsedFunction.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 
10 #ifdef MOOSE_MFEM_ENABLED
11 
12 #include "MFEMParsedFunction.h"
13 #include "MFEMParsedCoefficient.h"
14 
16 
19 {
22  params.addClassDescription("Parses scalar function of position, time and scalar "
23  "problem coefficients (including scalar variables).");
24  return params;
25 }
26 
28  : MooseParsedFunction(parameters),
29  FunctionParserUtils(parameters),
30  _mfem_problem(static_cast<MFEMProblem &>(_pfb_feproblem)),
31  _sym_function(std::make_shared<SymFunction>()),
32  _xyzt({"x", "y", "z", "t"})
33 {
34  // variable symbols the function depends on (including position and time)
35  std::string symbols = MooseUtils::stringJoin({_vars.begin(), _vars.end()}, ",");
36  symbols += (symbols.empty() ? "" : ",") + MooseUtils::stringJoin(_xyzt, ",");
37 
38  // setup parsed function
39  parsedFunctionSetup(_sym_function, _value, symbols, {}, {}, comm());
40 
41  // create MFEMParsedCoefficient
42  _mfem_problem.getCoefficients().declareScalar<MFEMParsedCoefficient>(
43  name(), _vars.size() + _xyzt.size(), _coefficients, _sym_function);
44 }
45 
46 void
48 {
49  for (const auto i : index_range(_vars))
51 }
52 
53 #endif
std::string name(const ElemQuality q)
MFEMProblem & _mfem_problem
reference to the MFEMProblem instance
void initialSetup() override
Creates the parsed function.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< std::string > _vals
Values passed by the user, they may be Reals for Postprocessors.
This class is used to evaluate symbolic equations passed in to Moose through the input file...
GenericSymFunction< is_ad > SymFunction
Shorthand for an autodiff function parser object.
static InputParameters validParams()
std::vector< std::reference_wrapper< mfem::Coefficient > > _coefficients
vector of references to the scalar coefficients used in the function
Moose::MFEM::CoefficientManager & getCoefficients()
Method to get the PropertyManager object for storing material properties and converting them to MFEM ...
Definition: MFEMProblem.h:248
registerMooseObject("MooseApp", MFEMParsedFunction)
static InputParameters validParams()
Created from MooseSystem via the FunctionFactory.
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Return a scalar coefficient with the given name or, if that doesn&#39;t exists, try interpreting the name...
Scalar, parsed function of position, time, and any number of scalar problem coefficients, including any scalar variables, postprocessors, material properties or functions.
Scalar coefficient that, given a set of scalar (possibly, but not necessarily, gridfunction) coeffici...
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...
static InputParameters validParams()
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
auto index_range(const T &sizable)
MFEMParsedFunction(const InputParameters &parameters)