24 #include "fmatvec/fmatvec.h"
25 #include "fmatvec/atom.h"
26 #include "mbsim/objectfactory.h"
28 #include <hdf5serie/vectorserie.h>
29 #include <mbxmlutilshelper/dom.h>
31 #include "mbsim_event.h"
33 #ifdef HAVE_OPENMBVCPPINTERFACE
48 const MBXMLUtils::NamespaceURI MBSIM(
"http://www.mbsim-env.de/MBSim");
50 class DynamicSystemSolver;
130 virtual std::string
getType()
const {
return "Element"; }
143 virtual void plot(
double t,
double dt = 1);
169 void setPath(
const std::string &str) {
path=str; }
224 virtual void initializeUsingXML(xercesc::DOMElement *element);
225 virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
227 const std::vector<MBXMLUtils::EmbedDOMLocator>& getLocationStack()
const {
return locationStack; }
233 template<
class T> T*
getByPath(
const std::string &
path,
bool initialCaller=
true)
const;
240 std::string
getPath(
const Element *relTo=NULL, std::string sep=
"/")
const;
246 THROW_MBSIMERROR(
"This element has no containers with childs.");
250 static double getDouble(xercesc::DOMElement *e);
251 static int getInt(xercesc::DOMElement *e);
252 static bool getBool(xercesc::DOMElement *e);
253 static fmatvec::Vec3 getVec3(xercesc::DOMElement *e);
254 static fmatvec::Vec getVec(xercesc::DOMElement *e,
int rows=0);
255 static fmatvec::Mat3xV getMat3xV(xercesc::DOMElement *e,
int cols=0);
256 static fmatvec::Mat getMat(xercesc::DOMElement *e,
int rows=0,
int cols=0);
257 static fmatvec::SqrMat3 getSqrMat3(xercesc::DOMElement *e);
259 static fmatvec::SymMat3 getSymMat3(xercesc::DOMElement *e);
262 #ifdef HAVE_OPENMBVCPPINTERFACE
263 virtual boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() {
return boost::shared_ptr<OpenMBV::Group>();}
266 virtual Element* getParent() {
return parent;}
267 virtual const Element* getParent()
const {
return parent;}
268 virtual void setParent(
Element* parent_) {parent = parent_;}
299 std::vector<MBXMLUtils::EmbedDOMLocator> locationStack;
326 void updatePlotFeatures();
343 if(path.substr(0, 1) ==
"/") {
347 return getByPath<T>(path.substr(1),
false);
349 else if (path.substr(0, 3) ==
"../")
350 return parent->
getByPath<T>(path.substr(3),
false);
353 size_t idx=path.find(
'/');
354 std::string first=path.substr(0, idx);
356 if(idx!=std::string::npos)
357 rest=path.substr(idx+1);
359 size_t pos0=first.find(
'[');
360 if(pos0==std::string::npos)
361 THROW_MBSIMERROR(
"Syntax error in subreference '"+first+
"': no [ found.");
362 std::string container=first.substr(0, pos0);
363 if(first[first.size()-1]!=
']')
364 THROW_MBSIMERROR(
"Syntax error in subreference '"+first+
"': not ending with ].");
365 std::string
name=first.substr(pos0+1, first.size()-pos0-2);
371 T *t=
dynamic_cast<T*
>(e);
375 THROW_MBSIMERROR(
"Cannot cast this element to type "+container+
".");
380 THROW_MBSIMERROR(
"Evaluation of refernece '"+path+
"' failed: Message from "+
381 ex.getPath()+
": "+ex.getErrorMessage());
virtual void createPlotGroup()
creates the plotGroup for H5-output
Definition: element.cc:103
virtual Element * getChildByContainerAndName(const std::string &container, const std::string &name) const
Get the Element named name in the container named container.
Definition: element.h:245
Definition: element.h:101
DynamicSystemSolver * getDynamicSystemSolver()
Definition: element.h:174
Definition: element.h:103
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:49
virtual void setPlotFeature(PlotFeature pf, PlotFeatureStatus value)
Set a plot feature.
Definition: element.h:198
std::vector< Element * > dependency
vector containing all dependencies.
Definition: element.h:331
std::string getPath(const Element *relTo=NULL, std::string sep="/") const
Return the path of this object. If relativeTo is not NULL return a relative path to relativeTo...
Definition: element.cc:132
H5::VectorSerie< double > * plotVectorSerie
time series
Definition: element.h:309
basic class of MBSim mainly for plotting
Definition: element.h:58
virtual void initDataInterfaceBase(DynamicSystemSolver *parentds)
TODO.
Definition: element.h:125
std::string path
The path of this object. Is set during the init stage reorganizeHierarchy. Before this the path is ca...
Definition: element.h:297
DynamicSystemSolver * ds
dynamic system
Definition: element.h:304
virtual void plot(double t, double dt=1)
plots time dependent data
Definition: element.cc:54
H5::GroupBase * getPlotGroup()
Definition: element.h:190
virtual std::string getType() const
Definition: element.h:130
virtual void plotAtSpecialEvent(double t, double dt=1)
plots time dependent data at special events
Definition: element.h:150
std::vector< std::string > plotColumns
columns of time series
Definition: element.h:319
Definition: element.h:105
Definition: element.h:107
Definition: element.h:104
void setPlotFeatureRecursive(PlotFeature pf, PlotFeatureStatus value)
Set a plot feature for this object and the children of this object.
Definition: element.h:212
virtual void closePlot()
closes plot file
Definition: element.cc:65
InitStage
The stages of the initialization.
Definition: element.h:97
T * getByPath(const std::string &path, bool initialCaller=true) const
Get the object of type T represented by the path path. Do not set any argurment other than path! ...
Definition: element.h:341
std::vector< double > plotVector
one entry of time series
Definition: element.h:314
PlotFeatureStatus getPlotFeature(PlotFeature pf)
Definition: element.h:217
std::string name
name of element
Definition: element.h:290
Definition: element.h:100
virtual void init(InitStage stage)
plots time series header
Definition: element.cc:70
virtual ~Element()
destructor
Definition: element.cc:51
const std::string & getName() const
Definition: element.h:161
virtual void setDynamicSystemSolver(DynamicSystemSolver *sys)
sets the used dynamics system solver to the element
Definition: element.h:136
Definition: element.h:106
H5::GroupBase * plotGroup
associated plot group
Definition: element.h:324
void setPlotFeatureForChildren(PlotFeature pf, PlotFeatureStatus value)
Set a plot feature for the children of this object.
Definition: element.h:205
void setName(const std::string &str)
Definition: element.h:166
PlotFeatureStatus plotFeature[LASTPLOTFEATURE]
plot feature
Definition: element.h:337
basic error class for mbsim
Definition: mbsim_event.h:38
int computeLevel()
computes the length of the pathes in the graph that represents the dependencies between all elements...
Definition: element.cc:365
std::vector< Element * > getElementsDependingOn() const
checks dependency on other elements.
Definition: element.h:274
PlotFeatureStatus
Plot feature status.
Definition: element.h:61
Element(const std::string &name)
constructor
Definition: element.cc:44
Definition: element.h:102
PlotFeature
Plot Features.
Definition: element.h:74
PlotFeatureStatus getPlotFeatureForChildren(PlotFeature pf)
Definition: element.h:222