https://mooseframework.inl.gov
InterfaceMaterial.h
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 #pragma once
11 
12 // MOOOSE includes
13 #include "MaterialBase.h"
14 #include "NeighborCoupleable.h"
16 
17 #define usingInterfaceMaterialMembers \
18  usingMaterialBaseMembers; \
19  usingNeighborCoupleableMembers; \
20  using InterfaceMaterial::_q_point; \
21  using InterfaceMaterial::_qrule; \
22  using InterfaceMaterial::_JxW; \
23  using InterfaceMaterial::_current_elem; \
24  using InterfaceMaterial::_neighbor_elem; \
25  using InterfaceMaterial::_current_side; \
26  using InterfaceMaterial::_neighbor_side
27 
32  public NeighborCoupleable,
34 {
35 public:
37 
39 
40  virtual bool isInterfaceMaterial() override { return true; };
41  void computeProperties() override;
42 
44 
50  template <typename T, bool is_ad>
52  getGenericMaterialProperty(const std::string & name, const unsigned int state = 0);
53  template <typename T>
54  const MaterialProperty<T> & getMaterialProperty(const std::string & name,
55  const unsigned int state = 0)
56  {
57  return getGenericMaterialProperty<T, false>(name, state);
58  }
59  template <typename T>
60  const ADMaterialProperty<T> & getADMaterialProperty(const std::string & name)
61  {
62  return getGenericMaterialProperty<T, true>(name, 0);
63  }
64  template <typename T>
65  const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name)
66  {
67  return getGenericMaterialProperty<T, false>(name, 1);
68  }
69  template <typename T>
70  const MaterialProperty<T> & getMaterialPropertyOlder(const std::string & name)
71  {
72  return getGenericMaterialProperty<T, false>(name, 2);
73  }
75 
77 
82  template <typename T, bool is_ad>
84  getGenericMaterialPropertyByName(const std::string & name, const unsigned int state = 0);
85  template <typename T>
86  const MaterialProperty<T> & getMaterialPropertyByName(const std::string & prop_name,
87  const unsigned int state = 0)
88  {
89 
90  return getGenericMaterialPropertyByName<T, false>(prop_name, state);
91  }
92  template <typename T>
93  const ADMaterialProperty<T> & getADMaterialPropertyByName(const std::string & prop_name)
94  {
95 
96  return getGenericMaterialPropertyByName<T, true>(prop_name, 0);
97  }
98  template <typename T>
99  const MaterialProperty<T> & getMaterialPropertyOldByName(const std::string & prop_name)
100  {
101 
102  return getGenericMaterialPropertyByName<T, false>(prop_name, 1);
103  }
104  template <typename T>
105  const MaterialProperty<T> & getMaterialPropertyOlderByName(const std::string & prop_name)
106  {
107 
108  return getGenericMaterialPropertyByName<T, false>(prop_name, 2);
109  }
111 
113 
119  template <typename T, bool is_ad>
121  getGenericNeighborMaterialProperty(const std::string & name, const unsigned int state = 0);
122  template <typename T>
124  const unsigned int state = 0)
125  {
126  return getGenericNeighborMaterialProperty<T, false>(name, state);
127  }
128  template <typename T>
130  {
131  return getGenericNeighborMaterialProperty<T, true>(name, 0);
132  }
133  template <typename T>
135  {
136  return getGenericNeighborMaterialProperty<T, false>(name, 1);
137  }
138  template <typename T>
140  {
141  return getGenericNeighborMaterialProperty<T, false>(name, 2);
142  }
144 
146 
151  template <typename T, bool is_ad>
153  getGenericNeighborMaterialPropertyByName(const std::string & name, const unsigned int state = 0);
154  template <typename T>
155  const MaterialProperty<T> & getNeighborMaterialPropertyByName(const std::string & prop_name,
156  const unsigned int state = 0)
157  {
158  return getGenericNeighborMaterialPropertyByName<T, false>(prop_name, state);
159  }
160  template <typename T>
161  const ADMaterialProperty<T> & getNeighborADMaterialPropertyByName(const std::string & prop_name)
162  {
163  return getGenericNeighborMaterialPropertyByName<T, true>(prop_name, 0);
164  }
166 
168 
169  virtual bool isBoundaryMaterial() const override { return true; }
170 
171  virtual const std::unordered_set<unsigned int> & getMatPropDependencies() const override
172  {
174  }
175 
176 protected:
177  virtual const MaterialData & materialData() const override { return _material_data; }
178  virtual MaterialData & materialData() override { return _material_data; }
180 
181  virtual const QBase & qRule() const override { return *_qrule; }
182 
183  bool _bnd;
185  const QBase * const & _qrule;
187 
189  const Elem * const & _current_elem;
191  const Elem * const & _neighbor_elem;
193  const unsigned int & _current_side;
195  const unsigned int & _neighbor_side;
196 };
197 
198 template <typename T, bool is_ad>
200 InterfaceMaterial::getGenericMaterialProperty(const std::string & name, const unsigned int state)
201 {
202  // Check if the supplied parameter is a valid input parameter key
203  const auto prop_name = getMaterialPropertyName(name);
204 
205  // Check if it's just a constant.
206  if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
207  return *default_property;
208 
209  return getGenericMaterialPropertyByName<T, is_ad>(prop_name, state);
210 }
211 
212 template <typename T, bool is_ad>
215  const unsigned int state)
216 {
218 
219  // The property may not exist yet, so declare it (declare/getMaterialProperty are referencing the
220  // same memory)
221  if (state == 0)
222  _requested_props.insert(prop_name);
223 
224  // Do this before hand so that the propery id is defined
225  auto & prop =
226  TwoMaterialPropertyInterface::getGenericMaterialPropertyByName<T, is_ad>(prop_name, state);
227 
228  registerPropName(prop_name, true, state);
229 
230  return prop;
231 }
232 
233 template <typename T, bool is_ad>
236  const unsigned int state)
237 {
238  // Check if the supplied parameter is a valid input parameter key
239  const auto prop_name = getMaterialPropertyName(name);
240 
241  // Check if it's just a constant.
242  if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
243  return *default_property;
244 
245  return getGenericNeighborMaterialPropertyByName<T, is_ad>(prop_name, state);
246 }
247 
248 template <typename T, bool is_ad>
251  const unsigned int state)
252 {
254 
255  // The property may not exist yet, so declare it (declare/getMaterialProperty are referencing the
256  // same memory)
257  if (state == 0)
258  _requested_props.insert(name);
259 
260  // Do this before hand so that the propery id is defined
261  auto & prop =
262  TwoMaterialPropertyInterface::getGenericNeighborMaterialPropertyByName<T, is_ad>(name, state);
263 
264  registerPropName(name, true, state);
265 
266  return prop;
267 }
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
void computeProperties() override
Performs the quadrature point loop, calling computeQpProperties.
Interface materials compute MaterialProperties.
virtual Moose::MaterialDataType materialDataType() override
virtual const QBase & qRule() const override
virtual bool isBoundaryMaterial() const override
Returns true of the MaterialData type is not associated with volume data.
static InputParameters validParams()
const MaterialProperty< T > & getMaterialPropertyOld(const std::string &name)
const MaterialProperty< T > & getNeighborMaterialPropertyOlder(const std::string &name)
const ADMaterialProperty< T > & getADMaterialProperty(const std::string &name)
virtual MaterialData & materialData() override
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
MaterialDataType
MaterialData types.
Definition: MooseTypes.h:692
const ADMaterialProperty< T > & getADMaterialPropertyByName(const std::string &prop_name)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MaterialProperty< T > & getMaterialPropertyOlderByName(const std::string &prop_name)
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName(const std::string &name, const unsigned int state=0)
Retrieve the property named "name".
const MaterialProperty< T > & getNeighborMaterialPropertyByName(const std::string &prop_name, const unsigned int state=0)
const ADMaterialProperty< T > & getNeighborADMaterialPropertyByName(const std::string &prop_name)
MaterialPropertyName getMaterialPropertyName(const std::string &name) const
const GenericMaterialProperty< T, is_ad > & getGenericNeighborMaterialProperty(const std::string &name, const unsigned int state=0)
Retrieve the neighbor property through a given input parameter key with a fallback to getting it by n...
MaterialData & _material_data
The material data class that stores properties.
const Elem *const & _neighbor_elem
Current neighbor element.
const MooseArray< Real > & _JxW
InterfaceMaterial(const InputParameters &parameters)
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
std::set< std::string > _requested_props
Set of properties accessed via get method.
Definition: MaterialBase.h:345
const MaterialProperty< T > & getMaterialPropertyByName(const std::string &prop_name, const unsigned int state=0)
void checkExecutionStage()
Check and throw an error if the execution has progressed past the construction stage.
Definition: MaterialBase.C:293
const Elem *const & _current_elem
Current element.
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
const MooseArray< Point > & _q_point
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const override
Retrieve the set of material properties that this object depends on.
virtual bool isInterfaceMaterial() override
virtual const MaterialData & materialData() const override
const QBase *const & _qrule
const MaterialProperty< T > & getMaterialPropertyOlder(const std::string &name)
const MaterialProperty< T > & getNeighborMaterialProperty(const std::string &name, const unsigned int state=0)
const MaterialProperty< T > & getMaterialProperty(const std::string &name, const unsigned int state=0)
const unsigned int & _neighbor_side
current side of the neighbor element
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty(const std::string &name, const unsigned int state=0)
Retrieve the property through a given input parameter key with a fallback to getting it by name...
const unsigned int & _current_side
current side of the current element
This interface is designed for DGKernel, InternalSideUserObject, InterfaceUserObject, where material properties on a side of both its primary side (face) and its secondary side (neighbor) all required.
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:37
void registerPropName(const std::string &prop_name, bool is_get, const unsigned int state)
Small helper function to call store{Subdomain,Boundary}MatPropName.
Definition: MaterialBase.C:205
const MaterialProperty< T > & getZeroMaterialProperty(Ts... args)
for backwards compatibility
Definition: MaterialBase.h:178
const Moose::MaterialDataType _material_data_type
The type of data.
const GenericMaterialProperty< T, is_ad > & getGenericNeighborMaterialPropertyByName(const std::string &name, const unsigned int state=0)
Retrieve the neighbor property named "name".
MaterialBases compute MaterialProperties.
Definition: MaterialBase.h:62
const MaterialProperty< T > & getNeighborMaterialPropertyOld(const std::string &name)
Enhances Coupleable interface to also couple the values from neighbor elements.
const MaterialProperty< T > & getMaterialPropertyOldByName(const std::string &prop_name)
const ADMaterialProperty< T > & getNeighborADMaterialProperty(const std::string &name)