mbsim 4.0.0 MBSim Kernel

solver.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 _SOLVER_H_
21 #define _SOLVER_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 <string>
28 #include <iostream>
29
30 namespace MBSim {
31
32 class DynamicSystemSolver;
33
38 class Solver : virtual public fmatvec::Atom {
39 public:
43 Solver() { }
44
48 ~Solver() override = default;
49
50 #ifndef SWIG
51 [[noreturn]]
52 #endif
53 void throwError(const std::string &msg) const {
54 throw MBSimError(this, msg);
55 }
56
57 /* INTERFACE FOR DERIVED CLASSES */
61 virtual void execute() = 0;
62
66 virtual void postprocessing();
67
68 virtual void initializeUsingXML(xercesc::DOMElement *element) {
69 // set the XML location of this element which can be used, later, by exceptions.
70 domEvalError=MBXMLUtils::DOMEvalException("", element);
71 }
72
73 virtual const fmatvec::Vec& getInitialState() const = 0;
74
75 void setSystem(DynamicSystemSolver *s) { system=s; }
76 MBSim::DynamicSystemSolver* getSystem() { return system; }
77
78 #ifndef SWIG
79 const MBXMLUtils::DOMEvalException& getDOMEvalError() const { return domEvalError; };
80 #endif
81
82 protected:
86 MBSim::DynamicSystemSolver* system;
87
88 #ifndef SWIG
89 MBXMLUtils::DOMEvalException domEvalError;
91 #endif
92 };
93
94 }
95
96 #endif /* _SOLVER_H_ */
MBSim::Solver
solver-interface for dynamic systems
Definition: solver.h:38
MBSim::DynamicSystemSolver
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
MBSim::Solver::~Solver
~Solver() override=default
destructor
MBSim::Solver::system
MBSim::DynamicSystemSolver * system
dynamic system
Definition: solver.h:79
MBSim::Solver::domEvalError
MBXMLUtils::DOMEvalException domEvalError
Special XML helper variable.
Definition: solver.h:90
MBXMLUtils::DOMEvalException
MBSim::Solver::Solver
Solver()
constructor
Definition: solver.h:43
MBSim::Solver::postprocessing
virtual void postprocessing()
Definition: solver.cc:25
MBSim::MBSimError
basic error class for mbsim
Definition: mbsim_event.h:39
MBSim::Solver::execute
virtual void execute()=0
start solving the dynamic system set by setSystem.
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30