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.
This commit is contained in:
mattijs 2016-01-25 13:03:15 +00:00
parent 9fd840c12a
commit e424059208
188 changed files with 3487 additions and 1364 deletions

View File

@ -9,7 +9,7 @@
surfaceScalarField* phiBPtr;
if (phiBHeader.headerOk())
if (phiBHeader.typeHeaderOk<surfaceScalarField>(true))
{
Info<< "Reading field phiB\n" << endl;

View File

@ -76,7 +76,7 @@
IOobject::AUTO_WRITE
);
if (betavSolidIO.headerOk())
if (betavSolidIO.typeHeaderOk<volScalarField>(true))
{
betavSolid.set
(

View File

@ -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
(

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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 "

View File

@ -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;

View File

@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(

View File

@ -19,7 +19,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(

View File

@ -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;

View File

@ -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 "

View File

@ -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;

View File

@ -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 : "

View File

@ -70,7 +70,7 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh
)
);
if (pts.headerOk())
if (pts.typeHeaderOk<pointIOField>(true))
{
labelIOField types
(

View File

@ -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;
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;
}
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.
const bool isParentFile = (points.objectPath() != points.filePath());
if (!isParentFile)
// See if processor local file
if (pointsIO.typeHeaderOk<pointIOField>(true))
{
decomposition().distributePoints(points);
// Found it (processor local)
points = pointIOField(pointsIO);
if (points.empty())
{
FatalErrorIn("List<Vb::Point> pointFile::initialPoints() const")
<< "Point file contain no points"
<< exit(FatalError) << endl;
}
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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -61,7 +61,7 @@ inline bool writeMeshObject
bool writeOk = false;
if (io.headerOk())
if (io.typeHeaderOk<T>(false))
{
Info<< " Reading " << io.headerClassName()
<< " : " << name << endl;

View File

@ -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"))
{

View File

@ -106,7 +106,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (obj.headerOk())
if (obj.typeHeaderOk<volScalarField>(false))
{
addToFieldList(vsf, obj, objI, mesh);
addToFieldList(vvf, obj, objI, mesh);

View File

@ -293,27 +293,9 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
const word& cloudName
) const
{
(void)srcMesh_.tetBasePtIs();
(void)tgtMesh_.tetBasePtIs();
// Temporarily: override master-only checking
regIOobject::fileCheckTypes oldCheckType =
regIOobject::fileModificationChecking;
if (oldCheckType == regIOobject::timeStampMaster)
{
regIOobject::fileModificationChecking = regIOobject::timeStamp;
}
else if (oldCheckType == regIOobject::inotifyMaster)
{
regIOobject::fileModificationChecking = regIOobject::inotify;
}
// Load cloud and send particle
passiveParticleCloud lpi(srcMesh_, cloudName, false);
regIOobject::fileModificationChecking = oldCheckType;
return redistributeLagrangianPositions(lpi);
}

View File

@ -1440,7 +1440,7 @@ void readProcAddressing
// mesh,
// IOobject::MUST_READ
//);
//if (io.headerOk())
//if (io.typeHeaderOk<labelIOList>(true))
//{
// Pout<< "Reading addressing from " << io.name() << " at "
// << mesh.facesInstance() << nl << endl;
@ -1793,28 +1793,12 @@ void readLagrangian
forAll(cloudNames, i)
{
{
// Note: disable master-only reading of uniform/cloudProperties
regIOobject::fileCheckTypes oldCheckType =
regIOobject::fileModificationChecking;
if (oldCheckType == regIOobject::timeStampMaster)
{
regIOobject::fileModificationChecking = regIOobject::timeStamp;
}
else if (oldCheckType == regIOobject::inotifyMaster)
{
regIOobject::fileModificationChecking = regIOobject::inotify;
}
clouds.set
(
i,
new unmappedPassiveParticleCloud(mesh, cloudNames[i], false)
);
regIOobject::fileModificationChecking = oldCheckType;
}
//Pout<< "Loading cloud " << cloudNames[i] << endl;
clouds.set
(
i,
new unmappedPassiveParticleCloud(mesh, cloudNames[i], false)
);
//forAllConstIter
@ -2441,7 +2425,7 @@ int main(int argc, char *argv[])
meshSubDir,
runTime,
IOobject::READ_IF_PRESENT
).headerOk();
).typeHeaderOk<labelIOList>(true);
}
else
{

View File

@ -16,6 +16,6 @@ for (label n1=0; n1<Times.size() && variableGood; ++n1)
Times[n1].name(),
mesh,
IOobject::NO_READ
).headerOk();
).typeHeaderOk<volScalarField>(false);
}
}

View File

@ -17,7 +17,7 @@ if (Times.size() > 1)
mesh,
IOobject::NO_READ
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
meshMoving = true;
break;

View File

@ -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
@ -28,6 +28,7 @@ License
#include "IOField.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "ensightPTraits.H"
using namespace Foam;
@ -105,8 +106,10 @@ void ensightCloudField
v = pTraits<Type>::zero;
}
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{
label cmpt = ensightPTraits<Type>::componentOrder[i];
ensightFile << setw(12) << component(v, cmpt);
if (++count % 6 == 0)
{

View File

@ -584,7 +584,10 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
bool fieldExists = fieldObject.headerOk();
bool fieldExists = fieldObject.typeHeaderOk<IOField<scalar> >
(
false
);
if (fieldType == scalarIOField::typeName)
{
ensightCloudField<scalar>

View File

@ -13,6 +13,6 @@ if (timeDirs.size() > 1)
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ
).headerOk();
).typeHeaderOk<pointIOField>(true);
}
}

