LCOV - code coverage report
Current view: top level - src/materials - LevelSetBiMaterialBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose xfem: #31405 (292dce) with base fef103 Lines: 39 43 90.7 %
Date: 2025-09-04 07:58:55 Functions: 4 10 40.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             : #include "LevelSetBiMaterialBase.h"
      11             : #include "AuxiliarySystem.h"
      12             : #include "MooseVariable.h"
      13             : #include "XFEM.h"
      14             : 
      15             : #include "metaphysicl/raw_type.h"
      16             : 
      17             : template <bool is_ad>
      18             : InputParameters
      19         344 : LevelSetBiMaterialBaseTempl<is_ad>::validParams()
      20             : {
      21         344 :   InputParameters params = Material::validParams();
      22         344 :   params.addClassDescription("Compute a material property for bi-materials (consisting of two "
      23             :                              "different materials) defined by a level set function.");
      24         688 :   params.addRequiredParam<VariableName>(
      25             :       "level_set_var", "The name of level set variable used to represent the interface");
      26         688 :   params.addRequiredParam<std::string>("levelset_positive_base",
      27             :                                        "Base name for the material in level set positive region.");
      28         688 :   params.addRequiredParam<std::string>("levelset_negative_base",
      29             :                                        "Base name for the material in level set negative region.");
      30         688 :   params.addParam<std::string>("base_name",
      31             :                                "Base name for the computed material property (optional)");
      32         688 :   params.addRequiredParam<std::string>("prop_name", "Name for the computed material property.");
      33         344 :   return params;
      34           0 : }
      35             : 
      36             : template <bool is_ad>
      37         258 : LevelSetBiMaterialBaseTempl<is_ad>::LevelSetBiMaterialBaseTempl(const InputParameters & parameters)
      38             :   : Material(parameters),
      39         258 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      40         774 :     _prop_name(getParam<std::string>("prop_name")),
      41         516 :     _level_set_var_number(_subproblem
      42         258 :                               .getVariable(_tid,
      43         258 :                                            parameters.get<VariableName>("level_set_var"),
      44             :                                            Moose::VarKindType::VAR_ANY,
      45             :                                            Moose::VarFieldType::VAR_FIELD_STANDARD)
      46             :                               .number()),
      47         516 :     _system(_subproblem.getSystem(getParam<VariableName>("level_set_var"))),
      48         258 :     _solution(*_system.current_local_solution.get()),
      49         258 :     _use_positive_property(false)
      50             : {
      51         258 :   FEProblemBase * fe_problem = dynamic_cast<FEProblemBase *>(&_subproblem);
      52             : 
      53         258 :   if (fe_problem == nullptr)
      54           0 :     mooseError("Problem casting _subproblem to FEProblemBase in XFEMMaterialStateMarkerBase");
      55             : 
      56         258 :   _xfem = MooseSharedNamespace::dynamic_pointer_cast<XFEM>(fe_problem->getXFEM());
      57         258 : }
      58             : 
      59             : template <bool is_ad>
      60             : void
      61           0 : LevelSetBiMaterialBaseTempl<is_ad>::initQpStatefulProperties()
      62             : {
      63           0 : }
      64             : 
      65             : template <bool is_ad>
      66             : void
      67      678402 : LevelSetBiMaterialBaseTempl<is_ad>::computeProperties()
      68             : {
      69      678402 :   const Node * node = _current_elem->node_ptr(0);
      70             : 
      71      678402 :   dof_id_type ls_dof_id = node->dof_number(_system.number(), _level_set_var_number, 0);
      72      678402 :   Number ls_node_value = _solution(ls_dof_id);
      73             : 
      74      678402 :   _use_positive_property = false;
      75             : 
      76      678402 :   if (_xfem->isPointInsidePhysicalDomain(_current_elem, *node))
      77             :   {
      78      597888 :     if (ls_node_value > 0.0)
      79      331556 :       _use_positive_property = true;
      80             :   }
      81             :   else
      82             :   {
      83       80514 :     if (ls_node_value < 0.0)
      84       56136 :       _use_positive_property = true;
      85             :   }
      86             : 
      87      678402 :   Material::computeProperties();
      88      678402 : }
      89             : 
      90             : template <bool is_ad>
      91             : void
      92     2724304 : LevelSetBiMaterialBaseTempl<is_ad>::computeQpProperties()
      93             : {
      94     2724304 :   if (_use_positive_property)
      95     1557756 :     assignQpPropertiesForLevelSetPositive();
      96             :   else
      97     1166548 :     assignQpPropertiesForLevelSetNegative();
      98     2724304 : }
      99             : 
     100             : template class LevelSetBiMaterialBaseTempl<false>;
     101             : template class LevelSetBiMaterialBaseTempl<true>;

Generated by: LCOV version 1.14