-
Notifications
You must be signed in to change notification settings - Fork 3
/
NewtonKrylov.cpp
57 lines (40 loc) · 1.1 KB
/
NewtonKrylov.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
#include "BasicNewtonKrylov.h"
int main(int argc, char *argv[])
{
std::cout << "STRATIFLOW Newton-GMRES" << std::endl;
flowParams.Ri = std::stod(argv[1]);
StateVector guess;
if (argc == 7)
{
flowParams.Re = 1000;
flowParams.Pr = std::stof(argv[2]);
StateVector::ResetForParams();
StateVector x1;
StateVector x2;
x1.LoadFromFile(argv[3]);
x2.LoadFromFile(argv[4]);
stratifloat p1 = std::stof(argv[5]);
stratifloat p2 = std::stof(argv[6]);
StateVector gradient = x2;
gradient -= x1;
gradient *= 1/(p2-p1);
guess = x2;
guess.MulAdd(flowParams.Pr-p2, gradient);
}
else
{
if(argc>3)
{
flowParams.Re = 1000;
flowParams.Pr = std::stof(argv[3]);
StateVector::ResetForParams();
}
guess.LoadFromFile(argv[2]);
}
DumpParameters();
RemoveAverage(guess.u1, flowParams.L3);
RemoveAverage(guess.b, flowParams.L3);
BasicNewtonKrylov solver;
solver.Run(guess);
guess.SaveToFile("final");
}