Line data Source code
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 : #pragma once 11 : 12 : // MOOSE includes 13 : #include "NodeFaceConstraint.h" 14 : #include "PenetrationLocator.h" 15 : #include "TwoMaterialPropertyInterface.h" 16 : #include "Coupleable.h" 17 : 18 : // Forward Declarations 19 : enum class ExplicitDynamicsContactModel; 20 : class DisplacedProblem; 21 : 22 : /** 23 : * A ExplicitDynamicsContactConstraint does mechanical contact for explicit dynamics simulations. 24 : */ 25 : class ExplicitDynamicsContactConstraint : public NodeFaceConstraint, 26 : public TwoMaterialPropertyInterface 27 : { 28 : public: 29 : static InputParameters validParams(); 30 : 31 : ExplicitDynamicsContactConstraint(const InputParameters & parameters); 32 : 33 : virtual void timestepSetup() override; 34 15756 : virtual void jacobianSetup() override {} 35 0 : virtual void residualEnd() override {} 36 : 37 : virtual void updateContactStatefulData(bool beginning_of_step); 38 : virtual Real computeQpSecondaryValue() override; 39 : virtual Real computeQpResidual(Moose::ConstraintType type) override; 40 : 41 : /** 42 : * Computes the jacobian for the current element. 43 : */ 44 0 : virtual void computeJacobian() override {} 45 : 46 : /** 47 : * Compute off-diagonal Jacobian entries 48 : * @param jvar The index of the coupled variable 49 : */ 50 0 : virtual void computeOffDiagJacobian(unsigned int /*jvar*/) override {} 51 : 52 0 : virtual Real computeQpJacobian(Moose::ConstraintJacobianType /*type*/) override { return 0.0; } 53 : 54 : /** 55 : * Compute off-diagonal Jacobian entries 56 : * @param type The type of coupling 57 : * @param jvar The index of the coupled variable 58 : */ 59 0 : virtual Real computeQpOffDiagJacobian(Moose::ConstraintJacobianType /*type*/, 60 : unsigned int /*jvar*/) override 61 : { 62 0 : return 0.0; 63 : } 64 : 65 : bool shouldApply() override; 66 : void computeContactForce(const Node & node, PenetrationInfo * pinfo, bool update_contact_set); 67 675264 : virtual bool isExplicitConstraint() const override { return true; } 68 : /** 69 : * Return false so that the nonlinear system does not try to add Jacobian entries 70 : * from the contact forces. 71 : * @return bool indicating whether we need to couple Jacobian entries 72 : */ 73 270 : virtual bool addCouplingEntriesToJacobian() override { return false; } 74 : 75 : virtual const std::unordered_set<unsigned int> & getMatPropDependencies() const override; 76 : 77 337632 : virtual void overwriteBoundaryVariables(NumericVector<Number> &, const Node &) const override 78 : { 79 337632 : return; 80 : }; 81 : 82 : protected: 83 : /** 84 : * Determine "Lagrange multipliers" from the iterative solution of the impact problem. 85 : * @param node The number of the variable to be checked 86 : * @param pinfo The component index computed in this routine 87 : * @param distance_gap The gap distance at the constraint node 88 : */ 89 : void solveImpactEquations(const Node & node, 90 : PenetrationInfo * pinfo, 91 : const RealVectorValue & distance_gap); 92 : 93 : MooseSharedPointer<DisplacedProblem> _displaced_problem; 94 : Real gapOffset(const Node & node); 95 : Real getPenalty(const Node & node); 96 : 97 : const unsigned int _component; 98 : const ExplicitDynamicsContactModel _model; 99 : 100 : bool _update_stateful_data; 101 : 102 : const unsigned int _mesh_dimension; 103 : 104 : std::vector<unsigned int> _vars; 105 : std::vector<MooseVariable *> _var_objects; 106 : 107 : const bool _has_secondary_gap_offset; 108 : const MooseVariable * const _secondary_gap_offset_var; 109 : const bool _has_mapped_primary_gap_offset; 110 : const MooseVariable * const _mapped_primary_gap_offset_var; 111 : 112 : const Real _penalty; 113 : 114 : const bool _print_contact_nodes; 115 : 116 : const static unsigned int _no_iterations; 117 : 118 : NumericVector<Number> & _residual_copy; 119 : 120 : /// Nodal gap rate (output for debugging or analyst perusal) 121 : MooseWritableVariable * _gap_rate; 122 : 123 : /// X component of velocity at the closest point 124 : const VariableValue & _neighbor_vel_x; 125 : /// Y component of velocity at the closest point 126 : const VariableValue & _neighbor_vel_y; 127 : /// Z component of velocity at the closest point 128 : const VariableValue & _neighbor_vel_z; 129 : 130 : private: 131 : std::unordered_map<dof_id_type, Real> _dof_to_position; 132 : 133 : /** 134 : * @param lumped_mass The inverted lumped mass vector 135 : * @return Effictive mass of the face 136 : */ 137 : Real computeFaceMass(const NumericVector<Real> & lumped_mass); 138 : }; 139 : 140 : inline const std::unordered_set<unsigned int> & 141 35178 : ExplicitDynamicsContactConstraint::getMatPropDependencies() const 142 : { 143 35178 : return TwoMaterialPropertyInterface::getMatPropDependencies(); 144 : }