MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-template2.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/modules/module-template2/module-template2.cc,v 1.9 2017/01/12 14:58: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  *
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 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
32 
33 #include <iostream>
34 #include <cfloat>
35 
36 #include "dataman.h"
37 #include "userelem.h"
38 
40 : virtual public Elem, public UserDefinedElem {
41 private:
42  // add private data
43 
44 public:
45  ModuleTemplate(unsigned uLabel, const DofOwner *pDO,
46  DataManager* pDM, MBDynParser& HP);
47  virtual ~ModuleTemplate(void);
48 
49  virtual void Output(OutputHandler& OH) const;
50  virtual void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
53  doublereal dCoef,
54  const VectorHandler& XCurr,
55  const VectorHandler& XPrimeCurr);
57  AssRes(SubVectorHandler& WorkVec,
58  doublereal dCoef,
59  const VectorHandler& XCurr,
60  const VectorHandler& XPrimeCurr);
61  unsigned int iGetNumPrivData(void) const;
62  int iGetNumConnectedNodes(void) const;
63  void GetConnectedNodes(std::vector<const Node *>& connectedNodes) const;
66  std::ostream& Restart(std::ostream& out) const;
67  virtual unsigned int iGetInitialNumDof(void) const;
68  virtual void
69  InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
72  const VectorHandler& XCurr);
74  InitialAssRes(SubVectorHandler& WorkVec, const VectorHandler& XCurr);
75 };
76 
78  unsigned uLabel, const DofOwner *pDO,
79  DataManager* pDM, MBDynParser& HP)
80 : Elem(uLabel, flag(0)),
81 UserDefinedElem(uLabel, pDO)
82 {
83  // help
84  if (HP.IsKeyWord("help")) {
85  silent_cout(
86 " \n"
87 "Module: template2 \n"
88 "Author: Pierangelo Masarati <masarati@aero.polimi.it> \n"
89 "Organization: Dipartimento di Ingegneria Aerospaziale \n"
90 " Politecnico di Milano \n"
91 " http://www.aero.polimi.it/ \n"
92 " \n"
93 " All rights reserved \n"
94  << std::endl);
95 
96  if (!HP.IsArg()) {
97  /*
98  * Exit quietly if nothing else is provided
99  */
100  throw NoErr(MBDYN_EXCEPT_ARGS);
101  }
102  }
103 
104  // do something useful
105 }
106 
108 {
109  // destroy private data
110  NO_OP;
111 }
112 
113 void
115 {
116  // should do something useful
117  NO_OP;
118 }
119 
120 void
121 ModuleTemplate::WorkSpaceDim(integer* piNumRows, integer* piNumCols) const
122 {
123  *piNumRows = 0;
124  *piNumCols = 0;
125 }
126 
129  doublereal dCoef,
130  const VectorHandler& XCurr,
131  const VectorHandler& XPrimeCurr)
132 {
133  // should do something useful
134  WorkMat.SetNullMatrix();
135 
136  return WorkMat;
137 }
138 
141  doublereal dCoef,
142  const VectorHandler& XCurr,
143  const VectorHandler& XPrimeCurr)
144 {
145  // should do something useful
146  WorkVec.ResizeReset(0);
147 
148  return WorkVec;
149 }
150 
151 unsigned int
153 {
154  return 0;
155 }
156 
157 int
159 {
160  return 0;
161 }
162 
163 void
164 ModuleTemplate::GetConnectedNodes(std::vector<const Node *>& connectedNodes) const
165 {
166  connectedNodes.resize(0);
167 }
168 
169 void
173 {
174  NO_OP;
175 }
176 
177 std::ostream&
178 ModuleTemplate::Restart(std::ostream& out) const
179 {
180  return out << "# ModuleTemplate: not implemented" << std::endl;
181 }
182 
183 unsigned int
185 {
186  return 0;
187 }
188 
189 void
191  integer* piNumRows,
192  integer* piNumCols) const
193 {
194  *piNumRows = 0;
195  *piNumCols = 0;
196 }
197 
200  VariableSubMatrixHandler& WorkMat,
201  const VectorHandler& XCurr)
202 {
203  // should not be called, since initial workspace is empty
204  ASSERT(0);
205 
206  WorkMat.SetNullMatrix();
207 
208  return WorkMat;
209 }
210 
213  SubVectorHandler& WorkVec,
214  const VectorHandler& XCurr)
215 {
216  // should not be called, since initial workspace is empty
217  ASSERT(0);
218 
219  WorkVec.ResizeReset(0);
220 
221  return WorkVec;
222 }
223 
224 extern "C" int
225 module_init(const char *module_name, void *pdm, void *php)
226 {
228 
229  if (!SetUDE("template2", rf)) {
230  delete rf;
231 
232  silent_cerr("module-template2: "
233  "module_init(" << module_name << ") "
234  "failed" << std::endl);
235 
236  return -1;
237  }
238 
239  return 0;
240 }
241 
virtual void Output(OutputHandler &OH) const
long int flag
Definition: mbdyn.h:43
VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
virtual void ResizeReset(integer)
Definition: vh.cc:55
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
virtual unsigned int iGetInitialNumDof(void) const
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
#define NO_OP
Definition: myassert.h:74
std::vector< Hint * > Hints
Definition: simentity.h:89
virtual ~ModuleTemplate(void)
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
int iGetNumConnectedNodes(void) const
void SetNullMatrix(void)
Definition: submat.h:1159
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
unsigned int uLabel
Definition: withlab.h:44
#define ASSERT(expression)
Definition: colamd.c:977
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: except.h:79
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
bool SetUDE(const std::string &s, UserDefinedElemRead *rude)
Definition: userelem.cc:97
void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
std::ostream & Restart(std::ostream &out) const
ModuleTemplate(unsigned uLabel, const DofOwner *pDO, DataManager *pDM, MBDynParser &HP)
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned int iGetNumPrivData(void) const
void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph)