mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: polyMesh: read_if_present support
This commit is contained in:
@ -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
|
||||
(
|
||||
|
||||
@ -70,20 +70,8 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcZoneMap() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Read constructor given IOobject and a MeshType reference
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const MeshType& mesh
|
||||
)
|
||||
:
|
||||
PtrList<ZoneType>(),
|
||||
regIOobject(io),
|
||||
mesh_(mesh),
|
||||
zoneMapPtr_(NULL)
|
||||
bool Foam::ZoneMesh<ZoneType, MeshType>::read()
|
||||
{
|
||||
if
|
||||
(
|
||||
@ -137,15 +125,36 @@ Foam::ZoneMesh<ZoneType, MeshType>::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<class ZoneType, class MeshType>
|
||||
Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const MeshType& mesh
|
||||
)
|
||||
:
|
||||
PtrList<ZoneType>(),
|
||||
regIOobject(io),
|
||||
mesh_(mesh),
|
||||
zoneMapPtr_(NULL)
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
|
||||
// Construct given size. Zones will be set later
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
@ -159,13 +168,16 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
regIOobject(io),
|
||||
mesh_(mesh),
|
||||
zoneMapPtr_(NULL)
|
||||
{}
|
||||
{
|
||||
// Optionally read contents, otherwise keep size
|
||||
read();
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
(
|
||||
const IOobject& io ,
|
||||
const IOobject& io,
|
||||
const MeshType& mesh,
|
||||
const PtrList<ZoneType>& pzm
|
||||
)
|
||||
@ -175,10 +187,9 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
mesh_(mesh),
|
||||
zoneMapPtr_(NULL)
|
||||
{
|
||||
ZoneMesh<ZoneType, MeshType>(io, mesh);
|
||||
|
||||
if (this->size() == 0)
|
||||
if (!read())
|
||||
{
|
||||
// Nothing read. Use supplied zones
|
||||
PtrList<ZoneType>& zones = *this;
|
||||
zones.setSize(pzm.size());
|
||||
forAll (zones, zoneI)
|
||||
@ -188,6 +199,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
|
||||
@ -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&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user