https://mooseframework.inl.gov
DerivativeParsedMaterialHelper.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 "ParsedMaterialHelper.h"
14 
15 #include "libmesh/fparser_ad.hh"
16 
17 #define usingDerivativeParsedMaterialHelperMembers(T) \
18  usingParsedMaterialHelperMembers(T); \
19  using typename DerivativeParsedMaterialHelperTempl<T>::Derivative; \
20  using typename DerivativeParsedMaterialHelperTempl<T>::MaterialPropertyDerivativeRule; \
21  using DerivativeParsedMaterialHelperTempl<T>::_derivative_order; \
22  using DerivativeParsedMaterialHelperTempl<T>::_derivatives
23 
27 template <bool is_ad>
29 {
30 protected:
32 
33 public:
35 
39 
41 
42 protected:
43  struct Derivative;
45 
46  void initQpStatefulProperties() override;
47  void computeQpProperties() override;
48 
49  void functionsPostParse() override;
50  void assembleDerivatives();
51 
52  void
53  recurseMatProps(unsigned int var, unsigned int order, const MatPropDescriptorList & parent_mpd);
54 
55  void
56  recurseDerivative(unsigned int var, unsigned int order, const Derivative & parent_derivative);
57 
59  unsigned int _derivative_order;
60 
62  std::vector<Derivative> _derivatives;
63 
65  const std::string _dmatvar_base;
66 
68  unsigned int _dmatvar_index;
69 
74  std::vector<std::size_t> _derivative_symbol_table;
75 
76 private:
77  // for bulk registration of material property derivatives
78  std::vector<MaterialPropertyDerivativeRule> _bulk_rules;
79 };
80 
81 template <bool is_ad>
83 {
86  std::vector<SymbolName> _darg_names;
87 };
88 
89 template <bool is_ad>
91 {
92  MaterialPropertyDerivativeRule(std::string p, std::string v, std::string c)
93  : _parent(p), _var(v), _child(c)
94  {
95  }
96 
97  std::string _parent;
98  std::string _var;
99  std::string _child;
100 };
101 
unsigned int _dmatvar_index
next available variable number for automatically created material property derivative variables ...
std::shared_ptr< SymFunction > SymFunctionPtr
Shorthand for an smart pointer to an autodiff function parser object.
std::vector< std::size_t > _derivative_symbol_table
list of all indices into _variable_names to take derivatives, w.r.t.
void computeQpProperties() override
Users must override this method.
DerivativeParsedMaterialHelperTempl< true > ADDerivativeParsedMaterialHelper
void assembleDerivatives()
Perform construction of all requested derivatives.
DerivativeParsedMaterialHelperTempl< false > DerivativeParsedMaterialHelper
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< Derivative > _derivatives
The requested derivatives of the free energy (sorted by order)
Helper class to perform the auto derivative taking.
void recurseMatProps(unsigned int var, unsigned int order, const MatPropDescriptorList &parent_mpd)
GenericMaterialProperty< Real, is_ad > * _mat_prop
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
const std::string _dmatvar_base
variable base name for the dynamically material property derivatives
Helper class to perform the parsing and optimization of the function expression.
void recurseDerivative(unsigned int var, unsigned int order, const Derivative &parent_derivative)
const InputParameters & parameters() const
Get the parameters of the object.
void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
unsigned int _derivative_order
maximum derivative order
DerivativeParsedMaterialHelperTempl(const InputParameters &parameters, VariableNameMappingMode map_mode=VariableNameMappingMode::USE_PARAM_NAMES)
const ParallelParamObject & _parent
DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
std::vector< MaterialPropertyDerivativeRule > _bulk_rules
std::vector< FunctionMaterialPropertyDescriptor< is_ad > > MatPropDescriptorList
convenience typedef for the material property descriptors