-
Notifications
You must be signed in to change notification settings - Fork 3
/
PseudoArclength.cpp
71 lines (52 loc) · 1.54 KB
/
PseudoArclength.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
#include "PseudoArclength.h"
int main(int argc, char *argv[])
{
std::cout << "STRATIFLOW Newton-GMRES Pseudo-Arclength continuation" << std::endl;
if (argc==5)
{
flowParams.Pr = std::stod(argv[4]);
StateVector::ResetForParams();
}
DumpParameters();
stratifloat delta = std::stof(argv[3]);
ExtendedStateVector x1;
ExtendedStateVector x2;
x1.LoadFromFile(argv[1]);
x2.LoadFromFile(argv[2]);
flowParams.Ri = x2.p;
x1.x.RemovePhaseShift();
RemoveAverage(x1.x.u1, flowParams.L3);
RemoveAverage(x1.x.b, flowParams.L3);
x2.x.RemovePhaseShift();
RemoveAverage(x2.x.u1, flowParams.L3);
RemoveAverage(x2.x.b, flowParams.L3);
// see stationarystates.pdf
ExtendedStateVector v;
if (x2.p == x1.p) // special case - vertical gradient
{
v.x = x2.x;
v.x -= x1.x;
v.x *= 1/v.x.Norm();
v.p = 0;
}
else
{
v.x = x2.x;
v.x -= x1.x;
v.x *= 1/(x2.p - x1.p);
v.p = 1/sqrt(1 + v.x.Norm2());
v.x *= v.p;
// take into account choice of sign of sqrt
if (x2.p < x1.p)
{
v *= -1.0;
}
}
ExtendedStateVector guess = x2;
guess.MulAdd(delta, v);
std::cout << "Guess averages: " << IntegrateAllSpace(guess.x.b,1,1,flowParams.L3) << " " << IntegrateAllSpace(guess.x.u1,1,1,flowParams.L3) << std::endl;
PseudoArclengthContinuation solver(x2, v, delta);
solver.EnforceConstraints(guess);
solver.Run(guess);
guess.SaveToFile("final");
}