https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
DerivativeMaterialInterface< T > Class Template Reference

Interface class ("Veneer") to provide generator methods for derivative material property names. More...

#include <DerivativeMaterialInterface.h>

Inheritance diagram for DerivativeMaterialInterface< T >:
[legend]

Public Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 DerivativeMaterialInterface (const InputParameters &parameters)
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialProperty (const std::string &name)
 Fetch a material property if it exists, otherwise return getZeroMaterialProperty.
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialPropertyByName (const std::string &name)
 Fetch a material property by name if it exists, otherwise return getZeroMaterialProperty.
 
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > declareKokkosPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 Declare a derivative Kokkos material property.
 
template<typename U , bool is_ad = false>
void validateDerivativeMaterialPropertyBase (const std::string &base)
 Check if the material property base exists.
 
const MaterialPropertyName derivativePropertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 Helper functions to generate the material property names for the arbitrary derivatives.
 
const MaterialPropertyName derivativePropertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 Helper functions to generate the material property names for the first derivatives.
 
const MaterialPropertyName derivativePropertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 Helper functions to generate the material property names for the second derivatives.
 
const MaterialPropertyName derivativePropertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 Helper functions to generate the material property names for the third derivatives.
 
template<typename U , bool is_ad = false>
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for declaring derivative material properties.
 
template<typename U , bool is_ad = false>
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
template<typename U , bool is_ad = false>
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for retrieving derivative material properties.
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 Convenience methods for retrieving derivative material properties based on a mix of variable names c and indices v into the _coupled_standard_moose_vars vector.
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 Methods for retrieving derivative material properties.
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
template<typename U , bool is_ad = false>
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > getKokkosMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 Methods for retrieving derivative Kokkos material properties.
 
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > getKokkosMaterialPropertyDerivative (const std::string &base, const SymbolName &c1)
 
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > getKokkosMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
template<typename U , bool is_ad = false>
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 check if derivatives of the passed in material property exist w.r.t a variable that is not coupled in to the current object
 
template<typename U , bool is_ad = false>
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
template<typename U , bool is_ad = false>
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 aliases for the deprecated old function names
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 

Private Member Functions

template<typename U , bool is_ad = false>
bool haveMaterialProperty (const std::string &prop_name)
 Check if a material property is present with the applicable restrictions.
 
std::vector< VariableName > buildVariableVector (const VariableName &c1, const VariableName &c2, const VariableName &c3)
 helper method to combine multiple VariableNames into a vector (if they are != "")
 
template<typename U , bool is_ad = false>
void validateCouplingHelper (const MaterialPropertyName &base, const std::vector< VariableName > &c, const System &system, std::vector< VariableName > &missing)
 helper method to compile list of missing coupled variables for a given system
 
bool isNotObjectVariable (const VariableName &name)
 

Private Attributes

FEProblemBase & _dmi_fe_problem
 Reference to FEProblemBase.
 

Detailed Description

template<class T>
class DerivativeMaterialInterface< T >

Interface class ("Veneer") to provide generator methods for derivative material property names.

Definition at line 32 of file DerivativeMaterialInterface.h.

Member Typedef Documentation

◆ SymbolName

Definition at line 35 of file DerivativeMaterialInterface.h.

Constructor & Destructor Documentation

◆ DerivativeMaterialInterface()

template<class T >
DerivativeMaterialInterface< T >::DerivativeMaterialInterface ( const InputParameters &  parameters)

Definition at line 244 of file DerivativeMaterialInterface.h.

245 : T(parameters),
246 _dmi_fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"))
247{
248}
FEProblemBase & _dmi_fe_problem
Reference to FEProblemBase.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller.

Member Function Documentation

◆ buildVariableVector()

template<class T >
std::vector< VariableName > DerivativeMaterialInterface< T >::buildVariableVector ( const VariableName &  c1,
const VariableName &  c2,
const VariableName &  c3 
)
private

helper method to combine multiple VariableNames into a vector (if they are != "")

Definition at line 571 of file DerivativeMaterialInterface.h.

574{
575 std::vector<VariableName> c;
576 if (c1 != "")
577 {
578 c.push_back(c1);
579 if (c2 != "")
580 {
581 c.push_back(c2);
582 if (c3 != "")
583 c.push_back(c3);
584 }
585 }
586 return c;
587}

