www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ElementJacobianDamper Class Reference

This class implements a damper that limits the change in the Jacobian of elements. More...

#include <ElementJacobianDamper.h>

Inheritance diagram for ElementJacobianDamper:
[legend]

Public Member Functions

 ElementJacobianDamper (const InputParameters &parameters)
 
virtual void initialSetup () override
 
virtual Real computeDamping (const NumericVector< Number > &, const NumericVector< Number > &update) override
 Computes this Damper's damping. More...
 

Protected Attributes

THREAD_ID _tid
 Thread ID. More...
 
Assembly & _assembly
 
QBase *& _qrule
 Quadrature rule. More...
 
const MooseArray< Real > & _JxW
 Transformed Jacobian weights. More...
 
FEProblemBase & _fe_problem
 The FE problem. More...
 
MooseSharedPointer< DisplacedProblem > _displaced_problem
 The displaced problem. More...
 
MooseMesh * _mesh
 The displaced mesh. More...
 
std::vector< MooseVariable * > _disp_var
 The displacement variables. More...
 
unsigned int _ndisp
 The number of displacement variables. More...
 
std::vector< VariableValue > _disp_incr
 The current Newton increment in the displacement variables. More...
 
const Real _max_jacobian_diff
 Maximum allowed relative increment in Jacobian. More...
 

Detailed Description

This class implements a damper that limits the change in the Jacobian of elements.

Definition at line 29 of file ElementJacobianDamper.h.

Constructor & Destructor Documentation

◆ ElementJacobianDamper()

ElementJacobianDamper::ElementJacobianDamper ( const InputParameters &  parameters)

Definition at line 36 of file ElementJacobianDamper.C.

37  : GeneralDamper(parameters),
38  _tid(parameters.get<THREAD_ID>("_tid")),
39  _assembly(_subproblem.assembly(_tid)),
40  _qrule(_assembly.qRule()),
41  _JxW(_assembly.JxW()),
42  _fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
43  _displaced_problem(_fe_problem.getDisplacedProblem()),
44  _max_jacobian_diff(parameters.get<Real>("max_increment"))
45 {
46  if (_displaced_problem == NULL)
47  mooseError("ElementJacobianDamper: Must use displaced problem");
48 
49  _mesh = &_displaced_problem->mesh();
50 
51  const std::vector<NonlinearVariableName> & nl_vnames(
52  getParam<std::vector<NonlinearVariableName>>("displacements"));
53  _ndisp = nl_vnames.size();
54 
55  for (unsigned int i = 0; i < _ndisp; ++i)
56  {
57  _disp_var.push_back(&_sys.getFieldVariable<Real>(_tid, nl_vnames[i]));
58  _disp_incr.push_back(_disp_var.back()->increment());
59  }
60 }
QBase *& _qrule
Quadrature rule.
unsigned int _ndisp
The number of displacement variables.
MooseSharedPointer< DisplacedProblem > _displaced_problem
The displaced problem.
std::vector< VariableValue > _disp_incr
The current Newton increment in the displacement variables.
MooseMesh * _mesh
The displaced mesh.
const Real _max_jacobian_diff
Maximum allowed relative increment in Jacobian.
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
FEProblemBase & _fe_problem
The FE problem.
std::vector< MooseVariable * > _disp_var
The displacement variables.
THREAD_ID _tid
Thread ID.

Member Function Documentation

◆ computeDamping()

Real ElementJacobianDamper::computeDamping ( const NumericVector< Number > &  ,
const NumericVector< Number > &  update 
)
overridevirtual

Computes this Damper's damping.

Definition at line 68 of file ElementJacobianDamper.C.

