-
Notifications
You must be signed in to change notification settings - Fork 1
/
xi_u_transformation.cpp
48 lines (39 loc) · 1.31 KB
/
xi_u_transformation.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
//
// Created by Simone Ulzega on 09.06.21.
//
#include <vector>
using namespace std;
//// **********************************************************************
//// Forward transformation xi -> u
vector<double> xi2u(int nx, int jx, const vector<double> & xi){
vector<double> u(nx*jx+1);
for (size_t s = 0; s < nx; ++s)
{
u[s*jx] = xi[s*jx];
for (int k = 2; k <= jx; ++k)
u[s*jx+k-1] = xi[s*jx+k-1] - ( ((double)k-1)*xi[s*jx+k] + xi[s*jx] )/(double)k;
}
u[nx*jx] = xi[nx*jx];
return u;
}
//// **********************************************************************
//// **********************************************************************
//// Back transformation u -> xi
vector<double> u2xi(int nx, int jx, const vector<double> & u){
double temp;
vector<double> out(nx*jx+1);
for (size_t s = 0; s < nx; ++s)
{
out[s*jx] = u[s*jx];
for (size_t k = 2; k <= jx; ++k){
temp = 0.0;
for (size_t l = k; l <= jx + 1; ++l){
temp += (((double)k-1.0)/((double)l-1.0)) * u[s*jx+l-1];
};
out[s*jx+k-1] = temp + (((double)jx-(double)k+1.0)/(double)jx) * u[s*jx];
}
}
out[nx*jx] = u[nx*jx];
return out;
}
//// **********************************************************************