◆ declareKokkosPropertyDerivative()

template<class T >
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > DerivativeMaterialInterface< T >::declareKokkosPropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)
inline

Declare a derivative Kokkos material property.

Template Parameters
UThe material property type
dimensionThe material property dimension
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to
Returns
The declared Kokkos material property

Definition at line 180 of file DerivativeMaterialInterface.h.

181 {
182 return this->template declareKokkosPropertyByName<U, dimension>(
183 derivativePropertyName(base, c));
184 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ declarePropertyDerivative() [1/3]

template<class T >
template<typename U , bool is_ad>
GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::declarePropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)

Definition at line 314 of file DerivativeMaterialInterface.h.

316{
317 return this->template declareGenericProperty<U, is_ad>(derivativePropertyName(base, c));
318}

◆ declarePropertyDerivative() [2/3]

template<class T >
template<typename U , bool is_ad>
GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::declarePropertyDerivative ( const std::string &  base,
const std::vector< VariableName > &  c 
)

Methods for declaring derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 304 of file DerivativeMaterialInterface.h.

306{
307 std::vector<SymbolName> symbol_vector(c.begin(), c.end());
308 return declarePropertyDerivative<U, is_ad>(base, symbol_vector);
309}

◆ declarePropertyDerivative() [3/3]

template<class T >
template<typename U , bool is_ad>
GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::declarePropertyDerivative ( const std::string &  base,
const SymbolName &  c1,
const SymbolName &  c2 = "",
const SymbolName &  c3 = "" 
)

Definition at line 323 of file DerivativeMaterialInterface.h.

327{
328 if (c3 != "")
329 return this->template declareGenericProperty<U, is_ad>(
330 derivativePropertyNameThird(base, c1, c2, c3));
331 if (c2 != "")
332 return this->template declareGenericProperty<U, is_ad>(
333 derivativePropertyNameSecond(base, c1, c2));
334 return this->template declareGenericProperty<U, is_ad>(derivativePropertyNameFirst(base, c1));
335}
const MaterialPropertyName derivativePropertyNameThird(const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
Helper functions to generate the material property names for the third derivatives.
const MaterialPropertyName derivativePropertyNameSecond(const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
Helper functions to generate the material property names for the second derivatives.
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
Helper functions to generate the material property names for the first derivatives.

◆ derivativePropertyName()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
) const
inherited

Helper functions to generate the material property names for the arbitrary derivatives.

Definition at line 16 of file DerivativeMaterialPropertyNameInterface.C.

18{
19 // to obtain well defined names we sort alphabetically
20 std::vector<SymbolName> a(c);
21 std::sort(a.begin(), a.end());
22
23 // derivative order
24 unsigned int order = a.size();
25 if (order == 0)
26 return base;
27
28 // build the property name as a stringstream
29 std::stringstream name;
30
31 // build numerator
32 name << 'd';
33 if (order > 1)
34 name << '^' << order;
35 name << base << '/';
36
37 // build denominator with 'pretty' names using exponents rather than repeat multiplication
38 unsigned int exponent = 1;
39 for (unsigned i = 1; i <= order; ++i)
40 {
41 if (i == order || a[i - 1] != a[i])
42 {
43 name << 'd' << a[i - 1];
44 if (exponent > 1)
45 name << '^' << exponent;
46 exponent = 1;
47 }
48 else
49 exponent++;
50 }
51
52 return name.str();
53}
std::string name(const ElemQuality q)

Referenced by DerivativeMaterialInterface< T >::declareKokkosPropertyDerivative(), DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond(), DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird(), and DerivativeMaterialPropertyNameInterface::propertyName().

◆ derivativePropertyNameFirst()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameFirst ( const MaterialPropertyName &  base,
const SymbolName &  c1 
) const
inherited

Helper functions to generate the material property names for the first derivatives.

Definition at line 56 of file DerivativeMaterialPropertyNameInterface.C.

58{
59 return "d" + base + "/d" + c1;
60}

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameFirst(), NEML2Action::setupDerivativeMappings(), and NEML2Action::setupParameterDerivativeMappings().

◆ derivativePropertyNameSecond()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond ( const MaterialPropertyName &  base,
const SymbolName &  c1,
const SymbolName &  c2 
) const
inherited

Helper functions to generate the material property names for the second derivatives.

Definition at line 63 of file DerivativeMaterialPropertyNameInterface.C.

65{
66 return derivativePropertyName(base, {c1, c2});
67}

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameSecond().

◆ derivativePropertyNameThird()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird ( const MaterialPropertyName &  base,
const SymbolName &  c1,
const SymbolName &  c2,
const SymbolName &  c3 
) const
inherited

Helper functions to generate the material property names for the third derivatives.

Definition at line 70 of file DerivativeMaterialPropertyNameInterface.C.

75{
76 return derivativePropertyName(base, {c1, c2, c3});
77}

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameThird().

◆ getDefaultMaterialProperty()

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getDefaultMaterialProperty ( const std::string &  name)

Fetch a material property if it exists, otherwise return getZeroMaterialProperty.

Parameters
nameThe input parameter key of type MaterialPropertyName

Definition at line 277 of file DerivativeMaterialInterface.h.

278{
279 // get the base property name
280 std::string prop_name = this->getMaterialPropertyName(name);
281
282 // Check if it's just a constant
283 const auto * default_property =
284 this->template defaultGenericMaterialProperty<U, is_ad>(prop_name);
285 if (default_property)
286 return *default_property;
287
288 // if found return the requested property
289 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(prop_name);
290}

◆ getDefaultMaterialPropertyByName()

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getDefaultMaterialPropertyByName ( const std::string &  name)

Fetch a material property by name if it exists, otherwise return getZeroMaterialProperty.

Definition at line 295 of file DerivativeMaterialInterface.h.

296{
297 // TODO: deprecate this
298 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(prop_name);
299}

◆ getKokkosMaterialPropertyDerivative() [1/2]

template<class T >
template<typename U , unsigned int dimension>
Moose::Kokkos::MaterialProperty< U, dimension > DerivativeMaterialInterface< T >::getKokkosMaterialPropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)

