-
Notifications
You must be signed in to change notification settings - Fork 3
/
CSolver_AWS.hpp
236 lines (186 loc) · 5.67 KB
/
CSolver_AWS.hpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#ifndef _CSOLVERAWSH_
#define _CSOLVERAWSH_
#include <omp.h>
#include <chrono>
#include <iostream>
#include <fstream>
#include "Macros.hpp"
#include "Utils.hpp"
#include "SpongeBC.hpp"
#include "AbstractCSolver.hpp"
#include "AeroOptics.hpp"
#include "PngWriter.hpp"
using namespace std::chrono;
class CSolver_AWS: public AbstractCSolver{
public:
double alphaF;
double mu_ref;
//Make local copies for macros...
int Nx, Ny, Nz, N;
int blocksize;
//Track the current time and timestep
int timeStep;
double time;
int filterTimeStep;
std::chrono::system_clock::time_point t1Save, t2Save;
//Kill solver condition
bool done;
//non-conserved data
double *U,
*V,
*W,
*T,
*p,
*mu,
*Amu,
*k,
*sos;
//derivatives of data
double *Ux, *Uy, *Uz;
double *Vx, *Vy, *Vz;
double *Wx, *Wy, *Wz;
double *Uxx, *Uyy, *Uzz;
double *Vxx, *Vyy, *Vzz;
double *Wxx, *Wyy, *Wzz;
double *Uxy, *Uxz, *Uyz;
double *Vxy, *Vxz, *Vyz;
double *Wxy, *Wxz, *Wyz;
double *Tx, *Ty, *Tz;
double *Txx, *Tyy, *Tzz;
double *contEulerX, *contEulerY, *contEulerZ;
double *momXEulerX, *momXEulerY, *momXEulerZ;
double *momYEulerX, *momYEulerY, *momYEulerZ;
double *momZEulerX, *momZEulerY, *momZEulerZ;
double *engyEulerX, *engyEulerY, *engyEulerZ;
double *temp, *temp2, *temp3, *temp4;
double *transRho, *transRhoU, *transRhoV, *transRhoW, *transRhoE;
double *transUx, *transVx, *transWx;
double *transUy, *transVy, *transWy;
//New memory allocated for AWS solver...
double *transTempUy;
double *transTempVy;
double *transTempWy;
double *transTempUyy;
double *transTempVyy;
double *transTempWyy;
double *transTempTy;
double *transTempTyy;
double *transTempUxy;
double *transTempVxy;
double *transTempWxy;
double *transTempUyz;
double *transTempVyz;
double *transTempWyz;
double *transTempContEuler;
double *transTempXEuler;
double *transTempYEuler;
double *transTempZEuler;
double *transTempEngEuler;
double *turbdiss, *uprime2, *uiprime2, *uvar, *kineticEng;
bool spongeFlag;
SpongeBC *spg;
//Moving Wall BC Velocities
double X0WallV, X0WallW, X1WallV, X1WallW;
double Y0WallU, Y0WallW, Y1WallU, Y1WallW;
double Z0WallU, Z0WallV, Z1WallU, Z1WallV;
//Aero Optics Stuff
AeroOptics *ao;
int aoWriteStep;
//For drawing images...
PngWriter *pngXY;
PngWriter *pngXZ;
PngWriter *pngYZ;
//Constructor to use for this class...
CSolver_AWS(Domain *dom, BC *bc, TimeStepping *ts, double alphaF, double mu_ref, int blocksize, bool useTiming){
//Take in input information and initialize data structures...
this->dom = dom;
this->bc = bc;
this->ts = ts;
this->alphaF = alphaF;
this->mu_ref = mu_ref;
this->blocksize = blocksize;
this->useTiming = useTiming;
ig = new IdealGas(dom, mu_ref);
//give ourselves the local copies of the domain sizes
Nx = dom->Nx;
Ny = dom->Ny;
Nz = dom->Nz;
N = dom->N;
//initialize time and timestep
time = 0.0;
timeStep = 0;
filterTimeStep = 0;
endFlag = false;
t1Save = std::chrono::system_clock::now();
t2Save = std::chrono::system_clock::now();
done = false;
rkLast = false;
//Allocate our arrays for the solver data
initializeSolverData();
//Initialize the sponge boundary conditions if necessary
if(bc->bcX0 == BC::SPONGE || bc->bcX1 == BC::SPONGE || bc->bcY0 == BC::SPONGE || bc->bcY1 == BC::SPONGE || bc->bcZ0 == BC::SPONGE || bc->bcZ1 == BC::SPONGE){
spongeFlag = true;
spg = new SpongeBC(dom, ig, bc);
}else{
spg = NULL;
}
//Initialize Aero Optics Solver
int numAngles = 5;
double maxAngle = 70.0;
aoWriteStep = 1;
ao = new AeroOptics(dom, ig, rho2, p, T, numAngles, maxAngle);
//Initialize our derivative calculations for each direction...
derivX = new Derivatives(dom, bc->bcXType, Derivatives::DIRX);
derivY = new Derivatives(dom, bc->bcYType, Derivatives::DIRY);
derivZ = new Derivatives(dom, bc->bcZType, Derivatives::DIRZ);
//Initialize the filters we're going to use for each direction
filtX = new Filter(alphaF, dom, bc->bcXType, Derivatives::DIRX);
filtY = new Filter(alphaF, dom, bc->bcYType, Derivatives::DIRY);
filtZ = new Filter(alphaF, dom, bc->bcZType, Derivatives::DIRZ);
pngXY = new PngWriter(Nx,Ny);
pngXZ = new PngWriter(Nz,Nx);
pngYZ = new PngWriter(Ny,Nz);
X0WallV = 0.0; X0WallW = 0.0; X1WallV = 0.0; X1WallW = 0.0;
Y0WallU = 0.0; Y0WallW = 0.0; Y1WallU = 0.0; Y1WallW = 0.0;
Z0WallU = 0.0; Z0WallV = 0.0; Z1WallU = 0.0; Z1WallV = 0.0;
}
//Functions required from AbstractCSolver...
void initializeSolverData();
void setInitialConditions();
void preStep();
void preSubStep();
void solveEqnSet();
void updateData();
void postSubStep();
void postStep();
//Pre Step Functions...
void calcDtFromCFL();
//Pre Sub Step Functions...
void preStepBCHandling();
void preStepDerivatives();
//Solve Eqn Set Functions...
void solveContinuity();
void solveXMomentum();
void solveYMomentum();
void solveZMomentum();
void solveEnergy();
//Post Sub Step Functions...
void postStepBCHandling();
void filterConservedData();
void updateNonConservedData();
//Post Step Functions
void calcTurbulenceQuantities();
void calcTaylorGreenQuantities();
void shearLayerInfoCalc();
void updateSponge();
void writeImages();
void checkSolution();
void dumpSolution();
void checkEnd();
void reportAll();
//Inline, Or general solver functions
inline double calcSpongeSource(double phi, double phiSpongeAvg, double sigma){
return sigma*(phiSpongeAvg - phi);
};
};
#endif