MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
point_contact.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/point_contact.cc,v 1.13 2017/01/12 14:46:43 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <iostream>
35 #include <cfloat>
36 
37 #include "dataman.h"
38 #include "loadable.h"
39 #include "point_contact.h"
40 
41 /* Contatto punto - superficie */
42 
43 /* STRUTTURA NEL FILE
44 joint: id contatto, point_contact,
45 id nodo 1, id nodo ground, posizione ground, direzione ground
46 */
47 
48 
49 /* Costruttore non banale */
51  const DofOwner* pDO,
52  const StructNode* pN1,
53  const StructNode* pNs,
54  const Vec3& SDir, const doublereal Ek,
55  flag fOut)
56 : Elem(uL,fOut),
57 Joint(uL, pDO, fOut), pNode1(pN1), pSup(pNs), SupDirection(SDir) // assegnamento campi
58 {
59  ASSERT(pNode1 != NULL); // esecuzione solo se i nodi sono assegnati e se sono strutturali
60  ASSERT(pSup != NULL);
61 
64 
65  ElasticStiffness = Ek;
66 }
67 
68 /* Distruttore banale*/
70 {
71  NO_OP;
72 }
73 
74 /* Contributo al file di restart */
75 std::ostream&
76 PointSurfaceContact::Restart(std::ostream& out) const
77 {
78  //Joint::Restart(out) << pNode1->GetLabel() << ", "
79  // << pSup->GetLabel() << std::endl;
80  return out << " not implemented yet: " << std::endl;
81 
82  //return out;
83 }
84 
86 {
87 
88 }
89 
90 
91 /* Assemblaggio residuo */
94  doublereal dCoef,
95  const VectorHandler& XCurr,
96  const VectorHandler& XPrimeCurr)
97 {
98 
99  /* Dimensiona e resetta la matrice di lavoro */
100  integer iNumRows = 0;
101  integer iNumCols = 0;
102  WorkSpaceDim(&iNumRows, &iNumCols);
103  WorkVec.ResizeReset(iNumRows);
104 
105  /* Recupera gli indici globali */
106  integer iNodePFirstMomIndex = pNode1->iGetFirstMomentumIndex();
107  integer iNodeSupFirstMomIndex = pSup->iGetFirstMomentumIndex();
108 
109  /* Setta gli indici della matrice */
110  for (int iCnt = 1; iCnt <=3; iCnt++) {
111  WorkVec.PutRowIndex(iCnt, iNodePFirstMomIndex + iCnt);
112  WorkVec.PutRowIndex(iCnt+3, iNodeSupFirstMomIndex + iCnt);
113  WorkVec.PutRowIndex(iCnt+6, iNodeSupFirstMomIndex + iCnt+3);
114  }
115 
116  /* Costruisco WorkVec in AssVec */
117  AssVec(WorkVec, dCoef);
118 
119  return WorkVec;
120 }
121 /* Costruzione matrice locale */
123 {
124  /* Orientazione del terreno nel sistema assoluto */
125  //Vec3
127 
128  /* Distanza punto-superficie (piano infinito) */
129  Vec3 x = - pSup->GetXCurr() + pNode1->GetXCurr(); // attenzione: VERIFICARE SE TIENE
130  // CONTO DI EVENTUALI DIFFERENZE
131  // DI SISTEMI DI RIFERIMENTO
132 
133  /* Distanza normale */
134  dDeltaL = x.Dot(n);
135 
136  //Vec3
137  Farm = x - n*dDeltaL; // braccio momento di trasporto
138 
139  /* se dDeltaL>0 c'รจ contatto */
140  if (dDeltaL < 0)
141  {
142  /* Forze e momenti scambiati */
144  FSup = -FNode1;
145  MSup = Farm.Cross(FSup);
146  }
147  else {
148  FNode1 = n*0;
149  FSup = n*0;
150  MSup = n*0;
151  };
152 
153  /* Costruzione vettore assemblato */
154  WorkVec.Add(1, FNode1);
155  WorkVec.Add(3+1, FSup);
156  WorkVec.Add(6+1, MSup);
157 
158  }
159 
160  /*Assemblaggio Jacobiano*/
163  doublereal dCoef,
164  const VectorHandler& /* XCurr */ ,
165  const VectorHandler& /* XPrimeCurr */ )
166 {
167  DEBUGCOUT("Entering PointSurfaceContact::AssJac()" << std::endl);
168 
169  if (dDeltaL < 0)
170  {
171  FullSubMatrixHandler& WM = WorkMat.SetFull();
172 
173  /* Dimensiona e resetta la matrice di lavoro */
174  integer iNumRows = 0;
175  integer iNumCols = 0;
176  WorkSpaceDim(&iNumRows, &iNumCols);
177  WM.ResizeReset(iNumRows, iNumCols);
178 
179  /* Recupera gli indici */
180  integer iNode1FirstPosIndex = pNode1->iGetFirstPositionIndex();
181  integer iNode1FirstMomIndex = pNode1->iGetFirstMomentumIndex();
182  integer iSupFirstPosIndex = pSup->iGetFirstPositionIndex();
183  integer iSupFirstMomIndex = pSup->iGetFirstMomentumIndex();
184 
185  /* Setta gli indici della matrice */
186  for (int iCnt = 1; iCnt <= 3; iCnt++) {
187  WM.PutRowIndex(iCnt, iNode1FirstMomIndex + iCnt);
188  WM.PutColIndex(iCnt, iNode1FirstPosIndex + iCnt);
189  WM.PutRowIndex(3 + iCnt, iSupFirstMomIndex + iCnt);
190  WM.PutColIndex(3 + iCnt, iSupFirstPosIndex + iCnt);
191  WM.PutRowIndex(6 + iCnt, iSupFirstMomIndex + iCnt + 3);
192  WM.PutColIndex(6 + iCnt, iSupFirstPosIndex + iCnt + 3);
193  }
194 
195  AssMat(WM, dCoef);
196  }
197  else
198  WorkMat.SetNullMatrix();
199 
200  return WorkMat;
201 
202 }
203 
204 
205 void
207 {
208  Mat3x3 MTmp = n.Tens(n*(-dCoef*ElasticStiffness));
209 
210  WM.Add(1, 1, MTmp);
211  WM.Sub(1, 3 + 1, MTmp);
212  WM.Sub(3 + 1, 1, MTmp);
213  WM.Add(3 + 1, 3 + 1, MTmp);
214 
215  Vec3 dFnode1_1 = -n*ElasticStiffness*n[0];
216  Vec3 dFnode1_2 = -n*ElasticStiffness*n[1];
217  Vec3 dFnode1_3 = -n*ElasticStiffness*n[2];
218 
219  // forza sul nodo pNode1
220  WM.Add(1,1,dFnode1_1);
221  WM.Add(1,2,dFnode1_2);
222  WM.Add(1,3,dFnode1_3);
223 
224  WM.Sub(1,4,dFnode1_1);
225  WM.Sub(1,5,dFnode1_2);
226  WM.Sub(1,6,dFnode1_3);
227 
228  // forza sulla superficie
229  WM.Sub(3+1,1,dFnode1_1);
230  WM.Sub(3+1,2,dFnode1_2);
231  WM.Sub(3+1,3,dFnode1_3);
232 
233  WM.Add(3+1,4,dFnode1_1);
234  WM.Add(3+1,5,dFnode1_2);
235  WM.Add(3+1,6,dFnode1_3);
236 
237  // momento sulla superficie
238  Vec3 dFarm_1 = n;//(1.,0.,0.,);//-n*n[1];
239  Vec3 dFarm_2 = n;//(0.,1.,0.,);//-n*n[2];
240  Vec3 dFarm_3 = n;//(0.,0.,1.,);//-n*n[3];
241 
242  WM.Add(6+1,1,dFarm_1.Cross(FSup)+Farm.Cross(-dFnode1_1));
243  WM.Add(6+1,2,dFarm_2.Cross(FSup)+Farm.Cross(-dFnode1_2));
244  WM.Add(6+1,3,dFarm_3.Cross(FSup)+Farm.Cross(-dFnode1_3));
245 
246  WM.Sub(6+1,4,dFarm_1.Cross(FSup)+Farm.Cross(-dFnode1_1));
247  WM.Sub(6+1,5,dFarm_2.Cross(FSup)+Farm.Cross(-dFnode1_2));
248  WM.Sub(6+1,6,dFarm_3.Cross(FSup)+Farm.Cross(-dFnode1_3));
249 
250 
251  }
252 
253 
254  /* Contributo al residuo durante l'assemblaggio iniziale */
257  const VectorHandler& XCurr)
258 {
259  DEBUGCOUT("Entering PointSurfaceContact::InitialAssRes()" << std::endl);
260 
261  /* Dimensiona e resetta la matrice di lavoro */
262  integer iNumRows = 0;
263  integer iNumCols = 0;
264  WorkSpaceDim(&iNumRows, &iNumCols);
265  WorkVec.ResizeReset(iNumRows);
266 
267  /* Recupera gli indici globali */
268  integer iNodePFirstMomIndex = pNode1->iGetFirstMomentumIndex();
269  integer iNodeSupFirstMomIndex = pSup->iGetFirstMomentumIndex();
270 
271  /* Setta gli indici della matrice */
272  for (int iCnt = 1; iCnt <=3; iCnt++) {
273  WorkVec.PutRowIndex(iCnt, iNodePFirstMomIndex + iCnt);
274  WorkVec.PutRowIndex(iCnt+3, iNodeSupFirstMomIndex + iCnt);
275  WorkVec.PutRowIndex(iCnt+6, iNodeSupFirstMomIndex + iCnt+3);
276  }
277 
278  /* Costruisco WorkVec in AssVec */
279  AssVec(WorkVec, 1);
280 
281  return WorkVec;
282 }
283 
284 /* Contributo allo jacobiano durante l'assemblaggio iniziale */
287  const VectorHandler& XCurr)
288 {
289  DEBUGCOUT("Entering PointSurfaceContact::Initial AssJac()" << std::endl);
290 
291  if (dDeltaL < 0)
292  {
293  FullSubMatrixHandler& WM = WorkMat.SetFull();
294 
295  /* Dimensiona e resetta la matrice di lavoro */
296  integer iNumRows = 0;
297  integer iNumCols = 0;
298  WorkSpaceDim(&iNumRows, &iNumCols);
299  WM.ResizeReset(iNumRows, iNumCols);
300 
301  /* Recupera gli indici */
302  integer iNode1FirstPosIndex = pNode1->iGetFirstPositionIndex();
303  integer iNode1FirstMomIndex = pNode1->iGetFirstMomentumIndex();
304  integer iSupFirstPosIndex = pSup->iGetFirstPositionIndex();
305  integer iSupFirstMomIndex = pSup->iGetFirstMomentumIndex();
306 
307  /* Setta gli indici della matrice */
308  for (int iCnt = 1; iCnt <= 3; iCnt++) {
309  WM.PutRowIndex(iCnt, iNode1FirstMomIndex + iCnt);
310  WM.PutColIndex(iCnt, iNode1FirstPosIndex + iCnt);
311  WM.PutRowIndex(3 + iCnt, iSupFirstMomIndex + iCnt);
312  WM.PutColIndex(3 + iCnt, iSupFirstPosIndex + iCnt);
313  WM.PutRowIndex(6 + iCnt, iSupFirstMomIndex + iCnt + 3);
314  WM.PutColIndex(6 + iCnt, iSupFirstPosIndex + iCnt + 3);
315  }
316 
317  AssMat(WM, 1);
318 
319  }
320  else
321  WorkMat.SetNullMatrix();
322 
323  return WorkMat;
324 
325 }
void PutColIndex(integer iSubCol, integer iCol)
Definition: submat.h:325
virtual VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
long int flag
Definition: mbdyn.h:43
Definition: matvec3.h:98
virtual void ResizeReset(integer)
Definition: vh.cc:55
FullSubMatrixHandler & SetFull(void)
Definition: submat.h:1168
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
virtual Node::Type GetNodeType(void) const
Definition: strnode.cc:145
doublereal Dot(const Vec3 &v) const
Definition: matvec3.h:243
void Add(integer iRow, integer iCol, const Vec3 &v)
Definition: submat.cc:209
virtual SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
#define NO_OP
Definition: myassert.h:74
void AssVec(SubVectorHandler &WorkVec, doublereal dCoef)
const StructNode * pSup
Definition: point_contact.h:50
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
const StructNode * pNode1
Definition: point_contact.h:47
void SetNullMatrix(void)
Definition: submat.h:1159
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual integer iGetFirstMomentumIndex(void) const =0
virtual integer iGetFirstPositionIndex(void) const
Definition: strnode.h:452
#define ASSERT(expression)
Definition: colamd.c:977
Mat3x3 Tens(const Vec3 &v) const
Definition: matvec3.cc:53
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual void Add(integer iRow, const Vec3 &v)
Definition: vh.cc:63
virtual void ResizeReset(integer, integer)
Definition: submat.cc:182
doublereal ElasticStiffness
Definition: point_contact.h:59
Definition: elem.h:75
void PutRowIndex(integer iSubRow, integer iRow)
Definition: submat.h:311
virtual std::ostream & Restart(std::ostream &out) const
PointSurfaceContact(unsigned int uL, const DofOwner *pDO, const StructNode *pN1, const StructNode *pNs, const Vec3 &SDir, const doublereal Ek, flag fOut)
void Sub(integer iRow, integer iCol, const Vec3 &v)
Definition: submat.cc:215
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
virtual ~PointSurfaceContact(void)
Definition: joint.h:50
void AssMat(FullSubMatrixHandler &WM, doublereal dCoef)
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual void Output(OutputHandler &OH) const
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const