diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index fc1b6e63d6..47fe014d60 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -309,7 +309,7 @@ public: //- Construct from IOobject explicit polyMesh(const IOobject& io); - //- Construct without boundary from components. + //- Construct from IOobject or from components. // Boundary is added using addPatches() member function polyMesh ( diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index eeec0974d6..0c0525d9ee 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -70,20 +70,8 @@ void Foam::ZoneMesh::calcZoneMap() const } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Read constructor given IOobject and a MeshType reference template -Foam::ZoneMesh::ZoneMesh -( - const IOobject& io, - const MeshType& mesh -) -: - PtrList(), - regIOobject(io), - mesh_(mesh), - zoneMapPtr_(NULL) +bool Foam::ZoneMesh::read() { if ( @@ -137,15 +125,36 @@ Foam::ZoneMesh::ZoneMesh ); close(); + + return true; } else { - // No files found. Force a write of zero-sized zones - // write(); + // Nothing read + return false; } } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Read constructor given IOobject and a MeshType reference +template +Foam::ZoneMesh::ZoneMesh +( + const IOobject& io, + const MeshType& mesh +) +: + PtrList(), + regIOobject(io), + mesh_(mesh), + zoneMapPtr_(NULL) +{ + read(); +} + + // Construct given size. Zones will be set later template Foam::ZoneMesh::ZoneMesh @@ -159,13 +168,16 @@ Foam::ZoneMesh::ZoneMesh regIOobject(io), mesh_(mesh), zoneMapPtr_(NULL) -{} +{ + // Optionally read contents, otherwise keep size + read(); +} template Foam::ZoneMesh::ZoneMesh ( - const IOobject& io , + const IOobject& io, const MeshType& mesh, const PtrList& pzm ) @@ -175,10 +187,9 @@ Foam::ZoneMesh::ZoneMesh mesh_(mesh), zoneMapPtr_(NULL) { - ZoneMesh(io, mesh); - - if (this->size() == 0) + if (!read()) { + // Nothing read. Use supplied zones PtrList& zones = *this; zones.setSize(pzm.size()); forAll (zones, zoneI) @@ -188,6 +199,7 @@ Foam::ZoneMesh::ZoneMesh } } + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 96868c359a..d0bb099026 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,7 +37,7 @@ SourceFiles #include "List.H" #include "regIOobject.H" -#include "pointFieldsFwd.H" +#include "pointField.H" #include "Map.H" #include "PackedBoolList.H" @@ -76,6 +76,9 @@ class ZoneMesh // Private Member Functions + //- Read if IOobject flags set. Return true if read. + bool read(); + //- Disallow construct as copy ZoneMesh(const ZoneMesh&);