MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
scalarvalue.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/scalarvalue.cc,v 1.14 2017/01/12 14:46:10 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 /*
33  * Michele Attolico <attolico@aero.polimi.it>
34  */
35 
36 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
37 
38 #include "dataman.h"
39 #include "scalarvalue.h"
40 
41 /* ScalarValue - begin */
42 
44 {
45  NO_OP;
46 }
47 
49 : ScalarDof(sd)
50 {
51  NO_OP;
52 }
53 
56 {
57  return ScalarDof::dGetValue();
58 }
59 
61 : pDC(pdc)
62 {
63  NO_OP;
64 }
65 
67 {
68  if (pDC) {
69  delete pDC;
70  }
71 }
72 
75 {
76  return pDC->dGet();
77 }
78 
81 {
82  ScalarValue *svp = 0;
83 
84  if (HP.IsKeyWord("drive")) {
85  svp = new ScalarDriveValue(HP.GetDriveCaller(false));
86 
87  } else {
88  if (!HP.IsKeyWord("node" "dof")) {
89  silent_cerr("Warning, missing keyword \"node dof\" "
90  "at line " << HP.GetLineData() << std::endl);
91  }
92 
93  svp = new ScalarDofValue(ReadScalarDof(pDM, HP, false, true));
94  }
95 
96  return svp;
97 }
98 
99 /* NOTE: the array must have the desired size */
100 void
102  std::vector<ScalarValue *>& Values)
103 {
104  unsigned nch = Values.size();
105  if (nch == 0) {
106  silent_cerr("Request to read an empty ScalarValue vector "
107  "at line " << HP.GetLineData() << std::endl);
109  }
110 
111  for (unsigned int i = 0; i < nch; i++) {
112  Values[i] = ReadScalarValue(pDM, HP);
113  }
114 }
115 
116 /* ScalarValue - end */
117 
doublereal dGetValue(void) const
Definition: scalarvalue.cc:74
ScalarDriveValue(const DriveCaller *pdc)
Definition: scalarvalue.cc:60
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define NO_OP
Definition: myassert.h:74
virtual ~ScalarValue(void)
Definition: scalarvalue.cc:43
const DriveCaller * pDC
Definition: scalarvalue.h:53
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
ScalarValue * ReadScalarValue(DataManager *pDM, MBDynParser &HP)
Definition: scalarvalue.cc:80
virtual doublereal dGet(const doublereal &dVar) const =0
ScalarDofValue(const ScalarDof &sd)
Definition: scalarvalue.cc:48
doublereal dGetValue(void) const
Definition: scalarvalue.cc:55
DriveCaller * GetDriveCaller(bool bDeferred=false)
Definition: mbpar.cc:2033
void ReadScalarValues(DataManager *pDM, MBDynParser &HP, std::vector< ScalarValue * > &Values)
Definition: scalarvalue.cc:101
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
~ScalarDriveValue(void)
Definition: scalarvalue.cc:66
const doublereal & dGetValue(void) const
Definition: node.cc:730
ScalarDof ReadScalarDof(const DataManager *pDM, MBDynParser &HP, bool bDof, bool bOrder)
Definition: dataman3.cc:2423