Methods for retrieving derivative Kokkos material properties.

A constant zero property is returned if the base property is a default (constant) property or if the derivative property is not declared.

Template Parameters
UThe material property type
dimensionThe material property dimension
Parameters
baseThe name of the property to take the derivative of, or the parameter name containing it
cThe variable(s) to take the derivatives with respect to

Definition at line 449 of file DerivativeMaterialInterface.h.

451{
452 const auto prop_name = this->getMaterialPropertyName(base);
453
454 // Derivatives of constants are zero
455 if (MooseUtils::parsesToReal(prop_name))
457
458 return getKokkosMaterialPropertyDerivativeByName<U, dimension>(prop_name, c);
459}
The Kokkos material property class.
bool parsesToReal(const std::string &input, Real *parsed_real)
Definition MooseUtils.C:152

◆ getKokkosMaterialPropertyDerivative() [2/2]

template<class T >
template<typename U , unsigned int dimension = 0>
Moose::Kokkos::MaterialProperty< U, dimension > DerivativeMaterialInterface< T >::getKokkosMaterialPropertyDerivative ( const std::string &  base,
const SymbolName &  c1 
)
inline

Definition at line 159 of file DerivativeMaterialInterface.h.

160 {
161 return getKokkosMaterialPropertyDerivative<U, dimension>(base, std::vector<SymbolName>{c1});
162 }

◆ getKokkosMaterialPropertyDerivativeByName()

template<class T >
template<typename U , unsigned int dimension>
Moose::Kokkos::MaterialProperty< U, dimension > DerivativeMaterialInterface< T >::getKokkosMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
)

Definition at line 464 of file DerivativeMaterialInterface.h.

466{
467 const auto prop_name = derivativePropertyName(base, c);
468
469 if (!this->template hasKokkosMaterialPropertyByName<U, dimension>(prop_name))
471
472 return this->template getKokkosMaterialPropertyByName<U, dimension>(prop_name);
473}

◆ getMaterialPropertyDerivative() [1/5]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)

Check if base is a default property and shortcut to returning zero, as derivatives of constants are zero.

Definition at line 350 of file DerivativeMaterialInterface.h.

352{
353 // get the base property name
354 std::string prop_name = this->getMaterialPropertyName(base);
355
360 if (this->template defaultGenericMaterialProperty<U, is_ad>(prop_name))
361 return this->template getGenericZeroMaterialProperty<U, is_ad>();
362
363 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
364 derivativePropertyName(prop_name, c));
365}

