OpenFOAM field reading: Automated the handling of <field>.orig files

Now if a <field> file does not exist first the compressed <field>.gz file is
searched for and if that also does not exist the <field>.orig file is searched
for.

This simplifies case setup and run scripts as now setField for example can read
the <field>.orig file directly and generate the <field> file from it which is
then read by the solver.  Additionally the cleanCase function used by
foamCleanCase and the Allclean scripts automatically removed <field> files if
there is a corresponding <field>.orig file.  So now there is no need for the
Allrun scripts to copy <field>.orig files into <field> or for the Allclean
scripts to explicitly remove them.
This commit is contained in:
Henry Weller
2018-02-14 17:42:14 +00:00
parent 019c2c08dc
commit df6e2da2dd
82 changed files with 31 additions and 95562 deletions

View File

@ -59,13 +59,6 @@ cleanCase()
rm -rf jobInfo > /dev/null 2>&1
rm -rf postProcessing > /dev/null 2>&1
rm -rf TDAC > /dev/null 2>&1
rm -rf probes* > /dev/null 2>&1
rm -rf forces* > /dev/null 2>&1
rm -rf graphs* > /dev/null 2>&1
rm -rf sets > /dev/null 2>&1
rm -rf surfaceSampling > /dev/null 2>&1
rm -rf cuttingPlane > /dev/null 2>&1
rm -rf system/machines > /dev/null 2>&1
if [ -d constant/polyMesh ]
then
@ -83,12 +76,16 @@ cleanCase()
rm -rf constant/tetDualMesh > /dev/null 2>&1
rm -rf VTK > /dev/null 2>&1
rm -rf sequencedVTK > /dev/null 2>&1
rm -f 0/cellLevel 0/pointLevel 0/cellDist constant/cellDecomposition
if [ -e system/blockMeshDict.m4 ]
then
rm -f system/blockMeshDict > /dev/null 2>&1
fi
find . -name "*.orig" -type f -exec sh -c 'rm -f ${0%.*} ${0%.*}.gz' {} \;
}
removeCase()

View File

@ -563,9 +563,11 @@ bool Foam::isFile
error::printStack(Pout);
}
}
return
S_ISREG(mode(name, followLink))
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)));
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)))
|| (checkGzip && S_ISREG(mode(name + ".orig", followLink)));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,15 +53,17 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
ifPtr_ = new ifstream(pathname.c_str());
// If the file is compressed, decompress it before reading.
if (!ifPtr_->good() && isFile(pathname + ".gz", false))
if (!ifPtr_->good())
{
if (isFile(pathname + ".gz", false))
{
delete ifPtr_;
if (IFstream::debug)
{
InfoInFunction << "Decompressing " << pathname + ".gz" << endl;
}
delete ifPtr_;
ifPtr_ = new igzstream((pathname + ".gz").c_str());
if (ifPtr_->good())
@ -69,6 +71,13 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
compression_ = IOstream::COMPRESSED;
}
}
else if (isFile(pathname + ".orig", false))
{
delete ifPtr_;
ifPtr_ = new ifstream((pathname + ".orig").c_str());
}
}
}

View File

@ -33,8 +33,6 @@ rm log.createPatch
# create actual patches
runApplication createPatch -region filmRegion -overwrite
cp 0/ph_rgh.orig 0/ph_rgh
# Run
runApplication `getApplication`

View File

@ -26,8 +26,6 @@ runApplication -s fBurner \
runApplication createPatch -overwrite
cp 0/ph_rgh.orig 0/ph_rgh
runApplication -s master \
decomposePar -force

View File

