LCOV - code coverage report
Current view: top level - src/mfem/functions - MFEMParsedFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31761 (28487c) with base 701993 Lines: 19 20 95.0 %
Date: 2025-11-11 13:51:07 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      15             : registerMooseObject("MooseApp", MFEMParsedFunction);
      16             : 
      17             : InputParameters
      18        8664 : MFEMParsedFunction::validParams()
      19             : {
      20        8664 :   InputParameters params = MooseParsedFunction::validParams();
      21        8664 :   params += FunctionParserUtils<false>::validParams();
      22        8664 :   params.addClassDescription("Parses scalar function of position, time and scalar "
      23             :                              "problem coefficients (including scalar variables).");
      24        8664 :   return params;
      25           0 : }
      26             : 
      27          16 : MFEMParsedFunction::MFEMParsedFunction(const InputParameters & parameters)
      28             :   : MooseParsedFunction(parameters),
      29             :     FunctionParserUtils(parameters),
      30          16 :     _mfem_problem(static_cast<MFEMProblem &>(_pfb_feproblem)),
      31          16 :     _sym_function(std::make_shared<SymFunction>()),
      32         112 :     _xyzt({"x", "y", "z", "t"})
      33             : {
      34             :   // variable symbols the function depends on (including position and time)
      35          64 :   std::string symbols = MooseUtils::stringJoin({_vars.begin(), _vars.end()}, ",");
      36          16 :   symbols += (symbols.empty() ? "" : ",") + MooseUtils::stringJoin(_xyzt, ",");
      37             : 
      38             :   // setup parsed function
      39          16 :   parsedFunctionSetup(_sym_function, _value, symbols, {}, {}, comm());
      40             : 
      41             :   // create MFEMParsedCoefficient
      42          32 :   _mfem_problem.getCoefficients().declareScalar<MFEMParsedCoefficient>(
      43          16 :       name(), _vars.size() + _xyzt.size(), _coefficients, _sym_function);
      44          64 : }
      45             : 
      46             : void
      47          16 : MFEMParsedFunction::initialSetup()
      48             : {
      49          72 :   for (const auto i : index_range(_vars))
      50          56 :     _coefficients.push_back(_mfem_problem.getCoefficients().getScalarCoefficient(_vals[i]));
      51          16 : }
      52             : 
      53             : #endif

Generated by: LCOV version 1.14