OOFEM 3.0
Loading...
Searching...
No Matches
contactpair.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 "contactpair.h"
37
38namespace oofem {
39
40ContactPair :: ContactPair(std::unique_ptr<ContactPoint> s) : slave(std::move(s)), tractionVector()
41{
42 tractionVector.resize(2);
43}
44
45
46const FloatArray &
47ContactPair :: giveTangentVector(int i) const
48{
49 if(i == 1) {
50 return tangentVector1;
51 } else if(i == 2) {
52 return tangentVector2;
53 } else {
54 OOFEM_ERROR("ContactPair:Wrong number of tangent vector");
55 }
56}
57
58const FloatArray &
59ContactPair :: givePreviousTangentVector(int i) const
60{
61 if(i == 1) {
62 // @todo
63 if (previousTangentVector1.giveSize() == 0) {
64 return tangentVector1;
65 }
67 } else if(i == 2) {
68 // @todo
69 if (previousTangentVector2.giveSize() == 0) {
70 return tangentVector2;
71 }
73 } else {
74 OOFEM_ERROR("ContactPair:Wrong number of tangent vector");
75 }
76}
77
78std::vector<FloatArray>
79ContactPair :: giveTangentVectors() const {
80 std::vector<FloatArray> ret;
81 for (int i = 1; i <= 2; i++) {
82 ret.emplace_back(giveTangentVector(i));
83 }
84 return ret;
85}
86
87std::vector<FloatArray>
88ContactPair :: givePreviousTangentVectors() const {
89 std::vector<FloatArray> ret;
90 for (int i = 1; i <= 2; i++) {
91 ret.emplace_back(givePreviousTangentVector(i));
92 }
93 return ret;
94}
95
96void
97ContactPair :: computeNmatrix(FloatMatrix &answer)
98{
99 FloatMatrix answer_slave, answer_master;
100 this->master->computeNmatrix(answer_master);
101 this->slave->computeNmatrix(answer_slave);
102 answer_master.times(-1);
103 //
104 auto master_ncols = answer_master.giveNumberOfColumns();
105 auto master_nrows = answer_master.giveNumberOfRows();
106 auto slave_ncols = answer_slave.giveNumberOfColumns();
107 //
108 answer.resize(master_nrows, master_ncols+slave_ncols);
109 //
110 answer.setSubMatrix(answer_master, 1, 1);
111 answer.setSubMatrix(answer_slave, 1, master_ncols+1);
112}
113
114
115
116
117
118void
119ContactPair :: compute_dNdxi_matrices(std::vector<FloatMatrix> &dNdxi)
120{
121 FloatMatrix dNs, dNm;
122 auto sd = this->slave->giveSurfaceDimension();
123 FloatMatrix dN(sd+1, 2 * (sd+1));
124 for(int i = 1; i <= master->giveSurfaceDimension(); i++) {
125 dN.zero();
126 master->compute_dNdxi_matrix(dNm, i);
127 slave->compute_dNdxi_matrix(dNs, i);
128 //
129 auto master_ncols = dNm.giveNumberOfColumns();
130 auto master_nrows = dNm.giveNumberOfRows();
131 auto slave_ncols = dNs.giveNumberOfColumns();
132 //
133 dN.resize(master_nrows, slave_ncols + master_ncols);
134 dNm.times(-1.);
135 //
136 dN.setSubMatrix(dNm, 1, 1);
137 //@todo: node-2-surface vs surface-2-surface!?!
138 //dN.setSubMatrix(dNs, 1, master_ncols+1);
139 dNdxi.emplace_back(dN);
140 }
141}
142
143
144
145void
146ContactPair :: computeCurvature(FloatMatrix &G, TimeStep *tStep)
147{
148 this->master->computeCurvature(G, this->normalVector, tStep);
149}
150
151
152
153void
154ContactPair :: initContactPoint()
155{
156 if (referenceContactPointInit == false) {
157 referenceContactPointCoords = slave->giveLocalCoordinates();
158 contactPointCoords = master->giveGlobalCoordinates();
160 }
161}
162
163
164
165
166
167void
168ContactPair :: giveLocationArray(const IntArray &dofs, IntArray &loc, const UnknownNumberingScheme &ns) const
169{
170 IntArray loc_slave;
171 this->master->giveLocationArray(loc, dofs, ns);
172 this->slave->giveLocationArray(loc_slave, dofs, ns);
173 //
174 loc.followedBy(loc_slave);
175
176}
177
178
179void
180ContactPair :: updateYourself(TimeStep *tStep)
181{
182 if(this->giveNormalGap() <= 0 && this->inContact()) {
184 previousContactPointCoords = master->giveGlobalCoordinates();
189 } else {
191 }
192
193
194}
195
196
197
198
199
200void
201ContactPair :: computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
202{
203 FloatArray s_vec;
204 this->master->computeVectorOf(u, tStep, answer);
205 this->slave->computeVectorOf(u, tStep, s_vec);
206 //
207 int offset = answer.giveSize();
208 answer.copySubVector(s_vec,offset+1);
209
210}
211
213ContactPair :: computeContactPointDisplacement() const
214{
215 // @todo
216 if (previousContactPointCoords.giveSize() == 0) {
217 FloatArray ret = master->giveGlobalCoordinates();
218 ret.times(0);
219 return ret;
220 }
221 FloatArray contactPointCoords = master->giveGlobalCoordinates();
223}
224
225AABB
226ContactPair :: computeSlaveAABB()
227{
228 // TODO
229 auto coords = slave->giveGlobalCoordinates();
230 double x = coords.at(1);
231 double y = coords.at(2);
232 double z = coords.at(3);
233 AABB aabb(Vector(x, y, z), Vector(x, y, z));
234 //
235 aabb.min.x -= 0.5;
236 aabb.min.y -= 0.5;
237 aabb.min.z -= 0.5;
238 //
239 aabb.max.x += 0.5;
240 aabb.max.y += 0.5;
241 aabb.max.z += 0.5;
242 //
243 return aabb;
244}
245
246};
247
Axis-aligned bounding box.
Definition aabb.h:65
Vector min
Definition aabb.h:67
Vector max
Definition aabb.h:68
FloatArray tractionVector
Definition contactpair.h:87
FloatArray normalVector
Definition contactpair.h:73
double giveNormalGap()
Returns the current normal gap (signed separation) of the pair.
const FloatArray & givePreviousTangentVector(int i) const
Returns the i-th tangent vector from the previous stored state.
Definition contactpair.C:59
FloatArray tangentVector2
Definition contactpair.h:77
FloatArray previousContactPointCoords
Definition contactpair.h:84
FloatArray previousTangentVector1
Definition contactpair.h:76
FloatArray tangentVector1
Definition contactpair.h:75
bool referenceContactPointInit
Definition contactpair.h:85
FloatArray tempTractionVector
Definition contactpair.h:88
std::unique_ptr< ContactPoint > master
Definition contactpair.h:70
virtual bool inContact()
Returns true if the pair is currently considered in contact.
FloatArray contactPointCoords
Definition contactpair.h:82
FloatArray referenceContactPointCoords
Definition contactpair.h:80
std::unique_ptr< ContactPoint > slave
Definition contactpair.h:71
FloatArray previousTangentVector2
Definition contactpair.h:78
const FloatArray & giveTangentVector(int i) const
Returns the i-th current tangent vector at the contact point.
Definition contactpair.C:47
FloatArray previousNormalVector
Definition contactpair.h:74
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void copySubVector(const FloatArray &src, int si)
Definition floatarray.C:886
void times(double s)
Definition floatarray.C:834
void times(double f)
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
int giveNumberOfColumns() const
Returns number of columns of receiver.
void setSubMatrix(const FloatMatrix &src, int sr, int sc)
void zero()
Zeroes all coefficient of receiver.
int giveNumberOfRows() const
Returns number of rows of receiver.
void followedBy(const IntArray &b, int allocChunk=0)
Definition intarray.C:94
double z
Definition aabb.h:42
double x
Definition aabb.h:42
double y
Definition aabb.h:42
#define OOFEM_ERROR(...)
Definition error.h:79

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