-
Notifications
You must be signed in to change notification settings - Fork 9
/
FullDataFileForRichExtrap.cpp
292 lines (275 loc) · 11.4 KB
/
FullDataFileForRichExtrap.cpp
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#include "FullDataFileForRichExtrap.h"
namespace Daetk
{
using std::setw;
using std::setprecision;
using std::endl;
FullDataFileForRichExtrap::FullDataFileForRichExtrap(const real& t0,const char* filename):
TimingDataFile(filename),
INCLUDE_SOLUTION(true),
tlast(t0),
condition(0),
avgCondition(0),
functionEvaluations(0),
jacobianEvaluations(0),
linearSolverIterations(0),
nonlinearSolverIterations(0),
lineSearches(0),
orderOneStepsTaken(0),
orderTwoStepsTaken(0),
orderThreeStepsTaken(0),
orderFourStepsTaken(0),
orderFiveStepsTaken(0),
errorFailures(0),
nonlinearSolverFailures(0),
linearSolverFailures(0),
totalJacobianEvaluations(0),
totalFunctionEvaluations(0),
totalStepsTaken(0),
totalStepsFailed(0),
totalNonlinearSolverIterations(0),
totalNonlinearSolverFailures(0),
totalLinearSolverIterations(0),
totalLinearSolverFailures(0),
totalLinesearches(0),
totalErrorFailures(0),
globalJacobianEvaluations(0),
globalFunctionEvaluations(0),
globalStepsTaken(0),
globalStepsFailed(0),
globalNonlinearSolverIterations(0),
globalNonlinearSolverFailures(0),
globalLinearSolverIterations(0),
globalLinearSolverFailures(0),
globalLinesearches(0),
globalErrorFailures(0),
globalOrderOneStepsTaken(0),
globalOrderTwoStepsTaken(0),
globalOrderThreeStepsTaken(0),
globalOrderFourStepsTaken(0),
globalOrderFiveStepsTaken(0)
{
Tracer tr("FullDataFileForRichExtrap::FullDataFileForRichExtrap(const real& t0,const int Neq)");
fout<<"======================================================================================================================================"<<endl
<<" k | Step Size | tn |errf|nlsf|ilsf|func|jacs|NLit|L_IT|linS| cond. | error | cpu | errorRichEx | extra |"<<endl;
}
FullDataFileForRichExtrap::~FullDataFileForRichExtrap()
{
Tracer tr("FullDataFileForRichExtrap::~FullDataFileForRichExtrap()");
fout<<endl
<<"Data for entire run"<<endl
<<"------------------------------"<<endl
<<"Jacobians evaluated:--------"<<globalJacobianEvaluations<<endl
<<"Function Evaluations:-------"<<globalFunctionEvaluations<<endl
<<"Steps Taken:----------------"<<globalStepsTaken<<endl
<<"Steps Failed:---------------"<<globalStepsFailed<<endl
<<"Error Failures:-------------"<<globalErrorFailures<<endl
<<"Nonlinear Solver Iterations:"<<globalNonlinearSolverIterations<<endl
<<"Nonlinear Solver Failures:--"<<globalNonlinearSolverFailures<<endl
<<"Linear Solver Iterations:---"<<globalLinearSolverIterations<<endl
<<"Linear Solver Failures:-----"<<globalLinearSolverFailures<<endl
<<"Line searches:--------------"<<globalLinesearches<<endl
<<"Order 1 steps:--------------"<<globalOrderOneStepsTaken<<endl
<<"Order 2 steps:--------------"<<globalOrderTwoStepsTaken<<endl
<<"Order 3 steps:--------------"<<globalOrderThreeStepsTaken<<endl
<<"Order 4 steps:--------------"<<globalOrderFourStepsTaken<<endl
<<"Order 5 steps:--------------"<<globalOrderFiveStepsTaken<<endl
<<endl;
}
void FullDataFileForRichExtrap::stepTaken(int k,real h,real tn, real err)
{ stepTaken(k,h,tn,err,-12345.,-12345.); }
void FullDataFileForRichExtrap::stepTaken(int k,real h,real tn, real err, real cpu, real err2, real extra)
{
avgCondition += condition;
totalStepsTaken++;
totalFunctionEvaluations+=functionEvaluations;
totalJacobianEvaluations+=jacobianEvaluations;
totalNonlinearSolverIterations+=nonlinearSolverIterations;
totalNonlinearSolverFailures+=nonlinearSolverFailures;
totalLinesearches+=lineSearches;
totalLinearSolverIterations+=linearSolverIterations;
totalLinearSolverFailures+=linearSolverFailures;
totalErrorFailures+=errorFailures;
totalStepsFailed+=(errorFailures+nonlinearSolverFailures);
switch(k)
{
case 1:
orderOneStepsTaken++;
break;
case 2:
orderTwoStepsTaken++;
break;
case 3:
orderThreeStepsTaken++;
break;
case 4:
orderFourStepsTaken++;
break;
case 5:
orderFiveStepsTaken++;
break;
}
fout<<setw(3)<<k<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<h<<setw(1)<<"|"
<<setw(14)<<tn<<setw(1)<<"|"
<<setw(4)<<errorFailures<<setw(1)<<"|"
<<setw(4)<<nonlinearSolverFailures<<setw(1)<<"|"
<<setw(4)<<linearSolverFailures<<setw(1)<<"|"
<<setw(4)<<functionEvaluations<<setw(1)<<"|"
<<setw(4)<<jacobianEvaluations<<setw(1)<<"|"
<<setw(4)<<nonlinearSolverIterations<<setw(1)<<"|"
<<setw(4)<<linearSolverIterations<<setw(1)<<"|"
<<setw(4)<<lineSearches<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<condition<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<err<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<cpu<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<err2<<setw(1)<<"|"
<<setw(14)<<setprecision(9)<<extra<<setw(1)<<"|"
<<endl;
errorFailures=0;
functionEvaluations=0;
jacobianEvaluations=0;
nonlinearSolverIterations=0;
nonlinearSolverFailures=0;
linearSolverIterations=0;
linearSolverFailures=0;
lineSearches=0;
}
void FullDataFileForRichExtrap::includeSolution(const real& tout,const Vec& solution)
{
runTime = clock.elapsed();
clock.reset();
if (totalStepsTaken)
avgCondition/=totalStepsTaken;
else
avgCondition=0.0;
fout<<endl
<<"Data over the interval ["<<tlast<<","<<tout<<"]"<<endl
<<"------------------------------"<<endl
<<"Jacobian Evaluations:-------"<<totalJacobianEvaluations<<endl
<<"Function Evaluations:-------"<<totalFunctionEvaluations<<endl
<<"Steps Taken:----------------"<<totalStepsTaken<<endl
<<"Steps Failed:---------------"<<totalStepsFailed<<endl
<<"Error Failures:-------------"<<totalErrorFailures<<endl
<<"Nonlinear Solver Iterations:"<<totalNonlinearSolverIterations<<endl
<<"Nonlinear Solver Failures:--"<<totalNonlinearSolverFailures<<endl
<<"Linear Solver Iterations:---"<<totalLinearSolverIterations<<endl
<<"Linear Solver Failures:-----"<<totalLinearSolverFailures<<endl
<<"Average Condition Number:---"<<avgCondition<<endl
<<"Line Searches:--------------"<<totalLinesearches<<endl
<<"Order 1 steps:--------------"<<orderOneStepsTaken<<endl
<<"Order 2 steps:--------------"<<orderTwoStepsTaken<<endl
<<"Order 3 steps:--------------"<<orderThreeStepsTaken<<endl
<<"Order 4 steps:--------------"<<orderFourStepsTaken<<endl
<<"Order 5 steps:--------------"<<orderFiveStepsTaken<<endl
<<"Wall Clock Time:------------"<<runTime<<endl
<<endl;
int neq = solution.dim();
if (analyticSolutionAvailable)
{
real rnorm;
Vec r(solution.dim());
analyticSolution(tout,r);
fout<<"Solution at t="<<tout<<" Analytic Solution"<<endl<<endl;
for (int i=0;i<neq;i++)
{
fout<<setw(14)<<solution(i)<<setw(3)<<" "<<setw(14)<<r(i)<<endl;
}
rnorm = nrm2(r);
r-=solution;
fout<<endl<<"Relative error= "<<(norm(r)/rnorm)<<endl<<endl;
}
else
{
if (INCLUDE_SOLUTION)
{
fout<<setw(1)<<"Solution at t="<<tout<<endl
<<solution<<endl;
}
}
fout<<"======================================================================================================================================"<<endl
<<" k | Step Size | tn |errf|nlsf|ilsf|func|jacs|NLit|L_IT|linS| cond. | error | cpu | errorRichEx |"<<endl;
globalJacobianEvaluations+=totalJacobianEvaluations;
globalFunctionEvaluations+=totalFunctionEvaluations;
globalStepsTaken+=totalStepsTaken;
globalNonlinearSolverIterations+=totalNonlinearSolverIterations;
globalNonlinearSolverFailures+=totalNonlinearSolverFailures;
globalLinearSolverIterations+=totalLinearSolverIterations;
globalLinearSolverFailures+=totalLinearSolverFailures;
globalLinesearches+=totalLinesearches;
globalErrorFailures+=totalErrorFailures;
globalStepsFailed+=totalStepsFailed;
globalOrderOneStepsTaken+=orderOneStepsTaken;
globalOrderTwoStepsTaken+=orderTwoStepsTaken;
globalOrderThreeStepsTaken+=orderThreeStepsTaken;
globalOrderFourStepsTaken+=orderFourStepsTaken;
globalOrderFiveStepsTaken+=orderFiveStepsTaken;
avgCondition =0;
totalJacobianEvaluations=0;
totalFunctionEvaluations=0;
totalStepsTaken=0;
totalNonlinearSolverIterations=0;
totalNonlinearSolverFailures=0;
totalLinearSolverIterations=0;
totalLinearSolverFailures=0;
totalLinesearches=0;
totalErrorFailures=0;
totalStepsFailed=0;
tlast=tout;
orderOneStepsTaken=0;
orderTwoStepsTaken=0;
orderThreeStepsTaken=0;
orderFourStepsTaken=0;
orderFiveStepsTaken=0;
}
void FullDataFileForRichExtrap::functionEvaluation(){functionEvaluations++;}
void FullDataFileForRichExtrap::jacobianEvaluation(){jacobianEvaluations++;}
void FullDataFileForRichExtrap::linearSolverIteration(){linearSolverIterations++;}
void FullDataFileForRichExtrap::setLinearSolverIterations(int i){linearSolverIterations+=i;}
void FullDataFileForRichExtrap::nonlinearSolverIteration(){nonlinearSolverIterations++;}
void FullDataFileForRichExtrap::lineSearch(){lineSearches++;}
void FullDataFileForRichExtrap::errorFailure(){errorFailures++;}
void FullDataFileForRichExtrap::nonlinearSolverFailure(){nonlinearSolverFailures++;}
void FullDataFileForRichExtrap::linearSolverFailure(){linearSolverFailures++;}
void FullDataFileForRichExtrap::conditionNumber(real& cond){condition = cond;}
int FullDataFileForRichExtrap::getLinearSolverIterations(){return linearSolverIterations;}
int FullDataFileForRichExtrap::getGlobalLinearSolverIterations(){return globalLinearSolverIterations;}
int FullDataFileForRichExtrap::getTotalLinearSolverIterations(){return totalLinearSolverIterations;}
int FullDataFileForRichExtrap::getNonlinearSolverIterations(){return nonlinearSolverIterations;}
int FullDataFileForRichExtrap::getGlobalNonlinearSolverIterations(){return globalNonlinearSolverIterations;}
int FullDataFileForRichExtrap::getTotalNonlinearSolverIterations(){return totalNonlinearSolverIterations;}
int FullDataFileForRichExtrap::getGlobalFunctionEvaluations (){return globalFunctionEvaluations;}
int FullDataFileForRichExtrap::getTotalFunctionEvaluations (){return totalFunctionEvaluations;}
void FullDataFileForRichExtrap::omitSolution(){ INCLUDE_SOLUTION=false;}
void FullDataFileForRichExtrap::reset()
{
globalJacobianEvaluations=0;
globalFunctionEvaluations=0;
globalStepsTaken=0;
globalStepsFailed=0;
globalNonlinearSolverIterations=0;
globalNonlinearSolverFailures=0;
globalLinearSolverIterations=0;
globalLinearSolverFailures=0;
globalLinesearches=0;
globalErrorFailures=0;
globalOrderOneStepsTaken=0;
globalOrderTwoStepsTaken=0;
globalOrderThreeStepsTaken=0;
globalOrderFourStepsTaken=0;
globalOrderFiveStepsTaken=0;
}
//mwf------- added functions for convenience ---------
int FullDataFileForRichExtrap::getGlobalJacobianEvaluations()
{ return globalJacobianEvaluations; }
int FullDataFileForRichExtrap::getGlobalStepsTaken()
{ return globalStepsTaken; }
int FullDataFileForRichExtrap::getGlobalStepsFailed()
{ return globalStepsFailed; }
int FullDataFileForRichExtrap::getGlobalLinesearches()
{ return globalLinesearches; }
int FullDataFileForRichExtrap::getGlobalLinearSolverFailures()
{ return globalLinearSolverFailures; }
int FullDataFileForRichExtrap::getGlobalNonlinearSolverFailures()
{ return globalNonlinearSolverFailures; }
}//Daetk