-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeIntegEuler.cpp
82 lines (64 loc) · 2.27 KB
/
TimeIntegEuler.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
72
73
74
75
76
77
78
79
80
81
82
#include "TimeIntegEuler.h"
TimeIntegEuler::TimeIntegEuler(Type limiterType, int_t limitVar, real_t CFL, real_t targetTime, std::shared_ptr<ConvFlux> convFlux, std::vector<std::shared_ptr<Zone>> zone, std::vector<std::shared_ptr<Boundary>> bdry)
:TimeInteg(limiterType, limitVar, CFL, targetTime, convFlux, zone, bdry)
{
_temp_DOF.resize(zone.size());
for (int_t inum = 0; inum < zone.size(); ++inum)
{
_temp_DOF[inum].resize(zone[inum]->getPolyOrder() + 1);
for (int_t idegree = 0; idegree <= zone[inum]->getPolyOrder(); ++idegree)
_temp_DOF[inum][idegree].resize(zone[inum]->getGrid()->getNumCell());
}
}
TimeIntegEuler::~TimeIntegEuler()
{
}
bool TimeIntegEuler::march(std::vector<std::shared_ptr<Zone>> zone)
{
// Apply boundary condition
for(int_t inum = 0; inum < zone.size(); ++inum)
_bdry[inum]->apply(zone[inum]);
// Marching starts
bool procedure = true;
if (abs(_currentTime) < epsilon) MESSAGE("Marching starts.....");
// Calculate time step
if ((_currentTime + _timeStep) > _targetTime)
{
_timeStep = _targetTime - _currentTime;
procedure = false;
}
else computeTimeStep(zone);
// Apply hMLP limiter
_limiter->hMLP_Limiter(zone);
// Pressure fix
_pressureFix->apply(zone);
// Save previous degree of freedom
for(int_t inum = 0; inum < zone.size(); ++inum)
_prev_DOF[inum] = zone[inum]->getDOF();
// Calculate RHS
for(int_t inum = 0; inum < zone.size(); ++inum)
_temp_RHS[inum] = computeRHS(zone, inum);
// Calculate DOF
for (int_t inum = 0; inum < zone.size(); ++inum)
{
for (int_t idegree = 0; idegree <= zone[inum]->getPolyOrder(); ++idegree)
{
for (int_t icell = 0; icell < zone[inum]->getGrid()->getNumCell(); ++icell)
_temp_DOF[inum][idegree][icell] = _prev_DOF[inum][idegree][icell] + _timeStep*_temp_RHS[inum][idegree][icell];
}
}
for(int_t inum = 0; inum < zone.size(); ++inum)
zone[inum]->setDOF(_temp_DOF[inum]);
// Apply hMLP limiter
_limiter->hMLP_Limiter(zone);
// Pressure fix
_pressureFix->apply(zone);
// Calculate solution
for(int_t inum = 0; inum < zone.size(); ++inum)
zone[inum]->calSolution();
// Update current time
_currentTime += _timeStep;
// Print finish condition
if (!procedure) print();
return procedure;
}