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); + } } }