sloverPerformance in OpenFOAM

How solverPerformance work in OpenFOAM

The research on how solverPerformance works in OpenFOAM comes from how the Iteration and residual are calculated in OpenFOAM. The results that we always see in the command window e.g.

1
2
DICPCG:  Solving for S, Initial residual = 0.0705455, Final residual = 9.09192e-15, No Iterations 4
ExecutionTime = 0.01 s ClockTime = 0 s

Showing this line calls the print() function in SolverPerformance.C:

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
template<class Type>
void Foam::SolverPerformance<Type>::print
(
Ostream& os
) const
{
for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
if (pTraits<Type>::nComponents == 1)
{
os << solverName_ << ": Solving for " << fieldName_;

}
...

if (singular_[cmpt])
...
else
{
os << ", Initial residual = " << component(initialResidual_, cmpt)
<< ", Final residualhah = " << component(finalResidual_, cmpt)
<< ", No Iterations " << nIterations_
<< endl;
}
}
}

We will start the research by digging into a very simple solver called laplacianFoam. In laplacianFoam, the following code will solve the equation:

1
2
3
4
5
6
7
8
9
10
11
12
13
while (simple.correctNonOrthogonal())
{
fvScalarMatrix TEqn
(
fvm::ddt(T) - fvm::laplacian(DT, T)
==
fvOptions(T)
);

fvOptions.constrain(TEqn);
TEqn.solve();
fvOptions.correct(T);
}

where the equation is:

to be continued….