MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
j2p.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/j2p.cc,v 1.33 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 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include "mynewmem.h"
35 #include "j2p.h"
36 
37 
38 /* Elem2Param - begin */
39 
40 Elem2Param::Elem2Param(unsigned int uL, const DofOwner* pDO, flag fOut)
41 : ParameterNode(uL, pDO, 0., fOut), pElem(0), iNum(0)
42 {
43  NO_OP;
44 }
45 
47 {
48  NO_OP;
49 }
50 
51 
52 void
53 Elem2Param::Bind(const Elem* pEl, unsigned int i)
54 {
55  if (pElem != 0) {
56  silent_cerr("Elem2Param::Bind(): parameter (" << GetLabel()
57  << ") is already bound to "
59  << " (" << pElem->GetLabel() << ')' << std::endl);
61  }
62 
63  if (i <= 0) {
64  silent_cerr("Elem2Param::Bind(): illegal value " << i
65  << " for " << psElemNames[pEl->GetElemType()]
66  << " (" << pEl->GetLabel() << ") private data"
67  << std::endl);
69  }
70 
71  iNum = i;
72 
73  if (iNum <= 0 || iNum > pEl->iGetNumPrivData()) {
74  silent_cerr("Elem2Param::Bind(): "
75  "wrong element private data number "
76  << iNum << " for " << psElemNames[pEl->GetElemType()]
77  << " (" << pEl->GetLabel() << ')' << std::endl);
79  }
80  pElem = pEl;
81 
82  dGetDofValue(1, 0);
83 }
84 
85 /* Contributo del nodo al file di restart */
86 std::ostream&
87 Elem2Param::Restart(std::ostream& out) const
88 {
89  //return out << "# Elem2Param is not implemented yet" << std::endl;
90  return out << " parameter: "
91  << GetLabel() << " ,element;" << std::endl;
92 }
93 
94 std::ostream&
95 Elem2Param::RestartBind(std::ostream& out) const
96 {
97  //return out << "# Elem2Param is not implemented yet" << std::endl;
98  return out << " bind: "
99  << pElem ->GetLabel() <<", "
100  << psReadElemsElems[pElem -> GetElemType()] << ", "
101  << GetLabel() << ", " << iNum << ";"
102  << std::endl;
103 }
104 
105 /* Setta il valore del dof iDof a dValue;
106  * se differenziale, iOrder puo' essere = 1 per la derivata */
107 void
108 Elem2Param::SetDofValue(const doublereal& /* dValue */ ,
109  unsigned int /* iDof */ ,
110  unsigned int /* iOrder */)
111 {
112  NO_OP;
113 }
114 
115 void
117  VectorHandler& /* X */, VectorHandler& /* XP */ ,
119 {
120  if (pElem == 0) {
121  silent_cerr("ParameterNode(" << GetLabel()
122  << "): never bound" << std::endl);
124  }
125 
126  dX = dGetX();
127 }
128 
129 /* Elem2Param - end */
130 
131 
132 /* StrainGageParam - begin */
133 
134 StrainGageParam::StrainGageParam(unsigned int uL, const DofOwner* pDO,
135  doublereal dy, doublereal dz, flag fOut)
136 : Elem2Param(uL, pDO, fOut), dY(dy), dZ(dz)
137 {
138  NO_OP;
139 }
140 
142 {
143  NO_OP;
144 }
145 
146 void
147 StrainGageParam::Bind(const Elem* pEl, unsigned int i)
148 {
149  ASSERT(pEl != 0);
150  if (pEl->GetElemType() != Elem::BEAM) {
151  silent_cerr("StrainGageParam::Bind(): must bind to a beam"
152  << std::endl);
154  }
155 
156  /* Nota: ora i == 1 o 2 per punto di valutazione I o II */
157  const char *s;
158  switch (i) {
159  case 1:
160  s = "pI.ex";
161  break;
162 
163  case 2:
164  s = "pII.ex";
165  break;
166 
167  default:
169  }
170 
171  unsigned int idx = pEl->iGetPrivDataIdx(s);
172  ASSERT(idx > 0);
173  ASSERT(idx <= pEl->iGetNumPrivData());
174 
175  Elem2Param::Bind(pEl, idx);
176 }
177 
178 /* Contributo del nodo al file di restart */
179 std::ostream&
180 StrainGageParam::Restart(std::ostream& out) const
181 {
182  return out << "StrainGageParam is not implemented yet" << std::endl;
183 }
184 
185 /* StrainGageParam - end */
186 
std::ostream & RestartBind(std::ostream &out) const
Definition: j2p.cc:95
virtual const doublereal & dGetDofValue(int iDof, int iOrder=0) const
Definition: j2p.h:78
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
StrainGageParam(unsigned int uL, const DofOwner *pDO, doublereal dy, doublereal dz, flag fOut)
Definition: j2p.cc:134
virtual std::ostream & Restart(std::ostream &out) const
Definition: j2p.cc:87
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: simentity.cc:142
#define NO_OP
Definition: myassert.h:74
virtual Elem::Type GetElemType(void) const =0
std::vector< Hint * > Hints
Definition: simentity.h:89
virtual ~Elem2Param(void)
Definition: j2p.cc:46
virtual std::ostream & Restart(std::ostream &out) const
Definition: j2p.cc:180
virtual const doublereal & dGetX(void) const
Definition: j2p.h:87
virtual unsigned int iGetNumPrivData(void) const
Definition: node.h:563
doublereal dX
Definition: node.h:405
virtual void Bind(const Elem *pEl, unsigned int i)
Definition: j2p.cc:147
virtual void SetDofValue(const doublereal &dValue, unsigned int iDof, unsigned int iOrder=0)
Definition: j2p.cc:108
virtual void Bind(const Elem *pEl, unsigned int i)
Definition: j2p.cc:53
const Elem * pElem
Definition: j2p.h:42
unsigned int iNum
Definition: j2p.h:43
#define ASSERT(expression)
Definition: colamd.c:977
virtual ~StrainGageParam(void)
Definition: j2p.cc:141
virtual unsigned int iGetNumPrivData(void) const
Definition: simentity.cc:136
Elem2Param(unsigned int uL, const DofOwner *pDO, flag fOut)
Definition: j2p.cc:40
Definition: j2p.h:40
Definition: elem.h:75
const char * psElemNames[]
Definition: enums.cc:39
virtual void SetValue(DataManager *pDM, VectorHandler &, VectorHandler &, SimulationEntity::Hints *ph=0)
Definition: j2p.cc:116
const char * psReadElemsElems[]
Definition: enums.cc:79
double doublereal
Definition: colamd.c:52
unsigned int GetLabel(void) const
Definition: withlab.cc:62