mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
SolverPerformance: Complete the integration of the templated SolverPerformance<Type>
Now solvers return solver performance information for all components with backward compatibility provided by the "max" function which created the scalar solverPerformance from the maximum component residuals from the SolverPerformance<Type>. The residuals functionObject has been upgraded to support SolverPerformance<Type> so that now the initial residuals for all (valid) components are tabulated, e.g. for the cavity tutorial case the residuals for p, Ux and Uy are listed vs time. Currently the residualControl option of pimpleControl and simpleControl is supported in backward compatibility mode (only the maximum component residual is considered) but in the future this will be upgraded to support convergence control for the components individually. This development started from patches provided by Bruno Santos, See http://www.openfoam.org/mantisbt/view.php?id=1824
This commit is contained in:
@ -35,6 +35,7 @@ namespace Foam
|
||||
defineTypeNameAndDebug(residuals, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::residuals::residuals
|
||||
@ -98,7 +99,13 @@ void Foam::residuals::writeFileHeader(const label i)
|
||||
|
||||
forAll(fieldSet_, fieldI)
|
||||
{
|
||||
writeTabbed(file(), fieldSet_[fieldI]);
|
||||
const word& fieldName = fieldSet_[fieldI];
|
||||
|
||||
writeFileHeader<scalar>(fieldName);
|
||||
writeFileHeader<vector>(fieldName);
|
||||
writeFileHeader<sphericalTensor>(fieldName);
|
||||
writeFileHeader<symmTensor>(fieldName);
|
||||
writeFileHeader<tensor>(fieldName);
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
@ -107,21 +114,15 @@ void Foam::residuals::writeFileHeader(const label i)
|
||||
|
||||
|
||||
void Foam::residuals::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void Foam::residuals::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void Foam::residuals::timeSet()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void Foam::residuals::write()
|
||||
@ -150,4 +151,5 @@ void Foam::residuals::write()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -115,6 +115,10 @@ protected:
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const residuals&);
|
||||
|
||||
//- Output field header information
|
||||
template<class Type>
|
||||
void writeFileHeader(const word& fieldName);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
@ -32,10 +32,37 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::residuals::writeResidual
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
void Foam::residuals::writeFileHeader(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
|
||||
const fvMesh& mesh = field.mesh();
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh.validComponents<Type>()
|
||||
);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
writeTabbed
|
||||
(
|
||||
file(),
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::residuals::writeResidual(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
@ -47,9 +74,25 @@ void Foam::residuals::writeResidual
|
||||
|
||||
if (solverDict.found(fieldName))
|
||||
{
|
||||
const List<solverPerformance> sp(solverDict.lookup(fieldName));
|
||||
const scalar residual = sp.first().initialResidual();
|
||||
file() << token::TAB << residual;
|
||||
const List<SolverPerformance<Type> > sp
|
||||
(
|
||||
solverDict.lookup(fieldName)
|
||||
);
|
||||
|
||||
const Type& residual = sp.first().initialResidual();
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh.validComponents<Type>()
|
||||
);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
file() << token::TAB << component(residual, cmpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user