Skip to content

Commit

Permalink
Merge pull request #24762 from loganharbour/material_rewrite_2
Browse files Browse the repository at this point in the history
Move restart restore further up in initial setup
  • Loading branch information
loganharbour authored Aug 22, 2023
2 parents 9b425d7 + cd2db43 commit 02a7758
Show file tree
Hide file tree
Showing 60 changed files with 964 additions and 779 deletions.
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
/framework/*/dampers @GiudGiud @lindsayad
/framework/*/executioners/*Solve* @GiudGiud @lindsayad
/framework/*/materials/Derivative* @dschwen @lindsayad
/framework/*/materials/Material* @roystgnr @lindsayad
/framework/*/materials/Material* @roystgnr @loganharbour @lindsayad
/framework/*/materials/Parsed* @dschwen @lindsayad
/framework/*/mesh @roystgnr @GiudGiud @lindsayad
/framework/*/meshgenerators @roystgnr @GiudGiud @lindsayad
/framework/*/multiapps @GiudGiud @lindsayad
/framework/*/loops @GiudGiud @lindsayad
/framework/*/outputs @roystgnr @lindsayad
/framework/*/postprocessors @GiudGiud @lindsayad
/framework/*/restart @loganharbour @lindsayad
/framework/*/reporters @loganharbour @zachmprince @lindsayad
/framework/*/samplers @zachmprince @lindsayad
/framework/*/systems @roystgnr @lindsayad
Expand Down
4 changes: 2 additions & 2 deletions framework/doc/content/source/reporters/AccumulateReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ AccumulateReporter gives the ability to accumulate reporter values over time and
- `std::vector<Real>` (this covers [VectorPostprocessors/index.md])
- `std::vector<std::string>`

If more types need to be supported, they can easily be added by adding a line in the `if` statement in `AccumulateReporter::initialSetup()`:
If more types need to be supported, they can easily be added by adding a line in the `if` statement in `AccumulateReporter::declareLateValues()`:

!listing framework/src/reporters/AccumulateReporter.C
re=void\nAccumulateReporter::initialSetup.*?^}
re=void\nAccumulateReporter::declareLateValues.*?^}

!alert note title=Reporter names
The reporter names created by the `AccumulateReporter` match each of the accumulated reporters' names.
Expand Down
22 changes: 22 additions & 0 deletions framework/include/actions/DeclareLateReportersAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "Action.h"

class DeclareLateReportersAction : public Action
{
public:
static InputParameters validParams();

DeclareLateReportersAction(const InputParameters & params);

virtual void act() override;
};
4 changes: 2 additions & 2 deletions framework/include/actions/MaterialOutputAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class MaterialOutputAction : public Action
bool get_names_only);

/// Pointer the MaterialData object storing the block restricted materials
std::shared_ptr<MaterialData> _block_material_data;
const MaterialData * _block_material_data;

/// Pointer the MaterialData object storing the boundary restricted materials
std::shared_ptr<MaterialData> _boundary_material_data;
const MaterialData * _boundary_material_data;

/// Map of variable name that contains the blocks to which the variable should be restricted
std::map<std::string, std::set<SubdomainID>> _block_variable_map;
Expand Down
2 changes: 1 addition & 1 deletion framework/include/interfaces/BlockRestrictable.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class BlockRestrictable

protected:
/// Pointer to the MaterialData class for this object
std::shared_ptr<MaterialData> _blk_material_data;
const MaterialData * _blk_material_data;

/**
* A helper method to allow the Material object to specialize the behavior
Expand Down
4 changes: 2 additions & 2 deletions framework/include/interfaces/BoundaryRestrictable.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class BoundaryRestrictable
THREAD_ID _bnd_tid;

/// Pointer to MaterialData for boundary (@see hasBoundaryMaterialProperty)
std::shared_ptr<MaterialData> _bnd_material_data;
const MaterialData & _bnd_material_data;

/// Whether or not this object is restricted to nodesets
bool _bnd_nodal;
Expand Down Expand Up @@ -235,5 +235,5 @@ BoundaryRestrictable::hasBoundaryMaterialProperty(const std::string & prop_name)
// If you get here the supplied property is defined on all boundaries, but is still subject
// existence in the MateialData class
return hasBoundaryMaterialPropertyHelper(prop_name) &&
_bnd_material_data->haveGenericProperty<T, is_ad>(prop_name);
_bnd_material_data.haveGenericProperty<T, is_ad>(prop_name);
}
15 changes: 5 additions & 10 deletions framework/include/interfaces/XFEMInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class XFEMInterface : public ConsoleStreamInterface
explicit XFEMInterface(const InputParameters & params)
: ConsoleStreamInterface(*params.getCheckedPointerParam<MooseApp *>("_moose_app")),
_fe_problem(params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
_material_data(nullptr),
_bnd_material_data(nullptr),
_moose_mesh(nullptr),
_moose_displaced_mesh(nullptr),
_mesh(nullptr),
Expand Down Expand Up @@ -78,17 +76,14 @@ class XFEMInterface : public ConsoleStreamInterface
/**
* Set the pointer to the MaterialData
*/
void setMaterialData(std::vector<std::shared_ptr<MaterialData>> * material_data)
{
_material_data = material_data;
}
void setMaterialData(const std::vector<MaterialData *> & data) { _material_data = data; }

/**
* Set the pointer to the Boundary MaterialData
*/
void setBoundaryMaterialData(std::vector<std::shared_ptr<MaterialData>> * bnd_material_data)
void setBoundaryMaterialData(const std::vector<MaterialData *> & data)
{
_bnd_material_data = bnd_material_data;
_bnd_material_data = data;
}

/**
Expand Down Expand Up @@ -139,8 +134,8 @@ class XFEMInterface : public ConsoleStreamInterface

protected:
FEProblemBase * _fe_problem;
std::vector<std::shared_ptr<MaterialData>> * _material_data;
std::vector<std::shared_ptr<MaterialData>> * _bnd_material_data;
std::vector<MaterialData *> _material_data;
std::vector<MaterialData *> _bnd_material_data;

MooseMesh * _moose_mesh;
MooseMesh * _moose_displaced_mesh;
Expand Down
10 changes: 1 addition & 9 deletions framework/include/loops/ComputeFVFluxThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,7 @@ ComputeFVFluxThread<RangeType, AttributeTagType>::checkPropDeps(
{
auto pr = supplied_props.insert(prop_id);
if (!pr.second)
{
const auto & prop_ids = _fe_problem.getMaterialPropertyRegistry().getNamesToIDs();
auto same_matprop_name_it =
std::find_if(prop_ids.begin(),
prop_ids.end(),
[prop_id](const std::pair<std::string, unsigned int> & map_pr)
{ return map_pr.second == prop_id; });
same_matprop_name.insert(same_matprop_name_it->first);
}
same_matprop_name.insert(_fe_problem.getMaterialPropertyRegistry().getName(prop_id));
}

const auto & mp_deps = mat->getMatPropDependencies();
Expand Down
6 changes: 0 additions & 6 deletions framework/include/loops/ComputeMaterialsObjectThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class ComputeMaterialsObjectThread : public ThreadedElementLoop<ConstElemRange>
{
public:
ComputeMaterialsObjectThread(FEProblemBase & fe_problem,
std::vector<std::shared_ptr<MaterialData>> & material_data,
std::vector<std::shared_ptr<MaterialData>> & bnd_material_data,
std::vector<std::shared_ptr<MaterialData>> & neighbor_material_data,
MaterialPropertyStorage & material_props,
MaterialPropertyStorage & bnd_material_props,
MaterialPropertyStorage & neighbor_material_props,
Expand All @@ -50,9 +47,6 @@ class ComputeMaterialsObjectThread : public ThreadedElementLoop<ConstElemRange>
protected:
FEProblemBase & _fe_problem;
NonlinearSystemBase & _nl;
std::vector<std::shared_ptr<MaterialData>> & _material_data;
std::vector<std::shared_ptr<MaterialData>> & _bnd_material_data;
std::vector<std::shared_ptr<MaterialData>> & _neighbor_material_data;
MaterialPropertyStorage & _material_props;
MaterialPropertyStorage & _bnd_material_props;
MaterialPropertyStorage & _neighbor_material_props;
Expand Down
4 changes: 0 additions & 4 deletions framework/include/loops/ProjectMaterialProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class ProjectMaterialProperties : public ThreadedElementLoop<ConstElemPointerRan
public:
ProjectMaterialProperties(bool refine,
FEProblemBase & fe_problem,
std::vector<std::shared_ptr<MaterialData>> & material_data,
std::vector<std::shared_ptr<MaterialData>> & bnd_material_data,
MaterialPropertyStorage & material_props,
MaterialPropertyStorage & bnd_material_props,
std::vector<std::vector<std::unique_ptr<Assembly>>> & assembly);
Expand All @@ -50,8 +48,6 @@ class ProjectMaterialProperties : public ThreadedElementLoop<ConstElemPointerRan
/// Whether or not you are projecting refinements. Set to false for coarsening.
bool _refine;
FEProblemBase & _fe_problem;
std::vector<std::shared_ptr<MaterialData>> & _material_data;
std::vector<std::shared_ptr<MaterialData>> & _bnd_material_data;
MaterialPropertyStorage & _material_props;
MaterialPropertyStorage & _bnd_material_props;
std::vector<std::vector<std::unique_ptr<Assembly>>> & _assembly;
Expand Down
8 changes: 4 additions & 4 deletions framework/include/materials/DerivativeMaterialInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const GenericMaterialProperty<U, is_ad> &
DerivativeMaterialInterface<T>::getDefaultMaterialProperty(const std::string & name)
{
// get the base property name
std::string prop_name = this->deducePropertyName(name);
std::string prop_name = this->getMaterialPropertyName(name);

// Check if it's just a constant
const auto * default_property =
Expand Down Expand Up @@ -305,7 +305,7 @@ DerivativeMaterialInterface<T>::getMaterialPropertyDerivative(const std::string
const std::vector<SymbolName> & c)
{
// get the base property name
std::string prop_name = this->deducePropertyName(base);
std::string prop_name = this->getMaterialPropertyName(base);

/**
* Check if base is a default property and shortcut to returning zero, as
Expand All @@ -327,7 +327,7 @@ DerivativeMaterialInterface<T>::getMaterialPropertyDerivative(const std::string
const SymbolName & c3)
{
// get the base property name
std::string prop_name = this->deducePropertyName(base);
std::string prop_name = this->getMaterialPropertyName(base);

/**
* Check if base is a default property and shortcut to returning zero, as
Expand Down Expand Up @@ -463,7 +463,7 @@ DerivativeMaterialInterface<T>::validateCoupling(const MaterialPropertyName & ba
bool validate_aux)
{
// get the base property name
std::string prop_name = this->deducePropertyName(base);
std::string prop_name = this->getMaterialPropertyName(base);
// list of potentially missing coupled variables
std::vector<VariableName> missing;

Expand Down
8 changes: 4 additions & 4 deletions framework/include/materials/InterfaceMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class InterfaceMaterial : public MaterialBase,
}

protected:
virtual const MaterialData & materialData() const override { return *_material_data; }
virtual MaterialData & materialData() override { return *_material_data; }
virtual const MaterialData & materialData() const override { return _material_data; }
virtual MaterialData & materialData() override { return _material_data; }

virtual const QBase & qRule() const override { return *_qrule; }

Expand All @@ -199,7 +199,7 @@ const GenericMaterialProperty<T, is_ad> &
InterfaceMaterial::getGenericMaterialProperty(const std::string & name, const unsigned int state)
{
// Check if the supplied parameter is a valid input parameter key
std::string prop_name = deducePropertyName(name);
const auto prop_name = getMaterialPropertyName(name);

// Check if it's just a constant.
if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
Expand Down Expand Up @@ -235,7 +235,7 @@ InterfaceMaterial::getGenericNeighborMaterialProperty(const std::string & name,
const unsigned int state)
{
// Check if the supplied parameter is a valid input parameter key
std::string prop_name = deducePropertyName(name);
const auto prop_name = getMaterialPropertyName(name);

// Check if it's just a constant.
if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
Expand Down
6 changes: 3 additions & 3 deletions framework/include/materials/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ class Material : public MaterialBase, public Coupleable, public MaterialProperty
virtual void resolveOptionalProperties() override;

protected:
virtual const MaterialData & materialData() const override { return *_material_data; }
virtual MaterialData & materialData() override { return *_material_data; }
virtual const MaterialData & materialData() const override { return _material_data; }
virtual MaterialData & materialData() override { return _material_data; }

virtual const QBase & qRule() const override { return *_qrule; }

Expand Down Expand Up @@ -260,7 +260,7 @@ const GenericMaterialProperty<T, is_ad> &
Material::getGenericMaterialProperty(const std::string & name, const unsigned int state)
{
// Check if the supplied parameter is a valid input parameter key
std::string prop_name = deducePropertyName(name);
const auto prop_name = getMaterialPropertyName(name);

// Check if it's just a constant.
if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
Expand Down
2 changes: 1 addition & 1 deletion framework/include/materials/MaterialBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const GenericMaterialProperty<T, is_ad> &
MaterialBase::getGenericZeroMaterialProperty()
{
// static zero property storage
static GenericMaterialProperty<T, is_ad> zero;
static GenericMaterialProperty<T, is_ad> zero(MaterialPropertyInterface::zero_property_id);

// resize to accomodate maximum number of qpoints
// (in multiapp scenarios getMaxQps can return different values in each app; we need the max)
Expand Down
Loading

0 comments on commit 02a7758

Please sign in to comment.