OOFEM 3.0
Loading...
Searching...
No Matches
contactbc.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35
36#include "contactbc.h"
37#include "set.h"
38#include "domain.h"
39#include "node.h"
40#include "floatmatrix.h"
41#include "sparsemtrx.h"
42#include "contactpair.h"
43#include "contactsearch.h"
45#include "timestep.h"
46#include "vtkxmlexportmodule.h"
47#include "vtkbaseexportmodule.h"
48
49namespace oofem {
50
51
52void
53ContactBoundaryCondition :: initForNewIteration(TimeStep *tStep, int iter)
54{
55 if(iter % updateEachNthIter == 0) {
56 this->giveContactSearchAlgorithm()->updateContactPairs(tStep);
57 }
58
59}
60
61
62
63
64void
65ContactBoundaryCondition :: assemble(SparseMtrx &answer, TimeStep *tStep, CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s, double scale, void *lock)
66{
67 if ( type != TangentStiffnessMatrix ) {
68 return;
69 }
70
72 IntArray loc, node_loc;
73
74 //iterate over all pairs of nodes and segments
75 const auto& contactPairs = getContactPairs();
76 for(auto const &cp : contactPairs) {
77 if(cp->inContact()) {
78 this->computeTangentFromContact(K, cp.get(), tStep);
79 this->giveLocationArray(loc, r_s, cp.get());
81 answer.assemble(loc, K);
82 }
83 }
84 }
85}
86
87
88void
89ContactBoundaryCondition :: assembleVector(FloatArray &answer, TimeStep *tStep, CharType type, ValueModeType mode, const UnknownNumberingScheme &s, FloatArray *eNorms, void *lock)
90{
91 if ( type != InternalForcesVector ) {
92 return;
93 }
94
95
96 IntArray loc;
97 FloatArray fint;
98 //iterate over all pairs of nodes and segments
99 const auto& contactPairs = getContactPairs();
100 for(auto const &cp : contactPairs) {
101 if(cp->inContact()) {
102 this->computeInternalForcesFromContact(fint, cp.get(), tStep);
103 this->giveLocationArray(loc, s, cp.get());
104 if(fint.giveSize()) {
105 answer.assemble(fint, loc);
106 }
107 }
108 }
109}
110
111
112
113
114void
115ContactBoundaryCondition :: assembleExtrapolatedForces(FloatArray &answer, TimeStep *tStep)
116{
117 /* if ( type != TangentStiffnessMatrix ) {
118 return;
119 }
120 */
121 FloatArray fext;
122 FloatMatrix K;
123 IntArray loc;
124
125 //iterate over all pairs of nodes and segments
126 const auto& contactPairs = getContactPairs();
127 for(auto const &cp : contactPairs) {
128 if(cp->inContact()) {
129 this->computeTangentFromContact(K, cp.get(), tStep);
131 //cp->computeVectorOf(VM_Incremental, tStep, delta_u);
132 FloatArray delta_u;
133 cp->computeVectorOf(VM_Total, tStep, delta_u);
134 FloatArray tmp;
135 if ( tStep->isTheFirstStep() ) {
136 tmp = delta_u;
137 tmp.zero();
138 } else {
139 cp->computeVectorOf(VM_Total, tStep->givePreviousStep(), tmp);
140 }
141 delta_u.subtract(tmp);
142 fext.beProductOf(K, delta_u);
144 this->giveLocationArray(loc, dn, cp.get());
145 answer.assemble(fext,loc);
146 }
147 }
148 }
149}
150
151
152
153void
154ContactBoundaryCondition :: giveLocationArray(IntArray &loc, const UnknownNumberingScheme &ns, const ContactPair *cp) const
155{
156 cp->giveLocationArray(dofs, loc, ns);
157}
158
159
160void ContactBoundaryCondition :: postInitialize()
161{
163 this->giveContactSearchAlgorithm()->createContactPairs();
164
165}
166
167
168void ContactBoundaryCondition :: updateYourself(TimeStep *tStep)
169{
170
171 const auto& contactPairs = getContactPairs();
172 for(auto &cp : contactPairs) {
173 cp->updateYourself(tStep);
174 }
175
176}
177
178
179
180void
181ContactBoundaryCondition :: giveExportData(std::vector< ExportRegion > &vtkPieces, FloatArray shift, TimeStep *tStep )
182{
183
184 vtkPieces.resize(1);
185
186 const auto& contactPairs = getContactPairs();
187 int numCells = contactPairs.size();
188 const int numCellNodes = 2; // linear line
189 int nNodes = numCells * numCellNodes;
190 //
191 vtkPieces.at(0).setNumberOfCells(numCells);
192 vtkPieces.at(0).setNumberOfNodes(nNodes);
193 //
194 int val = 1;
195 int offset = 0;
196 IntArray nodes(numCellNodes);
197 int nodeNum = 1;
198 int iElement = 1;
199 FloatArray nodeCoords(3);
200 IntArray connectivity(2);
201 for(auto const &cp : contactPairs) {
202 if(cp->inContact()) {
203 nodeCoords = cp->giveMasterContactPoint()->giveGlobalCoordinates();
204 if(shift.giveSize()){
205 nodeCoords.add(shift);
206 }
207 vtkPieces.at(0).setNodeCoords(nodeNum, nodeCoords);
208 connectivity.at(1) = val++;
209 nodeNum++;
210 nodeCoords = cp->giveSlaveContactPoint()->giveGlobalCoordinates();
211 if(shift.giveSize()){
212 nodeCoords.add(-1.*shift);
213 }
214 vtkPieces.at(0).setNodeCoords(nodeNum, nodeCoords);
215 connectivity.at(2) = val++;
216 nodeNum++;
217
218 vtkPieces.at(0).setConnectivity(iElement, connectivity);
219 offset += 2;
220 vtkPieces.at(0).setOffset(iElement, offset);
221 vtkPieces.at(0).setCellType(iElement, 3);
222 iElement++;
223 } else {
224 numCells--;
225 nNodes -= 2;
226 vtkPieces.at(0).setNumberOfCells(numCells);
227 vtkPieces.at(0).setNumberOfNodes(nNodes);
228 }
229 }
230}
231
232
233
234
235
236
237
238} // namespace oofem
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
void giveLocationArray(IntArray &loc, const UnknownNumberingScheme &ns, const ContactPair *cp) const
Builds a location array for a given contact pair and numbering scheme.
Definition contactbc.C:154
virtual void computeInternalForcesFromContact(FloatArray &answer, ContactPair *cp, TimeStep *tStep)=0
Computes internal force contribution for one contact pair (pure virtual).
virtual void computeTangentFromContact(FloatMatrix &answer, ContactPair *cp, TimeStep *tStep)=0
Computes a consistent tangent contribution for one contact pair (pure virtual).
virtual ContactSearchAlgorithm * giveContactSearchAlgorithm()
Returns the configured contact search algorithm.
Definition contactbc.h:197
std::vector< std::unique_ptr< ContactPair > > & getContactPairs()
Returns the current list of detected contact pairs (modifiable).
Definition contactbc.h:99
virtual void setupContactSearchAlgorithm()=0
Creates and configures the contact search algorithm (pure virtual).
Represents a contact interaction between a master and a slave contact point.
Definition contactpair.h:68
void giveLocationArray(const IntArray &dofs, IntArray &loc, const UnknownNumberingScheme &ns) const
Builds a location array for the pair based on selected DOFs.
void assemble(const FloatArray &fe, const IntArray &loc)
Definition floatarray.C:616
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
void add(const FloatArray &src)
Definition floatarray.C:218
void subtract(const FloatArray &src)
Definition floatarray.C:320
int giveNumberOfColumns() const
Returns number of columns of receiver.
int giveNumberOfRows() const
Returns number of rows of receiver.
IntArray dofs
Dofs that b.c. is applied to (relevant for Dirichlet type b.c.s).
int & at(std::size_t i)
Definition intarray.h:104
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)=0
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
Definition timestep.C:132
bool isTheFirstStep()
Definition timestep.C:148

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011