www.mooseframework.org
OneDContactConstraint.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 // MOOSE includes
11 #include "MooseVariable.h"
12 #include "SystemBase.h"
13 #include "PenetrationLocator.h"
14 
15 #include "libmesh/string_to_enum.h"
16 #include "libmesh/sparse_matrix.h"
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<NodeFaceConstraint>();
23  params.set<bool>("use_displaced_mesh") = true;
24  params.addParam<bool>("jacobian_update",
25  false,
26  "Whether or not to update the 'in contact' list "
27  "every jacobian evaluation (by default it will "
28  "happen once per timestep");
29  return params;
30 }
31 
32 OneDContactConstraint::OneDContactConstraint(const InputParameters & parameters)
33  : NodeFaceConstraint(parameters),
34  _residual_copy(_sys.residualGhosted()),
35  _jacobian_update(getParam<bool>("jacobian_update"))
36 {
37 }
38 
39 void
41 {
43 }
44 
45 void
47 {
48  if (_jacobian_update)
50 }
51 
52 void
54 {
55  std::set<dof_id_type> & has_penetrated = _penetration_locator._has_penetrated;
56 
57  std::map<dof_id_type, PenetrationInfo *>::iterator
58  it = _penetration_locator._penetration_info.begin(),
59  end = _penetration_locator._penetration_info.end();
60 
61  for (; it != end; ++it)
62  {
63  PenetrationInfo * pinfo = it->second;
64 
65  // Skip this pinfo if there are no DOFs on this node.
66  if (!pinfo || pinfo->_node->n_comp(_sys.number(), _var.number()) < 1)
67  continue;
68 
69  if (pinfo->_distance > 0)
70  {
71  dof_id_type slave_node_num = it->first;
72  has_penetrated.insert(slave_node_num);
73  }
74  }
75 }
76 
77 bool
79 {
80  std::set<dof_id_type>::iterator hpit =
81  _penetration_locator._has_penetrated.find(_current_node->id());
82  return (hpit != _penetration_locator._has_penetrated.end());
83 }
84 
85 Real
87 {
88  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
89  Moose::err << std::endl
90  << "Popping out node: " << _current_node->id() << std::endl
91  << "Closest Point x: " << pinfo->_closest_point(0) << std::endl
92  << "Current Node x: " << (*_current_node)(0) << std::endl
93  << "Current Value: " << _u_slave[_qp] << std::endl
94  << std::endl;
95 
96  return pinfo->_closest_point(0) - ((*_current_node)(0) - _u_slave[_qp]);
97 }
98 
99 Real
100 OneDContactConstraint::computeQpResidual(Moose::ConstraintType type)
101 {
102  PenetrationInfo * pinfo = _penetration_locator._penetration_info[_current_node->id()];
103 
104  switch (type)
105  {
106  case Moose::Slave:
107  // return (_u_slave[_qp] - _u_master[_qp])*_test_slave[_i][_qp];
108  return ((*_current_node)(0) - pinfo->_closest_point(0)) * _test_slave[_i][_qp];
109  case Moose::Master:
110  double slave_resid = _residual_copy(_current_node->dof_number(0, _var.number(), 0));
111  return slave_resid * _test_master[_i][_qp];
112  }
113  return 0;
114 }
115 
116 Real
117 OneDContactConstraint::computeQpJacobian(Moose::ConstraintJacobianType type)
118 {
119  double slave_jac = 0;
120  switch (type)
121  {
122  case Moose::SlaveSlave:
123  return _phi_slave[_j][_qp] * _test_slave[_i][_qp];
124  case Moose::SlaveMaster:
125  return -_phi_master[_j][_qp] * _test_slave[_i][_qp];
126  case Moose::MasterSlave:
127  slave_jac =
128  (*_jacobian)(_current_node->dof_number(0, _var.number(), 0), _connected_dof_indices[_j]);
129  return slave_jac * _test_master[_i][_qp];
130  case Moose::MasterMaster:
131  return 0;
132  }
133  return 0;
134 }
virtual Real computeQpSlaveValue()
virtual Real computeQpResidual(Moose::ConstraintType type)
NumericVector< Number > & _residual_copy
OneDContactConstraint(const InputParameters &parameters)
InputParameters validParams< OneDContactConstraint >()
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type)