https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
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
46void
48{
49 for (const auto i : index_range(_vars))
51}
52
53#endif
registerMooseObject("MooseApp", MFEMParsedFunction)
static InputParameters validParams()
GenericSymFunction< is_ad > SymFunction
Shorthand for an autodiff function parser object.
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.
Scalar coefficient that, given a set of scalar (possibly, but not necessarily, gridfunction) coeffici...
Scalar, parsed function of position, time, and any number of scalar problem coefficients,...
std::vector< std::reference_wrapper< mfem::Coefficient > > _coefficients
vector of references to the scalar coefficients used in the function
void initialSetup() override
Creates the parsed function.
MFEMParsedFunction(const InputParameters &parameters)
static InputParameters validParams()
MFEMProblem & _mfem_problem
reference to the MFEMProblem instance
Moose::MFEM::CoefficientManager & getCoefficients()
Method to get the PropertyManager object for storing material properties and converting them to MFEM ...
const std::vector< std::string > _vals
Values passed by the user, they may be Reals for Postprocessors.
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
This class is used to evaluate symbolic equations passed in to Moose through the input file.
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't exists, try interpreting the name...
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
std::string name(const ElemQuality q)