functionObjects::residuals: Write into directory of the start time

This restores the output to that prior to commit 0829dbdf, but retains
the bug fix from that commit.
This commit is contained in:
Will Bainbridge
2024-09-04 16:15:08 +01:00
parent 6aa359dae6
commit f1068151ee
3 changed files with 27 additions and 25 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -92,11 +92,10 @@ void Foam::functionObjects::residuals::writeFileHeader(const label i)
{ {
const word& fieldName = fieldSet_[fieldi]; const word& fieldName = fieldSet_[fieldi];
writeFileHeader<scalar>(fieldName); #define WRITE_FILE_HEADER(Type, nullArg) \
writeFileHeader<vector>(fieldName); writeFileHeader<Type>(fieldName);
writeFileHeader<sphericalTensor>(fieldName); FOR_ALL_FIELD_TYPES(WRITE_FILE_HEADER);
writeFileHeader<symmTensor>(fieldName); #undef WRITE_FILE_HEADER
writeFileHeader<tensor>(fieldName);
} }
file() << endl; file() << endl;
@ -122,11 +121,10 @@ bool Foam::functionObjects::residuals::write()
{ {
const word& fieldName = fieldSet_[fieldi]; const word& fieldName = fieldSet_[fieldi];
writeResidual<scalar>(fieldName); #define WRITE_RESIDUAL(Type, nullArg) \
writeResidual<vector>(fieldName); writeResidual<Type>(fieldName);
writeResidual<sphericalTensor>(fieldName); FOR_ALL_FIELD_TYPES(WRITE_RESIDUAL);
writeResidual<symmTensor>(fieldName); #undef WRITE_RESIDUAL
writeResidual<tensor>(fieldName);
} }
file() << endl; file() << endl;

View File

@ -139,12 +139,6 @@ public:
return wordList::null(); return wordList::null();
} }
//- There are no residuals to report at the start of a run
virtual bool executeAtStart() const
{
return false;
}
//- Execute, currently does nothing //- Execute, currently does nothing
virtual bool execute(); virtual bool execute();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,7 +60,16 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
{ {
if (obr_.foundObject<VolField<Type>>(fieldName)) if (obr_.foundObject<VolField<Type>>(fieldName))
{ {
if (Residuals<Type>::found(mesh_, fieldName)) typename pTraits<Type>::labelType validComponents
(
mesh_.validComponents<Type>()
);
if
(
mesh_.foundObject<Residuals<Type>>(Residuals<Type>::typeName)
&& Residuals<Type>::found(mesh_, fieldName)
)
{ {
const DynamicList<SolverPerformance<Type>>& sp const DynamicList<SolverPerformance<Type>>& sp
( (
@ -69,11 +78,6 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
const Type& residual = sp.first().initialResidual(); const Type& residual = sp.first().initialResidual();
typename pTraits<Type>::labelType validComponents
(
mesh_.validComponents<Type>()
);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {
if (component(validComponents, cmpt) != -1) if (component(validComponents, cmpt) != -1)
@ -84,7 +88,13 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
} }
else else
{ {
file() << tab << "N/A"; for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
if (component(validComponents, cmpt) != -1)
{
writeTabbed(file(), "N/A");
}
}
} }
} }
} }