Merge branch 'feature-shared-file' into 'develop'

Feature shared file

This contains the functionality from dev to do with (processor-)global/local file marking.
global files are those that are the same on all processors (e.g. dictionaries) and so can be read on the master processor only.  'local' files are specific to the processor (e.g. fields).


See merge request !30
This commit is contained in:
Andrew Heather 2016-03-14 17:35:40 +00:00
commit 53eadb0254
206 changed files with 3589 additions and 1363 deletions

View File

@ -15,8 +15,8 @@ OpenCFD Limited, owner of the OpenFOAM Trademark, has granted the use of the Tra
# Useful Links
- [Download and installation instructions](http://www.openfoam.com/releases)
- [Documentation](http://www.openfoam.com/documentation)
- [Reporting bugs/issues (including bugs/suggestions/feature requests) in OpenFOAM+](http://www.openfoam.com/???)
- [Collaborative and Community-based Developments](http://www.openfoam.com/development/community-projects.php)
- [Reporting bugs/issues (including bugs/suggestions/feature requests) in OpenFOAM+](http://www.openfoam.com/code/bug-reporting.php)
- [Collaborative and Community-based Developments](http://www.openfoam.com/services/community-projects.php)
- [Contacting OpenCFD](http://www.openfoam.com/contact)
Copyright 2016 OpenCFD Ltd

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

@ -1174,7 +1174,7 @@ int main(int argc, char *argv[])
}
}
Info << nl << "End" << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

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

@ -238,7 +238,7 @@ int main(int argc, char *argv[])
runTime
);
if (!readLevel && refHeader.headerOk())
if (!readLevel && refHeader.typeHeaderOk<labelIOList>(true))
{
WarningInFunction
<< "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

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
false
);
if (!meshDictIO.headerOk())
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< meshDictIO.objectPath()

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

@ -366,7 +366,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;
@ -392,7 +392,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;
@ -2655,7 +2655,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

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -394,7 +394,7 @@ Foam::cellShapeControlMesh::cellShapeControlMesh(const Time& runTime)
false
);
if (io.headerOk())
if (io.typeHeaderOk<pointScalarField>(true))
{
pointScalarField sizes(io, pointMesh::New(mesh));

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;
// See if processor local file
if (pointsIO.typeHeaderOk<pointIOField>(true))
{
// Found it (processor local)
points = pointIOField(pointsIO);
if (points.empty())
{
FatalErrorInFunction
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
// 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)
{
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

@ -187,7 +187,7 @@ int main(int argc, char *argv[])
IOobject::MUST_READ
);
if (!dictIO.headerOk())
if (!dictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< "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

@ -599,7 +599,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;
@ -626,7 +626,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

@ -89,7 +89,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

@ -122,7 +122,7 @@ void Foam::helpTypes::helpBoundary::execute
);
// Check for any type of volField
if (fieldHeader.headerOk())
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

@ -1436,7 +1436,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;
@ -1786,29 +1786,13 @@ 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;
}
//Pout<< "Loading cloud " << cloudNames[i] << endl;
clouds.set
(
i,
new unmappedPassiveParticleCloud(mesh, cloudNames[i], false)
);
regIOobject::fileModificationChecking = oldCheckType;
}
//forAllConstIter
//(
@ -2434,7 +2418,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

@ -706,7 +706,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

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

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

@ -306,7 +306,7 @@ void calc
false
);
if (turbulencePropertiesHeader.headerOk())
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
{
singlePhaseTransportModel laminarTransport(U, phi);
@ -364,7 +364,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

@ -76,7 +76,11 @@ int main(int argc, char *argv[])
if (findStrings(fieldPatterns, "k"))
{
if (!IOobject("k", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("k", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
Info<< " Writing turbulence field k" << endl;
const volScalarField k(RASModel->k());
@ -90,7 +94,11 @@ int main(int argc, char *argv[])
if (findStrings(fieldPatterns, "epsilon"))
{
if (!IOobject("epsilon", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("epsilon", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
Info<< " Writing turbulence field epsilon" << endl;
const volScalarField epsilon(RASModel->epsilon());
@ -104,7 +112,11 @@ int main(int argc, char *argv[])
if (findStrings(fieldPatterns, "R"))
{
if (!IOobject("R", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("R", runTime.timeName(), mesh).
typeHeaderOk<volSymmTensorField>(true)
)
{
Info<< " Writing turbulence field R" << endl;
const volSymmTensorField R(RASModel->R());
@ -118,7 +130,11 @@ int main(int argc, char *argv[])
if (findStrings(fieldPatterns, "omega"))
{
if (!IOobject("omega", runTime.timeName(), mesh).headerOk())
if
(
!IOobject("omega", runTime.timeName(), mesh).
typeHeaderOk<volScalarField>(true)
)
{
const scalar Cmu = 0.09;

View File

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

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

@ -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 | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -163,7 +163,7 @@ void calcOmega
false
);
if (omegaHeader.headerOk())
if (omegaHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("SMALL", k.dimensions(), SMALL);
@ -200,7 +200,7 @@ void setField
false
);
if (fldHeader.headerOk())
if (fldHeader.typeHeaderOk<volScalarField>(true))
{
volScalarField fld(fldHeader, mesh);
fld = value;
@ -388,7 +388,7 @@ int main(int argc, char *argv[])
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
).typeHeaderOk<IOdictionary>(true)
)
{
calcCompressible(mesh, mask, U, y, ybl);

View File

@ -628,7 +628,7 @@ int main(int argc, char *argv[])
false
);
if (fieldHeader.headerOk())
if (fieldHeader.typeHeaderOk<IOdictionary>(false))
{
IOdictionary fieldDict(fieldHeader);

View File

@ -90,7 +90,7 @@ Foam::boundaryTemplates::boundaryTemplates
IOobject::MUST_READ
);
if (io.headerOk())
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary dict(io);
regionTemplate.subDict(patchTypes[i]).merge(dict);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +57,7 @@ Foam::word Foam::solverTemplate::readFromDict
const word& entryName
) const
{
if (!dictHeader.headerOk())
if (!dictHeader.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< "Unable to open file "

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

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

View File

@ -194,7 +194,7 @@ int main(int argc, char *argv[])
}
if (!csDictIoPtr->headerOk())
if (!csDictIoPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< csDictIoPtr->objectPath() << nl

View File

@ -174,7 +174,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl

View File

@ -187,7 +187,7 @@ int main(int argc, char *argv[])
}
if (!ioPtr->headerOk())
if (!ioPtr->typeHeaderOk<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl

View File

@ -42,6 +42,7 @@ Note
#include "polyMesh.H"
#include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H"
#include "localIOdictionary.H"
using namespace Foam;
@ -165,23 +166,6 @@ int main(int argc, char *argv[])
Pstream::scatterList(meshBb);
}
// 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;
}
IOobject io
(
surfFileName, // name
@ -193,7 +177,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() + '/', "");
@ -271,10 +256,6 @@ int main(int argc, char *argv[])
Info<< "Writing surface." << nl << endl;
surfMesh.objectRegistry::write();
regIOobject::fileModificationChecking = oldCheckType;
Info<< "End\n" << endl;
return 0;

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,
@ -129,6 +205,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(false),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -148,7 +225,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(name),
@ -160,6 +238,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (objectRegistry::debug)
@ -177,7 +256,8 @@ Foam::IOobject::IOobject
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
bool registerObject,
bool globalObject
)
:
name_(),
@ -189,6 +269,7 @@ Foam::IOobject::IOobject
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(GOOD)
{
if (!fileNameComponents(path, instance_, local_, name_))
@ -207,6 +288,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,
@ -222,6 +323,7 @@ Foam::IOobject::IOobject
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
globalObject_(io.globalObject_),
objState_(io.objState_)
{}
@ -312,11 +414,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;
@ -337,25 +440,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
@ -384,9 +468,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;
}
}
@ -413,47 +595,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)
{
IOWarningInFunction((*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)
@ -482,6 +623,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,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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)
{
InfoInFunction
<< "file " << objectPath() << " could not be opened"
<< endl;
}
ok = false;
}
else
{
// Try reading header
if (readHeader(*isPtr))
{
if (checkType && headerClassName_ != Type::typeName)
{
IOWarningInFunction(*isPtr)
<< "unexpected class name " << headerClassName_
<< " expected " << Type::typeName << endl;
ok = false;
}
}
else
{
if (IOobject::debug)
{
IOWarningInFunction(*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)
{
WarningInFunction
<< 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

@ -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");
}
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Typedef
Foam::globalIOLists
Description
Typedefs for globalIOLists of primitive types. These are fully compatible
with 'normal' IOLists except have global filePath() scope.
\*---------------------------------------------------------------------------*/
#ifndef globalIOLists_H
#define globalIOLists_H
#include "primitiveFields.H"
#include "GlobalIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef GlobalIOList<label> labelGlobalIOList;
typedef GlobalIOList<scalar> scalarGlobalIOList;
typedef GlobalIOList<vector> vectorGlobalIOList;
typedef GlobalIOList<sphericalTensor> sphericalTensorGlobalIOList;
typedef GlobalIOList<symmTensor> symmTensorGlobalIOList;
typedef GlobalIOList<tensor> tensorGlobalIOList;
//- Template function for obtaining global status
template<>
inline bool typeGlobal<labelGlobalIOList>()
{
return true;
}
template<>
inline bool typeGlobal<scalarGlobalIOList>()
{
return true;
}
template<>
inline bool typeGlobal<vectorGlobalIOList>()
{
return true;
}
template<>
inline bool typeGlobal<sphericalTensorGlobalIOList>()
{
return true;
}
template<>
inline bool typeGlobal<symmTensorGlobalIOList>()
{
return true;
}
template<>
inline bool typeGlobal<tensorGlobalIOList>()
{
return true;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -32,15 +32,8 @@ Foam::IOField<Type>::IOField(const IOobject& io)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningInFunction
<< "IOField " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOField does not support automatic rereading."
<< endl;
}
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type> >();
if
(
@ -62,15 +55,8 @@ Foam::IOField<Type>::IOField(const IOobject& io, const label size)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningInFunction
<< "IOField " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOField does not support automatic rereading."
<< endl;
}
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type> >();
if
(
@ -96,15 +82,8 @@ Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningInFunction
<< "IOField " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOField does not support automatic rereading."
<< endl;
}
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type> >();
if
(
@ -130,15 +109,8 @@ Foam::IOField<Type>::IOField(const IOobject& io, const Xfer<Field<Type> >& f)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningInFunction
<< "IOField " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOField does not support automatic rereading."
<< endl;
}
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type> >();
Field<Type>::transfer(f());

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