View File

@ -24,7 +24,7 @@
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
IOdictionary timeObject(io);

View File

@ -7,7 +7,7 @@
mesh
);
if (io.headerOk())
if (io.typeHeaderOk<pointIOField>(true))
{
// Read new points
io.readOpt() = IOobject::MUST_READ;

View File

@ -71,7 +71,13 @@ for (label i=0; i < nTypes; i++)
IOobject::NO_READ
);
if (lagrangianHeader.headerOk())
if
(
lagrangianHeader.typeHeaderOk<IOPosition<Cloud<passiveParticle> > >
(
false
)
)
{
Cloud<passiveParticle> particles(mesh);

View File

@ -6,7 +6,7 @@ IOobject ioPoints
mesh
);
if (ioPoints.headerOk())
if (ioPoints.typeHeaderOk<pointIOField>(true))
{
Info<< "new points available" << endl;
// Reading new points

View File

@ -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
@ -567,7 +567,13 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
if
(
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
&& IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
)
{
break;

View File

@ -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
@ -124,7 +124,7 @@ Foam::wordList Foam::vtkPV3Foam::getZoneNames(const word& zoneType) const
false
);
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
{
zonesEntries zones(ioObj);
@ -333,7 +333,7 @@ void Foam::vtkPV3Foam::updateInfoPatches
);
// this should only ever fail if the mesh region doesn't exist
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
{
polyBoundaryMeshEntries patchEntries(ioObj);

View File

@ -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
@ -567,7 +567,13 @@ double* Foam::vtkPV4Foam::findTimes(int& nTimeSteps)
if
(
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
&& IOobject
(
"points",
timeName,
meshDir_,
runTime
).typeHeaderOk<pointIOField>(true)
)
{
break;

View File

@ -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
@ -124,7 +124,7 @@ Foam::wordList Foam::vtkPV4Foam::getZoneNames(const word& zoneType) const
false
);
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<cellZoneMesh>(false))
{
zonesEntries zones(ioObj);
@ -333,7 +333,7 @@ void Foam::vtkPV4Foam::updateInfoPatches
);
// this should only ever fail if the mesh region doesn't exist
if (ioObj.headerOk())
if (ioObj.typeHeaderOk<polyBoundaryMesh>(true))
{
polyBoundaryMeshEntries patchEntries(ioObj);

View File

@ -171,7 +171,7 @@ int USERD_set_filenames
false
);
if (sprayHeader.headerOk())
if (sprayHeader.typeHeaderOk<Cloud<passiveParticle> >(false))
{
Info<< "[Found lagrangian]" << endl;

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true))
{
return Z_UNDEF;
}

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true))
{
return Z_UNDEF;
}

View File

@ -12,7 +12,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volScalarField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volTensorField>(true))
{
return Z_UNDEF;
}

View File

@ -13,7 +13,7 @@ IOobject fieldObjectPtr
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
if (!fieldObjectPtr.typeHeaderOk<volVectorField>(true))
{
return Z_UNDEF;
}

View File

@ -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
@ -62,7 +62,11 @@ namespace Foam
IOobject::MUST_READ
);
if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
if
(
obj.typeHeaderOk<fieldType>(false)
&& obj.headerClassName() == fieldType::typeName
)
{
list.set(index++, new fieldType(obj, mesh));
}

View File

@ -308,7 +308,7 @@ void calc
false
);
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
singlePhaseTransportModel laminarTransport(U, phi);
@ -366,7 +366,7 @@ void calc
false
);
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<compressible::turbulenceModel> turbulenceModel
(

View File

@ -6,7 +6,7 @@
IOobject::MUST_READ
);
if (!UMeanHeader.headerOk())
if (!UMeanHeader.typeHeaderOk<volVectorField>(true))
{
Info<< " No UMean field" << endl;
continue;

View File

@ -69,7 +69,11 @@ int main(int argc, char *argv[])
// Check p and U exist
if (pheader.headerOk() && Uheader.headerOk())
if
(
pheader.typeHeaderOk<volScalarField>(true)
&& Uheader.typeHeaderOk<volVectorField>(true)
)
{
mesh.readUpdate();
@ -106,7 +110,7 @@ int main(int argc, char *argv[])
);
// Check rho exists
if (rhoheader.headerOk())
if (rhoheader.typeHeaderOk<volScalarField>(true))
{
Info<< " Reading rho" << endl;
volScalarField rho(rhoheader, mesh);

View File

@ -102,7 +102,7 @@ int main(int argc, char *argv[])
);
// Check field exists
if (io.headerOk())
if (io.typeHeaderOk<volScalarField>(false))
{
mesh.readUpdate();

View File

@ -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
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
);
// Check field exists
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<volScalarField>(false))
{
mesh.readUpdate();

View File

@ -76,7 +76,7 @@ int main(int argc, char *argv[])
);
// Check p exists
if (pheader.headerOk())
if (pheader.typeHeaderOk<volScalarField>(true))
{
mesh.readUpdate();

View File

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
);
// Check U exists
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
mesh.readUpdate();

