Commit e4240592 authored by mattijs's avatar mattijs
Browse files

ENH: glboal file handling: initial commit

Moved file path handling to regIOobject and made it type specific so
now every object can have its own rules. Examples:
- faceZones are now processor local (and don't search up anymore)
- timeStampMaster is now no longer hardcoded inside IOdictionary
  (e.g. uniformDimensionedFields support it as well)
- the distributedTriSurfaceMesh is properly processor-local; no need
  for fileModificationChecking manipulation.
parent 9fd840c1
......@@ -9,7 +9,7 @@
surfaceScalarField* phiBPtr;
if (phiBHeader.headerOk())
if (phiBHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading field phiB\n" << endl;
......
......@@ -76,7 +76,7 @@
IOobject::AUTO_WRITE
);
if (betavSolidIO.headerOk())
if (betavSolidIO.typeHeaderOk<volScalarField>(true))
{
betavSolid.set
(
......
......@@ -25,7 +25,7 @@
IOobject::MUST_READ
);
if (turbulenceHeader.headerOk())
if (turbulenceHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::turbulenceModel> turbulence
(
......@@ -40,7 +40,7 @@
talphaEff = turbulence->alphaEff();
}
else if (RASHeader.headerOk())
else if (RASHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::RASModel> turbulence
(
......@@ -55,7 +55,7 @@
talphaEff = turbulence->alphaEff();
}
else if (LESHeader.headerOk())
else if (LESHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::LESModel> turbulence
(
......
......@@ -79,7 +79,7 @@
autoPtr<volVectorField> HPtr;
if (Hheader.headerOk())
if (Hheader.typeHeaderOk<volVectorField>(true))
{
Info<< "\nReading field H\n" << endl;
......@@ -97,7 +97,7 @@
autoPtr<volVectorField> HdotGradHPtr;
if (HdotGradHheader.headerOk())
if (HdotGradHheader.typeHeaderOk<volVectorField>(true))
{
Info<< "Reading field HdotGradH" << endl;
......
......@@ -11,7 +11,13 @@
autoPtr<uniformDimensionedVectorField> linearAccelerationPtr;
if (linearAccelerationHeader.headerOk())
if
(
linearAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << linearAccelerationHeader.name() << endl;
......@@ -33,7 +39,7 @@
autoPtr<uniformDimensionedVectorField> angularVelocityPtr;
if (angularVelocityHeader.headerOk())
if (angularVelocityHeader.typeHeaderOk<uniformDimensionedVectorField>(true))
{
Info<< " Reading " << angularVelocityHeader.name() << endl;
......@@ -55,7 +61,13 @@
autoPtr<uniformDimensionedVectorField> angularAccelerationPtr;
if (angularAccelerationHeader.headerOk())
if
(
angularAccelerationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << angularAccelerationHeader.name() << endl;
......@@ -77,7 +89,13 @@
autoPtr<uniformDimensionedVectorField> centreOfRotationPtr;
if (centreOfRotationHeader.headerOk())
if
(
centreOfRotationHeader.typeHeaderOk<uniformDimensionedVectorField>
(
true
)
)
{
Info<< " Reading " << centreOfRotationHeader.name() << endl;
......
......@@ -122,7 +122,7 @@ Foam::phaseModel::phaseModel
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;
......
......@@ -54,7 +54,7 @@ Foam::MovingPhaseModel<BasePhaseModel>::phi(const volVectorField& U) const
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;
......
......@@ -120,7 +120,7 @@ Foam::phaseModel::phaseModel
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading face flux field " << phiName << endl;
......
......@@ -34,7 +34,8 @@ Description
NOTE: To avoid exposing wrong fields values faceSets should include
faces contained in the blockedCells cellset.
- coupledFaces reads coupledFacesSet to introduces mixe-coupled baffles
- coupledFaces reads coupledFacesSet to introduces mixed-coupled
duplicate baffles
Subsets out the blocked cells and splits the blockedFaces and updates
fields.
......@@ -1173,7 +1174,7 @@ int main(int argc, char *argv[])
}
}
Info << nl << "End" << endl;
Info<< "\nEnd\n" << endl;
return 0;
}
......
......@@ -17,7 +17,8 @@ FoamFile
//- Per faceSet the patch the faces should go into blocked baffles
blockedFaces ((blockedFacesSet blockedFaces));
//- Per faceSet the patch the faces should go into coupled baffles
//- Per faceSet the duplicate baffles to generate (one 'normal', wall baffle,
// one cyclic baffle). For use with active baffle boundary conditions.
coupledFaces
{
coupledFacesSet
......
......@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
// corrector for mesh motion
twoDPointCorrector* correct2DPtr = NULL;
if (motionObj.headerOk())
if (motionObj.typeHeaderOk<IOdictionary>(true))
{
Info<< "Reading " << runTime.constant() / "motionProperties"
<< endl << endl;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -238,7 +238,7 @@ int main(int argc, char *argv[])
runTime
);
if (!readLevel && refHeader.headerOk())
if (!readLevel && refHeader.typeHeaderOk<labelIOList>(true))
{
WarningIn(args.executable())
<< "Detected " << refHeader.name() << " file in "
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -82,7 +82,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
IOobject::NO_WRITE
);
if (motionObj.headerOk())
if (motionObj.typeHeaderOk<IOdictionary>(true))
{
Info<< "Reading " << mesh.time().constant() / "motionProperties"
<< endl << endl;
......
......@@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
......
......@@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
......
......@@ -37,6 +37,11 @@ Foam::label Foam::starMesh::readVtxLabel(IFstream& is)
for (int i=0; i<15; i++)
{
if (!is.good())
{
return -1;
}
is.get(lcs[i]);
}
......@@ -85,12 +90,10 @@ void Foam::starMesh::readPoints(const scalar scaleFactor)
if (pointsFile.good())
{
label pointLabel;
maxLabel = -1;
while (pointsFile)
{
pointLabel = readVtxLabel(pointsFile);
label pointLabel = readVtxLabel(pointsFile);
if (!pointsFile) break;
......
......@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
false
);
if (!meshDictIO.headerOk())
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorIn(args.executable())
<< "Cannot open mesh description file\n "
......
......@@ -96,7 +96,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(false))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
......@@ -122,7 +122,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(false))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
......
......@@ -372,7 +372,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
......@@ -398,7 +398,7 @@ void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
......@@ -2673,7 +2673,7 @@ int main(int argc, char *argv[])
mesh,
IOobject::MUST_READ
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
// Read patchFaceCentres and patchEdgeCentres
Info<< "Reading patch face,edge centres : "
......
......@@ -70,7 +70,7 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh
)
);
if (pts.headerOk())
if (pts.typeHeaderOk<pointIOField>(true))
{
labelIOField types
(
......
......@@ -75,43 +75,65 @@ pointFile::pointFile
List<Vb::Point> pointFile::initialPoints() const
{
pointIOField points
(
IOobject
pointField points;
{
// Look for points
IOobject pointsIO
(
pointFileName_.name(),
time().timeName(),
time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< " Inserting points from file " << pointFileName_ << endl;
);
if (points.empty())
{
FatalErrorIn("List<Vb::Point> pointFile::initialPoints() const")
<< "Point file contain no points"
<< exit(FatalError) << endl;
}
Info<< " Inserting points from file " << pointFileName_ << endl;
if (Pstream::parRun())
{
// Testing filePath to see if the file originated in a processor
// directory, if so, assume that the points in each processor file
// are unique. They are unlikely to belong on the current
// processor as the background mesh is unlikely to be the same.
// See if processor local file
if (pointsIO.typeHeaderOk<pointIOField>(true))
{
// Found it (processor local)
points = pointIOField(pointsIO);
const bool isParentFile = (points.objectPath() != points.filePath());
if (points.empty())
{
FatalErrorIn("List<Vb::Point> pointFile::initialPoints() const")
<< "Point file contain no points"
<< exit(FatalError) << endl;
}
if (!isParentFile)
{
decomposition().distributePoints(points);
if (Pstream::parRun())
{
// assume that the points in each processor file
// are unique. They are unlikely to belong on the current
// processor as the background mesh is unlikely to be the same.
decomposition().distributePoints(points);
}
}
else
else if (Pstream::parRun())
{
// Otherwise, this is assumed to be points covering the whole
// See if points can be found in parent directory
// (only if timeName = constant)
points = pointIOField
(
IOobject
(
pointFileName_.name(),
time().caseConstant(),
time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (points.empty())
{
FatalErrorIn("List<Vb::Point> pointFile::initialPoints() const")
<< "Point file contain no points"
<< exit(FatalError) << endl;
}
// Points are assumed to be covering the whole
// domain, so filter the points to be only those on this processor
boolList procPt(decomposition().positionOnThisProcessor(points));
......@@ -146,6 +168,12 @@ List<Vb::Point> pointFile::initialPoints() const
inplaceSubset(procPt, points);
}
else
{
FatalErrorIn("List<Vb::Point> pointFile::initialPoints() const")
<< "Cannot find points file " << pointsIO.objectPath()
<< exit(FatalError) << endl;
}
}
Field<bool> insidePoints(points.size(), true);
......
......@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
);
// Check U exists
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -62,7 +62,6 @@ int main(int argc, char *argv[])
"merge two meshes"
);
argList::noParallel();
#include "addOverwriteOption.H"
argList::validArgs.append("masterCase");
......@@ -97,6 +96,18 @@ int main(int argc, char *argv[])
word addRegion = polyMesh::defaultRegion;
args.optionReadIfPresent("addRegion", addRegion);
// Since we don't use argList processor directory detection, add it to
// the casename ourselves so it triggers the logic inside TimePath.
const fileName& cName = args.caseName();
std::string::size_type pos = cName.find("processor");
if (pos != string::npos && pos != 0)
{
fileName processorName = cName.substr(pos, cName.size()-pos);
masterCase += '/' + processorName;
addCase += '/' + processorName;
}
getRootCase(masterCase);
getRootCase(addCase);
......
......@@ -187,7 +187,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (!dictIO.headerOk())
if (!dictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorIn(args.executable())
<< "Cannot open specified refinement dictionary "
......@@ -209,7 +209,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (dictIO.headerOk())
if (dictIO.typeHeaderOk<IOdictionary>(true))
{
Info<< "Refining according to " << dictName << nl << endl;
......
......@@ -601,7 +601,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
......@@ -628,7 +628,7 @@ autoPtr<mapPolyMesh> createRegionMesh
false
);
if (!io.headerOk())
if (!io.typeHeaderOk<IOdictionary>(true))
//if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
......
......@@ -79,7 +79,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
bool writeOk = false;
if (io.headerOk())
if (io.typeHeaderOk<cellZoneMesh>(false))
{
Info<< " Reading " << io.headerClassName()
<< " : " << name << endl;
......
......@@ -61,7 +61,7 @@ inline bool writeMeshObject
bool writeOk = false;
if (io.headerOk())
if (io.typeHeaderOk<T>(false))
{
Info<< " Reading " << io.headerClassName()
<< " : " << name << endl;
......
......@@ -134,7 +134,8 @@ void Foam::helpTypes::helpBoundary::execute
IOobject::MUST_READ
);
if (fieldHeader.headerOk())
// Check for any type of volField
if (fieldHeader.typeHeaderOk<volScalarField>(false))
{
if (args.optionFound("fixedValue"))