◆ getMaterialPropertyDerivative() [2/5]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivative ( const std::string &  base,
const std::vector< VariableName > &  c 
)

Methods for retrieving derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 340 of file DerivativeMaterialInterface.h.

342{
343 std::vector<SymbolName> symbol_vector(c.begin(), c.end());
344 return getMaterialPropertyDerivative(base, symbol_vector);
345}
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative(const std::string &base, const std::vector< VariableName > &c)
Methods for retrieving derivative material properties.

◆ getMaterialPropertyDerivative() [3/5]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivative ( const std::string &  base,
const SymbolName &  c1,
const SymbolName &  c2 = "",
const SymbolName &  c3 = "" 
)

Check if base is a default property and shortcut to returning zero, as derivatives of constants are zero.

Definition at line 370 of file DerivativeMaterialInterface.h.

374{
375 // get the base property name
376 std::string prop_name = this->getMaterialPropertyName(base);
377
382 if (this->template defaultGenericMaterialProperty<Real, is_ad>(prop_name))
383 return this->template getGenericZeroMaterialProperty<U, is_ad>();
384
385 if (c3 != "")
386 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
387 derivativePropertyNameThird(prop_name, c1, c2, c3));
388 if (c2 != "")
389 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
390 derivativePropertyNameSecond(prop_name, c1, c2));
391 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
392 derivativePropertyNameFirst(prop_name, c1));
393}

◆ getMaterialPropertyDerivative() [4/5]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivative ( const std::string &  base,
const SymbolName &  c1,
unsigned int  v2,
unsigned int  v3 = libMesh::invalid_uint 
)

Convenience methods for retrieving derivative material properties based on a mix of variable names c and indices v into the _coupled_standard_moose_vars vector.

Definition at line 398 of file DerivativeMaterialInterface.h.

402{
403 return getMaterialPropertyDerivative<U, is_ad>(
404 base,
405 c1,
406 this->_coupled_standard_moose_vars[v2]->name(),
407 v3 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v3]->name());
408}
const unsigned int invalid_uint

◆ getMaterialPropertyDerivative() [5/5]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivative ( const std::string &  base,
unsigned int  v1,
unsigned int  v2 = libMesh::invalid_uint,
unsigned int  v3 = libMesh::invalid_uint 
)

Definition at line 413 of file DerivativeMaterialInterface.h.

417{
418 return getMaterialPropertyDerivative<U, is_ad>(
419 base,
420 this->_coupled_standard_moose_vars[v1]->name(),
421 v2 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v2]->name(),
422 v3 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v3]->name());
423}
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...

◆ getMaterialPropertyDerivativeByName() [1/3]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
)

Definition at line 438 of file DerivativeMaterialInterface.h.

440{
441 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
442 derivativePropertyName(base, c));
443}

◆ getMaterialPropertyDerivativeByName() [2/3]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c 
)

Methods for retrieving derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 428 of file DerivativeMaterialInterface.h.

430{
431 std::vector<SymbolName> symbol_vector(c.begin(), c.end());
432 return getMaterialPropertyDerivativeByName(base, symbol_vector);
433}
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName(const MaterialPropertyName &base, const std::vector< VariableName > &c)
Methods for retrieving derivative material properties.

◆ getMaterialPropertyDerivativeByName() [3/3]

template<class T >
template<typename U , bool is_ad>
const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const SymbolName &  c1,
const SymbolName &  c2 = "",
const SymbolName &  c3 = "" 
)

Definition at line 479 of file DerivativeMaterialInterface.h.

484{
485 if (c3 != "")
486 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
487 derivativePropertyNameThird(base, c1, c2, c3));
488 if (c2 != "")
489 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
490 derivativePropertyNameSecond(base, c1, c2));
491 return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
493}

◆ haveMaterialProperty()

template<class T >
template<typename U , bool is_ad>
bool DerivativeMaterialInterface< T >::haveMaterialProperty ( const std::string &  prop_name)
private

Check if a material property is present with the applicable restrictions.

Definition at line 263 of file DerivativeMaterialInterface.h.

