Skip to content

Commit

Permalink
Using delcarations for member templates forbidden (#15207)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed May 22, 2020
1 parent 68d7bc4 commit 58a1685
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 32 deletions.
37 changes: 15 additions & 22 deletions framework/include/materials/DerivativeMaterialInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@
#include "MooseVariableFE.h"
#include "NonlinearSystem.h"

#define usingDerivativeMaterialInterfaceMembers(T) \
usingDerivativeMaterialPropertyNameInterfaceMembers; \
using DerivativeMaterialInterface<T>::getDefaultMaterialProperty; \
using DerivativeMaterialInterface<T>::getDefaultMaterialPropertyByName; \
using DerivativeMaterialInterface<T>::declarePropertyDerivative; \
using DerivativeMaterialInterface<T>::getMaterialPropertyDerivative; \
using DerivativeMaterialInterface<T>::getMaterialPropertyDerivativeByName; \
using DerivativeMaterialInterface<T>::validateCoupling; \
using DerivativeMaterialInterface<T>::validateNonlinearCoupling; \
using DerivativeMaterialInterface<T>::validateDerivativeMaterialPropertyBase

// Forward declarations
class FEProblemBase;
template <typename>
Expand Down Expand Up @@ -67,6 +56,7 @@ class DerivativeMaterialInterface : public T, public DerivativeMaterialPropertyN
template <typename U, bool is_ad = false>
GenericMaterialProperty<U, is_ad> &
declarePropertyDerivative(const std::string & base, const std::vector<VariableName> & c);

template <typename U, bool is_ad = false>
GenericMaterialProperty<U, is_ad> & declarePropertyDerivative(const std::string & base,
const VariableName & c1,
Expand All @@ -84,6 +74,7 @@ class DerivativeMaterialInterface : public T, public DerivativeMaterialPropertyN
template <typename U, bool is_ad = false>
const GenericMaterialProperty<U, is_ad> &
getMaterialPropertyDerivative(const std::string & base, const std::vector<VariableName> & c);

template <typename U, bool is_ad = false>
const GenericMaterialProperty<U, is_ad> &
getMaterialPropertyDerivative(const std::string & base,
Expand Down Expand Up @@ -136,16 +127,18 @@ class DerivativeMaterialInterface : public T, public DerivativeMaterialPropertyN
* 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>
template <typename U>
void validateCoupling(const MaterialPropertyName & base,
const std::vector<VariableName> & c,
bool validate_aux = true);
template <typename U, bool is_ad = false>

template <typename U>
void validateCoupling(const MaterialPropertyName & base,
const VariableName & c1 = "",
const VariableName & c2 = "",
const VariableName & c3 = "");
template <typename U, bool is_ad = false>

template <typename U>
void validateNonlinearCoupling(const MaterialPropertyName & base,
const VariableName & c1 = "",
const VariableName & c2 = "",
Expand All @@ -171,7 +164,7 @@ class DerivativeMaterialInterface : public T, public DerivativeMaterialPropertyN
buildVariableVector(const VariableName & c1, const VariableName & c2, const VariableName & c3);

/// helper method to compile list of missing coupled variables for a given system
template <typename U, bool is_ad = false>
template <typename U>
void validateCouplingHelper(const MaterialPropertyName & base,
const std::vector<VariableName> & c,
const System & system,
Expand Down Expand Up @@ -375,7 +368,7 @@ DerivativeMaterialInterface<T>::getMaterialPropertyDerivativeByName(
}

template <class T>
template <typename U, bool is_ad>
template <typename U>
void
DerivativeMaterialInterface<T>::validateCouplingHelper(const MaterialPropertyName & base,
const std::vector<VariableName> & c,
Expand Down Expand Up @@ -415,7 +408,7 @@ DerivativeMaterialInterface<T>::validateCouplingHelper(const MaterialPropertyNam
}

template <class T>
template <typename U, bool is_ad>
template <typename U>
void
DerivativeMaterialInterface<T>::validateCoupling(const MaterialPropertyName & base,
const std::vector<VariableName> & c,
Expand Down Expand Up @@ -468,25 +461,25 @@ DerivativeMaterialInterface<T>::buildVariableVector(const VariableName & c1,
}

template <class T>
template <typename U, bool is_ad>
template <typename U>
void
DerivativeMaterialInterface<T>::validateCoupling(const MaterialPropertyName & base,
const VariableName & c1,
const VariableName & c2,
const VariableName & c3)
{
validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), true);
validateCoupling<U>(base, buildVariableVector(c1, c2, c3), true);
}

template <class T>
template <typename U, bool is_ad>
template <typename U>
void
DerivativeMaterialInterface<T>::validateNonlinearCoupling(const MaterialPropertyName & base,
const VariableName & c1,
const VariableName & c2,
const VariableName & c3)
{
validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), false);
validateCoupling<U>(base, buildVariableVector(c1, c2, c3), false);
}

template <class T>
Expand All @@ -500,7 +493,7 @@ DerivativeMaterialInterface<T>::validateDerivativeMaterialPropertyBase(const std
// check if the material property does not exist on the blocks of the current object,
// and check if it is not a plain number in the input file
if (!haveMaterialProperty<U>(prop_name) &&
this->template defaultMaterialProperty<U>(prop_name) == 0)
this->template defaultGenericMaterialProperty<U, is_ad>(prop_name) == 0)
mooseWarning("The material property '",
prop_name,
"' does not exist. The kernel '",
Expand Down
1 change: 0 additions & 1 deletion framework/include/materials/FunctionMaterialBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "DerivativeMaterialInterface.h"

#define usingFunctionMaterialBaseMembers(T) \
usingDerivativeMaterialInterfaceMembers(Material); \
using FunctionMaterialBase<T>::name; \
using FunctionMaterialBase<T>::_qp; \
using FunctionMaterialBase<T>::_qrule; \
Expand Down
6 changes: 3 additions & 3 deletions framework/src/materials/DerivativeFunctionMaterialBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ DerivativeFunctionMaterialBaseTempl<is_ad>::initialSetup()

for (unsigned int i = 0; i < _nargs; ++i)
{
if (!_fe_problem.isMatPropRequested(derivativePropertyNameFirst(_F_name, _arg_names[i])))
if (!_fe_problem.isMatPropRequested(this->derivativePropertyNameFirst(_F_name, _arg_names[i])))
_prop_dF[i] = NULL;

// second derivatives
for (unsigned int j = i; j < _nargs; ++j)
{
if (!_fe_problem.isMatPropRequested(
derivativePropertyNameSecond(_F_name, _arg_names[i], _arg_names[j])))
this->derivativePropertyNameSecond(_F_name, _arg_names[i], _arg_names[j])))
_prop_d2F[i][j] = _prop_d2F[j][i] = NULL;

// third derivatives
if (_third_derivatives)
{
for (unsigned int k = j; k < _nargs; ++k)
{
if (!_fe_problem.isMatPropRequested(derivativePropertyNameThird(
if (!_fe_problem.isMatPropRequested(this->derivativePropertyNameThird(
_F_name, _arg_names[i], _arg_names[j], _arg_names[k])))
_prop_d3F[i][j][k] = _prop_d3F[k][i][j] = _prop_d3F[j][k][i] = _prop_d3F[k][j][i] =
_prop_d3F[j][i][k] = _prop_d3F[i][k][j] = NULL;
Expand Down
6 changes: 4 additions & 2 deletions framework/src/materials/DerivativeParsedMaterialHelper.C
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ DerivativeParsedMaterialHelperTempl<is_ad>::recurseDerivative(unsigned int var,
recurseDerivative(i, order + 1, current);

// set up a material property for the derivative
current._mat_prop = &declarePropertyDerivative<Real, is_ad>(_F_name, current._darg_names);
current._mat_prop =
&this->template declarePropertyDerivative<Real, is_ad>(_F_name, current._darg_names);

// save off current derivative
_derivatives.push_back(current);
Expand Down Expand Up @@ -166,7 +167,8 @@ DerivativeParsedMaterialHelperTempl<is_ad>::assembleDerivatives()
for (const auto & D : master->_derivatives)
{
Derivative newderivative;
newderivative._mat_prop = &declarePropertyDerivative<Real>(_F_name, D._darg_names);
newderivative._mat_prop =
&this->template declarePropertyDerivative<Real, is_ad>(_F_name, D._darg_names);
newderivative._F = std::make_shared<SymFunction>(*D._F);
_derivatives.push_back(newderivative);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/src/materials/DerivativeSumMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ DerivativeSumMaterialTempl<is_ad>::initialSetup()
{
if (_validate_coupling)
for (unsigned int n = 0; n < _num_materials; ++n)
validateCoupling<Real>(_sum_materials[n]);
this->template validateCoupling<Real>(_sum_materials[n]);
}

template <bool is_ad>
Expand Down
8 changes: 5 additions & 3 deletions framework/src/utils/FunctionMaterialPropertyDescriptor.C
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ FunctionMaterialPropertyDescriptor<is_ad>::value() const

// get the material property reference
if (_material_parent)
_value =
&(_material_parent->getMaterialPropertyDerivative<Real>(_base_name, _derivative_vars));
_value = &(_material_parent->getMaterialPropertyDerivative<Real, is_ad>(_base_name,
_derivative_vars));
else if (_kernel_parent)
_value = &(_kernel_parent->getMaterialPropertyDerivative<Real>(_base_name, _derivative_vars));
_value = &(
_kernel_parent->getMaterialPropertyDerivative<Real, is_ad>(_base_name, _derivative_vars));
else
mooseError("A FunctionMaterialPropertyDescriptor must be owned by either a Material or a "
"Kernel object.");
Expand All @@ -240,3 +241,4 @@ FunctionMaterialPropertyDescriptor<is_ad>::updatePropertyName()

// explicit instantiation
template class FunctionMaterialPropertyDescriptor<false>;
template class FunctionMaterialPropertyDescriptor<true>;

0 comments on commit 58a1685

Please sign in to comment.