From 1807f2d20bf9be45b253a534835a37b0d1ba2d05 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 15 Apr 2009 15:14:38 +0200 Subject: [PATCH] backwardsCompatibilityWallFunctions: move files instead of writing fields - this helps avoid trashing carefully crafted input dictionaries --- .../backwardsCompatibilityWallFunctions.C | 12 +++--- ...wardsCompatibilityWallFunctionsTemplates.C | 38 ++++++++++--------- .../backwardsCompatibilityWallFunctions.C | 6 +-- ...wardsCompatibilityWallFunctionsTemplates.C | 38 ++++++++++--------- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C index c86f2f43eb..657dfbb48e 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -64,8 +64,8 @@ tmp autoCreateAlphat } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -104,7 +104,7 @@ tmp autoCreateAlphat ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; alphat().write(); return alphat; @@ -134,8 +134,8 @@ tmp autoCreateMut } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -174,7 +174,7 @@ tmp autoCreateMut ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; mut().write(); return mut; diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 98c750c71a..91f739abfb 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -26,6 +26,7 @@ License #include "backwardsCompatibilityWallFunctions.H" #include "Time.H" +#include "OSspecific.H" #include "wallPolyPatch.H" @@ -77,27 +78,35 @@ autoCreateWallFunctionField } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Upgrading " << fieldName + << " to employ run-time selectable wall functions" << endl; + + // Read existing field + IOobject ioObj + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); - // Read existing epsilon field tmp fieldOrig ( new fieldType ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), + ioObj, mesh ) ); + // rename file + Info<< " Backup original " << fieldName << " to " + << fieldName << ".old" << endl; + mv(ioObj.objectPath(), ioObj.objectPath() + ".old"); + + PtrList > newPatchFields(mesh.boundary().size()); forAll(newPatchFields, patchI) @@ -145,11 +154,6 @@ autoCreateWallFunctionField ) ); - Info<< " Writing backup of original " << fieldName << " to " - << fieldName << ".old" << endl; - fieldOrig().rename(fieldName + ".old"); - fieldOrig().write(); - Info<< " Writing updated " << fieldName << endl; fieldNew().write(); diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C index 949c334726..f7b144a03b 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -63,8 +63,8 @@ tmp autoCreateNut } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -103,7 +103,7 @@ tmp autoCreateNut ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; nut().write(); return nut; diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 563f529d61..10247d493e 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -26,6 +26,7 @@ License #include "backwardsCompatibilityWallFunctions.H" #include "Time.H" +#include "OSspecific.H" #include "wallPolyPatch.H" @@ -77,27 +78,35 @@ autoCreateWallFunctionField } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Upgrading " << fieldName + << " to employ run-time selectable wall functions" << endl; + + // Read existing field + IOobject ioObj + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); - // Read existing epsilon field tmp fieldOrig ( new fieldType ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), + ioObj, mesh ) ); + // rename file + Info<< " Backup original " << fieldName << " to " + << fieldName << ".old" << endl; + mv(ioObj.objectPath(), ioObj.objectPath() + ".old"); + + PtrList > newPatchFields(mesh.boundary().size()); forAll(newPatchFields, patchI) @@ -145,11 +154,6 @@ autoCreateWallFunctionField ) ); - Info<< " Writing backup of original " << fieldName << " to " - << fieldName << ".old" << endl; - fieldOrig().rename(fieldName + ".old"); - fieldOrig().write(); - Info<< " Writing updated " << fieldName << endl; fieldNew().write();