diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C index 7eb8216b00..3afdf9cf13 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.C @@ -31,12 +31,6 @@ License #include "labelIOField.H" #include "pointConversion.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -61,6 +55,8 @@ Foam::DelaunayMesh::DelaunayMesh cellCount_(0), runTime_(runTime) { + Info<< "Reading " << meshName << " from " << runTime.timeName() << endl; + pointIOField pts ( IOobject @@ -74,83 +70,71 @@ Foam::DelaunayMesh::DelaunayMesh ) ); - 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) + labelIOField types + ( + IOobject + ( + "types", + runTime.timeName(), + meshName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + +// Do not read in indices +// labelIOField indices +// ( +// IOobject +// ( +// "indices", +// runTime.timeName(), +// meshName, +// runTime, +// IOobject::MUST_READ, +// IOobject::NO_WRITE +// ) +// ); + + labelIOField processorIndices + ( + IOobject + ( + "processorIndices", + runTime.timeName(), + meshName, + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + List pointsToInsert(pts.size()); + + forAll(pointsToInsert, pI) { - 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; - } + pointsToInsert[pI] = + Vb + ( + toPoint(pts[pI]), + pI, + static_cast(types[pI]), + processorIndices[pI] + ); } + + rangeInsertWithInfo + ( + pointsToInsert.begin(), + pointsToInsert.end(), + false, + false + ); + + vertexCount_ = Triangulation::number_of_vertices(); } } @@ -219,7 +203,7 @@ void Foam::DelaunayMesh::insertPoints(const List& vertices) ( vertices.begin(), vertices.end(), - true + false ); } @@ -288,7 +272,8 @@ void Foam::DelaunayMesh::rangeInsertWithInfo ( PointIterator begin, PointIterator end, - bool printErrors + bool printErrors, + bool reIndex ) { typedef DynamicList @@ -348,7 +333,14 @@ void Foam::DelaunayMesh::rangeInsertWithInfo } else { - hint->index() = getNewVertexIndex(); + if (reIndex) + { + hint->index() = getNewVertexIndex(); + } + else + { + hint->index() = vert.index(); + } hint->type() = vert.type(); hint->procIndex() = vert.procIndex(); hint->targetCellSize() = vert.targetCellSize(); @@ -358,15 +350,6 @@ void Foam::DelaunayMesh::rangeInsertWithInfo } -// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "DelaunayMeshIO.C" diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H index 63d227fcca..a7cbf26766 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMesh.H @@ -90,6 +90,7 @@ public: FixedList::Hash<> > labelTolabelPairHashTable; + private: // Private data @@ -184,62 +185,84 @@ public: // Member Functions - inline const Time& time() const; + // Access - inline void timeCheck - ( - const string& description, - const bool check = true - ) const; - - inline label getNewVertexIndex() const; - - inline label getNewCellIndex() const; - - inline label cellCount() const; - - inline void resetCellCount(); - - inline label vertexCount() const; - - inline void resetVertexCount(); + //- Return a reference to the Time object + inline const Time& time() const; - //- Remove the entire triangulation - void reset(); + // Check - void insertPoints(const List& vertices); - - //- Function inserting points into a triangulation and setting the - // index and type data of the point in the correct order. This is - // faster than inserting points individually. - // - // Adapted from a post on the CGAL lists: 2010-01/msg00004.html by - // Sebastien Loriot (Geometry Factory). - template - void rangeInsertWithInfo - ( - PointIterator begin, - PointIterator end, - bool printErrors = true - ); + //- Write the cpuTime to screen + inline void timeCheck + ( + const string& description, + const bool check = true + ) const; - // Queries + // Indexing functions - void printInfo(Ostream& os) const; + //- Create a new unique cell index and return + inline label getNewCellIndex() const; - void printVertexInfo(Ostream& os) const; + //- Create a new unique vertex index and return + inline label getNewVertexIndex() const; - //- Create an fvMesh from the triangulation. - // The mesh is not parallel consistent - only used for viewing - autoPtr createMesh - ( - const fileName& name, - labelTolabelPairHashTable& vertexMap, - labelList& cellMap, - const bool writeDelaunayData = true - ) const; + //- Return the cell count (the next unique cell index) + inline label cellCount() const; + + //- Return the vertex count (the next unique vertex index) + inline label vertexCount() const; + + //- Set the cell count to zero + inline void resetCellCount(); + + //- Set the vertex count to zero + inline void resetVertexCount(); + + + // Triangulation manipulation functions + + //- Clear the entire triangulation + void reset(); + + //- Insert the list of vertices (calls rangeInsertWithInfo) + void insertPoints(const List& vertices); + + //- Function inserting points into a triangulation and setting the + // index and type data of the point in the correct order. This is + // faster than inserting points individually. + // + // Adapted from a post on the CGAL lists: 2010-01/msg00004.html by + // Sebastien Loriot (Geometry Factory). + template + void rangeInsertWithInfo + ( + PointIterator begin, + PointIterator end, + bool printErrors = false, + bool reIndex = true + ); + + + // Write + + //- Write mesh statistics to stream + void printInfo(Ostream& os) const; + + //- Write vertex statistics in the form of a table to stream + void printVertexInfo(Ostream& os) const; + + //- Create an fvMesh from the triangulation. + // The mesh is not parallel consistent - only used for viewing + autoPtr createMesh + ( + const fileName& name, + 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 bad25b2b83..daecf18c58 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshI.H @@ -25,17 +25,6 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - template inline const Foam::Time& Foam::DelaunayMesh::time() const { @@ -70,23 +59,6 @@ void Foam::DelaunayMesh::timeCheck } -template -inline Foam::label Foam::DelaunayMesh::getNewVertexIndex() const -{ - label id = vertexCount_++; - - if (id == labelMax) - { - WarningIn - ( - "Foam::DelaunayMesh::getNewVertexIndex() const" - ) << "Vertex counter has overflowed." << endl; - } - - return id; -} - - template inline Foam::label Foam::DelaunayMesh::getNewCellIndex() const { @@ -105,16 +77,26 @@ inline Foam::label Foam::DelaunayMesh::getNewCellIndex() const template -Foam::label Foam::DelaunayMesh::cellCount() const +inline Foam::label Foam::DelaunayMesh::getNewVertexIndex() const { - return cellCount_; + label id = vertexCount_++; + + if (id == labelMax) + { + WarningIn + ( + "Foam::DelaunayMesh::getNewVertexIndex() const" + ) << "Vertex counter has overflowed." << endl; + } + + return id; } template -void Foam::DelaunayMesh::resetCellCount() +Foam::label Foam::DelaunayMesh::cellCount() const { - cellCount_ = 0; + return cellCount_; } @@ -125,6 +107,13 @@ Foam::label Foam::DelaunayMesh::vertexCount() const } +template +void Foam::DelaunayMesh::resetCellCount() +{ + cellCount_ = 0; +} + + template void Foam::DelaunayMesh::resetVertexCount() { @@ -132,22 +121,4 @@ void Foam::DelaunayMesh::resetVertexCount() } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C index 1a341348b1..d987a8ad4f 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DelaunayMeshIO.C @@ -146,7 +146,8 @@ void Foam::DelaunayMesh::printInfo(Ostream& os) const ++vit ) { - if (!vit->farPoint()) + // Only internal or boundary vertices have a size + if (vit->internalOrBoundaryPoint()) { minSize = min(vit->targetCellSize(), minSize); maxSize = max(vit->targetCellSize(), maxSize); @@ -361,19 +362,19 @@ Foam::DelaunayMesh::createMesh // Calculate pts and a map of point index to location in pts. label vertI = 0; - labelIOField indices - ( - IOobject - ( - "indices", - time().timeName(), - name, - time(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - Triangulation::number_of_vertices() - ); +// labelIOField indices +// ( +// IOobject +// ( +// "indices", +// time().timeName(), +// name, +// time(), +// IOobject::NO_READ, +// IOobject::AUTO_WRITE +// ), +// Triangulation::number_of_vertices() +// ); labelIOField types ( @@ -414,7 +415,7 @@ Foam::DelaunayMesh::createMesh { vertexMap(labelPair(vit->index(), vit->procIndex())) = vertI; points[vertI] = topoint(vit->point()); - indices[vertI] = vit->index(); +// indices[vertI] = vit->index(); types[vertI] = static_cast