264{
265 // Call the correct method to test for material property declarations
266 BlockRestrictable * blk = dynamic_cast<BlockRestrictable *>(this);
267 BoundaryRestrictable * bnd = dynamic_cast<BoundaryRestrictable *>(this);
268 return ((bnd && bnd->boundaryRestricted() &&
269 bnd->template hasBoundaryMaterialProperty<U, is_ad>(prop_name)) ||
270 (blk && blk->template hasBlockMaterialProperty<U, is_ad>(prop_name)) ||
271 (this->template hasGenericMaterialProperty<U, is_ad>(prop_name)));
272}
An interface that restricts an object to subdomains via the 'blocks' input parameter.
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
virtual bool boundaryRestricted() const
Returns true if this object has been restricted to a boundary.

◆ isNotObjectVariable()

template<class T >
bool DerivativeMaterialInterface< T >::isNotObjectVariable ( const VariableName &  name)
inlineprivate

Definition at line 632 of file DerivativeMaterialInterface.h.

633{
634 // try to cast this to a Kernel pointer
635 KernelBase * kernel_ptr = dynamic_cast<KernelBase *>(this);
636 if (kernel_ptr != nullptr)
637 return kernel_ptr->variable().name() != name;
638
639 // try to cast this to a BoundaryCondition pointer
640 BoundaryCondition * bc_ptr = dynamic_cast<BoundaryCondition *>(this);
641 if (bc_ptr != nullptr)
642 return bc_ptr->variable().name() != name;
643
644 // This interface is not templated on a class derived from either Kernel or BC
645 return true;
646}
Base class for creating new types of boundary conditions.
This is the common base class for the three main kernel types implemented in MOOSE,...
Definition KernelBase.h:29
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
virtual const MooseVariableBase & variable() const =0
Returns the variable that this object operates on.

◆ propertyName()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
) const
inlineinherited

aliases for the deprecated old function names

Definition at line 58 of file DerivativeMaterialPropertyNameInterface.h.

60 {
61 mooseDeprecated("This function was renamed to 'derivativePropertyName'");
62 return derivativePropertyName(base, c);
63 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363

◆ propertyNameFirst()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameFirst ( const MaterialPropertyName &  base,
const SymbolName &  c1 
) const
inlineinherited

Definition at line 64 of file DerivativeMaterialPropertyNameInterface.h.

66 {
67 mooseDeprecated("This function was renamed to 'derivativePropertyNameFirst'");
68 return derivativePropertyNameFirst(base, c1);
69 }

◆ propertyNameSecond()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameSecond ( const MaterialPropertyName &  base,
const SymbolName &  c1,
const SymbolName &  c2 
) const
inlineinherited

Definition at line 70 of file DerivativeMaterialPropertyNameInterface.h.

73 {
74 mooseDeprecated("This function was renamed to 'derivativePropertyNameSecond'");
75 return derivativePropertyNameSecond(base, c1, c2);
76 }

◆ propertyNameThird()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameThird ( const MaterialPropertyName &  base,
const SymbolName &  c1,
const SymbolName &  c2,
const SymbolName &  c3 
) const
inlineinherited

Definition at line 77 of file DerivativeMaterialPropertyNameInterface.h.

81 {
82 mooseDeprecated("This function was renamed to 'derivativePropertyNameThird'");
83 return derivativePropertyNameThird(base, c1, c2, c3);
84 }

◆ validateCoupling() [1/2]

template<class T >
template<typename U , bool is_ad>
void DerivativeMaterialInterface< T >::validateCoupling ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c,
bool  validate_aux = true 
)

check if derivatives of the passed in material property exist w.r.t a variable that is not coupled in to the current object

Definition at line 538 of file DerivativeMaterialInterface.h.

541{
542 // get the base property name
543 std::string prop_name = this->getMaterialPropertyName(base);
544 // list of potentially missing coupled variables
545 std::vector<VariableName> missing;
546
547 // iterate over all variables in the both the non-linear and auxiliary system (optional)
548 validateCouplingHelper<U, is_ad>(
549 prop_name, c, _dmi_fe_problem.getNonlinearSystemBase(/*nl_sys=*/0).system(), missing);
550 if (validate_aux)
551 validateCouplingHelper<U, is_ad>(
552 prop_name, c, _dmi_fe_problem.getAuxiliarySystem().system(), missing);
553
554 if (missing.size() > 0)
555 {
556 // join list of missing variable names
557 std::string list = missing[0];
558 for (unsigned int i = 1; i < missing.size(); ++i)
559 list += ", " + missing[i];
560
561 mooseWarning("Missing coupled variables {",
562 list,
563 "} (add them to coupled_variables parameter of ",
564 this->name(),
565 ")");
566 }
567}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
virtual libMesh::System & system() override
Get the reference to the libMesh system.
AuxiliarySystem & getAuxiliarySystem()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ validateCoupling() [2/2]

template<class T >
template<typename U , bool is_ad>
void DerivativeMaterialInterface< T >::validateCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)

Definition at line 592 of file DerivativeMaterialInterface.h.

596{
597 validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), true);
598}
std::vector< VariableName > buildVariableVector(const VariableName &c1, const VariableName &c2, const VariableName &c3)
helper method to combine multiple VariableNames into a vector (if they are != "")

◆ validateCouplingHelper()

template<class T >
template<typename U , bool is_ad>
void DerivativeMaterialInterface< T >::validateCouplingHelper ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c,
const System &  system,
std::vector< VariableName > &  missing 
)
private

helper method to compile list of missing coupled variables for a given system

Definition at line 498 of file DerivativeMaterialInterface.h.

502{
503 unsigned int ncoupled = this->_coupled_standard_moose_vars.size();
504
505 // iterate over all variables in the current system (in groups)
506 for (unsigned int i = 0; i < system.n_variable_groups(); ++i)
507 {
508 const libMesh::VariableGroup & vg = system.variable_group(i);
509 for (unsigned int j = 0; j < vg.n_variables(); ++j)
510 {
511 std::vector<SymbolName> cj(c.begin(), c.end());
512 SymbolName jname = vg.name(j);
513 cj.push_back(jname);
514
515 // if the derivative exists make sure the variable is coupled
516 if (haveMaterialProperty<U, is_ad>(derivativePropertyName(base, cj)))
517 {
518 // kernels and BCs to not have the variable they are acting on in coupled_moose_vars
519 bool is_missing = isNotObjectVariable(jname);
520
521 for (unsigned int k = 0; k < ncoupled; ++k)
522 if (this->_coupled_standard_moose_vars[k]->name() == jname)
523 {
524 is_missing = false;
525 break;
526 }
527
528 if (is_missing)
529 missing.push_back(jname);
530 }
531 }
532 }
533}
DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
bool isNotObjectVariable(const VariableName &name)
unsigned int n_variables() const
const std::string & name(unsigned int v) const

◆ validateDerivativeMaterialPropertyBase()

template<class T >
template<typename U , bool is_ad>
void DerivativeMaterialInterface< T >::validateDerivativeMaterialPropertyBase ( const std::string &  base)

Check if the material property base exists.

Print a warning if it doesn't. This is useful in materials that pull in only derivative properties, which are optional. If the base property name has a typo all derivatives will be set to zero without the user ever knowing.

Definition at line 614 of file DerivativeMaterialInterface.h.

615{
616 // resolve the input parameter name base to the actual material property name
617 const MaterialPropertyName prop_name = this->template getParam<MaterialPropertyName>(base);
618
619 // check if the material property does not exist on the blocks of the current object,
620 // and check if it is not a plain number in the input file
621 if (!haveMaterialProperty<U, is_ad>(prop_name) &&
622 this->template defaultGenericMaterialProperty<U, is_ad>(prop_name) == 0)
623 mooseWarning("The material property '",
624 prop_name,
625 "' does not exist. The kernel '",
626 this->name(),
627 "' only needs its derivatives, but this may indicate a typo in the input file.");
628}

◆ validateNonlinearCoupling()

template<class T >
template<typename U , bool is_ad>
void DerivativeMaterialInterface< T >::validateNonlinearCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)

Definition at line 603 of file DerivativeMaterialInterface.h.

607{
608 validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), false);
609}

Member Data Documentation

◆ _dmi_fe_problem

template<class T >
FEProblemBase& DerivativeMaterialInterface< T >::_dmi_fe_problem
private

Reference to FEProblemBase.

Definition at line 240 of file DerivativeMaterialInterface.h.


The documentation for this class was generated from the following file: