• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

step/stepcore

  • sources
  • kde-4.12
  • kdeedu
  • step
  • stepcore
solver.h
Go to the documentation of this file.
1 /* This file is part of StepCore library.
2  Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
3 
4  StepCore library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  StepCore library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with StepCore; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
23 #ifndef STEPCORE_SOLVER_H
24 #define STEPCORE_SOLVER_H
25 
26 #include "object.h"
27 #include "vector.h"
28 
29 namespace StepCore
30 {
31 
70 class Solver: public Object
71 {
72  //Q_OBJECT
73  STEPCORE_OBJECT(Solver)
74 
75 public:
77  typedef int (*Function)(double t, const double* y, const double* yvar,
78  double* f, double* fvar, void* params);
79 
81  explicit Solver(int dimension = 0, Function function = NULL,
82  void* params = NULL, double stepSize = 0.001);
84  Solver(double stepSize);
85 
86  virtual ~Solver() {}
87 
89  QString solverType() const { return metaObject()->className(); }
90 
92  int dimension() const { return _dimension; }
94  virtual void setDimension(int dimension) { _dimension = dimension; }
95 
97  Function function() const { return _function; }
99  virtual void setFunction(Function function) { _function = function; }
100 
102  void* params() const { return _params; }
104  virtual void setParams(void* params) { _params = params; }
105 
107  double stepSize() const { return _stepSize; }
109  virtual void setStepSize(double stepSize) { _stepSize = stepSize; }
110 
112  double toleranceAbs() const { return _toleranceAbs; }
114  virtual void setToleranceAbs(double toleranceAbs) { _toleranceAbs = toleranceAbs; }
115 
117  double toleranceRel() const { return _toleranceRel; }
119  virtual void setToleranceRel(double toleranceRel) { _toleranceRel = toleranceRel; }
120 
122  double localError() const { return _localError; }
124  double localErrorRatio() const { return _localErrorRatio; }
125 
127  virtual int doCalcFn(double* t, const VectorXd* y, const VectorXd* yvar = 0,
128  VectorXd* f = 0, VectorXd* fvar = 0) = 0;
129 
138  virtual int doEvolve(double* t, double t1, VectorXd* y, VectorXd* yvar) = 0;
139 
140 public:
142  enum { OK = 0,
143  ToleranceError = 2048,
144  InternalError = 2049,
145  CollisionDetected = 4096,
146  IntersectionDetected = 4097,
147  Aborted = 8192,
148  CollisionError = 16384,
149  ConstraintError = 32768
150  };
151 
152 protected:
153  int _dimension;
154  Function _function;
155  void* _params;
156 
157  double _stepSize;
158  double _toleranceAbs;
159  double _toleranceRel;
160  double _localError;
161  double _localErrorRatio;
162 };
163 
164 inline Solver::Solver(int dimension, Function function, void* params, double stepSize)
165  : _dimension(dimension), _function(function), _params(params), _stepSize(stepSize),
166  _toleranceAbs(0.001), _toleranceRel(0.001), _localError(0), _localErrorRatio(0)
167 {
168 }
169 
170 inline Solver::Solver(double stepSize)
171  : _dimension(0), _function(0), _params(0), _stepSize(stepSize),
172  _toleranceAbs(0.001), _toleranceRel(0.001), _localError(0), _localErrorRatio(0)
173 {
174 }
175 
176 } // namespace StepCore
177 
178 #endif
179 
StepCore::Solver::InternalError
Definition: solver.h:144
StepCore::Solver::_stepSize
double _stepSize
Definition: solver.h:157
StepCore::Solver::doEvolve
virtual int doEvolve(double *t, double t1, VectorXd *y, VectorXd *yvar)=0
Integrate.
StepCore::Object
Root of the StepCore classes hierarchy.
Definition: object.h:57
StepCore::Solver::params
void * params() const
Get callback function params.
Definition: solver.h:102
StepCore::Solver::_toleranceAbs
double _toleranceAbs
Definition: solver.h:158
StepCore::Solver
Generic Solver interface.
Definition: solver.h:70
StepCore::Solver::OK
Definition: solver.h:142
StepCore::Solver::Solver
Solver(int dimension=0, Function function=NULL, void *params=NULL, double stepSize=0.001)
Cunstructs a solver.
Definition: solver.h:164
StepCore::Solver::_localErrorRatio
double _localErrorRatio
Definition: solver.h:161
StepCore::Solver::Function
int(* Function)(double t, const double *y, const double *yvar, double *f, double *fvar, void *params)
Callback function type.
Definition: solver.h:77
StepCore::Solver::_params
void * _params
Definition: solver.h:155
StepCore::Solver::toleranceAbs
double toleranceAbs() const
Get absolute allowed local tolerance.
Definition: solver.h:112
StepCore::Solver::_localError
double _localError
Definition: solver.h:160
StepCore::Solver::IntersectionDetected
Definition: solver.h:146
StepCore::Solver::CollisionDetected
Definition: solver.h:145
StepCore::Solver::setParams
virtual void setParams(void *params)
Set callback function params.
Definition: solver.h:104
StepCore::Solver::setToleranceAbs
virtual void setToleranceAbs(double toleranceAbs)
Set absolute allowed local tolerance.
Definition: solver.h:114
StepCore::Solver::solverType
QString solverType() const
Get solver type.
Definition: solver.h:89
StepCore::Solver::CollisionError
Definition: solver.h:148
StepCore::Solver::_toleranceRel
double _toleranceRel
Definition: solver.h:159
StepCore::Solver::Aborted
Definition: solver.h:147
StepCore::Solver::_function
Function _function
Definition: solver.h:154
StepCore::Solver::_dimension
int _dimension
Definition: solver.h:153
StepCore::Solver::dimension
int dimension() const
Get ODE dimension.
Definition: solver.h:92
StepCore::Solver::toleranceRel
double toleranceRel() const
Get relative allowed local tolerance.
Definition: solver.h:117
StepCore::Solver::setFunction
virtual void setFunction(Function function)
Set callback function.
Definition: solver.h:99
object.h
Object, MetaObject and MetaProperty classes.
vector.h
StepCore::Solver::stepSize
double stepSize() const
Get step size.
Definition: solver.h:107
StepCore::Solver::doCalcFn
virtual int doCalcFn(double *t, const VectorXd *y, const VectorXd *yvar=0, VectorXd *f=0, VectorXd *fvar=0)=0
Calculate function value.
StepCore::Solver::ToleranceError
Definition: solver.h:143
StepCore::Solver::setDimension
virtual void setDimension(int dimension)
Set ODE dimension.
Definition: solver.h:94
StepCore::Solver::setStepSize
virtual void setStepSize(double stepSize)
Set step size (solver can adjust it later)
Definition: solver.h:109
STEPCORE_OBJECT
#define STEPCORE_OBJECT(_className)
Definition: object.h:49
StepCore::Solver::localErrorRatio
double localErrorRatio() const
Get local tolerance calculated at last step.
Definition: solver.h:124
StepCore::Solver::localError
double localError() const
Get error estimation from last step.
Definition: solver.h:122
StepCore::Solver::ConstraintError
Definition: solver.h:149
StepCore::Solver::setToleranceRel
virtual void setToleranceRel(double toleranceRel)
Set relative allowed local tolerance.
Definition: solver.h:119
StepCore::Solver::~Solver
virtual ~Solver()
Definition: solver.h:86
StepCore::VectorXd
Eigen::VectorXd VectorXd
Definition: vector.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:43:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal