https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementDamper.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 "ElementDamper.h"
11
12// MOOSE includes
13#include "Assembly.h"
14#include "FEProblem.h"
15#include "MooseVariableFE.h"
16#include "SubProblem.h"
17#include "SystemBase.h"
18
19#include "libmesh/quadrature.h"
20
23{
26 params.addRequiredParam<NonlinearVariableName>(
27 "variable", "The name of the variable that this damper operates on");
28 return params;
29}
30
32 : Damper(parameters),
33 MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, Moose::EMPTY_BOUNDARY_IDS),
34 _tid(parameters.get<THREAD_ID>("_tid")),
35 _assembly(_subproblem.assembly(_tid, _sys.number())),
36 _coord_sys(_assembly.coordSystem()),
37 _var(_sys.getFieldVariable<Real>(_tid, parameters.get<NonlinearVariableName>("variable"))),
38
39 _current_elem(_var.currentElem()),
40 _q_point(_assembly.qPoints()),
41 _qrule(_assembly.qRule()),
42 _JxW(_assembly.JxW()),
43
44 _u_increment(_var.increment()),
45
46 _u(_var.sln()),
47 _grad_u(_var.gradSln())
48{
49 mooseAssert(_var.count() == 1,
50 "ElementDamper only supports scalar variables. Variable '" + _var.name() +
51 "' has multiple components.");
52}
53
54Real
56{
57 Real damping = 1.0;
58 Real cur_damping = 1.0;
59
60 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
61 {
62 cur_damping = computeQpDamping();
63 if (cur_damping < damping)
64 damping = cur_damping;
65 }
66
67 return damping;
68}
69
70bool
72{
73 return _var.hasBlocks(elem->subdomain_id());
74}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Base class for deriving dampers.
Definition Damper.h:28
static InputParameters validParams()
Definition Damper.C:16
const libMesh::QBase *const & _qrule
Quadrature rule.
MooseVariable & _var
Non-linear variable this damper works on.
Real computeDamping()
Computes this Damper's damping for one element.
unsigned int _qp
Quadrature point index.
virtual Real computeQpDamping()=0
This MUST be overridden by a child damper.
static InputParameters validParams()
bool variableDefinedOnElement(const Elem *elem) const
Check whether this damper's variable has DOFs/components on the given element.
ElementDamper(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
An interface for accessing Materials.
static InputParameters validParams()
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
bool hasBlocks(const SubdomainID id) const override
Returns whether the functor is defined on this block.
unsigned int n_points() const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...