-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkResidualControls.H
68 lines (60 loc) · 1.46 KB
/
checkResidualControls.H
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
// Residual control used?
bool resControlUsed = false;
int nFluidControlled = fluidRegions.size();
int nSolidControlled = solidRegions.size();
// Check wheater there is a single regions that uses residual control
forAll(fluidRegions, i)
{
if (residualControlUsedFluid[i])
{
resControlUsed = true;
break;
}
}
forAll(solidRegions, i)
{
if(residualControlUsedSolid[i])
{
resControlUsed = true;
break;
}
}
if (resControlUsed)
{
int nFluidConv = 0;
int nSolidConv = 0;
// Sum of all converged regions (Note: if no residual control is used
// the residualReached* flag is already set to true)
forAll(fluidRegions, i)
{
if (residualReachedFluid[i])
{
nFluidConv++;
}
}
forAll(solidRegions, i)
{
if (residualReachedSolid[i])
{
nSolidConv++;
}
}
if (nFluidConv == nFluidControlled && nSolidConv == nSolidControlled)
{
// Activate flag to go to the 'Final' loop using the 'Final'
// relaxation factors
allRegionsConverged = true;
}
}
if (!runTime.run())
{
Info<< "\nRegions not converged after " << runTime.timeName()
<< " iterations" << endl;
}
else if (runTime.run() && resControlUsed && allRegionsConverged)
{
Info<< "\nRegions converged after " << runTime.timeName()
<< " iterations" << endl;
// Save converged time step and end the run
runTime.writeAndEnd();
}