Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions framework/include/dampers/ElementDamper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class ElementDamper : public Damper, public MaterialPropertyInterface
*/
Real computeDamping();

/**
* Check whether this damper's variable has DOFs/components on the given element
*/
bool variableDefinedOnElement(const Elem * elem) const;

/**
* Get the variable this damper is acting on
*/
Expand Down
13 changes: 13 additions & 0 deletions framework/src/dampers/ElementDamper.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ ElementDamper::ElementDamper(const InputParameters & parameters)
_u(_var.sln()),
_grad_u(_var.gradSln())
{
mooseAssert(_var.count() == 1,
Comment thread
GiudGiud marked this conversation as resolved.
"ElementDamper only supports scalar variables. Variable '" + _var.name() +
"' has multiple components.");
}

Real
Expand All @@ -63,3 +66,13 @@ ElementDamper::computeDamping()

return damping;
}

bool
ElementDamper::variableDefinedOnElement(const Elem * elem) const
{
const unsigned int sys_num = _var.sys().number();
const unsigned int var_num = _var.number();

const unsigned int n_comp = elem->n_comp(sys_num, var_num);
return n_comp;
}
20 changes: 11 additions & 9 deletions framework/src/loops/ComputeElemDampingThread.C
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,21 @@ ComputeElemDampingThread::onElement(const Elem * elem)

std::set<MooseVariable *> damped_vars;

const std::vector<std::shared_ptr<ElementDamper>> & edampers =
_nl.getElementDamperWarehouse().getActiveObjects(_tid);
const auto & edampers = _element_dampers.getActiveObjects(_tid);
for (const auto & damper : edampers)
damped_vars.insert(damper->getVariable());
if (damper->variableDefinedOnElement(elem))
damped_vars.insert(damper->getVariable());

_nl.reinitIncrementAtQpsForDampers(_tid, damped_vars);
if (!damped_vars.empty())
_nl.reinitIncrementAtQpsForDampers(_tid, damped_vars);

const std::vector<std::shared_ptr<ElementDamper>> & objects =
_element_dampers.getActiveObjects(_tid);
for (const auto & obj : objects)
for (const auto & damper : edampers)
{
Real cur_damping = obj->computeDamping();
obj->checkMinDamping(cur_damping);
if (!damper->variableDefinedOnElement(elem))
continue;

Real cur_damping = damper->computeDamping();
damper->checkMinDamping(cur_damping);
if (cur_damping < _damping)
_damping = cur_damping;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 1
xmin = 0.0
xmax = 1.0
ymin = 0.0
ymax = 1.0
[]
[left_block]
type = SubdomainBoundingBoxGenerator
input = gen
block_id = 1
bottom_left = '0.0 0.0 0.0'
top_right = '0.1 1.0 0.0'
[]
[right_block]
type = SubdomainBoundingBoxGenerator
input = left_block
block_id = 2
bottom_left = '0.1 0.0 0.0'
top_right = '1.0 1.0 0.0'
[]
[]

[Variables]
[theta_m]
family = MONOMIAL
order = CONSTANT
block = 1
initial_condition = 0.0
[]
[dummy]
family = MONOMIAL
order = CONSTANT
block = 2
initial_condition = 0.0
[]
[]

[Kernels]
[theta_td]
type = TimeDerivative
variable = theta_m
block = 1
[]
[theta_src]
type = BodyForce
variable = theta_m
value = 1.0
block = 1
[]
[dummy_td]
type = TimeDerivative
variable = dummy
block = 2
[]
[]

[Dampers]
[limit_theta]
type = BoundingValueElementDamper
variable = theta_m
min_value = -0.1
max_value = 0.25
min_damping = 1e-8
[]
[]

[Executioner]
type = Transient
solve_type = NEWTON
dt = 1.0
num_steps = 1
nl_rel_tol = 1e-12
nl_abs_tol = 1e-12
l_tol = 1e-14
[]

[Outputs]
exodus = true
[]
10 changes: 9 additions & 1 deletion test/tests/dampers/bounding_value_element_damper/tests
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
[Tests]
issues = '#7856'
design = 'source/dampers/BoundingValueElementDamper.md'
[./bounding_value_max]
issues = '#7856'
type = 'RunException'
input = 'bounding_value_max_test.i'
expect_out = 'Damping factor: 0.2388'
expect_err = 'Solve failed and timestep already at or below dtmin, cannot continue!'
requirement = "The system shall include the ability to reduce the change in nonlinear residual based on a maximum value on elements."
[../]
[./bounding_value_min]
issues = '#7856'
type = 'RunException'
input = 'bounding_value_max_test.i'
cli_args = "Kernels/source/function='-t'"
expect_out = 'Damping factor: 0.2388'
expect_err = 'Solve failed and timestep already at or below dtmin, cannot continue!'
requirement = "The system shall include the ability to reduce the change in nonlinear residual based on a minimum value on elements."
[../]
[./bounding_value_block_restricted]
issues = '#32058'
type = 'RunApp'
input = 'bounding_value_element_block_restricted_test.i'
cli_args = '--n-threads=2'
requirement = "The system shall not evaluate an elemental bounding-value damper on elements where a block-restricted variable to damp is undefined."
[../]
[]