mbsim  4.0.0
MBSim Kernel
integrator.h
1/* Copyright (C) 2004-2014 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@googlemail.com
18 */
19
20#ifndef _INTEGRATOR_H_
21#define _INTEGRATOR_H_
22
23#include <fmatvec/fmatvec.h>
24#include <fmatvec/atom.h>
25#include <mbsim/namespace.h>
26#include <mbsim/mbsim_event.h>
27#include <mbsim/solver.h>
28#include <string>
29
30namespace MBSim {
31
37 class Integrator : public MBSim::Solver {
38 public:
42 Integrator() : name("Integrator") { }
43
47 ~Integrator() override = default;
48
49 /* GETTER / SETTER */
50 void setStartTime(double tStart_) { tStart=tStart_; }
51 void setEndTime(double tEnd_) { tEnd = tEnd_; }
52 void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
53 void setInitialState(const fmatvec::Vec &z0_) { z0 <<= z0_; }
54 double getStartTime() const { return tStart; }
55 double getEndTime() const { return tEnd; }
56 double getPlotStepSize() const { return dtPlot; }
57 const fmatvec::Vec& getInitialState() const override { return z0; }
58 /***************************************************/
59
60 void execute() override { integrate(); }
61
62 /* INTERFACE FOR DERIVED CLASSES */
67 virtual void integrate() = 0;
68
70 void integrate(MBSim::DynamicSystemSolver& sys) { setSystem(&sys); integrate(); }
71
77 void debugInit();
78
79 virtual void preIntegrate() { throwError("preIntegrate is not defined"); }
80 virtual void subIntegrate(double tStop) { throwError("subIntegrate is not defined"); }
81 virtual void postIntegrate() { throwError("postIntegrate is not defined"); }
82
87 void initializeUsingXML(xercesc::DOMElement *element) override;
88
89 protected:
93 double tStart{0.}, tEnd{1.}, dtPlot{1e-4};
94
98 fmatvec::Vec z0;
99
103 std::string name;
104 };
105
106}
107
108#endif /* _INTEGRATOR_H_ */
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
integrator-interface for dynamic systems
Definition: integrator.h:37
void integrate(MBSim::DynamicSystemSolver &sys)
Convinent function: call setSystem(&sys) and integrate()
Definition: integrator.h:70
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: integrator.cc:32
std::string name
name of integrator
Definition: integrator.h:103
fmatvec::Vec z0
initial state
Definition: integrator.h:98
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
~Integrator() override=default
destructor
Integrator()
constructor
Definition: integrator.h:42
double tStart
start, end, plot time
Definition: integrator.h:93
void execute() override
start solving the dynamic system set by setSystem.
Definition: integrator.h:60
void debugInit()
Definition: integrator.cc:47
solver-interface for dynamic systems
Definition: solver.h:38
namespace MBSim
Definition: bilateral_constraint.cc:30