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

View File

@ -139,12 +139,6 @@ public:
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
virtual bool execute();

View File

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