MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
therm.cc
Go to the documentation of this file.
1 /*
2  * MBDyn (C) is a multibody analysis code.
3  * http://www.mbdyn.org
4  *
5  * Copyright (C) 1996-2005
6  *
7  * Pierangelo Masarati <masarati@aero.polimi.it>
8  * Paolo Mantegazza <mantegazza@aero.polimi.it>
9  *
10  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
11  * via La Masa, 34 - 20156 Milano, Italy
12  * http://www.aero.polimi.it
13  *
14  * Changing this copyright notice is forbidden.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation (version 2 of the License).
19  *
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 /* Elementi termici */
32 
33 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
34 
35 #include "mynewmem.h"
36 #include "therm.h"
37 #include "thermalnode.h"
38 #include "thermalcapacitance.h"
39 #include "thermalresistance.h"
40 #include "thermalsource.h"
41 #include "dataman.h"
42 
43 /* Thermal - begin */
44 
45 Thermal::Thermal(unsigned int uL,
46  const DofOwner* pDO, flag fOut)
47 : Elem(uL, fOut),
48 ElemWithDofs(uL, pDO, fOut)
49 {
50  NO_OP;
51 }
52 
53 
55 {
56  NO_OP;
57 }
58 
59 
60 /* Contributo al file di restart
61  * (Nota: e' incompleta, deve essere chiamata dalla funzione corrispndente
62  * relativa alla classe derivata */
63 std::ostream& Thermal::Restart(std::ostream& out) const {
64  return out << " thermal: " << GetLabel();
65 }
66 
67 
68 /* Tipo dell'elemento (usato solo per debug ecc.) */
70 {
71  return Elem::THERMAL;
72 }
73 
74 /* Electric - end */
75 
76 
77 
78 
79 
80 /* Legge un elemento elettrico */
81 
83  MBDynParser& HP,
84  const DofOwner* pDO,
85  unsigned int uLabel)
86 {
87  DEBUGCOUTFNAME("ReadEThermal()");
88 
89  const char* sKeyWords[] = {
90  "resistance",
91  "capacitance",
92  "source"
93  };
94 
95  /* enum delle parole chiave */
96  enum KeyWords {
97  UNKNOWN = -1,
98 
99  THERMALRESISTANCE = 0,
100  THERMALCAPACITANCE,
101  THERMALSOURCE,
102 
104  };
105 
106  /* tabella delle parole chiave */
107  KeyTable K(HP, sKeyWords);
108 
109  /* lettura del tipo di elemento elettrico */
110  KeyWords CurrKeyWord = KeyWords(HP.GetWord());
111 
112 #ifdef DEBUG
113  if (CurrKeyWord >= 0) {
114  std::cout << "thermal element type: "
115  << sKeyWords[CurrKeyWord] << std::endl;
116  }
117 #endif
118 
119  Elem* pEl = 0;
120 
121  switch (CurrKeyWord) {
122  /* */
123 
124  case THERMALRESISTANCE: {
125  const ThermalNode* pThNode1 = pDM->ReadNode<const ThermalNode, Node::THERMAL>(HP);
126  const ThermalNode* pThNode2 = pDM->ReadNode<const ThermalNode, Node::THERMAL>(HP);
127  doublereal r = HP.GetReal();
128  flag fOut = pDM->fReadOutput(HP, Elem::ELECTRIC);
131  ThermalResistance(uLabel, pDO,
132  pThNode1, pThNode2,
133  r, fOut));
134 
135  std::ostream& out = pDM->GetLogFile();
136  out << "thermal resistance: " << uLabel
137  << " " << pThNode1->GetLabel()
138  << " " << pThNode2->GetLabel()
139  << std::endl;
140  break;
141  }
142 
143  case THERMALCAPACITANCE: {
144  const ThermalNode* pThNode1 = pDM->ReadNode<const ThermalNode, Node::THERMAL>(HP);
145  doublereal c = HP.GetReal();
146  flag fOut = pDM->fReadOutput(HP, Elem::ELECTRIC);
149  ThermalCapacitance(uLabel, pDO, pThNode1, c, fOut));
150 
151  std::ostream& out = pDM->GetLogFile();
152  out << "thermal capacitance: " << uLabel
153  << " " << pThNode1->GetLabel()
154  << std::endl;
155  break;
156  }
157 
158  case THERMALSOURCE: {
159  const ThermalNode* pThNode1 = pDM->ReadNode<const ThermalNode, Node::THERMAL>(HP);
160  DriveCaller* pDC = HP.GetDriveCaller();
161  flag fOut = pDM->fReadOutput(HP, Elem::ELECTRIC);
164  ThermalSource(uLabel, pDO, pThNode1, pDC, fOut));
165 
166  std::ostream& out = pDM->GetLogFile();
167  out << "thermal source: " << uLabel
168  << " " << pThNode1->GetLabel()
169  << std::endl;
170  break;
171  }
172 
173  /* Aggiungere altri elementi elettrici */
174 
175  default: {
176  silent_cerr("unknown thermal element type in thermal element " << uLabel
177  << " at line " << HP.GetLineData() << std::endl);
179  }
180  }
181 
182  /* Se non c'e' il punto e virgola finale */
183  if (HP.IsArg()) {
184  silent_cerr("semicolon expected at line " << HP.GetLineData() << std::endl);
186  }
187 
188  return pEl;
189 } /* ReadThermal() */
190 
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
Thermal(unsigned int uL, const DofOwner *pDO, flag fOut)
Definition: therm.cc:45
virtual ~Thermal(void)
Definition: therm.cc:54
#define NO_OP
Definition: myassert.h:74
Elem * ReadThermal(DataManager *pDM, MBDynParser &HP, const DofOwner *pDO, unsigned int uLabel)
Definition: therm.cc:82
virtual std::ostream & Restart(std::ostream &out) const
Definition: therm.cc:63
KeyWords
Definition: dataman4.cc:94
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
static std::stack< cleanup * > c
Definition: cleanup.cc:59
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
Type
Definition: elem.h:91
virtual int GetWord(void)
Definition: parser.cc:1083
std::ostream & GetLogFile(void) const
Definition: dataman.h:326
virtual Elem::Type GetElemType(void) const
Definition: therm.cc:69
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056