https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FunctionMaterialBase.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#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
32template <bool is_ad = false>
34{
35public:
37
39
40protected:
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
94private:
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 GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
Moose::GenericType< VariableValue, is_ad > GenericVariableValue
Definition MooseTypes.h:712
Interface class ("Veneer") to provide generator methods for derivative material property names.
Material base class, central to all Materials that provide a Function as a material property value.
std::vector< std::string > _arg_names
String vector of all argument names.
bool _mapping_is_unique
Flag that indicates if exactly one linear variable is coupled per input file coupling parameter.
std::vector< const GenericVariableValue< is_ad > * > _args
Coupled variables for function arguments.
std::string _F_name
Name of the function value material property and used as a base name to concatenate the material prop...
std::vector< std::string > _arg_constant_defaults
coupled variables with default values
std::vector< std::string > _arg_param_names
String vector of the input file coupling parameter name for each argument.
static InputParameters validParams()
const GenericVariableValue< is_ad > & coupledGenericValue(const std::string &var_name, unsigned int comp=0)
helper function for coupling ad/regular variable values
unsigned int _nargs
Number of coupled arguments.
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number.
FunctionMaterialBase(const InputParameters &parameters)
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w....
GenericMaterialProperty< Real, is_ad > * _prop_F
Material property to store the function value.
std::vector< int > _arg_param_numbers
unsigned int libMeshVarNumberRemap(unsigned int var) const
map the variable numbers to an even/odd interspersed pattern
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131