23#include "fmatvec/fmatvec.h"
24#include "fmatvec/atom.h"
25#include "mbsim/objectfactory.h"
26#include "mbsim/utils/plotfeatureenum.h"
27#include "mbsim/utils/initconfigenum.h"
28#include "mbsim/namespace.h"
29#include "mbsim/mbsim_event.h"
30#include <hdf5serie/vectorserie.h>
45 extern const PlotFeatureEnum plotRecursive, openMBV, debug;
47 class DynamicSystemSolver;
56 class Element :
virtual public fmatvec::Atom {
83 void throwError(
const std::string &msg)
const {
118 void setPath(
const std::string &str) {
path=str; }
129 virtual void init(
InitStage stage,
const InitConfigSet &config=InitConfigSet());
140 virtual H5::GroupBase *getFramesPlotGroup() {
return nullptr; }
141 virtual H5::GroupBase *getContoursPlotGroup() {
return nullptr; }
142 virtual H5::GroupBase *getGroupsPlotGroup() {
return nullptr; }
143 virtual H5::GroupBase *getObjectsPlotGroup() {
return nullptr; }
144 virtual H5::GroupBase *getLinksPlotGroup() {
return nullptr; }
145 virtual H5::GroupBase *getConstraintsPlotGroup() {
return nullptr; }
146 virtual H5::GroupBase *getObserversPlotGroup() {
return nullptr; }
183 plotAttribute[
name] = value;
186 plotAttribute[
name] = std::monostate();
189 virtual void initializeUsingXML(xercesc::DOMElement *element);
195 template<
class T> T*
getByPath(
const std::string &
path,
bool initialCaller=
true)
const;
202 std::string
getPath(
const Element *relTo=
nullptr, std::string sep=
"/")
const;
208 throwError(
"This element has no containers with childs.");
211 virtual std::shared_ptr<OpenMBV::Group> getOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
212 virtual std::shared_ptr<OpenMBV::Group> getFramesOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
213 virtual std::shared_ptr<OpenMBV::Group> getContoursOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
214 virtual std::shared_ptr<OpenMBV::Group> getGroupsOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
215 virtual std::shared_ptr<OpenMBV::Group> getObjectsOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
216 virtual std::shared_ptr<OpenMBV::Group> getLinksOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
217 virtual std::shared_ptr<OpenMBV::Group> getConstraintsOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
218 virtual std::shared_ptr<OpenMBV::Group> getObserversOpenMBVGrp() {
return std::shared_ptr<OpenMBV::Group>(); }
220 virtual Element* getParent() {
return parent;}
221 virtual const Element* getParent()
const {
return parent;}
222 virtual void setParent(
Element* parent_) {parent = parent_;}
239 virtual void updatePositions(Frame *frame) { }
240 virtual void updateVelocities(Frame *frame) { }
241 virtual void updateAccelerations(Frame *frame) { }
242 virtual void updateJacobians(Frame *frame,
int j=0) { }
243 virtual void updateGyroscopicAccelerations(Frame *frame) { }
245 virtual void resetUpToDate() { }
247 const double& getTime()
const;
248 double getStepSize()
const;
299 void updatePlotFeatures();
311 std::map<std::string, std::variant<
318 std::vector<std::vector<double>>
321 void addToPlot(
const std::string &
name);
322 void addToPlot(
const std::string &
name,
int size);
323 void addToPlot(
const std::string &
name,
const std::vector<std::string> &iname);
325 template<
class AT>
void plot(
const AT &x) {
328 template<
class Type,
class AT>
void plot(
const fmatvec::Vector<Type,AT> &x) {
329 for(
int i=0; i<x.size(); i++)
333 Element* getByPathElement(
const std::string &
path,
bool initialCaller=
true)
const;
338 Element *e = getByPathElement(
path, initialCaller);
339 auto *t=
dynamic_cast<T*
>(e);
343 throwError(std::string(
"Cannot cast this element to type ")+
typeid(T).
name()+
".");
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
basic class of MBSim mainly for plotting
Definition: element.h:56
std::string getPath(const Element *relTo=nullptr, std::string sep="/") const
Return the path of this object. If relativeTo is not NULL return a relative path to relativeTo....
Definition: element.cc:179
H5::GroupBase * plotGroup
associated plot group
Definition: element.h:297
virtual void plot()
plots time dependent data
Definition: element.cc:74
std::vector< Element * > dependency
vector containing all dependencies.
Definition: element.h:304
std::vector< Element * > getDependencies() const
checks dependency on other elements.
Definition: element.h:228
virtual void setPlotFeature(const PlotFeatureEnum &pf, bool value)
Set a plot feature.
Definition: element.cc:239
Element(const std::string &name)
constructor
Definition: element.cc:63
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:207
virtual void init(InitStage stage, const InitConfigSet &config=InitConfigSet())
plots time series header
Definition: element.cc:85
void setPlotFeatureRecursive(const PlotFeatureEnum &pf, bool value)
Set a plot feature for this object and the children of this object.
Definition: element.h:176
bool getPlotFeature(const PlotFeatureEnum &pf)
Definition: element.h:150
virtual void setDynamicSystemSolver(DynamicSystemSolver *sys)
sets the used dynamics system solver to the element
Definition: element.h:91
~Element() override=default
destructor
virtual void plotAtSpecialEvent()
plots time dependent data at special events
Definition: element.h:105
InitStage
The stages of the initialization.
Definition: element.h:62
@ plotting
Definition: element.h:65
@ unknownStage
Definition: element.h:66
@ resolveStringRef
Definition: element.h:63
@ preInit
Definition: element.h:64
H5::GroupBase * getPlotGroup()
Definition: element.h:139
virtual void createPlotGroup()
creates the plotGroup for H5-output
Definition: element.cc:141
std::string path
The path of this object. Is set during the init stage reorganizeHierarchy. Before this the path is ca...
Definition: element.h:267
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:337
std::vector< double > plotVector
one entry of time series
Definition: element.h:287
H5::VectorSerie< double > * plotVectorSerie
time series
Definition: element.h:282
std::vector< std::string > plotColumns
columns of time series
Definition: element.h:292
void setPlotAttribute(const std::string &name, const T &value)
Set a plot attribute: static data attached as key/value pairs to the plot datasets/groups.
Definition: element.h:182
MBXMLUtils::DOMEvalException domEvalError
Special XML helper variable.
Definition: element.h:271
std::string name
name of element
Definition: element.h:260
const std::string & getName() const
Definition: element.h:110
PlotFeatureMap plotFeature
plot feature
Definition: element.h:309
DynamicSystemSolver * ds
dynamic system
Definition: element.h:277
DynamicSystemSolver * getDynamicSystemSolver()
Definition: element.h:123
int computeLevel()
computes the length of the pathes in the graph that represents the dependencies between all elements.
Definition: element.cc:292
void setPlotFeatureForChildren(const PlotFeatureEnum &pf, bool value)
Set a plot feature for the children of this object.
Definition: element.cc:243
void setName(const std::string &str)
Definition: element.h:115
basic error class for mbsim
Definition: mbsim_event.h:39
Definition: plotfeatureenum.h:29
namespace MBSim
Definition: bilateral_constraint.cc:30