-
Notifications
You must be signed in to change notification settings - Fork 1
/
stabilitymode.cpp
53 lines (50 loc) · 1.41 KB
/
stabilitymode.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
#include<fstream>
#include<map>
#include<cmath>
#include<algorithm>
#include<set>
#include "IncFlow.h"
#include "Util.h"
using namespace std;
/************
* description
* produce the disturbed flow by
* adding the amplified linear mode to the baseflow
* Usage:
* stabilitymode baseflow.plt amplitude mode.plt
***********/
double func(std::vector<double> p) {
p[0] = 0.;
return p[0];
}
int main(int argc, char *argv[]) {
if (argc<4) {
printf("argc is %d [<4]\n", argc);
exit(-1);
}
string baseflowname(argv[1]);
double amplitude = 0.05;
sscanf(argv[2], "%lf", &litude);
string modename(argv[3]);
IncFlow baseflow;
IncFlow modeflow;
baseflow.InputData(baseflowname, true);
modeflow.InputData(modename, true);
if (modeflow.GetNumPhys()==2) {
modeflow.AddPhysics("w", (void(*)())func);
}
for (int f=0; f<baseflow.GetNumPhys() - 1; ++f) { //no p
for (int p=0; p < baseflow.GetTotPoints(); ++p) {
double v = baseflow.GetPhysValue(f, p) + amplitude * modeflow.GetPhysValue(f, p);
modeflow.SetPhysValue(v, f, p);
}
}
int fw = modeflow.GetNumPhys() - 1;
for (int p=0; p < baseflow.GetTotPoints(); ++p) {
double v = amplitude * modeflow.GetPhysValue(fw, p);
modeflow.SetPhysValue(v, fw, p);
}
modeflow.CalculateVorticity();
modeflow.OutputData("summaryflow.plt");
return 0;
}