https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RANFSTieNode.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 "RANFSTieNode.h"
11#include "PenetrationLocator.h"
12#include "PenetrationInfo.h"
13#include "SystemBase.h"
14#include "Assembly.h"
15#include "NearestNodeLocator.h"
16
17#include "libmesh/numeric_vector.h"
18#include "libmesh/sparse_matrix.h"
19
21
24{
26 params.set<bool>("use_displaced_mesh") = true;
27
28 MooseEnum component("x=0 y=1 z=2");
30 "component", component, "The force component constraint that this object is supplying");
32 "displacements",
33 "The displacements appropriate for the simulation geometry and coordinate system");
34 return params;
35}
36
38 : NodeFaceConstraint(parameters),
39 _component(getParam<MooseEnum>("component")),
40 _mesh_dimension(_mesh.dimension()),
41 _residual_copy(_sys.residualGhosted())
42{
43 // modern parameter scheme for displacements
44 for (unsigned int i = 0; i < coupledComponents("displacements"); ++i)
45 {
46 _vars.push_back(coupled("displacements", i));
47 _var_objects.push_back(getVar("displacements", i));
48 }
49
50 if (_vars.size() != _mesh_dimension)
51 mooseError("The number of displacement variables does not match the mesh dimension!");
52}
53
54void
59
60bool
65
66bool
68{
69 auto & nearest_node_loc = _penetration_locator._nearest_node;
70 _nearest_node = nearest_node_loc.nearestNode(_current_node->id());
71 if (_nearest_node)
72 {
73 auto secondary_dof_number = _current_node->dof_number(0, _vars[_component], 0);
74 // We overwrite the secondary residual so we cannot use the residual
75 // copy for determining the Lagrange multiplier when computing the Jacobian
77 _node_to_lm.insert(std::make_pair(_current_node->id(),
78 _residual_copy(secondary_dof_number) /
79 _var_objects[_component]->scalingFactor()));
80 else
81 {
82 std::vector<dof_id_type> primary_cols;
83 std::vector<Number> primary_values;
84
85 _jacobian->get_row(secondary_dof_number, primary_cols, primary_values);
86 mooseAssert(primary_cols.size() == primary_values.size(),
87 "The size of the dof container and value container are different");
88
90
91 for (MooseIndex(primary_cols) i = 0; i < primary_cols.size(); ++i)
93 std::make_pair(primary_cols[i], primary_values[i] / _var.scalingFactor()));
94 }
95
96 mooseAssert(_node_to_lm.find(_current_node->id()) != _node_to_lm.end(),
97 "The node " << _current_node->id() << " should map to a lagrange multiplier");
99
102 "nearest node not a node on the current primary element");
103
104 return true;
105 }
106
107 return false;
108}
109
110Real
112{
113 switch (type)
114 {
115 case Moose::ConstraintType::Secondary:
117
118 case Moose::ConstraintType::Primary:
119 {
120 if (_i == _primary_index)
122
123 else
124 return 0;
125 }
126
127 default:
128 return 0;
129 }
130}
131
132Real
134{
135 switch (type)
136 {
137 case Moose::ConstraintJacobianType::SecondarySecondary:
138 return _phi_secondary[_j][_qp];
139
140 case Moose::ConstraintJacobianType::SecondaryPrimary:
141 if (_primary_index == _j)
142 return -1;
143 else
144 return 0;
145
146 case Moose::ConstraintJacobianType::PrimarySecondary:
147 if (_i == _primary_index)
148 {
151 "The connected dof index is not found in the _dof_number_to_value container. "
152 "This must mean that insufficient sparsity was allocated");
154 }
155 else
156 return 0;
157
158 default:
159 return 0;
160 }
161}
162
163void
165{
166}
167
168Real
170{
172 "We overrode commputeSecondaryValue so computeQpSecondaryValue should never get called");
173}
registerMooseObject("ContactTestApp", RANFSTieNode)
unsigned int _qp
unsigned int _j
unsigned int _i
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
unsigned int coupledComponents(const std::string &var_name) const
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const std::string & type() const
void mooseError(Args &&... args) const
void scalingFactor(const std::vector< Real > &factor)
const Node * nearestNode(dof_id_type node_id)
PenetrationLocator & _penetration_locator
const Node *const & _current_node
const Elem *const & _current_primary
std::vector< dof_id_type > _connected_dof_indices
const SparseMatrix< Number > * _jacobian
static InputParameters validParams()
MooseVariable & _var
VariablePhiValue _phi_secondary
NearestNodeLocator & _nearest_node
const MooseEnum _component
std::vector< MooseVariable * > _var_objects
NumericVector< Number > & _residual_copy
const Node * _nearest_node
void computeSecondaryValue(NumericVector< Number > &solution) override
dof_id_type _primary_index
std::vector< unsigned int > _vars
std::unordered_map< dof_id_type, Real > _node_to_lm
virtual Real computeQpSecondaryValue() override
bool shouldApply() override
void residualSetup() override
static InputParameters validParams()
RANFSTieNode(const InputParameters &parameters)
Real _lagrange_multiplier
std::unordered_map< dof_id_type, Number > _dof_number_to_value
bool overwriteSecondaryResidual() override
const unsigned int _mesh_dimension
virtual Real computeQpResidual(Moose::ConstraintType type) override
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) override
SubProblem & _subproblem
const bool & currentlyComputingJacobian() const
virtual void get_row(numeric_index_type i, std::vector< numeric_index_type > &indices, std::vector< T > &values) const=0
ConstraintType
ConstraintJacobianType
const unsigned int invalid_uint