writeObjects: Prepend field expression names with "expr"

for example

cacheTemporaryObjects
(
    "((1|((1|(1|A(U)))-H(1)))-(1|A(U)))"
);

functions
{
    #includeFunc writeObjects(regExp=off, "((1|((1|(1|A(U)))-H(1)))-(1|A(U)))")
}

writes the temporary field with the name
"expr((1|((1|(1|A(U)))-H(1)))-(1|A(U)))" so that it can be read by paraFoam and
other post-processing tools.
This commit is contained in:
Henry Weller
2020-09-29 17:21:06 +01:00
parent 99cc2c4514
commit 06af648dc3

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ void Foam::functionObjects::writeObjects::writeObject
{
case writeOption::AUTO_WRITE:
{
if(obj.writeOpt() != IOobject::AUTO_WRITE)
if (obj.writeOpt() != IOobject::AUTO_WRITE)
{
return;
}
@ -84,7 +84,7 @@ void Foam::functionObjects::writeObjects::writeObject
}
case writeOption::NO_WRITE:
{
if(obj.writeOpt() != IOobject::NO_WRITE)
if (obj.writeOpt() != IOobject::NO_WRITE)
{
return;
}
@ -115,7 +115,19 @@ void Foam::functionObjects::writeObjects::writeObject
}
else
{
writeObjectsBase::writeObject(obj);
if (obj.name()[0] == '(')
{
// If the object is a temporary field expression prepend with "expr"
const word name(obj.name());
regIOobject& objRef = const_cast<regIOobject&>(obj);
objRef.IOobject::rename("expr" + name);
writeObjectsBase::writeObject(obj);
objRef.IOobject::rename(name);
}
else
{
writeObjectsBase::writeObject(obj);
}
}
}