Skip to content

Commit

Permalink
Remove now extraneous shift code
Browse files Browse the repository at this point in the history
The properties in `MaterialPropertyStorage` are all regular
`MaterialProperty` so there is no need to change property types when
shifting anymore.

Refs #16836
  • Loading branch information
lindsayad committed Feb 2, 2021
1 parent a2eea10 commit 74be21e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 77 deletions.
42 changes: 0 additions & 42 deletions framework/include/materials/MaterialProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ class PropertyValue

virtual bool isAD() = 0;

/**
* Creates a regular material property, copying any existing qp values from this
*/
virtual PropertyValue * makeRegularProperty() = 0;

/**
* Creates an AD material property, copying any existing qp *values* from this. Derivative
* information is zeroed
*/
virtual PropertyValue * makeADProperty() = 0;

/**
* Copy the value of a Property from one specific to a specific qp in this Property.
* Important note: this copy operation loses AD derivative information if either this
Expand Down Expand Up @@ -123,9 +112,6 @@ class MaterialPropertyBase : public PropertyValue

bool isAD() override { return is_ad; }

PropertyValue * makeRegularProperty() override;
PropertyValue * makeADProperty() override;

/**
* @returns a read-only reference to the parameter value.
*/
Expand Down Expand Up @@ -246,34 +232,6 @@ rawValueEqualityHelper(std::vector<T1> & out, const std::vector<T2> & in)
}
}

template <typename T, bool is_ad>
PropertyValue *
MaterialPropertyBase<T, is_ad>::makeRegularProperty()
{
auto * new_prop = new MaterialProperty<T>;

new_prop->resize(this->size());

for (MooseIndex(_value) i = 0; i < _value.size(); ++i)
moose::internal::rawValueEqualityHelper((*new_prop)[i], _value[i]);

return new_prop;
}

template <typename T, bool is_ad>
PropertyValue *
MaterialPropertyBase<T, is_ad>::makeADProperty()
{
auto * new_prop = new ADMaterialProperty<T>;

new_prop->resize(this->size());

for (MooseIndex(_value) i = 0; i < _value.size(); ++i)
moose::internal::rawValueEqualityHelper((*new_prop)[i], _value[i]);

return new_prop;
}

template <typename T, bool is_ad>
inline std::string
MaterialPropertyBase<T, is_ad>::type()
Expand Down
35 changes: 0 additions & 35 deletions framework/src/materials/MaterialPropertyStorage.C
Original file line number Diff line number Diff line change
Expand Up @@ -298,41 +298,6 @@ MaterialPropertyStorage::shift(const FEProblemBase & fe_problem)

// Intentional fall through for case above and for handling just using old properties
std::swap(_props_elem_old, _props_elem);

// We swapped current and old props. If we're doing AD, that means what was formerly an
// ADMaterialProperty in current is now a MaterialProperty, and what was formerly a
// MaterialProperty in old is now an ADMaterialProperty. We need to run through and make sure what
// needs to be AD in current is AD (to preserve Jacobian accuracy) and that every property in old
// is a regular MaterialProperty (to save memory)
if (fe_problem.usingADMatProps())
{
for (auto & elem_pair : (*_props_elem_old))
for (auto & side_pair : elem_pair.second)
{
auto & old_mat_props_vec = side_pair.second;
auto & current_mat_props_vec = (*_props_elem)[elem_pair.first][side_pair.first];
for (MooseIndex(old_mat_props_vec) i = 0; i < old_mat_props_vec.size(); ++i)
{
PropertyValue * possibly_ad_old_prop = old_mat_props_vec[i];
if (possibly_ad_old_prop->isAD())
{
// Make the old property regular
PropertyValue * regular_old_prop = possibly_ad_old_prop->makeRegularProperty();
delete possibly_ad_old_prop;
old_mat_props_vec[i] = regular_old_prop;

// Make the current property AD
PropertyValue * regular_current_prop = current_mat_props_vec[i];
mooseAssert(!regular_current_prop->isAD(),
"We must have somehow had an old material property that was an "
"ADMaterialProperty. That's not right");
PropertyValue * ad_current_prop = regular_current_prop->makeADProperty();
delete regular_current_prop;
current_mat_props_vec[i] = ad_current_prop;
}
}
}
}
}

void
Expand Down

0 comments on commit 74be21e

Please sign in to comment.