This repository was archived by the owner on May 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathSolverDefaultImplementation.h
More file actions
125 lines (96 loc) · 4.56 KB
/
SolverDefaultImplementation.h
File metadata and controls
125 lines (96 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
/** @addtogroup coreSolver
*
* @{
*/
#include <Core/Solver/SimulationMonitor.h>
#ifdef RUNTIME_PROFILING
#include <Core/Utils/extension/measure_time.hpp>
#endif
/// typedef to hand over (callback) functions to fortran routines
typedef int (*U_fp)(...);
/*****************************************************************************/
/**
Services, which can be used by numerical integration methods (solver).
Implementation of standart functions (e.g. setStartTime(...), etc.).
Provision of member variables used by all solvers.
\date October, 1st, 2008
\author
*/
/*****************************************************************************
Copyright (c) 2008, OSMC
*****************************************************************************/
class BOOST_EXTENSION_SOLVER_DECL SolverDefaultImplementation : public SimulationMonitor
{
public:
void updateEventState();
SolverDefaultImplementation(IMixedSystem* system, ISolverSettings* settings);
virtual ~SolverDefaultImplementation();
/// Set start time for numerical solution
void setStartTime(const double& t);
/// Set end time for numerical solution
void setEndTime(const double& t);
/// Set the initial step size (needed for reinitialization after external zero search)
void setInitStepSize(const double& h);
/// Assemble system and (re-)initialize solver
void initialize();
/// Provides the status of the solver after returning
const ISolver::SOLVERSTATUS getSolverStatus();
/// Determines current status of a all zero functions (checks for a change in sign in any of all zero functions)
void setZeroState();
/// Called by solver after every successful integration step (calls writeOutput)
void writeToFile(const int& stp, const double& t, const double& h);
protected:
// Member variables
//---------------------------------------------------------------
IMixedSystem
*_system; ///< System to be solved
ISolverSettings
*_settings; ///< Settings for the solver
double
_tInit, ///< (initiale) Startzeit (wird nicht vom Solver verändert)
_tCurrent, ///< current time (is changed by the solver)
_tEnd, ///< end time
_tLastSuccess, ///< time of last successful integration step (before zero crossing)
_tLastUnsucess, ///< time of last unsuccessful integration step (after zero crossing)
_tLargeStep;
double
_h; ///< step size (changed by the solver)
bool
_firstCall, ///< Denotes the first call to the solver. May be used to call init()
_firstStep; ///< Denotes the first step. May be used for (re-)initialization to call giveVars(...)
int
_totStps, ///< Total number of time integration steps
_accStps, ///< Number of accepted time integration steps
_rejStps, ///< Number of rejected time integration steps
_zeroStps, ///< Number of zero search steps during whole time integration interval
_zeros; ///< Number of zeros in whole time integration interval
int
_dimSys, ///< Number of equations (=dimension of the system)
_dimZeroFunc; ///< Number of zero functions
bool*
_events; ///< Vector (of dimension _dimZeroF) indicating which zero function caused an event
event_times_type ///< Map including all time entries and the event ID occurring a time event
_time_events;
double
*_zeroVal, ///< Vector (of dimension _dimZeroF) containing values of all zero functions
*_zeroValInit, ///< Vektor (der Dimension _dimZeroF) mit Nullstellenfunktionswerten am Anfang des Integrationsintervalles
*_zeroValLastSuccess; ///< Vector (of dimension _dimZeroF) containing values of all zero functions of last successful integration step (before zero crossing)
ISolver::ZEROSTATUS
_zeroStatus; ///< Denotes whether a change in sign in at least one zero function occured
ISolver::SOLVERSTATUS
_solverStatus; ///< Denotes the current status of the solver
IWriteOutput::OUTPUT
_outputCommand; ///< Controls the output
private:
/// Definition of signum function
inline static int sgn (const double &c)
{
return (c < 0) ? -1 : ((c == 0) ? 0 : 1);
}
#ifdef RUNTIME_PROFILING
std::vector<MeasureTimeData*> *measureTimeFunctionsArray;
MeasureTimeValues *writeFunctionStartValues, *writeFunctionEndValues;
#endif
};
/** @} */ // end of coreSolver