https://mooseframework.inl.gov
LevelSetBiMaterialBase.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 #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>
20 {
22  params.addClassDescription("Compute a material property for bi-materials (consisting of two "
23  "different materials) defined by a level set function.");
24  params.addRequiredParam<VariableName>(
25  "level_set_var", "The name of level set variable used to represent the interface");
26  params.addRequiredParam<std::string>("levelset_positive_base",
27  "Base name for the material in level set positive region.");
28  params.addRequiredParam<std::string>("levelset_negative_base",
29  "Base name for the material in level set negative region.");
30  params.addParam<std::string>("base_name",
31  "Base name for the computed material property (optional)");
32  params.addRequiredParam<std::string>("prop_name", "Name for the computed material property.");
33  return params;
34 }
35 
36 template <bool is_ad>
38  : Material(parameters),
39  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
40  _prop_name(getParam<std::string>("prop_name")),
41  _level_set_var_number(_subproblem
42  .getVariable(_tid,
43  parameters.get<VariableName>("level_set_var"),
46  .number()),
47  _system(_subproblem.getSystem(getParam<VariableName>("level_set_var"))),
48  _solution(*_system.current_local_solution.get()),
49  _use_positive_property(false)
50 {
51  FEProblemBase * fe_problem = dynamic_cast<FEProblemBase *>(&_subproblem);
52 
53  if (fe_problem == nullptr)
54  mooseError("Problem casting _subproblem to FEProblemBase in XFEMMaterialStateMarkerBase");
55 
56  _xfem = MooseSharedNamespace::dynamic_pointer_cast<XFEM>(fe_problem->getXFEM());
57 }
58 
59 template <bool is_ad>
60 void
62 {
63 }
64 
65 template <bool is_ad>
66 void
68 {
69  const Node * node = _current_elem->node_ptr(0);
70 
71  dof_id_type ls_dof_id = node->dof_number(_system.number(), _level_set_var_number, 0);
72  Number ls_node_value = _solution(ls_dof_id);
73 
74  _use_positive_property = false;
75 
76  if (_xfem->isPointInsidePhysicalDomain(_current_elem, *node))
77  {
78  if (ls_node_value > 0.0)
79  _use_positive_property = true;
80  }
81  else
82  {
83  if (ls_node_value < 0.0)
84  _use_positive_property = true;
85  }
86 
88 }
89 
90 template <bool is_ad>
91 void
93 {
94  if (_use_positive_property)
95  assignQpPropertiesForLevelSetPositive();
96  else
97  assignQpPropertiesForLevelSetNegative();
98 }
99 
101 template class LevelSetBiMaterialBaseTempl<true>;
VarFieldType
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
SubProblem & _subproblem
virtual void computeProperties() override
virtual void computeQpProperties() override
This is the XFEM class.
Definition: XFEM.h:107
void addRequiredParam(const std::string &name, const std::string &doc_string)
std::shared_ptr< XFEM > _xfem
shared pointer to XFEM
static InputParameters validParams()
VarKindType
virtual void computeProperties() override
VAR_ANY
LevelSetBiMaterialBaseTempl(const InputParameters &parameters)
virtual void initQpStatefulProperties() override
static InputParameters validParams()
std::shared_ptr< XFEMInterface > getXFEM()
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
VAR_FIELD_STANDARD
Real Number
Base class for switching between materials in a bi-material system where the interface is defined by ...
const Elem & get(const ElemType type_in)
uint8_t dof_id_type