https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NonlocalDamage.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "NonlocalDamage.h"
11
12registerMooseObject("SolidMechanicsApp", NonlocalDamage);
14
15template <bool is_ad>
18{
21 "Nonlocal damage model. Given an RadialAverage UO this creates a new damage index that can "
22 "be used as for ComputeDamageStress without havign to change existing local damage models.");
23 params.addRequiredParam<UserObjectName>("average_UO", "Radial Average user object");
24 params.addRequiredParam<MaterialName>("local_damage_model",
25 "Name of the local damage model used to compute "
26 "the nonlocal damage index");
27 return params;
28}
29
30template <bool is_ad>
32 : ScalarDamageBaseTempl<is_ad>(parameters),
34 _average(this->template getUserObject<RadialAverage>("average_UO").getAverage()),
35 _local_damage_model_name(this->template getParam<MaterialName>("local_damage_model")),
36 _prev_elem(nullptr)
37{
38}
39template <bool is_ad>
40void
42{
43 _local_damage_model = dynamic_cast<ScalarDamageBaseTempl<is_ad> *>(
44 &this->getMaterialByName(_local_damage_model_name));
45
46 if (!_local_damage_model)
47 this->paramError("damage_model",
48 "Damage Model " + _local_damage_model_name +
49 " is not compatible with NonlocalDamage model");
50}
51
52template <bool is_ad>
53void
58
59template <bool is_ad>
60void
62{
63 // First update underlying local damage model
64 _local_damage_model->getQpDamageIndex(_qp);
65 // Now update the nonlocal damage model
66 // Only update iterator when we change to another element. This is for
67 // computational costs related to map lookup.
68 if (_prev_elem != _current_elem)
69 {
70 _average_damage = _average.find(_current_elem->id());
71 _prev_elem = _current_elem;
72 }
73 // Check that we found the new element
74 if (_average_damage != _average.end())
75 // return max of the old damage or new average damage
76 _damage_index[_qp] = std::max(_average_damage->second[_qp], _damage_index_old[_qp]);
77 else
78 // during startup the map is not made yet or
79 // if AMR is used then the new element will not be found but it should
80 // already have an old nonlocal damage value that needs to perserved
81 _damage_index[_qp] = std::max(0.0, _damage_index_old[_qp]);
82}
83
84template class NonlocalDamageTempl<false>;
85template class NonlocalDamageTempl<true>;
registerMooseObject("SolidMechanicsApp", NonlocalDamage)
Add-on class that provides the functionality to check if guarantees for material properties are provi...
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Scalar damage model that defines the damage parameter using a material property.
static InputParameters validParams()
virtual void initQpStatefulProperties() override
virtual void updateQpDamageIndex() override
Update the damage index at the current qpoint.
NonlocalDamageTempl(const InputParameters &parameters)
virtual void initialSetup() override
Base class for scalar damage models.
virtual void initQpStatefulProperties() override
static InputParameters validParams()