MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
contactj.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/contactj.h,v 1.32 2017/01/12 14:46:09 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 /* Vincolo di contatto con un piano */
33 
34 #ifndef CONTACTJ_H
35 #define CONTACTJ_H
36 
37 #include <limits>
38 
39 #include "joint.h"
40 
41 /* ContactJoint - begin */
42 
43 class ContactJoint : virtual public Elem, public Joint {
44  private:
50 
51  public:
52  /* Costruttore non banale */
53  ContactJoint(unsigned int uL, const DofOwner* pDO,
54  const StructNode* pN1, const StructNode* pN2,
55  const Vec3& n, flag fOut)
56  : Elem(uL, fOut),
57  Joint(uL, pDO, fOut),
58  pNode1(pN1), pNode2(pN2),
59  n(n), dD(0.), dF(0.) {
60  ASSERT(pNode1 != NULL);
62  ASSERT(pNode2 != NULL);
64  ASSERT(n.Dot() > std::numeric_limits<doublereal>::epsilon());
65 
67  Vec3 N(pNode1->GetRCurr()*n);
68  dD = N.Dot(D);
69  };
70 
71  ~ContactJoint(void) {
72  NO_OP;
73  };
74 
75  /* Tipo di Joint */
76  virtual Joint::Type GetJointType(void) const {
77  return Joint::INPLANECONTACT;
78  };
79 
80  /* Contributo al file di restart */
81  virtual ostream& Restart(ostream& out) const {
82  return out << "ContactJoint: not implemented yet" << endl;
83  };
84 
85  virtual unsigned int iGetNumDof(void) const {
86  return 1;
87  };
88 
89  virtual DofOrder::Order GetDofType(unsigned int i) const {
90  ASSERT(i == 0);
91  return DofOrder::ALGEBRAIC;
92  };
93 
94  virtual void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const {
95  *piNumRows = 7;
96  *piNumCols = 10;
97  };
98 
100  doublereal dCoef,
101  const VectorHandler& XCurr,
102  const VectorHandler& XPrimeCurr) {
103  SparseSubMatrixHandler& WM = WorkMat.SetSparse();
104 
105  integer iIndex = iGetFirstIndex()+1;
106 
109  Vec3 N(pNode1->GetRCurr()*n);
110  dD = N.Dot(D);
111  doublereal dV = N.Dot(V);
112 
113  dF = XCurr(iIndex);
114 
115  if (dD > 0.
116  || (dD == 0. && dF >= 0.)
117  || (dD == 0. && dF == 0. && dV > 0.)) {
118  /* non attivo */
119  WM.Resize(1, 0);
120  WM.PutItem(1, iIndex, iIndex, 1.);
121  } else {
122  /* attivo */
123  WM.Resize(27, 0);
124 
125  integer iNode1RowIndex = pNode1->iGetFirstMomentumIndex();
126  integer iNode1ColIndex = pNode1->iGetFirstPositionIndex();
127  integer iNode2RowIndex = pNode2->iGetFirstMomentumIndex();
128  integer iNode2ColIndex = pNode2->iGetFirstPositionIndex();
129 
130  Vec3 Tmp(N.Cross(D));
131  for (integer i = 1; i <= 3; i++) {
132  WM.PutItem(i, iIndex, iNode1ColIndex+3+i, Tmp.dGet(i));
133  doublereal d = N.dGet(i);
134  WM.PutItem(9+i, iNode1RowIndex+i, iIndex, -d);
135  WM.PutItem(12+i, iNode2RowIndex+i, iIndex, d);
136  WM.PutItem(3+i, iIndex, iNode1ColIndex+i, -d);
137  WM.PutItem(6+i, iIndex, iNode2ColIndex+i, d);
138  }
139 
140  Tmp = N*(dF*dCoef);
141  WM.PutCross(16, iNode1RowIndex+4, iNode1ColIndex+4, Tmp);
142  WM.PutCross(22, iNode2RowIndex+4, iNode1ColIndex+4, -Tmp);
143  }
144  return WorkMat;
145  };
146 
148  doublereal dCoef,
149  const VectorHandler& XCurr,
150  const VectorHandler& XPrimeCurr) {
151  integer iIndex = iGetFirstIndex()+1;
152 
155  Vec3 N(pNode1->GetRCurr()*n);
156  dD = N.Dot(D);
157  doublereal dV = N.Dot(V);
158 
159  dF = XCurr(iIndex);
160 
161  if (dD > 0.
162  || (dD == 0. && dF >= 0.)
163  || (dD == 0. && dF == 0. && dV > 0.)) {
164  /* non attivo */
165  WorkVec.Resize(1);
166  WorkVec.PutItem(1, iIndex, -dF);
167  } else {
168  /* attivo */
169  WorkVec.Resize(7);
170 
171  integer iNode1RowIndex = pNode1->iGetFirstMomentumIndex();
172  integer iNode2RowIndex = pNode2->iGetFirstMomentumIndex();
173 
174  Vec3 Tmp(N*dF);
175  for (integer i = 1; i <= 3; i++) {
176  doublereal d = Tmp.dGet(i);
177  WorkVec.PutItem(i, iNode1RowIndex+i, d);
178  WorkVec.PutItem(3+i, iNode2RowIndex+i, -d);
179  }
180  WorkVec.PutItem(7, iIndex, -dD/dCoef);
181  }
182 
183  return WorkVec;
184  };
185 
186  virtual void Output(OutputHandler& OH) const {
187  Vec3 F(pNode1->GetRCurr()*(n*dF));
188  Joint::Output(OH.Joints(), "Contact", GetLabel(),
189  Vec3(dF, 0., 0.), Zero3, F, Zero3)
190  << " " << dD << endl;
191  };
192 
193 
194  /* funzioni usate nell'assemblaggio iniziale */
195 
196  virtual unsigned int iGetInitialNumDof(void) const {
197  return 2;
198  };
199  virtual void InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const {
200  *piNumRows = 14;
201  *piNumCols = 20;
202  };
203 
204  /* Contributo allo jacobiano durante l'assemblaggio iniziale */
206  const VectorHandler& XCurr) {
207  WorkMat.SetNullMatrix();
208  return WorkMat;
209  };
210 
211  /* Contributo al residuo durante l'assemblaggio iniziale */
213  const VectorHandler& XCurr) {
214  WorkVec.Resize(0);
215  return WorkVec;
216  };
217 
218  /* Setta il valore iniziale delle proprie variabili */
219  virtual void SetInitialValue(VectorHandler& X) {
220  NO_OP;
221  };
222 
223  virtual void SetValue(DataManager *pDM,
225  SimulationEntity::Hints *ph = 0)
226  {
227  X.PutCoef(iGetFirstIndex() + 1, 0.);
228  };
229 
230  /* *******PER IL SOLUTORE PARALLELO******** */
231  /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento
232  utile per l'assemblaggio della matrice di connessione fra i dofs */
233  virtual void GetConnectedNodes(std::vector<const Node *>& connectedNodes) const {
234  connectedNodes.resize(2);
235  connectedNodes[0] = pNode1;
236  connectedNodes[1] = pNode2;
237  };
238  /* ************************************************ */
239 };
240 
241 /* ContactJoint - end */
242 
243 #endif /* CONTACTJ_H */
244 
virtual void Output(OutputHandler &OH) const
Definition: contactj.h:186
Type
Definition: joint.h:66
const Vec3 Zero3(0., 0., 0.)
long int flag
Definition: mbdyn.h:43
virtual DofOrder::Order GetDofType(unsigned int i) const
Definition: contactj.h:89
SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
Definition: contactj.h:212
Definition: matvec3.h:98
const StructNode * pNode2
Definition: contactj.h:46
ContactJoint(unsigned int uL, const DofOwner *pDO, const StructNode *pN1, const StructNode *pN2, const Vec3 &n, flag fOut)
Definition: contactj.h:53
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
doublereal dF
Definition: contactj.h:49
#define NO_OP
Definition: myassert.h:74
void PutCross(integer iSubIt, integer iFirstRow, integer iFirstCol, const Vec3 &v)
Definition: submat.cc:1236
std::vector< Hint * > Hints
Definition: simentity.h:89
virtual void PutItem(integer iSubRow, integer iRow, const doublereal &dCoef)
Definition: submat.h:1445
void Resize(integer iNewRow, integer iNewCol)
Definition: submat.cc:1053
void PutItem(integer iSubIt, integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:997
const StructNode * pNode1
Definition: contactj.h:45
void SetNullMatrix(void)
Definition: submat.h:1159
const doublereal & dGet(unsigned short int iRow) const
Definition: matvec3.h:285
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: contactj.h:233
virtual unsigned int iGetInitialNumDof(void) const
Definition: contactj.h:196
virtual integer iGetFirstMomentumIndex(void) const =0
virtual integer iGetFirstPositionIndex(void) const
Definition: strnode.h:452
std::ostream & Joints(void) const
Definition: output.h:443
virtual ostream & Restart(ostream &out) const
Definition: contactj.h:81
#define ASSERT(expression)
Definition: colamd.c:977
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
Definition: contactj.h:205
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: contactj.h:199
doublereal dD
Definition: contactj.h:48
virtual Joint::Type GetJointType(void) const
Definition: contactj.h:76
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: contactj.h:147
Definition: elem.h:75
virtual void SetInitialValue(VectorHandler &X)
Definition: contactj.h:219
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
Definition: contactj.h:223
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: contactj.h:94
Definition: joint.h:50
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: contactj.h:99
SparseSubMatrixHandler & SetSparse(void)
Definition: submat.h:1178
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
std::ostream & Output(std::ostream &out, const char *sJointName, unsigned int uLabel, const Vec3 &FLocal, const Vec3 &MLocal, const Vec3 &FGlobal, const Vec3 &MGlobal) const
Definition: joint.cc:138
long int integer
Definition: colamd.c:51
~ContactJoint(void)
Definition: contactj.h:71
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual void Resize(integer iNewSize)=0
virtual unsigned int iGetNumDof(void) const
Definition: contactj.h:85