-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprocessVortexMoment.cpp
More file actions
58 lines (55 loc) · 1.86 KB
/
Copy pathprocessVortexMoment.cpp
File metadata and controls
58 lines (55 loc) · 1.86 KB
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
#include "FileIO.h"
#include "Util.h"
#include "LBMData.h"
#include "IncFlow.h"
#include "LineData.h"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <map>
#include <set>
#include <numeric>
#include <iostream>
using namespace std;
std::string VortexMoment(IncFlow &baseflow) {
std::vector<double> W_zfield = baseflow.GetPhys(baseflow.GetPhysID("W_z"));
std::vector<double> integrandx(W_zfield.size());
std::vector<double> integrandy(W_zfield.size());
std::vector<double> integrandx2y2(W_zfield.size());
for(size_t i=0; i<W_zfield.size(); ++i) {
double x = baseflow.GetCoordValue(0, i) ;
double y = baseflow.GetCoordValue(1, i) ;
if(y<0) {
W_zfield[i] = 0.;
}
integrandx[i] = W_zfield[i]*x;
integrandy[i] = W_zfield[i]*y;
}
double gamma = baseflow.Integrate(W_zfield);
double centerx = baseflow.Integrate(integrandx) / gamma;
double centery = baseflow.Integrate(integrandy) / gamma;
for(size_t i=0; i<W_zfield.size(); ++i) {
double x = baseflow.GetCoordValue(0, i) - centerx;
double y = baseflow.GetCoordValue(1, i) - centery ;
integrandx2y2[i] = W_zfield[i]*(x*x+y*y);
}
double sigma = sqrt(baseflow.Integrate(integrandx2y2) / gamma);
char buffer[1000];
sprintf(buffer, "%25.14f %25.14f %25.14f %25.14f ", gamma, centerx, centery, sigma);
return std::string(buffer);
}
int main(int argc, char* argv[]) {
string flowfilename;
if(argc<2) {
cout << "1 input files requred: flow field with vorticity" << std::endl;
return argc - 2;
}
flowfilename = argv[1];
// load uniform grid of phi file
IncFlow baseflow;
baseflow.InputData(flowfilename);
string res = VortexMoment(baseflow);
printf("Volume force; friction force; acceleration force; viscous pressure force\n");
printf("%s %s\n", flowfilename.c_str(), res.c_str());
return 0;
}