-
Notifications
You must be signed in to change notification settings - Fork 9
/
FLCBDF.h
185 lines (156 loc) · 5.23 KB
/
FLCBDF.h
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef FLCBDF_H
#define FLCBDF_H
#include <fstream>
#include <iostream>
#include "Definitions.h"
#include "Integrator.h"
#include "Utilities.h"
#include "DaeDefinition.h"
#include "LinearSolver.h"
#include "ModifiedNewton.h"
#include "Jacobian.h"
#include "VectorNorm.h"
#include "DataCollector.h"
#include "Vec.h"
#include "VecOperators.h"
#include "VecBlas.h"
#include "Chronograph.h"
namespace Daetk
{
class FLCBDF : public Integrator
{
public:
FLCBDF();
virtual ~FLCBDF();
FLCBDF(DaeDefinition&,LinearSolver&,NonlinearSolver&,Jacobian&,
VectorNorm&,DataCollector&);
bool takeInitialSteps(const real& tout,real& tStep,Vec& solutionAtTStep,
Vec& sp);
bool takeInitialStepsOriginal(const real& tout,real& tStep,Vec& solutionAtTStep,
Vec& sp);
bool takeInitialStepsWithRichExtrap(const real& tout,real& tStep,Vec& solutionAtTStep,
Vec& sp);
bool takeInitialStepsWithModifiedCoefs(const real& tout,real& tStep,Vec& solutionAtTStep,
Vec& sp);
bool step(const real& tout,real& tStep,Vec& solutionAtTStep, Vec& sp);
bool stepSpecial(const real& tout,real& tStep,Vec& solutionAtTStep, Vec& sp);
bool calculateSolution(const real& tout,Vec& solutionAtTout, Vec& sp);
bool calculateSteadyStateSolution(Vec& solutionAtTout, Vec& sp, real sstol);
void useFixedStep(const real step);
void useFixedOrder(const int order);
void updateJacobians();
void useInterpolant();
void reset();
//for testing startup procedures and step size choice
void setStepSizeProcedure(const int& stepSizeFlag);
void setStepIncreaseFloor(const real& floorIn);
void setStepIncreaseCeiling(const real& ceilIn);
void setStepDecreaseFloor(const real& floorIn);
void setStepDecreaseCeiling(const real& ceilIn);
void setStartupProcedure(const int& startFlag);
void setStepIncreaseFloorForStartup(const real& floorIn);
void setStepIncreaseCeilingForStartup(const real& ceilIn);
void setStepDecreaseFloorForStartup(const real& floorIn);
void setStepDecreaseCeilingForStartup(const real& ceilIn);
void setRichardsonExtrapolationOrder(const int& richExtrapOrder);
private:
bool prepareJacobian,
predictorAlreadyUpdated,
firstCallToSolver,
jacobianIsOld,
correctorStepFailed,
kRaisedOnLastStep,
USE_FIXED_STEP,
USE_FIXED_ORDER,
UPDATE_JACOBIANS,
STEP_EXACT;
int neq, //number of equtions
k, //order
kLast,
constStepsTaken,
kLastUpdate,
constStepsTakenLastUpdate,
stepsFailed,
errorFailures,
MAX_FAILURES,
shortCutFactor,
kFixed;
real h, //stepsize
hLast,
hLastUpdate,
tn, //time of previous step
tnPlusH,
error,
errorEstimate,
errorRichExt, //seg for Richardson Extrapolation
norm_yCminusyP,
convergenceFactor, //for nonlinear solver
hFixed;
Vec *yn,*ynprime, //solution values at tn
yCminusyP,tempvec;
//coefficient data
real psiNp1[7],
alphaNp1[6],
betaNp1[6],
sigmaNp1[7],
gammaNp1[6],
alphaS,
alphaoNp1,
alphaOld,
alphaLast;
//data members for startup routines
int startupType; // 0 original
// 1 original routine with user dependent
// floor/ceiling on step size growth
// 2 Richardson Extrapolation
//bounds for ratio used in step size increase/decrease for startup
real stepIncreaseCeilingStartup,
stepIncreaseFloorStartup,
stepDecreaseCeilingStartup,
stepDecreaseFloorStartup;
//mwf add for Richardson extrapolation configuration
int forceRichardsonExtrapolationOrder;
int chooseStepSizeFlag; // 0 original
// 1 original routine with user dependent
// floor/ceiling on step size growth
//bounds for ratio used in step size increase/decrease for general running
real stepIncreaseCeiling,
stepIncreaseFloor,
stepDecreaseCeiling,
stepDecreaseFloor;
// seg--timing each step during startup routine
Chronograph clock;
real stepRunTime;
real norm_yByS; // variables for extrapolation norm
Vec tmp,
yBigStep,ySmallStep, // temporary vectors for initialSteps routine -- seg
yExt,ySminusyB;
Vec phiN[7];
DaeDefinition* dae;
DataCollector* data;
LinearSolver* linearSolver;
NonlinearSolver* nonlinearSolver;
Jacobian* jacobian;
VectorNorm* weightedNorm;
//private member functions
bool analyzeJacobian();
bool evaluateJacobian();
void computeDeltaForJacobian();
void resetCoefficients();
void updateCoefficients();
void chooseOrderForStep();
void predictor();
void interpolant(const real& T,Vec& yAtT,Vec& yPAtT);
void chooseStepSize();
void chooseStepSizeOriginal();
//mwf added so that I can try and eliminate need to interpolate to
//mwf time for final soluiton
void chooseStepSize(const real& tin, const real& tout);
void chooseStepSizeOriginal(const real& tin, const real& tout);
void chooseStepSizeStartup(const real& tin, const real& tout);
bool corrector();
bool errorForStepTooLarge();
void checkStepSize();
};
}//Daetk
#endif