www.mooseframework.org
FunctionMaterialBase.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 
12 #include "Material.h"
14 
15 #define usingFunctionMaterialBaseMembers(T) \
16  usingMaterialMembers; \
17  using FunctionMaterialBase<T>::_args; \
18  using FunctionMaterialBase<T>::_F_name; \
19  using FunctionMaterialBase<T>::_nargs; \
20  using FunctionMaterialBase<T>::_arg_names; \
21  using FunctionMaterialBase<T>::_arg_numbers; \
22  using FunctionMaterialBase<T>::_arg_param_names; \
23  using FunctionMaterialBase<T>::_arg_param_numbers; \
24  using FunctionMaterialBase<T>::_arg_constant_defaults; \
25  using FunctionMaterialBase<T>::_prop_F; \
26  using FunctionMaterialBase<T>::_communicator
27 
32 template <bool is_ad = false>
34 {
35 public:
37 
39 
40 protected:
55  unsigned int argIndex(unsigned int i_var) const
56  {
57  const unsigned int idx = libMeshVarNumberRemap(i_var);
58  mooseAssert(idx < _arg_index.size() && _arg_numbers[_arg_index[idx]] == i_var,
59  "Requesting argIndex() for a derivative w.r.t. a variable not coupled to.");
60  return _arg_index[idx];
61  }
62 
64  std::vector<const GenericVariableValue<is_ad> *> _args;
65 
70  std::string _F_name;
71 
74 
76  unsigned int _nargs;
77 
79  std::vector<std::string> _arg_names;
80 
82  std::vector<unsigned int> _arg_numbers;
83 
85  std::vector<std::string> _arg_param_names;
86  std::vector<int> _arg_param_numbers;
87 
89  std::vector<std::string> _arg_constant_defaults;
90 
93 
94 private:
96  unsigned int libMeshVarNumberRemap(unsigned int var) const
97  {
98  const int b = static_cast<int>(var);
99  return b >= 0 ? b << 1 : (-b << 1) - 1;
100  }
101 
103  const GenericVariableValue<is_ad> & coupledGenericValue(const std::string & var_name,
104  unsigned int comp = 0);
105 
107  std::vector<unsigned int> _arg_index;
108 };
typename Moose::GenericType< VariableValue, is_ad > GenericVariableValue
Definition: MooseTypes.h:573
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.
Material base class, central to all Materials that provide a Function as a material property value...
const GenericVariableValue< is_ad > & coupledGenericValue(const std::string &var_name, unsigned int comp=0)
helper function for coupling ad/regular variable values
std::string _F_name
Name of the function value material property and used as a base name to concatenate the material prop...
std::vector< int > _arg_param_numbers
bool _mapping_is_unique
Flag that indicates if exactly one linear variable is coupled per input file coupling parameter...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< std::string > _arg_names
String vector of all argument names.
static InputParameters validParams()
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
std::vector< std::string > _arg_constant_defaults
coupled variables with default values
FunctionMaterialBase(const InputParameters &parameters)
std::vector< std::string > _arg_param_names
String vector of the input file coupling parameter name for each argument.
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w...
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number...
Interface class ("Veneer") to provide generator methods for derivative material property names...
GenericMaterialProperty< Real, is_ad > * _prop_F
Material property to store the function value.
const InputParameters & parameters() const
Get the parameters of the object.
unsigned int _nargs
Number of coupled arguments.
unsigned int libMeshVarNumberRemap(unsigned int var) const
map the variable numbers to an even/odd interspersed pattern
std::vector< const GenericVariableValue< is_ad > * > _args
Coupled variables for function arguments.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)