View File

@ -78,7 +78,7 @@ void calcCompressibleR
IOobject::NO_WRITE
);
if (!rhoHeader.headerOk())
if (!rhoHeader.typeHeaderOk<volScalarField>(true))
{
Info<< " no " << rhoHeader.name() <<" field" << endl;
return;
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
);
if (UHeader.headerOk())
if (UHeader.typeHeaderOk<volVectorField>(true))
{
Info<< "Reading field " << UHeader.name() << nl << endl;
volVectorField U(UHeader, mesh);
@ -144,7 +144,7 @@ int main(int argc, char *argv[])
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
).typeHeaderOk<IOdictionary>(true)
)
{
calcCompressibleR(mesh, runTime, U);

View File

@ -70,7 +70,11 @@ int main(int argc, char *argv[])
// Check availability of tubulence fields
if (!IOobject("k", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("k", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
Info<< "\nWriting turbulence field k" << endl;
k.write();
@ -80,7 +84,11 @@ int main(int argc, char *argv[])
Info<< "\nTurbulence k field already exists" << endl;
}
if (!IOobject("epsilon", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("epsilon", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
Info<< "\nWriting turbulence field epsilon" << endl;
epsilon.write();
@ -90,7 +98,11 @@ int main(int argc, char *argv[])
Info<< "\nTurbulence epsilon field already exists" << endl;
}
if (!IOobject("R", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("R", runTime.timeName(), mesh).
typeHeaderOk<volSymmTensorField>(true)
)
{
Info<< "\nWriting turbulence field R" << endl;
R.write();
@ -100,7 +112,11 @@ int main(int argc, char *argv[])
Info<< "\nTurbulence R field already exists" << endl;
}
if (!IOobject("omega", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("omega", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
const scalar Cmu = 0.09;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,7 +50,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
volScalarField Co
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -58,7 +58,11 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
);
// Check U and T exists
if (Uheader.headerOk() && Theader.headerOk())
if
(
Uheader.typeHeaderOk<volVectorField>(true)
&& Theader.typeHeaderOk<volScalarField>(true)
)
{
autoPtr<volScalarField> MachPtr;
@ -71,7 +75,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
).typeHeaderOk<IOdictionary>(false)
)
{
// thermophysical Mach

View File

@ -24,7 +24,11 @@
// Check U exists
if (Uheader.headerOk() && Theader.headerOk())
if
(
Uheader.typeHeaderOk<volVectorField>(true)
&& Theader.typeHeaderOk<volScalarField>(true)
)
{
mesh.readUpdate();

View File

@ -14,7 +14,7 @@
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
volVectorField U(Uheader, mesh);

View File

@ -55,7 +55,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
autoPtr<surfaceScalarField> PePtr;
@ -87,7 +87,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
singlePhaseTransportModel laminarTransport(U, phi);
@ -144,7 +144,8 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
(
"Pef",
runTime.timeName(),
mesh
mesh,
IOobject::NO_READ
),
mag(phi)
/(
@ -158,7 +159,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
}
else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
{
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
autoPtr<fluidThermo> thermo(fluidThermo::New(mesh));
@ -274,6 +275,8 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
Info<< " No phi" << endl;
}
Info<< "\nEnd\n" << endl;
}

View File

@ -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
@ -51,7 +51,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,7 +57,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
IOobject::NO_READ
);
if (phiHeader.headerOk())
if (phiHeader.typeHeaderOk<surfaceScalarField>(true))
{
mesh.readUpdate();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (kheader.headerOk())
if (kheader.typeHeaderOk<volScalarField>(true))
{
Info<< " Reading k" << endl;
volScalarField k(kheader, mesh);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
IOobject::MUST_READ
);
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
Info<< " Reading U" << endl;
volVectorField U(Uheader, mesh);

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
);
// Check U exists
if (Uheader.headerOk())
if (Uheader.typeHeaderOk<volVectorField>(true))
{
mesh.readUpdate();
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
}
}
Info<< "End" << endl;
Info<< "End\n" << endl;
return 0;
}

View File

@ -88,7 +88,7 @@ void calcCompressible
IOobject::NO_WRITE
);
if (!rhoHeader.headerOk())
if (!rhoHeader.typeHeaderOk<volScalarField>(true))
{
Info<< " no rho field" << endl;
return;
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
);
if (UHeader.headerOk())
if (UHeader.typeHeaderOk<volVectorField>(true))
{
Info<< "Reading field U\n" << endl;
volVectorField U(UHeader, mesh);
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
).typeHeaderOk<IOdictionary>(true)
)
{
calcCompressible(mesh, runTime, U, wallShearStress);

View File

@ -149,7 +149,7 @@ void calcCompressibleYPlus
IOobject::NO_WRITE
);
if (!rhoHeader.headerOk())
if (!rhoHeader.typeHeaderOk<volScalarField>(true))
{
Info<< " no rho field" << endl;
return;
@ -216,7 +216,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
);
if (UHeader.headerOk())
if (UHeader.typeHeaderOk<volVectorField>(true))
{
Info<< "Reading field U\n" << endl;
volVectorField U(UHeader, mesh);
@ -228,7 +228,7 @@ int main(int argc, char *argv[])
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
).typeHeaderOk<IOdictionary>(true)
)
{
calcCompressibleYPlus(mesh, runTime, U, yPlus);

View File

@ -187,7 +187,7 @@ int main(int argc, char *argv[])
false
);
if (omegaHeader.headerOk())
if (omegaHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("VSMALL", k.dimensions(), VSMALL);
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
false
);
if (nuTildaHeader.headerOk())
if (nuTildaHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField nuTilda(nuTildaHeader, mesh);
nuTilda = nut;

View File

@ -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
@ -612,41 +612,51 @@ int main(int argc, char *argv[])
}
else
{
// Read dictionary. (disable class type checking so we can load
// field)
// Read dictionary
// Note: disable class type checking so we can load field
Info<< "Loading dictionary " << fieldName << endl;
const word oldTypeName = IOdictionary::typeName;
const_cast<word&>(IOdictionary::typeName) = word::null;
IOdictionary fieldDict
IOobject fieldHeader
(
IOobject
(
fieldName,
instance,
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
fieldName,
instance,
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
if (fieldHeader.typeHeaderOk<IOdictionary>(false))
{
IOdictionary fieldDict(fieldHeader);
Info<< "Loaded dictionary " << fieldName
<< " with entries " << fieldDict.toc() << endl;
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Get the replacement dictionary for the field
const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) =
fieldDict.headerClassName();
// Merge the replacements in
merge(fieldDict, replaceDict, literalRE, patchGroups);
Info<< "Loaded dictionary " << fieldName
<< " with entries " << fieldDict.toc() << endl;
Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write();
// Get the replacement dictionary for the field
const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in
merge(fieldDict, replaceDict, literalRE, patchGroups);
Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write();
}
else
{
WarningIn(args.executable())
<< "Requested field to change " << fieldName
<< " does not exist in " << fieldHeader.path() << endl;
}
}
}

View File

@ -74,7 +74,8 @@ void rewriteBoundary
HashTable<word>& nbrNames
)
{
Info<< "Reading boundary from " << io.filePath() << endl;
Info<< "Reading boundary from " << typeFilePath<IOPtrList<entry> >(io)
<< endl;
// Read PtrList of dictionary.
const word oldTypeName = IOPtrList<entry>::typeName;
@ -446,7 +447,7 @@ int main(int argc, char *argv[])
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOPtrList<entry> >(false))
{
rewriteBoundary
(
@ -480,7 +481,7 @@ int main(int argc, char *argv[])
false
);
if (io.headerOk())
if (io.typeHeaderOk<IOPtrList<entry> >(false))
{
rewriteBoundary
(

View File

@ -44,13 +44,12 @@ void MapConsistentVolFields
const CombineOp& cop
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
word fieldClassName
(
GeometricField<Type, fvPatchField, volMesh>::typeName
);
word fieldClassName(fieldType::typeName);
IOobjectList fields = objects.lookupClass(fieldClassName);
@ -60,11 +59,7 @@ void MapConsistentVolFields
<< endl;
// Read field
GeometricField<Type, fvPatchField, volMesh> fieldSource
(
*fieldIter(),
meshSource
);
fieldType fieldSource(*fieldIter(), meshSource);
IOobject fieldTargetIOobject
(
@ -75,14 +70,10 @@ void MapConsistentVolFields
IOobject::AUTO_WRITE
);
if (fieldTargetIOobject.headerOk())
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
{
// Read fieldTarget
GeometricField<Type, fvPatchField, volMesh> fieldTarget
(
fieldTargetIOobject,
meshTarget
);
fieldType fieldTarget(fieldTargetIOobject, meshTarget);
// Interpolate field
meshToMesh0Interp.interpolate
@ -101,7 +92,7 @@ void MapConsistentVolFields
fieldTargetIOobject.readOpt() = IOobject::NO_READ;
// Interpolate field
GeometricField<Type, fvPatchField, volMesh> fieldTarget
fieldType fieldTarget
(
fieldTargetIOobject,
meshToMesh0Interp.interpolate

View File

@ -44,13 +44,12 @@ void MapVolFields
const CombineOp& cop
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
word fieldClassName
(
GeometricField<Type, fvPatchField, volMesh>::typeName
);
word fieldClassName(fieldType::typeName);
IOobjectList fields = objects.lookupClass(fieldClassName);
@ -65,20 +64,20 @@ void MapVolFields
IOobject::AUTO_WRITE
);
if (fieldTargetIOobject.headerOk())
if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
{
Info<< " interpolating " << fieldIter()->name()
<< endl;
// Read field fieldSource
GeometricField<Type, fvPatchField, volMesh> fieldSource
fieldType fieldSource
(
*fieldIter(),
meshSource
);
// Read fieldTarget
GeometricField<Type, fvPatchField, volMesh> fieldTarget
fieldType fieldTarget
(
fieldTargetIOobject,
meshTarget

View File

@ -69,7 +69,7 @@ void MapVolFields
IOobject::MUST_READ
);
if (targetIO.headerOk())
if (targetIO.typeHeaderOk<fieldType>(true))
{
fieldType fieldTarget(targetIO, meshTarget);

View File

@ -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
@ -64,7 +64,7 @@ bool setCellFieldType
);
// Check the "constant" directory
if (!fieldHeader.headerOk())
if (!fieldHeader.typeHeaderOk<fieldType>(true))
{
fieldHeader = IOobject
(
@ -76,7 +76,7 @@ bool setCellFieldType
}
// Check field exists
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<fieldType>(true))
{
Info<< " Setting internal values of "
<< fieldHeader.headerClassName()
@ -216,7 +216,7 @@ bool setFaceFieldType
);
// Check the "constant" directory
if (!fieldHeader.headerOk())
if (!fieldHeader.typeHeaderOk<fieldType>(true))
{
fieldHeader = IOobject
(
@ -228,7 +228,7 @@ bool setFaceFieldType
}
// Check field exists
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<fieldType>(true))
{
Info<< " Setting patchField values of "
<< fieldHeader.headerClassName()

View File

@ -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
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
}
if (!csDictIoPtr->headerOk())
if (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "

View File

@ -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
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "

View File

@ -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
@ -187,7 +187,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n "

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,6 +42,7 @@ Note
#include "polyMesh.H"
#include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H"
#include "localIOdictionary.H"
using namespace Foam;
@ -171,7 +172,8 @@ int main(int argc, char *argv[])
IOobject::AUTO_WRITE
);
const fileName actualPath(io.filePath());
// Look for file (using searchableSurface rules)
const fileName actualPath(typeFilePath<searchableSurface>(io));
fileName localPath(actualPath);
localPath.replace(runTime.rootPath() + '/', "");
@ -193,7 +195,7 @@ int main(int argc, char *argv[])
dict.add("distributionType", distType);
dict.add("mergeDistance", SMALL);
IOdictionary ioDict
localIOdictionary ioDict
(
IOobject
(
@ -238,7 +240,6 @@ int main(int argc, char *argv[])
(
"faceCentres", // name
surfMesh.searchableSurface::time().timeName(), // instance
surfMesh.searchableSurface::local(), // local
surfMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE

View File

@ -183,11 +183,17 @@ $(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/baseIOdictionary.C
$(IOdictionary)/baseIOdictionaryIO.C
$(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C
$(IOdictionary)/localIOdictionary.C
$(IOdictionary)/unwatchedIOdictionary.C
db/IOobjects/IOMap/IOMapName.C
db/IOobjects/GlobalIOList/globalIOLists.C
IOobject = db/IOobject
$(IOobject)/IOobject.C
$(IOobject)/IOobjectIO.C
@ -592,6 +598,9 @@ $(Fields)/quaternionField/quaternionIOField.C
$(Fields)/triadField/triadIOField.C
$(Fields)/transformField/transformField.C
$(Fields)/globalFields/globalIOFields.C
pointPatchFields = fields/pointPatchFields
$(pointPatchFields)/pointPatchField/pointPatchFields.C

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,11 +32,87 @@ License
namespace Foam
{
defineTypeNameAndDebug(IOobject, 0);
template<>
const char* NamedEnum
<
IOobject::fileCheckTypes,
4
>::names[] =
{
"timeStamp",
"timeStampMaster",
"inotify",
"inotifyMaster"
};
}
const Foam::NamedEnum<Foam::IOobject::fileCheckTypes, 4>
Foam::IOobject::fileCheckTypesNames;
// Default fileCheck type
Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking
(
fileCheckTypesNames.read
(
debug::optimisationSwitches().lookup
(
"fileModificationChecking"
)
)
);
namespace Foam
{
// Register re-reader
class addfileModificationCheckingToOpt
:
public ::Foam::simpleRegIOobject
{
public:
addfileModificationCheckingToOpt(const char* name)
:
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
{}
virtual ~addfileModificationCheckingToOpt()
{}
virtual void readData(Foam::Istream& is)
{
IOobject::fileModificationChecking =
IOobject::fileCheckTypesNames.read(is);
}
virtual void writeData(Foam::Ostream& os) const
{
os << IOobject::fileCheckTypesNames
[IOobject::fileModificationChecking];
}
};
addfileModificationCheckingToOpt addfileModificationCheckingToOpt_
(
"fileModificationChecking"
);
}
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// Return components following the IOobject requirements
//
// behaviour
// input IOobject(instance, local, name)
// ----- ------
// "foo" ("", "", "foo")
// "foo/bar" ("foo", "", "bar")
// "/XXX/bar" ("/XXX", "", "bar")
// "foo/bar/" ERROR - no name
// "foo/xxx/bar" ("foo", "xxx", "bar")
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
bool Foam::IOobject::fileNameComponents
(
const fileName& path,
@ -146,6 +222,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(false),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -165,7 +242,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(name),
@ -177,6 +255,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -194,7 +273,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(),
@ -206,6 +286,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (!fileNameComponents(path, instance_, local_, name_))
@ -234,6 +315,26 @@ Foam::IOobject::IOobject
}
Foam::IOobject::IOobject
(
const IOobject& io,
const objectRegistry& registry
)
:
name_(io.name_),
headerClassName_(io.headerClassName_),
note_(io.note_),
instance_(io.instance_),
local_(io.local_),
db_(registry),
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
globalObject_(io.globalObject_),
objState_(io.objState_)
{}
Foam::IOobject::IOobject
(
const IOobject& io,
@ -249,6 +350,7 @@ Foam::IOobject::IOobject
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
globalObject_(io.globalObject_),
objState_(io.objState_)
{}
@ -339,11 +441,12 @@ Foam::fileName Foam::IOobject::path
}
Foam::fileName Foam::IOobject::filePath() const
Foam::fileName Foam::IOobject::localFilePath() const
{
if (instance().isAbsolute())
{
fileName objectPath = instance()/name();
if (isFile(objectPath))
{
return objectPath;
@ -364,25 +467,6 @@ Foam::fileName Foam::IOobject::filePath() const
}
else
{
if
(
time().processorCase()
&& (
instance() == time().system()
|| instance() == time().constant()
)
)
{
fileName parentObjectPath =
rootPath()/time().globalCaseName()
/instance()/db_.dbDir()/local()/name();
if (isFile(parentObjectPath))
{
return parentObjectPath;
}
}
if (!isDir(path))
{
word newInstancePath = time().findInstancePath
@ -411,9 +495,107 @@ Foam::fileName Foam::IOobject::filePath() const
}
Foam::Istream* Foam::IOobject::objectStream()
Foam::fileName Foam::IOobject::globalFilePath() const
{
return objectStream(filePath());
if (instance().isAbsolute())
{
fileName objectPath = instance()/name();
if (isFile(objectPath))
{
if (objectRegistry::debug)
{
Pout<< "globalFilePath : returning absolute:" << objectPath
<< endl;
}
return objectPath;
}
else
{
if (objectRegistry::debug)
{
Pout<< "globalFilePath : absolute not found:" << objectPath
<< endl;
}
return fileName::null;
}
}
else
{
fileName path = this->path();
fileName objectPath = path/name();
if (isFile(objectPath))
{
if (objectRegistry::debug)
{
Pout<< "globalFilePath : returning time:" << objectPath << endl;
}
return objectPath;
}
else
{
if
(
time().processorCase()
&& (
instance() == time().system()
|| instance() == time().constant()
)
)
{
// Constant & system can come from global case
fileName parentObjectPath =
rootPath()/time().globalCaseName()
/instance()/db().dbDir()/local()/name();
if (isFile(parentObjectPath))
{
if (objectRegistry::debug)
{
Pout<< "globalFilePath : returning parent:"
<< parentObjectPath << endl;
}
return parentObjectPath;
}
}
// Check for approximately same time
if (!isDir(path))
{
word newInstancePath = time().findInstancePath
(
instant(instance())
);
if (newInstancePath.size())
{
fileName fName
(
rootPath()/caseName()
/newInstancePath/db().dbDir()/local()/name()
);
if (isFile(fName))
{
if (objectRegistry::debug)
{
Pout<< "globalFilePath : returning similar time:"
<< fName << endl;
}
return fName;
}
}
}
}
if (objectRegistry::debug)
{
Pout<< "globalFilePath : time not found:" << objectPath << endl;
}
return fileName::null;
}
}
@ -440,47 +622,6 @@ Foam::Istream* Foam::IOobject::objectStream(const fileName& fName)
}
bool Foam::IOobject::headerOk()
{
bool ok = true;
Istream* isPtr = objectStream();
// If the stream has failed return
if (!isPtr)
{
if (objectRegistry::debug)
{
Info
<< "IOobject::headerOk() : "
<< "file " << objectPath() << " could not be opened"
<< endl;
}
ok = false;
}
else
{
// Try reading header
if (!readHeader(*isPtr))
{
if (objectRegistry::debug)
{
IOWarningIn("IOobject::headerOk()", (*isPtr))
<< "failed to read header of file " << objectPath()
<< endl;
}
ok = false;
}
}
delete isPtr;
return ok;
}
void Foam::IOobject::setBad(const string& s)
{
if (objState_ != GOOD)
@ -509,6 +650,7 @@ void Foam::IOobject::operator=(const IOobject& io)
local_ = io.local_;
rOpt_ = io.rOpt_;
wOpt_ = io.wOpt_;
globalObject_ = io.globalObject_;
objState_ = io.objState_;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,6 +76,7 @@ SourceFiles
#include "typeInfo.H"
#include "autoPtr.H"
#include "InfoProxy.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,6 +120,16 @@ public:
NO_WRITE = 1
};
//- Enumeration defining the file checking options
enum fileCheckTypes
{
timeStamp,
timeStampMaster,
inotify,
inotifyMaster
};
static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
private:
@ -151,6 +162,9 @@ private:
//- Register object created from this IOobject with registry if true
bool registerObject_;
//- Is object same for all processors
bool globalObject_;
//- IOobject state
objectState objState_;
@ -159,10 +173,6 @@ protected:
// Protected Member Functions
//- Construct and return an IFstream for the object.
// The results is NULL if the stream construction failed
Istream* objectStream();
//- Construct and return an IFstream for the object given the
// exact file. The results is NULL if the stream construction failed
Istream* objectStream(const fileName&);
@ -180,14 +190,6 @@ public:
// Static Member Functions
//- Split path into instance, local, name components
// input IOobject(instance, local, name)
// ----- ------
// "foo" ("", "", "foo")
// "foo/bar" ("foo", "", "bar")
// "/XXX/bar" ("/XXX", "", "bar")
// "foo/bar/" ERROR - no name
// "foo/xxx/bar" ("foo", "xxx", "bar")
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
static bool fileNameComponents
(
const fileName& path,
@ -199,6 +201,9 @@ public:
template<class Name>
static inline word groupName(Name name, const word& group);
//- Type of file modification checking
static fileCheckTypes fileModificationChecking;
// Constructors
@ -222,7 +227,8 @@ public:
const objectRegistry& registry,
readOption r=NO_READ,
writeOption w=NO_WRITE,
bool registerObject=true
bool registerObject=true,
bool globalObject = false
);
//- Construct from path, registry, io options
@ -233,7 +239,15 @@ public:
const objectRegistry& registry,
readOption r=NO_READ,
writeOption w=NO_WRITE,
bool registerObject=true
bool registerObject=true,
bool globalObject = false
);
//- Construct as copy resetting registry
IOobject
(
const IOobject& io,
const objectRegistry& registry
);
//- Construct as copy resetting name
@ -244,11 +258,17 @@ public:
);
//- Clone
Foam::autoPtr<IOobject> clone() const
autoPtr<IOobject> clone() const
{
return autoPtr<IOobject>(new IOobject(*this));
}
//- Clone resetting registry
autoPtr<IOobject> clone(const objectRegistry& registry) const
{
return autoPtr<IOobject>(new IOobject(*this, registry));
}
//- Destructor
virtual ~IOobject();
@ -306,6 +326,18 @@ public:
return registerObject_;
}
//- Is object same for all processors
bool& globalObject()
{
return globalObject_;
}
//- Is object same for all processors
bool globalObject() const
{
return globalObject_;
}
// Read/write options
@ -373,9 +405,11 @@ public:
return path()/name();
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
fileName filePath() const;
//- Helper for filePath that searches locally
fileName localFilePath() const;
//- Helper for filePath that searches up if in parallel
fileName globalFilePath() const;
// Reading
@ -383,9 +417,14 @@ public:
//- Read header
bool readHeader(Istream&);
//- Read and check header info
bool headerOk();
//- Read header (uses typeFilePath to find file) and check header
// info. Optionally checks headerClassName against type
template<class Type>
bool typeHeaderOk(const bool checkType = true);
//- Helper: warn that type does not support re-reading
template<class Type>
void warnNoRereading() const;
// Writing
@ -442,6 +481,21 @@ template<>
Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
//- Template function for obtaining global status
template<class T>
inline bool typeGlobal()
{
return false;
}
//- Template function for obtaining filePath
template<class T>
inline fileName typeFilePath(const IOobject& io)
{
return (typeGlobal<T>() ? io.globalFilePath() : io.localFilePath());
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
@ -452,6 +506,12 @@ Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IOobjectTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -36,6 +36,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOobject>& ip)
os << "IOobject: "
<< io.type() << token::SPACE
<< io.name() << token::SPACE
<< "readOpt:" << token::SPACE << io.readOpt() << token::SPACE
<< "writeOpt:" << token::SPACE << io.writeOpt() << token::SPACE
<< "globalObject:" << token::SPACE << io.globalObject() << token::SPACE
<< io.path() << endl;
return os;

View File

@ -0,0 +1,121 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IOobject.H"
#include "Istream.H"
#include "IOstreams.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::IOobject::typeHeaderOk(const bool checkType)
{
bool ok = true;
// Everyone check or just master
bool masterOnly =
typeGlobal<Type>()
&& (
IOobject::fileModificationChecking == timeStampMaster
|| IOobject::fileModificationChecking == inotifyMaster
);
// Determine local status
if (!masterOnly || Pstream::master())
{
Istream* isPtr = objectStream(typeFilePath<Type>(*this));
// If the stream has failed return
if (!isPtr)
{
if (IOobject::debug)
{
Info
<< "IOobject::typeHeaderOk() : "
<< "file " << objectPath() << " could not be opened"
<< endl;
}
ok = false;
}
else
{
// Try reading header
if (readHeader(*isPtr))
{
if (checkType && headerClassName_ != Type::typeName)
{
IOWarningIn("IOobject::typeHeaderOk()", (*isPtr))
<< "unexpected class name " << headerClassName_
<< " expected " << Type::typeName << endl;
ok = false;
}
}
else
{
if (IOobject::debug)
{
IOWarningIn("IOobject::typeHeaderOk()", (*isPtr))
<< "failed to read header of file " << objectPath()
<< endl;
}
ok = false;
}
}
delete isPtr;
}
// If masterOnly make sure all processors know about it
if (masterOnly)
{
Pstream::scatter(ok);
}
return ok;
}
template<class Type>
void Foam::IOobject::warnNoRereading() const
{
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn("IOobject::warnNoRereading()")
<< Type::typeName << ' ' << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but " << Type::typeName
<< " does not support automatic rereading."
<< endl;
}
}
// ************************************************************************* //

View File

@ -26,7 +26,7 @@ License
#include "IOobjectList.H"
#include "Time.H"
#include "OSspecific.H"
#include "IOList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -77,7 +77,8 @@ Foam::IOobjectList::IOobjectList
registerObject
);
if (objectPtr->headerOk())
// Use object with local scope
if (objectPtr->typeHeaderOk<IOList<label> >(false))
{
insert(ObjectNames[i], objectPtr);
}

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "GlobalIOField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::GlobalIOField<Type>::GlobalIOField(const IOobject& io)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOField<Type> >();
readHeaderOk(IOstream::BINARY, typeName);
}
template<class Type>
Foam::GlobalIOField<Type>::GlobalIOField(const IOobject& io, const label size)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOField<Type> >();
if (!readHeaderOk(IOstream::BINARY, typeName))
{
Field<Type>::setSize(size);
}
}
template<class Type>
Foam::GlobalIOField<Type>::GlobalIOField
(
const IOobject& io,
const Field<Type>& f
)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOField<Type> >();
if (!readHeaderOk(IOstream::BINARY, typeName))
{
Field<Type>::operator=(f);
}
}
template<class Type>
Foam::GlobalIOField<Type>::GlobalIOField
(
const IOobject& io,
const Xfer<Field<Type> >& f
)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOField<Type> >();
Field<Type>::transfer(f());
readHeaderOk(IOstream::BINARY, typeName);
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class Type>
Foam::GlobalIOField<Type>::~GlobalIOField()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::GlobalIOField<Type>::readData(Istream& is)
{
is >> *this;
return is.good();
}
template<class Type>
bool Foam::GlobalIOField<Type>::writeData(Ostream& os) const
{
return (os << static_cast<const Field<Type>&>(*this)).good();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void Foam::GlobalIOField<Type>::operator=(const GlobalIOField<Type>& rhs)
{
Field<Type>::operator=(rhs);
}
template<class Type>
void Foam::GlobalIOField<Type>::operator=(const Field<Type>& rhs)
{
Field<Type>::operator=(rhs);
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::GlobalIOField
Description
IOField with global data (so optionally read from master)
SourceFiles
GlobalIOField.C
\*---------------------------------------------------------------------------*/
#ifndef GlobalIOField_H
#define GlobalIOField_H
#include "regIOobject.H"
#include "Field.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class GlobalIOField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class GlobalIOField
:
public regIOobject,
public Field<Type>
{
public:
TypeName("Field");
// Constructors
//- Construct from IOobject
GlobalIOField(const IOobject&);
//- Construct from IOobject and size (does not set values)
GlobalIOField(const IOobject&, const label size);
//- Construct from components
GlobalIOField(const IOobject&, const Field<Type>&);
//- Construct by transferring the Field contents
GlobalIOField(const IOobject&, const Xfer<Field<Type> >&);
//- Destructor
virtual ~GlobalIOField();
// Member functions
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath();
}
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation
bool writeData(Ostream&) const;
// Member operators
void operator=(const GlobalIOField<Type>&);
void operator=(const Field<Type>&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "GlobalIOField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "GlobalIOList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOList<Type> >();
readHeaderOk(IOstream::BINARY, typeName);
}
template<class Type>
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label size)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOList<Type> >();
if (!readHeaderOk(IOstream::BINARY, typeName))
{
List<Type>::setSize(size);
}
}
template<class Type>
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const List<Type>& f)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOList<Type> >();
if (!readHeaderOk(IOstream::BINARY, typeName))
{
List<Type>::operator=(f);
}
}
template<class Type>
Foam::GlobalIOList<Type>::GlobalIOList
(
const IOobject& io,
const Xfer<List<Type> >& f
)
:
regIOobject(io)
{
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<GlobalIOList<Type> >();
List<Type>::transfer(f());
readHeaderOk(IOstream::BINARY, typeName);
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class Type>
Foam::GlobalIOList<Type>::~GlobalIOList()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::GlobalIOList<Type>::readData(Istream& is)
{
is >> *this;
return is.good();
}
template<class Type>
bool Foam::GlobalIOList<Type>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void Foam::GlobalIOList<Type>::operator=(const GlobalIOList<Type>& rhs)
{
List<Type>::operator=(rhs);
}
template<class Type>
void Foam::GlobalIOList<Type>::operator=(const List<Type>& rhs)
{
List<Type>::operator=(rhs);
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::GlobalIOList
Description
IOList with global data (so optionally read from master)
SourceFiles
GlobalIOList.C
\*---------------------------------------------------------------------------*/
#ifndef GlobalIOList_H
#define GlobalIOList_H
#include "List.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class GlobalIOList Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class GlobalIOList
:
public regIOobject,
public List<Type>
{
public:
TypeName("List");
// Constructors
//- Construct from IOobject
GlobalIOList(const IOobject&);
//- Construct from IOobject
GlobalIOList(const IOobject&, const label size);
//- Construct from IOobject and a List
GlobalIOList(const IOobject&, const List<Type>&);
//- Construct by transferring the List contents
GlobalIOList(const IOobject&, const Xfer<List<Type> >&);
//- Destructor
virtual ~GlobalIOList();
// Member functions
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath();
}
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation
bool writeData(Ostream&) const;
// Member operators
void operator=(const GlobalIOList<Type>&);
void operator=(const List<Type>&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "GlobalIOList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "globalIOLists.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTemplateTypeNameWithName(labelGlobalIOList, "labelList");
defineTemplateTypeNameWithName(scalarGlobalIOList, "scalarList");
defineTemplateTypeNameWithName(vectorGlobalIOList, "vectorList");
defineTemplateTypeNameWithName
(
sphericalTensorGlobalIOList,
"sphericalTensorList"
);
defineTemplateTypeNameWithName(symmTensorGlobalIOList, "symmTensorList");
defineTemplateTypeNameWithName(tensorGlobalIOList, "tensorList");
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More