@ -8,10 +8,6 @@ cd ${0%/*} || exit 1 # Run from this directory
runApplication blockMesh
runApplication topoSet
runApplication createPatch -overwrite
cp 0/ph_rgh.orig 0/ph_rgh
# Run
runApplication `getApplication`
#------------------------------------------------------------------------------

View File

@ -9,12 +9,7 @@ application=`getApplication`
runApplication blockMesh
runApplication topoSet
runApplication createPatch -overwrite
cp 0/ph_rgh.orig 0/ph_rgh
runApplication decomposePar -force
# Run
runParallel $application
#------------------------------------------------------------------------------

View File

@ -7,9 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
# Set application name
application=`getApplication`
rm -f 0/T
cp 0/T.orig 0/T
runApplication chemkinToFoam \
chemkin/grimech30.dat chemkin/thermo30.dat chemkin/transportProperties \
constant/reactionsGRI constant/thermo.compressibleGasGRI

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -f 0/T
#------------------------------------------------------------------------------

View File

@ -7,7 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
application=`getApplication`
runApplication blockMesh
cp 0/T.orig 0/T
runApplication setFields
runApplication $application

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -f 0/T
#------------------------------------------------------------------------------

View File

@ -7,7 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
application=`getApplication`
runApplication blockMesh
cp 0/T.orig 0/T
runApplication setFields
runApplication $application

View File

@ -1,41 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
floor
{
type fixedValue;
value uniform 300;
}
ceiling
{
type fixedValue;
value uniform 300;
}
fixedWalls
{
type zeroGradient;
}
}
// ************************************************************************* //

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
cp 0/T.orig 0/T
#------------------------------------------------------------------------------

View File

@ -9,8 +9,6 @@ rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
rm -f constant/triSurface/motorBike.eMesh > /dev/null 2>&1
rm -rf 0 > /dev/null 2>&1
cleanCase
#------------------------------------------------------------------------------

View File

@ -10,8 +10,6 @@ runApplication surfaceFeatureExtract
runApplication blockMesh
[ ! -d 0 ] && cp -r 0.orig 0
runApplication decomposePar -copyZero
runParallel snappyHexMesh -overwrite

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -1,51 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
leftWall
{
type zeroGradient;
}
rightWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
cp 0/alpha.water.orig 0/alpha.water
#------------------------------------------------------------------------------

View File

@ -1,57 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alpha.water.org;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
leftWall
{
type zeroGradient;
}
rightWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
defaultFaces
{
type empty;
}
porous_half0
{
type cyclic;
}
porous_half1
{
type cyclic;
}
}
// ************************************************************************* //

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
cp 0/alpha.water.orig 0/alpha.water
#------------------------------------------------------------------------------

View File

@ -7,10 +7,7 @@ cd ${0%/*} || exit 1 # Run from this directory
application=`getApplication`
./Allmesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication $application
#------------------------------------------------------------------------------

View File

@ -6,9 +6,5 @@
cp -r 0.orig 0 > /dev/null 2>&1
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -7,7 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
application=`getApplication`
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication $application

View File

@ -1,51 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
leftWall
{
type zeroGradient;
}
rightWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //

View File

@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
cp 0/alpha.water.orig 0/alpha.water
#------------------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
writeCompression compressed;
timeFormat general;

View File

@ -1,41 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
walls
{
type zeroGradient;
}
obstacle
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -7,7 +7,6 @@ cd ${0%/*} || exit 1 # Run from this directory
application=`getApplication`
runApplication ./makeMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication $application

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
runApplication blockMesh
runApplication snappyHexMesh -overwrite
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -6,7 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -5,7 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -2,7 +2,5 @@
cd ${0%/*} || exit 1 # Run from this directory
foamCleanTutorials cases
rm -rf alpha.air alpha.other alpha.water \
alpha.air.gz alpha.other.gz alpha.water.gz
#------------------------------------------------------------------------------

View File

@ -5,9 +5,6 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
cp 0/alpha.air.orig 0/alpha.air
cp 0/alpha.other.orig 0/alpha.other
cp 0/alpha.water.orig 0/alpha.water
runApplication setFields
runApplication `getApplication`

View File

@ -1,47 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alpha.airI;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.25;
}
outlet
{
type inletOutlet;
phi phi.airI;
inletValue uniform 0;
value uniform 0;
}
walls
{
type zeroGradient;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //

View File

@ -1,47 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alpha.airI;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.25;
}
outlet
{
type inletOutlet;
phi phi.airI;
inletValue uniform 0;
value uniform 0;
}
walls
{
type zeroGradient;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //

View File

@ -7,10 +7,9 @@ cd ${0%/*} || exit 1 # run from this directory
# Set application name
application=`getApplication`
cp 0/alpha.air.orig 0/alpha.air
cp 0/f.air.bubbles.orig 0/f.air.bubbles
runApplication blockMesh
runApplication topoSet
runApplication setFields
runApplication $application
#------------------------------------------------------------------------------

View File

@ -1,47 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application solidEquilibriumDisplacementFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 5000;
deltaT 1;
writeControl runTime;
writeInterval 1000;
purgeWrite 0;
writeFormat ascii;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //