Skip to content

Commit

Permalink
fix step1 for patch recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Nov 14, 2023
1 parent 0024f68 commit ac7aa79
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//* 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

// MOOSE includes
#include "NodalPatchRecoveryMaterialProperty.h"

/**
* Nodal patch recovery for material property components for projected stateful properties
*/
class ProjectedStatefulMaterialNodalPatchRecovery : public NodalPatchRecoveryMaterialProperty
{
public:
static InputParameters validParams();

ProjectedStatefulMaterialNodalPatchRecovery(const InputParameters & parameters);

virtual void initialSetup() override;
virtual void subdomainSetup() override;

protected:
virtual Real computeValue() override;

const SubdomainID & _current_subdomain_id;

std::set<MaterialBase *> _all_materials;
std::vector<MaterialBase *> _active_materials;
};
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ ProjectedStatefulMaterialStorageAction::processComponent(const std::string & pro

{
// add user object
const auto & type_name =
is_ad ? "ADNodalPatchRecoveryMaterialProperty" : "NodalPatchRecoveryMaterialProperty";
const auto & type_name = is_ad ? "ADProjectedStatefulMaterialNodalPatchRecovery"
: "ProjectedStatefulMaterialNodalPatchRecovery";
auto params = _factory.getValidParams(type_name);
params.applySpecificParameters(parameters(), {"block"});
params.set<std::vector<unsigned int>>("component") = idx;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//* 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

#include "ProjectedStatefulMaterialNodalPatchRecovery.h"

registerMooseObject("TensorMechanicsApp", ProjectedStatefulMaterialNodalPatchRecovery);

InputParameters
ProjectedStatefulMaterialNodalPatchRecovery::validParams()
{
InputParameters params = NodalPatchRecoveryMaterialProperty::validParams();
return params;
}

ProjectedStatefulMaterialNodalPatchRecovery::ProjectedStatefulMaterialNodalPatchRecovery(
const InputParameters & parameters)
: NodalPatchRecoveryMaterialProperty(parameters),
_current_subdomain_id(_assembly.currentSubdomainID())
{
}

void
ProjectedStatefulMaterialNodalPatchRecovery::initialSetup()
{
NodalPatchRecoveryMaterialProperty::initialSetup();

// get all material classes that provide properties for this object
_all_materials = getSupplyerMaterials();
}

void
ProjectedStatefulMaterialNodalPatchRecovery::subdomainSetup()
{
// get materials for the current subdomain
_active_materials.clear();
for (const auto & mat : _all_materials)
if (mat->hasBlocks(_current_subdomain_id))
_active_materials.push_back(mat);
}

Real
ProjectedStatefulMaterialNodalPatchRecovery::computeValue()
{
if (_t_step == 0)
for (const auto & mat : _active_materials)
mat->initStatefulProperties(_qrule->size());

return _prop[_qp];
}

0 comments on commit ac7aa79

Please sign in to comment.