diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C index 00aa92630f..d78011c9db 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C @@ -26,6 +26,10 @@ License #include "DelaunayMesh.H" #include "labelPair.H" #include "PrintTable.H" +#include "pointIOField.H" +#include "scalarIOField.H" +#include "labelIOField.H" +#include "pointConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,14 +40,121 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::DelaunayMesh::DelaunayMesh() +Foam::DelaunayMesh::DelaunayMesh(const Time& runTime) : Triangulation(), vertexCount_(0), - cellCount_(0) + cellCount_(0), + runTime_(runTime) {} +template +Foam::DelaunayMesh::DelaunayMesh +( + const Time& runTime, + const word& meshName +) +: + Triangulation(), + vertexCount_(0), + cellCount_(0), + runTime_(runTime) +{ + pointIOField pts + ( + IOobject + ( + "points", + runTime.timeName(), + meshName/polyMesh::meshSubDir, + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ); + + labelIOField types + ( + IOobject + ( + "types", + runTime.timeName(), + meshName, + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ); + + labelIOField indices + ( + IOobject + ( + "indices", + runTime.timeName(), + meshName, + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ); + + labelIOField processorIndices + ( + IOobject + ( + "processorIndices", + runTime.timeName(), + meshName, + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ); + + if (pts.headerOk()) + { + forAll(pts, ptI) + { + Vertex_handle vh = this->insert(toPoint(pts[ptI])); + + if (indices.headerOk()) + { + vh->index() = indices[ptI]; + vertexCount()++; + } + else + { + vh->index() = getNewVertexIndex(); + } + + if (processorIndices.headerOk()) + { + vh->procIndex() = processorIndices[ptI]; + } + else + { + vh->procIndex() = Pstream::myProcNo(); + } + + if (types.headerOk()) + { + vh->type() = + static_cast + ( + types[ptI] + ); + } + else + { + vh->type() = Vb::vtUnassigned; + } + } + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H index 383ee64bae..1fbf19c1d6 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H @@ -43,6 +43,7 @@ SourceFiles #include "boundBox.H" #include "indexedVertex.H" #include "CGALTriangulation3Ddefs.H" +#include "Time.H" #include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -82,6 +83,12 @@ public: FixedList::Hash<> > labelPairHashSet; + typedef HashTable + < + label, + labelPair, + FixedList::Hash<> + > labelTolabelPairHashTable; private: @@ -95,6 +102,9 @@ private: // This allows a unique index to be assigned to each cell. mutable label cellCount_; + //- Reference to Time + const Time& runTime_; + //- Spatial sort traits to use with a pair of point pointers and an int. // Taken from a post on the CGAL lists: 2010-01/msg00004.html by // Sebastien Loriot (Geometry Factory). @@ -159,7 +169,13 @@ public: // Constructors //- Construct from components - DelaunayMesh(); + explicit DelaunayMesh(const Time& runTime); + + DelaunayMesh + ( + const Time& runTime, + const word& meshName + ); //- Destructor @@ -168,6 +184,14 @@ public: // Member Functions + inline const Time& time() const; + + inline void timeCheck + ( + const string& description, + const bool check = true + ) const; + inline label getNewVertexIndex() const; inline label getNewCellIndex() const; @@ -177,6 +201,7 @@ public: inline void resetCellCount(); inline label vertexCount() const; + inline label& vertexCount(); inline void resetVertexCount(); @@ -209,12 +234,12 @@ public: //- Create an fvMesh from the triangulation. // The mesh is not parallel consistent - only used for viewing - autoPtr createMesh + autoPtr createMesh ( const fileName& name, - const Time& runTime, - labelList& vertexMap, - labelList& cellMap + labelTolabelPairHashTable& vertexMap, + labelList& cellMap, + const bool writeDelaunayData = true ) const; }; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H index 733f1230f7..bf2277e356 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H @@ -36,6 +36,40 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +inline const Foam::Time& Foam::DelaunayMesh::time() const +{ + return runTime_; +} + + +template +void Foam::DelaunayMesh::timeCheck +( + const string& description, + const bool check +) const +{ + if (check) + { + Info<< nl << "--- [ cpuTime " + << time().elapsedCpuTime() << " s, " + << "delta " << time().cpuTimeIncrement()<< " s"; + + if (description != word::null) + { + Info<< ", " << description << " "; + } + else + { + Info<< " "; + } + + Info<< "] --- " << endl; + } +} + + template inline Foam::label Foam::DelaunayMesh::getNewVertexIndex() const { @@ -90,6 +124,12 @@ Foam::label Foam::DelaunayMesh::vertexCount() const return vertexCount_; } +template +Foam::label& Foam::DelaunayMesh::vertexCount() +{ + return vertexCount_; +} + template void Foam::DelaunayMesh::resetVertexCount() diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C index bed42012cf..1a341348b1 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C @@ -28,6 +28,7 @@ License #include "pointConversion.H" #include "wallPolyPatch.H" #include "processorPolyPatch.H" +#include "labelIOField.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -331,13 +332,13 @@ void Foam::DelaunayMesh::printVertexInfo(Ostream& os) const template -Foam::autoPtr +Foam::autoPtr Foam::DelaunayMesh::createMesh ( const fileName& name, - const Time& runTime, - labelList& vertexMap, - labelList& cellMap + labelTolabelPairHashTable& vertexMap, + labelList& cellMap, + const bool writeDelaunayData ) const { pointField points(Triangulation::number_of_vertices()); @@ -354,12 +355,54 @@ Foam::DelaunayMesh::createMesh List > patchFaces(1, DynamicList()); List > patchOwners(1, DynamicList