ENH: foamyHexMesh: Move writing functions to a new namespace

This commit is contained in:
laurence
2013-07-29 15:16:37 +01:00
parent c1a77b102e
commit 2bfe5c8864
9 changed files with 654 additions and 434 deletions

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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 "DelaunayMeshTools.H"
#include "meshTools.H"
#include "OFstream.H"
#include "pointConversion.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::DelaunayMeshTools::writeOBJ
(
const fileName& fName,
const List<Foam::point>& points
)
{
if (points.size())
{
OFstream str(fName);
Pout<< nl
<< "Writing " << points.size() << " points from pointList to "
<< str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
}
}
void Foam::DelaunayMeshTools::writeOBJ
(
const fileName& fName,
const List<Vb>& points
)
{
if (points.size())
{
OFstream str(fName);
Pout<< nl
<< "Writing " << points.size() << " points from pointList to "
<< str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, topoint(points[p].point()));
}
}
}
void Foam::DelaunayMeshTools::writeObjMesh
(
const fileName& fName,
const pointField& points,
const faceList& faces
)
{
OFstream str(fName);
Pout<< nl
<< "Writing points and faces to " << str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
forAll(faces, f)
{
str<< 'f';
const face& fP = faces[f];
forAll(fP, p)
{
str<< ' ' << fP[p] + 1;
}
str<< nl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,152 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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::DelaunayMeshTools
Description
Collection of functions for operating on a Delaunay mesh. Includes:
- Functions for writing to an OBJ file
- Functions for extracting fields from the Delaunay triangulation
SourceFiles
DelaunayMeshToolsI.H
DelaunayMeshTools.C
\*---------------------------------------------------------------------------*/
#ifndef DelaunayMeshTools_H
#define DelaunayMeshTools_H
#include "fileName.H"
#include "List.H"
#include "point.H"
#include "CGALTriangulation3Ddefs.H"
#include "indexedVertexEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Namespace DelaunayMeshTools Declaration
\*---------------------------------------------------------------------------*/
namespace DelaunayMeshTools
{
// OBJ writing
//- Write list of points to file
void writeOBJ(const fileName& fName, const List<Foam::point>& points);
//- Write list of points to file
void writeOBJ(const fileName& fName, const List<Vb>& points);
//- Write an OBJ mesh consisting of points and faces
void writeObjMesh
(
const fileName& fName,
const pointField& points,
const faceList& faces
);
//- Write Delaunay points in the range between (and including)
// type startPointType and endPointType to an OBJ file
template<typename Triangulation>
void writeOBJ
(
const fileName& fName,
const Triangulation& t,
const indexedVertexEnum::vertexType startPointType,
const indexedVertexEnum::vertexType endPointType
);
//- Write Delaunay points of type pointType to .obj file
template<typename Triangulation>
void writeOBJ
(
const fileName& fName,
const Triangulation& t,
const indexedVertexEnum::vertexType pointType
);
//- Write the fixed Delaunay points to an OBJ file
template<typename Triangulation>
void writeFixedPoints(const fileName& fName, const Triangulation& t);
//- Write the boundary Delaunay points to an OBJ file
template<typename Triangulation>
void writeBoundaryPoints(const fileName& fName, const Triangulation& t);
//- Write the processor interface to an OBJ file
template<typename Triangulation>
void writeProcessorInterface
(
const fileName& fName,
const Triangulation& t,
const faceList& faces
);
//- Write the internal Delaunay vertices of the tessellation as a
// pointField that may be used to restart the meshing process
template<typename Triangulation>
void writeInternalDelaunayVertices
(
const fileName& instance,
const Triangulation& t
);
//- Draws a tet cell to an output stream. The offset is supplied as the tet
// number to be drawn.
template<typename CellHandle>
void drawDelaunayCell(Ostream& os, const CellHandle& c, label offset = 0);
// Field extraction
//- Extract all points in vertex-index order
template<typename Triangulation>
tmp<pointField> allPoints(const Triangulation& t);
} // End namespace DelaunayMeshTools
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "DelaunayMeshToolsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,305 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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 "DelaunayMeshTools.H"
#include "meshTools.H"
#include "OFstream.H"
#include "pointConversion.H"
#include "pointIOField.H"
#include "indexedVertexOps.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeOBJ
(
const fileName& fName,
const Triangulation& t,
const indexedVertexEnum::vertexType startPointType,
const indexedVertexEnum::vertexType endPointType
)
{
OFstream str(fName);
Pout<< nl
<< "Writing points of types:" << nl;
forAllConstIter
(
HashTable<int>,
indexedVertexEnum::vertexTypeNames_,
iter
)
{
if (iter() >= startPointType && iter() <= endPointType)
{
Pout<< " " << iter.key() << nl;
}
}
Pout<< "to " << str.name() << endl;
for
(
typename Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (vit->type() >= startPointType && vit->type() <= endPointType)
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeOBJ
(
const fileName& fName,
const Triangulation& t,
const indexedVertexEnum::vertexType pointType
)
{
writeOBJ(fName, t, pointType, pointType);
}
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeFixedPoints
(
const fileName& fName,
const Triangulation& t
)
{
OFstream str(fName);
Pout<< nl
<< "Writing fixed points to " << str.name() << endl;
for
(
typename Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (vit->fixed())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeBoundaryPoints
(
const fileName& fName,
const Triangulation& t
)
{
OFstream str(fName);
Pout<< nl
<< "Writing boundary points to " << str.name() << endl;
for
(
typename Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (!vit->internalPoint())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeProcessorInterface
(
const fileName& fName,
const Triangulation& t,
const faceList& faces
)
{
OFstream str(fName);
pointField points(t.number_of_finite_cells(), point::max);
for
(
typename Triangulation::Finite_cells_iterator cit =
t.finite_cells_begin();
cit != t.finite_cells_end();
++cit
)
{
if (!cit->hasFarPoint() && !t.is_infinite(cit))
{
points[cit->cellIndex()] = cit->dual();
}
}
meshTools::writeOBJ(str, faces, points);
}
template<typename Triangulation>
void Foam::DelaunayMeshTools::writeInternalDelaunayVertices
(
const fileName& instance,
const Triangulation& t
)
{
pointField internalDelaunayVertices(t.number_of_vertices());
label vertI = 0;
for
(
typename Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (vit->internalPoint())
{
internalDelaunayVertices[vertI++] = topoint(vit->point());
}
}
internalDelaunayVertices.setSize(vertI);
pointIOField internalDVs
(
IOobject
(
"internalDelaunayVertices",
instance,
t.time(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
internalDelaunayVertices
);
Info<< nl
<< "Writing " << internalDVs.name()
<< " to " << internalDVs.instance()
<< endl;
internalDVs.write();
}
template<typename CellHandle>
void Foam::DelaunayMeshTools::drawDelaunayCell
(
Ostream& os,
const CellHandle& c,
label offset
)
{
// Supply offset as tet number
offset *= 4;
os << "# cell index: " << label(c->cellIndex())
<< " INT_MIN = " << INT_MIN
<< endl;
os << "# circumradius "
<< mag(c->dual() - topoint(c->vertex(0)->point()))
<< endl;
for (int i = 0; i < 4; i++)
{
os << "# index / type / procIndex: "
<< label(c->vertex(i)->index()) << " "
<< label(c->vertex(i)->type()) << " "
<< label(c->vertex(i)->procIndex())
<<
(
CGAL::indexedVertexOps::uninitialised(c->vertex(i))
? " # This vertex is uninitialised!"
: ""
)
<< endl;
meshTools::writeOBJ(os, topoint(c->vertex(i)->point()));
}
os << "f " << 1 + offset << " " << 3 + offset << " " << 2 + offset << nl
<< "f " << 2 + offset << " " << 3 + offset << " " << 4 + offset << nl
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
// os << "# cicumcentre " << endl;
// meshTools::writeOBJ(os, c->dual());
// os << "l " << 1 + offset << " " << 5 + offset << endl;
}
template<typename Triangulation>
Foam::tmp<Foam::pointField> Foam::DelaunayMeshTools::allPoints
(
const Triangulation& t
)
{
tmp<pointField> tpts(new pointField(t.number_of_vertices(), point::max));
pointField& pts = tpts();
label nVert = 0;
for
(
typename Triangulation::Finite_vertices_iterator vit =
t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit
)
{
if (vit->internalOrBoundaryPoint())
{
pts[nVert++] = topoint(vit->point());
}
}
return tpts;
}
// ************************************************************************* //

View File

@ -1,5 +1,7 @@
#include CGAL_FILES
DelaunayMeshTools/DelaunayMeshTools.C
conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C
conformalVoronoiMesh/indexedCell/indexedCellEnum.C

View File

@ -34,6 +34,7 @@ License
#include "controlMeshRefinement.H"
#include "smoothAlignmentSolver.H"
#include "OBJstream.H"
#include "DelaunayMeshTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -288,7 +289,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
if (foamyHexMeshControls().objOutput() && fName != fileName::null)
{
writePoints(fName, pts);
DelaunayMeshTools::writeOBJ(time().path()/fName, pts);
}
}
@ -328,7 +329,7 @@ void Foam::conformalVoronoiMesh::insertEdgePointGroups
if (foamyHexMeshControls().objOutput() && fName != fileName::null)
{
writePoints(fName, pts);
DelaunayMeshTools::writeOBJ(time().path()/fName, pts);
}
}
@ -381,9 +382,10 @@ void Foam::conformalVoronoiMesh::insertInitialPoints()
if (foamyHexMeshControls().objOutput())
{
writePoints
DelaunayMeshTools::writeOBJ
(
"initialPoints.obj",
time().path()/"initialPoints.obj",
*this,
Foam::indexedVertexEnum::vtInternal
);
}
@ -625,8 +627,8 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace
Vertex_handle vA = c->vertex(eit->second);
Vertex_handle vB = c->vertex(eit->third);
drawDelaunayCell(Pout, cc1);
drawDelaunayCell(Pout, cc2);
DelaunayMeshTools::drawDelaunayCell(Pout, cc1);
DelaunayMeshTools::drawDelaunayCell(Pout, cc2);
FatalErrorIn("Foam::conformalVoronoiMesh::buildDualFace")
<< "Dual face uses circumcenter defined by a "
@ -953,9 +955,10 @@ void Foam::conformalVoronoiMesh::initialiseForMotion()
if (foamyHexMeshControls().objOutput())
{
writePoints
DelaunayMeshTools::writeOBJ
(
"internalPoints_" + runTime_.timeName() + ".obj",
time().path()/"internalPoints_" + time().timeName() + ".obj",
*this,
Foam::indexedVertexEnum::vtUnassigned,
Foam::indexedVertexEnum::vtExternalFeaturePoint
);
@ -1614,16 +1617,21 @@ void Foam::conformalVoronoiMesh::move()
if (foamyHexMeshControls().objOutput())
{
writePoints
DelaunayMeshTools::writeOBJ
(
"internalPoints_" + time().timeName() + ".obj",
time().path()/"internalPoints_" + time().timeName() + ".obj",
*this,
Foam::indexedVertexEnum::vtInternal
);
}
if (foamyHexMeshControls().objOutput() && time().outputTime())
{
writeBoundaryPoints("boundaryPoints_" + time().timeName() + ".obj");
if (reconformToSurface())
{
DelaunayMeshTools::writeBoundaryPoints
(
time().path()/"boundaryPoints_" + time().timeName() + ".obj",
*this
);
}
}
timeCheck("After conformToSurface");
@ -1776,7 +1784,7 @@ void Foam::conformalVoronoiMesh::checkCoPlanarCells() const
<< " quality = " << quality << nl
<< " dual = " << topoint(cit->dual()) << endl;
drawDelaunayCell(str, cit, badCells++);
DelaunayMeshTools::drawDelaunayCell(str, cit, badCells++);
FixedList<PointExact, 4> cellVerticesExact(PointExact(0,0,0));
forAll(cellVerticesExact, vI)

View File

@ -228,36 +228,6 @@ private:
const Delaunay::Finite_facets_iterator& fit
) const;
//- Return the local point pair separation at the given location
inline scalar pointPairDistance(const Foam::point& pt) const;
//- Return the local mixed feature point placement distance
inline scalar mixedFeaturePointDistance(const Foam::point& pt) const;
//- Return the square of the local feature point exclusion distance
inline scalar featurePointExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local feature edge exclusion distance
inline scalar featureEdgeExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local surface point exclusion distance
inline scalar surfacePtExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local surface search distance
inline scalar surfaceSearchDistanceSqr(const Foam::point& pt) const;
//- Return the local maximum surface protrusion distance
inline scalar maxSurfaceProtrusion(const Foam::point& pt) const;
//- Insert Delaunay vertices using the CGAL range insertion method,
// optionally check processor occupancy and distribute to other
// processors
@ -850,9 +820,6 @@ private:
//- Create the cell centres to use for the mesh
void createCellCentres(pointField& cellCentres) const;
//- Extract all points in vertex-index order
tmp<pointField> allPoints() const;
//- Sort the faces, owner and neighbour lists into
// upper-triangular order. For internal faces only, use
// before adding patch faces
@ -1022,6 +989,49 @@ public:
inline const cvControls& foamyHexMeshControls() const;
// Query
//- Return the local point pair separation at the given location
inline scalar pointPairDistance(const Foam::point& pt) const;
//- Return the local mixed feature point placement distance
inline scalar mixedFeaturePointDistance
(
const Foam::point& pt
) const;
//- Return the square of the local feature point exclusion distance
inline scalar featurePointExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local feature edge exclusion distance
inline scalar featureEdgeExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local surface point exclusion distance
inline scalar surfacePtExclusionDistanceSqr
(
const Foam::point& pt
) const;
//- Return the square of the local surface search distance
inline scalar surfaceSearchDistanceSqr(const Foam::point& pt) const;
//- Return the local maximum surface protrusion distance
inline scalar maxSurfaceProtrusion(const Foam::point& pt) const;
//- Call the appropriate function to conform to an edge
void createEdgePointGroup
(
const extendedFeatureEdgeMesh& feMesh,
const pointIndexHit& edHit,
DynamicList<Vb>& pts
) const;
// Write
//- Write the elapsedCpuTime and memory usage, with an optional
@ -1038,53 +1048,6 @@ public:
const string& description = string::null
) const;
//- Write the Delaunay cell
void drawDelaunayCell
(
Ostream& os,
const Cell_handle& c,
label offset = 0
) const;
//- Write Delaunay points in the range between (and including)
// type startPointType and endPointType to .obj file
void writePoints
(
const fileName& fName,
const Foam::indexedVertexEnum::vertexType startPointType,
const Foam::indexedVertexEnum::vertexType endPointType
) const;
//- Write Delaunay points of type pointType to .obj file
void writePoints
(
const fileName& fName,
const Foam::indexedVertexEnum::vertexType pointType
) const;
void writeFixedPoints(const fileName& fName) const;
//- Write the boundary Delaunay points to .obj file
void writeBoundaryPoints(const fileName& fName) const;
//- Write list of points to file
void writePoints
(
const fileName& fName,
const List<Foam::point>& points
) const;
//- Write list of points to file
void writePoints
(
const fileName& fName,
const List<Vb>& points
) const;
//- Write the internal Delaunay vertices of the tessellation as a
// pointField that may be used to restart the meshing process
void writeInternalDelaunayVertices(const fileName& instance) const;
//- Prepare data and call writeMesh for polyMesh and
// tetDualMesh
void writeMesh(const fileName& instance);
@ -1105,14 +1068,6 @@ public:
const PackedBoolList& boundaryFacesToRemove
) const;
//- Write points and faces as .obj file
void writeObjMesh
(
const pointField& points,
const faceList& faces,
const fileName& fName
) const;
//- Calculate and write a field of the target cell size,
// target cell volume, actual cell volume and equivalent
// actual cell size (cbrt(actual cell volume)).
@ -1126,12 +1081,6 @@ public:
//- Find the cellSet of the boundary cells which have points that
// protrude out of the surface beyond a tolerance.
labelHashSet findRemainingProtrusionSet(const polyMesh& mesh) const;
void writeProcessorInterface
(
const fileName& fName,
const faceList& faces
) const;
};

View File

@ -29,6 +29,7 @@ License
#include "polyMeshGeometry.H"
#include "indexedCellChecks.H"
#include "OBJstream.H"
#include "DelaunayMeshTools.H"
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
#include "CGAL/Gmpq.h"
@ -598,7 +599,7 @@ void Foam::conformalVoronoiMesh::calcDualMesh
// deferredCollapseFaceSet(owner, neighbour, deferredCollapseFaces);
cellCentres = allPoints();
cellCentres = DelaunayMeshTools::allPoints(*this);
cellToDelaunayVertex = removeUnusedCells(owner, neighbour);
@ -1227,7 +1228,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
);
//createCellCentres(cellCentres);
cellCentres = allPoints();
cellCentres = DelaunayMeshTools::allPoints(*this);
labelList cellToDelaunayVertex(removeUnusedCells(owner, neighbour));
cellCentres = pointField(cellCentres, cellToDelaunayVertex);
@ -2443,7 +2444,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
&& vc2->neighbor(cI)->hasConstrainedPoint()
)
{
drawDelaunayCell
DelaunayMeshTools::drawDelaunayCell
(
cellStr,
vc2->neighbor(cI),
@ -2837,7 +2838,12 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
+ name(neighbour)
+ "_interface.obj";
writeProcessorInterface(fName, procPatchFaces);
DelaunayMeshTools::writeProcessorInterface
(
time().path()/fName,
*this,
procPatchFaces
);
}
}
}
@ -2871,30 +2877,6 @@ void Foam::conformalVoronoiMesh::createCellCentres
}
Foam::tmp<Foam::pointField> Foam::conformalVoronoiMesh::allPoints() const
{
tmp<pointField> tpts(new pointField(number_of_vertices(), point::max));
pointField& pts = tpts();
label nVert = 0;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->internalOrBoundaryPoint())
{
pts[nVert++] = topoint(vit->point());
}
}
return tpts;
}
void Foam::conformalVoronoiMesh::sortFaces
(
faceList& faces,

View File

@ -28,6 +28,7 @@ License
#include "triangle.H"
#include "tetrahedron.H"
#include "const_circulator.H"
#include "DelaunayMeshTools.H"
using namespace Foam::vectorTools;

View File

@ -33,6 +33,7 @@ License
#include "polyTopoChange.H"
#include "PrintTable.H"
#include "pointMesh.H"
#include "DelaunayMeshTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -91,272 +92,9 @@ void Foam::conformalVoronoiMesh::timeCheck
}
void Foam::conformalVoronoiMesh::drawDelaunayCell
(
Ostream& os,
const Cell_handle& c,
label offset
) const
{
// Supply offset as tet number
offset *= 4;
os << "# cell index: " << label(c->cellIndex())
<< " INT_MIN = " << INT_MIN
<< endl;
os << "# circumradius "
<< mag(c->dual() - topoint(c->vertex(0)->point()))
<< endl;
for (int i = 0; i < 4; i++)
{
os << "# index / type / procIndex: "
<< label(c->vertex(i)->index()) << " "
<< label(c->vertex(i)->type()) << " "
<< label(c->vertex(i)->procIndex())
<< (is_infinite(c->vertex(i)) ? " # This vertex is infinite!" : "")
<<
(
c->vertex(i)->uninitialised()
? " # This vertex is uninitialised!"
: ""
)
<< endl;
meshTools::writeOBJ(os, topoint(c->vertex(i)->point()));
}
os << "f " << 1 + offset << " " << 3 + offset << " " << 2 + offset << nl
<< "f " << 2 + offset << " " << 3 + offset << " " << 4 + offset << nl
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
// os << "# cicumcentre " << endl;
// meshTools::writeOBJ(os, c->dual());
// os << "l " << 1 + offset << " " << 5 + offset << endl;
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
const Foam::indexedVertexEnum::vertexType startPointType,
const Foam::indexedVertexEnum::vertexType endPointType
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing points of types:" << nl;
forAllConstIter
(
HashTable<int>,
Foam::indexedVertexEnum::vertexTypeNames_,
iter
)
{
if (iter() >= startPointType && iter() <= endPointType)
{
Pout<< " " << iter.key() << nl;
}
}
Pout<< "to " << str.name() << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->type() >= startPointType && vit->type() <= endPointType)
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
const Foam::indexedVertexEnum::vertexType pointType
) const
{
writePoints(fName, pointType, pointType);
}
void Foam::conformalVoronoiMesh::writeFixedPoints
(
const fileName& fName
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing fixed points to " << str.name() << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->fixed())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
void Foam::conformalVoronoiMesh::writeBoundaryPoints
(
const fileName& fName
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing boundary points to " << str.name() << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (!vit->internalPoint())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
const List<Foam::point>& points
) const
{
if (points.size())
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing " << points.size() << " points from pointList to "
<< str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
}
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
const List<Vb>& points
) const
{
if (points.size())
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing " << points.size() << " points from pointList to "
<< str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, topoint(points[p].point()));
}
}
}
void Foam::conformalVoronoiMesh::writeProcessorInterface
(
const fileName& fName,
const faceList& faces
) const
{
OFstream str(runTime_.path()/fName);
pointField points(number_of_finite_cells(), point::max);
for
(
Delaunay::Finite_cells_iterator cit = finite_cells_begin();
cit != finite_cells_end();
++cit
)
{
if (!cit->hasFarPoint() && !is_infinite(cit))
{
points[cit->cellIndex()] = cit->dual();
}
}
meshTools::writeOBJ(str, faces, points);
}
void Foam::conformalVoronoiMesh::writeInternalDelaunayVertices
(
const fileName& instance
) const
{
pointField internalDelaunayVertices(number_of_vertices());
label vertI = 0;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->internalPoint())
{
internalDelaunayVertices[vertI++] = topoint(vit->point());
}
}
internalDelaunayVertices.setSize(vertI);
pointIOField internalDVs
(
IOobject
(
"internalDelaunayVertices",
instance,
runTime_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
internalDelaunayVertices
);
Info<< nl
<< "Writing " << internalDVs.name()
<< " to " << internalDVs.instance()
<< endl;
internalDVs.write();
}
void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
{
writeInternalDelaunayVertices(instance);
DelaunayMeshTools::writeInternalDelaunayVertices(instance, *this);
// Per cell the Delaunay vertex
labelList cellToDelaunayVertex;
@ -1049,7 +787,12 @@ void Foam::conformalVoronoiMesh::writeMesh
{
if (foamyHexMeshControls().objOutput())
{
writeObjMesh(points, faces, word(meshName + ".obj"));
DelaunayMeshTools::writeObjMesh
(
time().path()/word(meshName + ".obj"),
points,
faces
);
}
const label nInternalFaces = readLabel(patchDicts[0].lookup("startFace"));
@ -1404,38 +1147,6 @@ void Foam::conformalVoronoiMesh::writeMesh
}
void Foam::conformalVoronoiMesh::writeObjMesh
(
const pointField& points,
const faceList& faces,
const fileName& fName
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing points and faces to " << str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
forAll(faces, f)
{
str<< 'f';
const face& fP = faces[f];
forAll(fP, p)
{
str<< ' ' << fP[p] + 1;
}
str<< nl;
}
}
void Foam::conformalVoronoiMesh::writeCellSizes
(
const fvMesh& mesh