www.mooseframework.org
TwoMaterialPropertyInterface.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 
14 // Forward Declarations
15 class MaterialData;
17 
18 template <>
20 
21 #define adGetNeighborMaterialProperty this->template getNeighborMaterialProperty
22 #define adGetNeighborADMaterialProperty this->template getNeighborADMaterialProperty
23 
25 {
26 public:
27  TwoMaterialPropertyInterface(const MooseObject * moose_object,
28  const std::set<SubdomainID> & blocks_ids,
29  const std::set<BoundaryID> & boundary_ids);
30 
34  template <typename T>
35  const MaterialProperty<T> & getNeighborMaterialProperty(const std::string & name);
36 
40  template <typename T>
41  const ADMaterialPropertyObject<T> & getNeighborADMaterialProperty(const std::string & name);
42 
43  template <typename T>
44  const MaterialProperty<T> & getNeighborMaterialPropertyOld(const std::string & name);
45 
46  template <typename T>
47  const MaterialProperty<T> & getNeighborMaterialPropertyOlder(const std::string & name);
48 
49 protected:
50  std::shared_ptr<MaterialData> _neighbor_material_data;
51 };
52 
53 template <typename T>
54 const MaterialProperty<T> &
56 {
57  // Check if the supplied parameter is a valid input parameter key
58  std::string prop_name = deducePropertyName(name);
59 
60  // Check if it's just a constant
61  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
62  if (default_property)
63  return *default_property;
64  else
65  return _neighbor_material_data->getProperty<T>(prop_name);
66 }
67 
68 template <typename T>
71 {
72  // Check if the supplied parameter is a valid input parameter key
73  std::string prop_name = deducePropertyName(name);
74 
75  // Check if it's just a constant
76  const ADMaterialPropertyObject<T> * default_property = defaultADMaterialProperty<T>(prop_name);
77  if (default_property)
78  return *default_property;
79  else
80  return _neighbor_material_data->getADProperty<T>(prop_name);
81 }
82 
83 template <typename T>
84 const MaterialProperty<T> &
86 {
87  // Check if the supplied parameter is a valid input parameter key
88  std::string prop_name = deducePropertyName(name);
89 
90  // Check if it's just a constant
91  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
92  if (default_property)
93  return *default_property;
94  else
95  return _neighbor_material_data->getPropertyOld<T>(prop_name);
96 }
97 
98 template <typename T>
99 const MaterialProperty<T> &
101 {
102  // Check if the supplied parameter is a valid input parameter key
103  std::string prop_name = deducePropertyName(name);
104 
105  // Check if it's just a constant
106  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
107  if (default_property)
108  return *default_property;
109  else
110  return _neighbor_material_data->getPropertyOlder<T>(prop_name);
111 }
112 
const MaterialProperty< T > & getNeighborMaterialProperty(const std::string &name)
Retrieve the property named "name".
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.
TwoMaterialPropertyInterface(const MooseObject *moose_object, const std::set< SubdomainID > &blocks_ids, const std::set< BoundaryID > &boundary_ids)
std::shared_ptr< MaterialData > _neighbor_material_data
const MaterialProperty< T > & getNeighborMaterialPropertyOlder(const std::string &name)
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
An interface for accessing Materials.
Concrete definition of a parameter value for a specified type.
InputParameters validParams< TwoMaterialPropertyInterface >()
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:27
const MaterialProperty< T > & getNeighborMaterialPropertyOld(const std::string &name)
const ADMaterialPropertyObject< T > & getNeighborADMaterialProperty(const std::string &name)
Retrieve the ADMaterialProperty named "name".