LCOV - code coverage report
Current view: top level - src/mfem/functormaterials - MFEMGenericFunctorVectorMaterial.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 26ef6a Lines: 40 45 88.9 %
Date: 2026-06-24 21:19:51 Functions: 4 5 80.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 "MFEMGenericFunctorVectorMaterial.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMGenericFunctorVectorMaterial);
      16             : 
      17             : /// Handle any numerical vector values, which should be enclosed in curly braces
      18             : std::vector<MFEMVectorCoefficientName>
      19          16 : processLiteralVectors(const std::vector<MFEMVectorCoefficientName> & input)
      20             : {
      21          16 :   std::vector<MFEMVectorCoefficientName> result;
      22          16 :   bool in_literal = false;
      23          16 :   MFEMVectorCoefficientName literal;
      24          78 :   for (const auto & item : input)
      25             :   {
      26          62 :     if (in_literal)
      27             :     {
      28          32 :       if (item.front() == '{')
      29           0 :         mooseError("Nested numeric vector values are not permitted in "
      30             :                    "MFEMGenericFunctorVectoMaterial prop_values.");
      31          32 :       else if (item.back() == '}')
      32             :       {
      33          16 :         in_literal = false;
      34          16 :         literal += " " + item.substr(0, item.size() - 1);
      35          16 :         result.push_back(literal);
      36             :       }
      37             :       else
      38          16 :         literal += " " + item;
      39             :     }
      40          30 :     else if (item.front() == '{')
      41             :     {
      42          18 :       if (item.back() == '}')
      43           2 :         result.push_back(item.substr(1, item.size() - 2));
      44             :       else
      45             :       {
      46          16 :         in_literal = true;
      47          16 :         literal = item.substr(1);
      48             :       }
      49             :     }
      50             :     else
      51          12 :       result.push_back(item);
      52             :   }
      53          16 :   if (in_literal)
      54           0 :     mooseError("No closing curly brace for vector value in "
      55           0 :                "MFEMGenericFunctorVectorMaterial prop_values: '{" +
      56           0 :                literal + "'");
      57          32 :   return result;
      58          16 : }
      59             : 
      60             : InputParameters
      61        2128 : MFEMGenericFunctorVectorMaterial::validParams()
      62             : {
      63        2128 :   InputParameters params = MFEMFunctorMaterial::validParams();
      64        4256 :   params.addClassDescription("Declares material vector properties based on names and coefficients "
      65             :                              "prescribed by input parameters.");
      66        8512 :   params.addRequiredParam<std::vector<std::string>>(
      67             :       "prop_names", "The names of the properties this material will have");
      68        6384 :   params.addRequiredParam<std::vector<MFEMVectorCoefficientName>>(
      69             :       "prop_values",
      70             :       "The corresponding names of coefficients associated with the named properties");
      71             : 
      72        2128 :   return params;
      73           0 : }
      74             : 
      75          16 : MFEMGenericFunctorVectorMaterial::MFEMGenericFunctorVectorMaterial(
      76          16 :     const InputParameters & parameters)
      77             :   : MFEMFunctorMaterial(parameters),
      78          16 :     _prop_names(getParam<std::vector<std::string>>("prop_names")),
      79          32 :     _prop_values(
      80          16 :         processLiteralVectors(getParam<std::vector<MFEMVectorCoefficientName>>("prop_values")))
      81             : {
      82          16 :   if (_prop_names.size() != _prop_values.size())
      83           6 :     paramError("prop_names", "Must match the size of prop_values");
      84             : 
      85          42 :   for (const auto i : index_range(_prop_names))
      86          28 :     _properties.declareVectorProperty(_prop_names[i],
      87          56 :                                       isBoundaryRestricted() ? boundariesToStrings()
      88             :                                                              : subdomainsToStrings(),
      89          28 :                                       _prop_values[i]);
      90          18 : }
      91             : 
      92          14 : MFEMGenericFunctorVectorMaterial::~MFEMGenericFunctorVectorMaterial() {}
      93             : 
      94             : #endif

Generated by: LCOV version 1.14