From 06af648dc37a10c02531bc8b9d481995fa41ddc6 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 29 Sep 2020 17:21:06 +0100 Subject: [PATCH] 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. --- .../utilities/writeObjects/writeObjects.C | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.C b/src/functionObjects/utilities/writeObjects/writeObjects.C index 679411f8dd..b2a9ab1381 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.C +++ b/src/functionObjects/utilities/writeObjects/writeObjects.C @@ -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(obj); + objRef.IOobject::rename("expr" + name); + writeObjectsBase::writeObject(obj); + objRef.IOobject::rename(name); + } + else + { + writeObjectsBase::writeObject(obj); + } } }