MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
displacement.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/elec/displacement.cc,v 1.27 2017/01/12 14:46:22 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 /* Elementi elettrici */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include "strnode.h"
37 #include "elecnode.h"
38 #include "displacement.h"
39 
40 /* DispMeasure - begin */
41 
42 /* Costruttore */
43 DispMeasure::DispMeasure(unsigned int uL, const DofOwner* pDO,
44  const StructNode* pS1, const StructNode* pS2,
45  const ScalarDifferentialNode* pA,
46  const Vec3& Tmpf1, const Vec3& Tmpf2,
47  flag fOut)
48 : Elem(uL, fOut),
49 Electric(uL, pDO, fOut),
50 pStrNode1(pS1), pStrNode2(pS2), pAbsNode(pA),
51 f1(Tmpf1), f2(Tmpf2)
52 {
53  ASSERT(pStrNode1 != NULL);
55  ASSERT(pStrNode2 != NULL);
57  ASSERT(pAbsNode != NULL);
59 }
60 
61 /* Distruttore banale */
63 {
64  NO_OP;
65 }
66 
67 /* Contributo al file di restart */
68 std::ostream&
69 DispMeasure::Restart(std::ostream& out) const
70 {
71  Electric::Restart(out) << ", displacement, "
72  << pStrNode1->GetLabel() << ", "
73  "reference, node, ", f1.Write(out, ", ") << ", "
74  << pStrNode2->GetLabel() << ", "
75  "reference, node, ", f2.Write(out, ", ") << ", "
76  << pAbsNode->GetLabel() << ';'
77  << std::endl;
78  return out;
79 }
80 
81 /* Costruisce il contributo allo jacobiano */
84  doublereal dCoef,
85  const VectorHandler& /* XCurr */ ,
86  const VectorHandler& /* XPrimeCurr */ )
87 {
88  DEBUGCOUT("Entering DispMeasure::AssJac()" << std::endl);
89 
90  /* Casting di WorkMat */
91  SparseSubMatrixHandler& WM = WorkMat.SetSparse();
92  WM.ResizeReset(1, 0);
93 
94  /* Indici delle equazioni */
95  integer iAbstractIndex = pAbsNode->iGetFirstIndex()+1;
96 
97  WM.PutItem(1, iAbstractIndex, iAbstractIndex, dCoef);
98 
99  return WorkMat;
100 }
101 
102 /* Costruisce il contributo al residuo */
105  doublereal /* dCoef */ ,
106  const VectorHandler& /* XCurr */ ,
107  const VectorHandler& /* XPrimeCurr */ )
108 {
109  DEBUGCOUT("Entering DispMeasure::AssRes()" << std::endl);
110 
111  /* Dimensiona e resetta la matrice di lavoro */
112  WorkVec.Resize(1);
113 
114  integer iAbstractIndex = pAbsNode->iGetFirstIndex() + 1;
115 
116  WorkVec.PutRowIndex(1, iAbstractIndex);
117 
120 
121  doublereal a = pAbsNode->dGetX();
122 
123  doublereal d = (x2 - x1).Norm();
124 
125  WorkVec.PutCoef(1, d - a);
126 
127  return WorkVec;
128 }
129 
130 void
131 DispMeasure::WorkSpaceDim(integer* piNumRows, integer* piNumCols) const
132 {
133  *piNumRows = 1;
134  *piNumCols = 1;
135 }
136 
137 /* Setta i valori iniziali delle variabili (e fa altre cose)
138  * prima di iniziare l'integrazione */
139 void
143 {
144  integer iIndex = pAbsNode->iGetFirstIndex() + 1;
145 
146  /* distanza */
147  Vec3 ff1 = pStrNode1->GetRCurr()*f1;
148  Vec3 ff2 = pStrNode2->GetRCurr()*f2;
149 
150  Vec3 x1 = pStrNode1->GetXCurr()+ff1;
151  Vec3 x2 = pStrNode2->GetXCurr()+ff2;
152 
153  doublereal d = (x2 - x1).Norm();
154 
155  const_cast<ScalarDifferentialNode *>(pAbsNode)->SetX(d);
156  X.PutCoef(iIndex, d);
157 
158  /* velocita' */
159  Vec3 v1 = pStrNode1->GetVCurr() + (pStrNode1->GetWCurr()).Cross(ff1);
160  Vec3 v2 = pStrNode2->GetVCurr() + (pStrNode2->GetWCurr()).Cross(ff2);
161 
162  doublereal v = (v2 - v1).Norm();
163 
164  const_cast<ScalarDifferentialNode *>(pAbsNode)->SetXPrime(v);
165 
166  XP.PutCoef(iIndex, v);
167 }
168 
169 /* DispMeasure - end */
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
std::ostream & Write(std::ostream &out, const char *sFill=" ") const
Definition: matvec3.cc:738
long int flag
Definition: mbdyn.h:43
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
virtual Node::Type GetNodeType(void) const
Definition: strnode.cc:145
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: displacement.cc:83
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
const StructNode * pStrNode2
Definition: displacement.h:44
void ResizeReset(integer iNewRow, integer iNewCol)
Definition: submat.cc:1084
#define NO_OP
Definition: myassert.h:74
std::vector< Hint * > Hints
Definition: simentity.h:89
const ScalarDifferentialNode * pAbsNode
Definition: displacement.h:45
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
void PutItem(integer iSubIt, integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:997
Definition: elec.h:43
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
#define ASSERT(expression)
Definition: colamd.c:977
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
Definition: matvec.h:3248
~DispMeasure(void)
Definition: displacement.cc:62
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
VectorExpression< VectorExpr, N_rows >::ScalarType Norm(const VectorExpression< VectorExpr, N_rows > &u)
Definition: matvec.h:3163
Definition: elem.h:75
virtual std::ostream & Restart(std::ostream &out) const
Definition: elec.cc:65
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
static const doublereal a
Definition: hfluid_.h:289
DispMeasure(unsigned int uL, const DofOwner *pD, const StructNode *pS1, const StructNode *pS2, const ScalarDifferentialNode *pA, const Vec3 &Tmpf1, const Vec3 &Tmpf2, flag fOut)
Definition: displacement.cc:43
SparseSubMatrixHandler & SetSparse(void)
Definition: submat.h:1178
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
virtual Node::Type GetNodeType(void) const
Definition: node.cc:169
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned int GetLabel(void) const
Definition: withlab.cc:62
virtual std::ostream & Restart(std::ostream &out) const
Definition: displacement.cc:69
virtual void Resize(integer iNewSize)=0
virtual const doublereal & dGetX(void) const
Definition: node.h:386
const StructNode * pStrNode1
Definition: displacement.h:43