mbsim 4.0.0 MBSim Kernel

root_finding_integrator.h
1 /* Copyright (C) 2004-2018 Martin Förg
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 *
18 * Contact:
19 * martin.o.foerg@googlemail.com
20 *
21 */
22
23 #ifndef _ROOT_FINDING_INTEGRATOR_H_
24 #define _ROOT_FINDING_INTEGRATOR_H_
25
26 #include "integrator.h"
27
28 namespace MBSim {
29
32 class RootFindingIntegrator : public Integrator {
33
34 protected:
35
36 // Helper function to check if svLast and svStepEnd has a sign change in any element.
37 bool signChangedWRTsvLast(const fmatvec::Vec &svStepEnd) const;
38
40 double dtRoot{1e-10};
41
43 bool plotOnRoot{false};
44
46 double gMax{-1};
48 double gdMax{-1};
49
50 fmatvec::Vec svLast;
51 bool shift{false};
52
53 public:
54
56 void setRootFindingAccuracy(double dtRoot_) { dtRoot = dtRoot_; }
57
59 void setPlotOnRoot(bool b) { plotOnRoot = b; }
60
62 void setToleranceForPositionConstraints(double gMax_) { gMax = gMax_; }
63
65 void setToleranceForVelocityConstraints(double gdMax_) { gdMax = gdMax_; }
66
68 double getToleranceForPositionConstraints() { return gMax; }
69
71 double getToleranceForVelocityConstraints() { return gdMax; }
72
73 virtual void initializeUsingXML(xercesc::DOMElement *element);
74 };
75
76 }
77
78 #endif
MBSim::RootFindingIntegrator::setToleranceForVelocityConstraints
void setToleranceForVelocityConstraints(double gdMax_)
Set the maximum allowed velocity drift.
Definition: root_finding_integrator.h:65
MBSim::RootFindingIntegrator::plotOnRoot
bool plotOnRoot
Definition: root_finding_integrator.h:43
MBSim::RootFindingIntegrator::gMax
double gMax
Definition: root_finding_integrator.h:46
MBSim::RootFindingIntegrator::getToleranceForPositionConstraints
double getToleranceForPositionConstraints()
Get the maximum allowed position drift.
Definition: root_finding_integrator.h:68
MBSim::Integrator
integrator-interface for dynamic systems
Definition: integrator.h:37
MBSim::RootFindingIntegrator::getToleranceForVelocityConstraints
double getToleranceForVelocityConstraints()
Get the maximum allowed velocity drift.
Definition: root_finding_integrator.h:71
MBSim::RootFindingIntegrator
Integrator with root-finding.
Definition: root_finding_integrator.h:32
MBSim::RootFindingIntegrator::dtRoot
double dtRoot
Definition: root_finding_integrator.h:40
MBSim::RootFindingIntegrator::setPlotOnRoot
void setPlotOnRoot(bool b)
Define wether to trigger a plot before and after each found root.
Definition: root_finding_integrator.h:59
MBSim::RootFindingIntegrator::initializeUsingXML
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: root_finding_integrator.cc:44
MBSim::RootFindingIntegrator::gdMax
double gdMax
Definition: root_finding_integrator.h:48
MBSim::RootFindingIntegrator::setRootFindingAccuracy
void setRootFindingAccuracy(double dtRoot_)
Define the root-finding accuracy.
Definition: root_finding_integrator.h:56
MBSim::RootFindingIntegrator::setToleranceForPositionConstraints
void setToleranceForPositionConstraints(double gMax_)
Set the maximum allowed position drift.
Definition: root_finding_integrator.h:62
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30