70 {
71  // Maximum difference in the Jacobian for this Newton iteration
72  Real max_difference = 0.0;
73  MooseArray<Real> JxW_displaced;
74 
75  // Vector for storing the original node coordinates
76  std::vector<Point> point_copies;
77 
78  // Loop over elements in the mesh
79  for (auto & current_elem : _mesh->getMesh().active_local_element_ptr_range())
80  {
81  point_copies.clear();
82  point_copies.reserve(current_elem->n_nodes());
83 
84  // Displace nodes with current Newton increment
85  for (unsigned int i = 0; i < current_elem->n_nodes(); ++i)
86  {
87  Node & displaced_node = current_elem->node_ref(i);
88 
89  point_copies.push_back(displaced_node);
90 
91  for (unsigned int j = 0; j < _ndisp; ++j)
92  {
93  dof_id_type disp_dof_num =
94  displaced_node.dof_number(_sys.number(), _disp_var[j]->number(), 0);
95  displaced_node(j) += update(disp_dof_num);
96  }
97  }
98 
99  // Reinit element to compute Jacobian of displaced element
100  _assembly.reinit(current_elem);
101  JxW_displaced = _JxW;
102 
103  // Un-displace nodes
104  for (unsigned int i = 0; i < current_elem->n_nodes(); ++i)
105  {
106  Node & displaced_node = current_elem->node_ref(i);
107 
108  for (unsigned int j = 0; j < _ndisp; ++j)
109  displaced_node(j) = point_copies[i](j);
110  }
111 
112  // Reinit element to compute Jacobian before displacement
113  _assembly.reinit(current_elem);
114 
115  for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp)
116  {
117  Real diff = std::abs(JxW_displaced[qp] - _JxW[qp]) / _JxW[qp];
118  if (diff > max_difference)
119  max_difference = diff;
120  }
121 
122  JxW_displaced.release();
123  }
124 
125  _communicator.max(max_difference);
126 
127  if (max_difference > _max_jacobian_diff)
128  return _max_jacobian_diff / max_difference;
129 
130  return 1.0;
131 }
QBase *& _qrule
Quadrature rule.
unsigned int _ndisp
The number of displacement variables.
MooseMesh * _mesh
The displaced mesh.
const Real _max_jacobian_diff
Maximum allowed relative increment in Jacobian.
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
std::vector< MooseVariable * > _disp_var
The displacement variables.

◆ initialSetup()

void ElementJacobianDamper::initialSetup ( )
overridevirtual

Definition at line 63 of file ElementJacobianDamper.C.

64 {
65 }

Member Data Documentation

◆ _assembly

Assembly& ElementJacobianDamper::_assembly
protected

Definition at line 45 of file ElementJacobianDamper.h.

Referenced by computeDamping().

◆ _disp_incr

std::vector<VariableValue> ElementJacobianDamper::_disp_incr
protected

The current Newton increment in the displacement variables.

Definition at line 69 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().

◆ _disp_var

std::vector<MooseVariable *> ElementJacobianDamper::_disp_var
protected

The displacement variables.

Definition at line 63 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

◆ _displaced_problem

MooseSharedPointer<DisplacedProblem> ElementJacobianDamper::_displaced_problem
protected

The displaced problem.

Definition at line 57 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().

◆ _fe_problem

FEProblemBase& ElementJacobianDamper::_fe_problem
protected

The FE problem.

Definition at line 54 of file ElementJacobianDamper.h.

◆ _JxW

const MooseArray<Real>& ElementJacobianDamper::_JxW
protected

Transformed Jacobian weights.

Definition at line 51 of file ElementJacobianDamper.h.

Referenced by computeDamping().

◆ _max_jacobian_diff

const Real ElementJacobianDamper::_max_jacobian_diff
protected

Maximum allowed relative increment in Jacobian.

Definition at line 72 of file ElementJacobianDamper.h.

Referenced by computeDamping().

◆ _mesh

MooseMesh* ElementJacobianDamper::_mesh
protected

The displaced mesh.

Definition at line 60 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

◆ _ndisp

unsigned int ElementJacobianDamper::_ndisp
protected

The number of displacement variables.

Definition at line 66 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

◆ _qrule

QBase*& ElementJacobianDamper::_qrule
protected

Quadrature rule.

Definition at line 48 of file ElementJacobianDamper.h.

Referenced by computeDamping().

◆ _tid

THREAD_ID ElementJacobianDamper::_tid
protected

Thread ID.

Definition at line 44 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().


The documentation for this class was generated from the following files: