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 34 of file ElementJacobianDamper.h.

Constructor & Destructor Documentation

ElementJacobianDamper::ElementJacobianDamper ( const InputParameters &  parameters)

Definition at line 39 of file ElementJacobianDamper.C.

40  : GeneralDamper(parameters),
41  _tid(parameters.get<THREAD_ID>("_tid")),
42  _assembly(_subproblem.assembly(_tid)),
43  _qrule(_assembly.qRule()),
44  _JxW(_assembly.JxW()),
45  _fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
46  _displaced_problem(_fe_problem.getDisplacedProblem()),
47  _max_jacobian_diff(parameters.get<Real>("max_increment"))
48 {
49  if (_displaced_problem == NULL)
50  mooseError("ElementJacobianDamper: Must use displaced problem");
51 
52  _mesh = &_displaced_problem->mesh();
53 
54  const std::vector<NonlinearVariableName> & nl_vnames(
55  getParam<std::vector<NonlinearVariableName>>("displacements"));
56  _ndisp = nl_vnames.size();
57 
58  for (unsigned int i = 0; i < _ndisp; ++i)
59  {
60  _disp_var.push_back(&_sys.getVariable(_tid, nl_vnames[i]));
61  _disp_incr.push_back(_disp_var.back()->increment());
62  }
63 }
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

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

Computes this Damper's damping.

Definition at line 71 of file ElementJacobianDamper.C.

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

Definition at line 66 of file ElementJacobianDamper.C.

67 {
68 }

Member Data Documentation

Assembly& ElementJacobianDamper::_assembly
protected

Definition at line 50 of file ElementJacobianDamper.h.

Referenced by computeDamping().

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

The current Newton increment in the displacement variables.

Definition at line 74 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().

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

The displacement variables.

Definition at line 68 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

MooseSharedPointer<DisplacedProblem> ElementJacobianDamper::_displaced_problem
protected

The displaced problem.

Definition at line 62 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().

FEProblemBase& ElementJacobianDamper::_fe_problem
protected

The FE problem.

Definition at line 59 of file ElementJacobianDamper.h.

const MooseArray<Real>& ElementJacobianDamper::_JxW
protected

Transformed Jacobian weights.

Definition at line 56 of file ElementJacobianDamper.h.

Referenced by computeDamping().

const Real ElementJacobianDamper::_max_jacobian_diff
protected

Maximum allowed relative increment in Jacobian.

Definition at line 77 of file ElementJacobianDamper.h.

Referenced by computeDamping().

MooseMesh* ElementJacobianDamper::_mesh
protected

The displaced mesh.

Definition at line 65 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

unsigned int ElementJacobianDamper::_ndisp
protected

The number of displacement variables.

Definition at line 71 of file ElementJacobianDamper.h.

Referenced by computeDamping(), and ElementJacobianDamper().

QBase*& ElementJacobianDamper::_qrule
protected

Quadrature rule.

Definition at line 53 of file ElementJacobianDamper.h.

Referenced by computeDamping().

THREAD_ID ElementJacobianDamper::_tid
protected

Thread ID.

Definition at line 49 of file ElementJacobianDamper.h.

Referenced by ElementJacobianDamper().


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