mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Incorported CV3DMesher into dev version. Added CGAL and Boost to ThirdParty, altered template-depth
This commit is contained in:
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedefs
|
||||
CGALTriangulation3Ddefs
|
||||
|
||||
Description
|
||||
CGAL data structures used for 3D Delaunay meshing.
|
||||
|
||||
Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
|
||||
otherwise the more robust but much less efficient
|
||||
Exact_predicates_exact_constructions will be used.
|
||||
|
||||
Define CGAL_HIERARCHY to use hierarchical Delaunay triangulation which is
|
||||
faster but uses more memory than the standard Delaunay triangulation.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CGALTriangulation3Ddefs_H
|
||||
#define CGALTriangulation3Ddefs_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "CGAL/Delaunay_triangulation_3.h"
|
||||
|
||||
#include "indexedVertex.H"
|
||||
#include "indexedCell.H"
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
// Fast kernel using a double as the storage type but the triangulation
|
||||
// may fail
|
||||
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
#else
|
||||
// Very robust but expensive kernel
|
||||
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||
#endif
|
||||
|
||||
typedef CGAL::indexedVertex<K> Vb;
|
||||
typedef CGAL::indexedCell<K> Cb;
|
||||
|
||||
#ifdef CGAL_HIERARCHY
|
||||
// Data structures for hierarchical Delaunay triangulation which is more
|
||||
// efficient but also uses more storage
|
||||
#include "CGAL/Triangulation_hierarchy_3.h"
|
||||
typedef CGAL::Triangulation_hierarchy_vertex_base_3<Vb> Vbh;
|
||||
typedef CGAL::Triangulation_data_structure_3<Vbh, Cb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, Tds> Triangulation;
|
||||
typedef CGAL::Triangulation_hierarchy_3<Triangulation> HTriangulation;
|
||||
#else
|
||||
// Data structures for standard Delaunay triangulation
|
||||
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, Tds> Triangulation;
|
||||
typedef Triangulation HTriangulation;
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
259
applications/utilities/mesh/generation/CV3DMesher/CV3D.C
Normal file
259
applications/utilities/mesh/generation/CV3DMesher/CV3D.C
Normal file
@ -0,0 +1,259 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
#include "Random.H"
|
||||
#include "IFstream.H"
|
||||
#include "uint.H"
|
||||
#include "ulong.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::insertBoundingBox()
|
||||
{
|
||||
Info<< "insertBoundingBox: creating bounding mesh" << nl << endl;
|
||||
scalar bigSpan = 10*tols_.span;
|
||||
insertPoint(point(-bigSpan, -bigSpan, -bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point(-bigSpan, -bigSpan, bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point(-bigSpan, bigSpan, -bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point(-bigSpan, bigSpan, bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point( bigSpan, -bigSpan, -bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point( bigSpan, -bigSpan, bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point( bigSpan, bigSpan, -bigSpan), Vb::FAR_POINT);
|
||||
insertPoint(point( bigSpan, bigSpan , bigSpan), Vb::FAR_POINT);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CV3D::CV3D
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const querySurface& qSurf
|
||||
)
|
||||
:
|
||||
HTriangulation(),
|
||||
qSurf_(qSurf),
|
||||
controls_(controlDict),
|
||||
tols_(controlDict, controls_.minCellSize, qSurf.bb()),
|
||||
startOfInternalPoints_(0),
|
||||
startOfSurfacePointPairs_(0)
|
||||
{
|
||||
// insertBoundingBox();
|
||||
insertFeaturePoints();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CV3D::~CV3D()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::insertPoints
|
||||
(
|
||||
const pointField& points,
|
||||
const scalar nearness
|
||||
)
|
||||
{
|
||||
Info<< "insertInitialPoints(const pointField& points): ";
|
||||
|
||||
startOfInternalPoints_ = number_of_vertices();
|
||||
label nVert = startOfInternalPoints_;
|
||||
|
||||
// Add the points and index them
|
||||
forAll(points, i)
|
||||
{
|
||||
const point& p = points[i];
|
||||
|
||||
if (qSurf_.wellInside(p, nearness))
|
||||
{
|
||||
insert(toPoint(p))->index() = nVert++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning
|
||||
<< "Rejecting point " << p << " outside surface" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nVert << " vertices inserted" << endl;
|
||||
|
||||
if (controls_.writeInitialTriangulation)
|
||||
{
|
||||
// Checking validity of triangulation
|
||||
assert(is_valid());
|
||||
|
||||
writeTriangles("initial_triangles.obj", true);
|
||||
// writeFaces("initial_faces.obj", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CV3D::insertPoints(const fileName& pointFileName)
|
||||
{
|
||||
IFstream pointsFile(pointFileName);
|
||||
|
||||
if (pointsFile.good())
|
||||
{
|
||||
insertPoints(pointField(pointsFile), 0.5*controls_.minCellSize2);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("insertInitialPoints")
|
||||
<< "Could not open pointsFile " << pointFileName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CV3D::insertGrid()
|
||||
{
|
||||
Info<< "insertInitialGrid: ";
|
||||
|
||||
startOfInternalPoints_ = number_of_vertices();
|
||||
label nVert = startOfInternalPoints_;
|
||||
|
||||
scalar x0 = qSurf_.bb().min().x();
|
||||
scalar xR = qSurf_.bb().max().x() - x0;
|
||||
int ni = int(xR/controls_.minCellSize) + 1;
|
||||
|
||||
scalar y0 = qSurf_.bb().min().y();
|
||||
scalar yR = qSurf_.bb().max().y() - y0;
|
||||
int nj = int(yR/controls_.minCellSize) + 1;
|
||||
|
||||
scalar z0 = qSurf_.bb().min().z();
|
||||
scalar zR = qSurf_.bb().max().z() - z0;
|
||||
int nk = int(zR/controls_.minCellSize) + 1;
|
||||
|
||||
vector delta(xR/ni, yR/nj, zR/nk);
|
||||
|
||||
delta *= pow((1.0/2.0),-(1.0/3.0));
|
||||
|
||||
Random rndGen(1321);
|
||||
scalar pert = controls_.randomPerturbation*cmptMin(delta);
|
||||
|
||||
for (int i=0; i<ni; i++)
|
||||
{
|
||||
for (int j=0; j<nj; j++)
|
||||
{
|
||||
for (int k=0; k<nk; k++)
|
||||
{
|
||||
point p1
|
||||
(
|
||||
x0 + i*delta.x(),
|
||||
y0 + j*delta.y(),
|
||||
z0 + k*delta.z()
|
||||
);
|
||||
|
||||
point p2 = p1 + 0.5*delta;
|
||||
|
||||
if (controls_.randomiseInitialGrid)
|
||||
{
|
||||
p1.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p1.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p1.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
if (qSurf_.wellInside(p1, 0.5*controls_.minCellSize2))
|
||||
{
|
||||
insert(Point(p1.x(), p1.y(), p1.z()))->index() = nVert++;
|
||||
}
|
||||
|
||||
if (controls_.randomiseInitialGrid)
|
||||
{
|
||||
p2.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p2.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p2.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
if (qSurf_.wellInside(p2, 0.5*controls_.minCellSize2))
|
||||
{
|
||||
insert(Point(p2.x(), p2.y(), p2.z()))->index() = nVert++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nVert << " vertices inserted" << nl << endl;
|
||||
|
||||
if (controls_.writeInitialTriangulation)
|
||||
{
|
||||
// Checking validity of triangulation
|
||||
assert(is_valid());
|
||||
|
||||
writePoints("initial_points.obj", true);
|
||||
writeTriangles("initial_triangles.obj", true);
|
||||
// writeFaces("initial_faces.obj", true);
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::CV3D::insertSurfacePointPairs()
|
||||
{
|
||||
startOfSurfacePointPairs_ = number_of_vertices();
|
||||
|
||||
if (controls_.insertSurfaceNearestPointPairs)
|
||||
{
|
||||
insertSurfaceNearestPointPairs();
|
||||
}
|
||||
|
||||
// if (controls_.writeNearestTriangulation)
|
||||
// {
|
||||
// writeFaces("near_allFaces.obj", false);
|
||||
// writeFaces("near_faces.obj", true);
|
||||
// writeTriangles("near_triangles.obj", true);
|
||||
// }
|
||||
|
||||
if (controls_.insertSurfaceNearPointPairs)
|
||||
{
|
||||
insertSurfaceNearPointPairs();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Foam::CV3D::boundaryConform()
|
||||
{
|
||||
}
|
||||
|
||||
void Foam::CV3D::removeSurfacePointPairs()
|
||||
{
|
||||
}
|
||||
|
||||
void Foam::CV3D::write() const
|
||||
{
|
||||
if (controls_.writeFinalTriangulation)
|
||||
{
|
||||
writePoints("allPoints.obj", false);
|
||||
writePoints("points.obj", true);
|
||||
// writeFaces("allFaces.obj", false);
|
||||
// writeFaces("faces.obj", true);
|
||||
writeTriangles("allTriangles.obj", false);
|
||||
writeTriangles("triangles.obj", true);
|
||||
// writeMesh();
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
299
applications/utilities/mesh/generation/CV3DMesher/CV3D.H
Normal file
299
applications/utilities/mesh/generation/CV3DMesher/CV3D.H
Normal file
@ -0,0 +1,299 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
CV3D
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
CV3DI.H
|
||||
CV3D.C
|
||||
CV3DIO.C
|
||||
controls.C
|
||||
tolerances.C
|
||||
insertFeaturePoints.C
|
||||
insertSurfaceNearestPointPairs.C
|
||||
insertSurfaceNearPointPairs.C
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CV3D_H
|
||||
#define CV3D_H
|
||||
|
||||
#define CGAL_INEXACT
|
||||
#define CGAL_HIERARCHY
|
||||
|
||||
#include "CGALTriangulation3Ddefs.H"
|
||||
|
||||
#include "querySurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "DynamicList.H"
|
||||
#include "Switch.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CV3D Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class CV3D
|
||||
:
|
||||
public HTriangulation
|
||||
{
|
||||
public:
|
||||
|
||||
class controls
|
||||
{
|
||||
public:
|
||||
|
||||
//- Minimum cell size below which protusions through the surface are
|
||||
// not split
|
||||
scalar minCellSize;
|
||||
|
||||
//- Square of minCellSize
|
||||
scalar minCellSize2;
|
||||
|
||||
//- The feature angle used to select corners to be
|
||||
// explicitly represented in the mesh.
|
||||
// 0 = all features, 180 = no features
|
||||
scalar featAngle;
|
||||
|
||||
//- Maximum quadrant angle allowed at a concave corner before
|
||||
// additional "mitering" lines are added
|
||||
scalar maxQuadAngle;
|
||||
|
||||
//- Insert near-boundary point mirror or point-pairs
|
||||
Switch insertSurfaceNearestPointPairs;
|
||||
|
||||
//- Insert point-pairs for dual-cell vertices very near the surface
|
||||
Switch insertSurfaceNearPointPairs;
|
||||
|
||||
Switch writeInitialTriangulation;
|
||||
Switch writeFeatureTriangulation;
|
||||
Switch writeNearestTriangulation;
|
||||
Switch writeInsertedPointPairs;
|
||||
Switch writeFinalTriangulation;
|
||||
|
||||
Switch randomiseInitialGrid;
|
||||
scalar randomPerturbation;
|
||||
|
||||
controls(const dictionary& controlDict);
|
||||
};
|
||||
|
||||
class tolerances
|
||||
{
|
||||
public:
|
||||
|
||||
//- Maximum cartesian span of the geometry
|
||||
scalar span;
|
||||
|
||||
//- Distance between boundary conforming point-pairs
|
||||
scalar ppDist;
|
||||
|
||||
//- Square of ppDist
|
||||
scalar ppDist2;
|
||||
|
||||
tolerances
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
scalar minCellSize,
|
||||
const boundBox&
|
||||
);
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- The surface to mesh
|
||||
const querySurface& qSurf_;
|
||||
|
||||
//- Meshing controls
|
||||
controls controls_;
|
||||
|
||||
//- Meshing tolerances
|
||||
tolerances tols_;
|
||||
|
||||
//- Keep track of the start of the internal points
|
||||
label startOfInternalPoints_;
|
||||
|
||||
//- Keep track of the start of the surface point-pairs
|
||||
label startOfSurfacePointPairs_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CV3D(const CV3D&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CV3D&);
|
||||
|
||||
//- Insert point and return it's index
|
||||
inline label insertPoint
|
||||
(
|
||||
const point& pt,
|
||||
const label type
|
||||
);
|
||||
|
||||
//- Create the initial mesh from the bounding-box
|
||||
void insertBoundingBox();
|
||||
|
||||
//- Insert point-pairs at the nearest points on the surface to the
|
||||
// control vertex of dual-cells which intersect the boundary in order
|
||||
// to provide a boundary-layer mesh.
|
||||
// NB: This is not guaranteed to close the boundary
|
||||
void insertSurfaceNearestPointPairs();
|
||||
|
||||
//- Insert point-pairs at small dual-cell edges on the surface in order
|
||||
// to improve the boundary-layer mesh generated by
|
||||
// insertSurfaceNearestPointPairs.
|
||||
void insertSurfaceNearPointPairs();
|
||||
|
||||
//- Dual calculation
|
||||
void calcDualMesh
|
||||
(
|
||||
pointField& points,
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
labelList& neighbour,
|
||||
wordList& patchNames,
|
||||
labelList& patchSizes,
|
||||
labelList& patchStarts
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given surface
|
||||
CV3D(const dictionary& controlDict, const querySurface& qSurf);
|
||||
|
||||
// Destructor
|
||||
|
||||
~CV3D();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const controls& meshingControls() const
|
||||
{
|
||||
return controls_;
|
||||
}
|
||||
|
||||
// Conversion functions between point and Point
|
||||
|
||||
# ifdef CGAL_INEXACT
|
||||
typedef const point& pointFromPoint;
|
||||
typedef const Point& PointFrompoint;
|
||||
# else
|
||||
typedef point pointFromPoint;
|
||||
typedef Point PointFrompoint;
|
||||
# endif
|
||||
|
||||
inline pointFromPoint topoint(const Point&) const;
|
||||
inline PointFrompoint toPoint(const point&) const;
|
||||
|
||||
// Point insertion
|
||||
|
||||
//- Create the initial mesh from the given internal points.
|
||||
// Points must be inside the boundary by at least nearness
|
||||
// otherwise they are ignored.
|
||||
void insertPoints
|
||||
(
|
||||
const pointField& points,
|
||||
const scalar nearness
|
||||
);
|
||||
|
||||
//- Create the initial mesh from the internal points in the given
|
||||
// file. Points outside the geometry are ignored.
|
||||
void insertPoints(const fileName& pointFileName);
|
||||
|
||||
//- Create the initial mesh as a regular grid of points.
|
||||
// Points outside the geometry are ignored.
|
||||
void insertGrid();
|
||||
|
||||
//- Insert point groups at the feature points.
|
||||
void insertFeaturePoints();
|
||||
|
||||
//- Insert all surface point-pairs from
|
||||
// insertSurfaceNearestPointPairs and
|
||||
// findIntersectionForOutsideCentroid
|
||||
void insertSurfacePointPairs();
|
||||
|
||||
//- Insert point-pairs where there are protrusions into
|
||||
// or out of the surface
|
||||
void boundaryConform();
|
||||
|
||||
// Point removal
|
||||
|
||||
//- Remove the point-pairs introduced by insertSurfacePointPairs
|
||||
// and boundaryConform
|
||||
void removeSurfacePointPairs();
|
||||
|
||||
// Check
|
||||
|
||||
// Edit
|
||||
|
||||
// Write
|
||||
|
||||
//- Write Delaunay points to .obj file
|
||||
void writePoints(const fileName& fName, bool internalOnly) const;
|
||||
|
||||
//- Write Delaunay triangles as .obj file
|
||||
void writeTriangles(const fileName& fName, bool internalOnly) const;
|
||||
|
||||
//- Write dual points and faces as .obj file
|
||||
void writeDual(const fileName& fName) const;
|
||||
|
||||
//- Write polyMesh
|
||||
void writeMesh(const Time& runTime);
|
||||
|
||||
void write() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "CV3DI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
104
applications/utilities/mesh/generation/CV3DMesher/CV3DI.H
Normal file
104
applications/utilities/mesh/generation/CV3DMesher/CV3DI.H
Normal file
@ -0,0 +1,104 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline Foam::label Foam::CV3D::insertPoint
|
||||
(
|
||||
const point& p,
|
||||
const label type
|
||||
)
|
||||
{
|
||||
uint nVert = number_of_vertices();
|
||||
|
||||
Vertex_handle vh = insert(toPoint(p));
|
||||
|
||||
if (nVert == number_of_vertices())
|
||||
{
|
||||
WarningIn("Foam::CV3D::insertPoint")
|
||||
<< "Failed to insert point " << p << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vh->index() = nVert;
|
||||
vh->type() = type;
|
||||
}
|
||||
|
||||
return vh->index();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
|
||||
inline Foam::CV3D::pointFromPoint Foam::CV3D::topoint
|
||||
(
|
||||
const Point& P
|
||||
) const
|
||||
{
|
||||
return reinterpret_cast<pointFromPoint>(P);
|
||||
}
|
||||
|
||||
inline Foam::CV3D::PointFrompoint Foam::CV3D::toPoint
|
||||
(
|
||||
const point& p
|
||||
) const
|
||||
{
|
||||
return reinterpret_cast<PointFrompoint>(p);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline Foam::CV3D::pointFromPoint Foam::CV3D::topoint
|
||||
(
|
||||
const Point& P
|
||||
) const
|
||||
{
|
||||
return point
|
||||
(
|
||||
CGAL::to_double(P.x()),
|
||||
CGAL::to_double(P.y()),
|
||||
CGAL::to_double(P.z())
|
||||
);
|
||||
}
|
||||
|
||||
inline Foam::CV3D::PointFrompoint Foam::CV3D::toPoint
|
||||
(
|
||||
const point& p
|
||||
) const
|
||||
{
|
||||
return Point(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
277
applications/utilities/mesh/generation/CV3DMesher/CV3DIO.C
Normal file
277
applications/utilities/mesh/generation/CV3DMesher/CV3DIO.C
Normal file
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::writePoints(const fileName& fName, bool internalOnly) const
|
||||
{
|
||||
Info << "Writing points to " << fName << nl << endl;
|
||||
OFstream str(fName);
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!internalOnly || vit->internalOrBoundaryPoint())
|
||||
{
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CV3D::writeDual(const fileName& fName) const
|
||||
{
|
||||
Info << "Writing dual points and faces to " << fName << nl << endl;
|
||||
OFstream str(fName);
|
||||
|
||||
label dualVerti = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_cells_iterator cit = finite_cells_begin();
|
||||
cit != finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
cit->vertex(0)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(1)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(2)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(3)->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
cit->cellIndex() = dualVerti;
|
||||
meshTools::writeOBJ(str, topoint(dual(cit)));
|
||||
dualVerti++;
|
||||
}
|
||||
else
|
||||
{
|
||||
cit->cellIndex() = -1;
|
||||
}
|
||||
}
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||
eit != finite_edges_end();
|
||||
++eit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
eit->first->vertex(eit->second)->internalOrBoundaryPoint()
|
||||
|| eit->first->vertex(eit->third)->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
Cell_circulator ccStart = incident_cells(*eit);
|
||||
Cell_circulator cc = ccStart;
|
||||
|
||||
str<< 'f';
|
||||
|
||||
do
|
||||
{
|
||||
if (!is_infinite(cc))
|
||||
{
|
||||
if (cc->cellIndex() < 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::CV3D::writeDual(const fileName& fName)"
|
||||
)<< "Dual face uses circumcenter defined by a Delaunay"
|
||||
" tetrahedron with no internal or boundary points."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
str<< ' ' << cc->cellIndex() + 1;
|
||||
}
|
||||
} while (++cc != ccStart);
|
||||
|
||||
str<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CV3D::writeTriangles(const fileName& fName, bool internalOnly) const
|
||||
{
|
||||
Info << "Writing triangles to " << fName << nl << endl;
|
||||
OFstream str(fName);
|
||||
|
||||
labelList vertexMap(number_of_vertices());
|
||||
label verti = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (!internalOnly || !vit->farPoint())
|
||||
{
|
||||
vertexMap[vit->index()] = verti++;
|
||||
meshTools::writeOBJ(str, topoint(vit->point()));
|
||||
}
|
||||
}
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_facets_iterator fit = finite_facets_begin();
|
||||
fit != finite_facets_end();
|
||||
++fit
|
||||
)
|
||||
{
|
||||
const Cell_handle& c(fit->first);
|
||||
|
||||
const int& oppositeVertex(fit->second);
|
||||
|
||||
List<label> facetIndices(3,-1);
|
||||
|
||||
bool writeFacet = true;
|
||||
|
||||
for(label i = 0, k = 0;i < 4; i++)
|
||||
{
|
||||
if(i != oppositeVertex)
|
||||
{
|
||||
if(!internalOnly || !c->vertex(i)->farPoint())
|
||||
{
|
||||
facetIndices[k] = i;
|
||||
k++;
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFacet = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(writeFacet)
|
||||
{
|
||||
str << "f "
|
||||
<< vertexMap[c->vertex(facetIndices[0])->index()] + 1
|
||||
<< ' ' << vertexMap[c->vertex(facetIndices[1])->index()] + 1
|
||||
<< ' ' << vertexMap[c->vertex(facetIndices[2])->index()] + 1
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::CV3D::writeMesh(const Time& runTime)
|
||||
{
|
||||
Info<< nl << "Writing polyMesh." << endl;
|
||||
|
||||
Info << nl << "Temporary hack to produce boundary" << endl;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
mag(topoint(vit->point()).x()) > 1.5
|
||||
|| mag(topoint(vit->point()).y()) > 1.5
|
||||
|| mag(topoint(vit->point()).z()) > 1.5
|
||||
)
|
||||
{
|
||||
vit->type() = Vb::FAR_POINT;
|
||||
}
|
||||
}
|
||||
|
||||
pointField points(0);
|
||||
faceList faces(0);
|
||||
labelList owner(0);
|
||||
labelList neighbour(0);
|
||||
wordList patchNames(0);
|
||||
labelList patchSizes(0);
|
||||
labelList patchStarts(0);
|
||||
|
||||
calcDualMesh
|
||||
(
|
||||
points,
|
||||
faces,
|
||||
owner,
|
||||
neighbour,
|
||||
patchNames,
|
||||
patchSizes,
|
||||
patchStarts
|
||||
);
|
||||
|
||||
IOobject io
|
||||
(
|
||||
Foam::polyMesh::defaultRegion,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
);
|
||||
|
||||
polyMesh pMesh
|
||||
(
|
||||
io,
|
||||
points,
|
||||
faces,
|
||||
owner,
|
||||
neighbour
|
||||
);
|
||||
|
||||
List<polyPatch*> patches(patchStarts.size());
|
||||
|
||||
forAll (patches, p)
|
||||
{
|
||||
patches[p] = new polyPatch
|
||||
(
|
||||
patchNames[p],
|
||||
patchSizes[p],
|
||||
patchStarts[p],
|
||||
p,
|
||||
pMesh.boundaryMesh()
|
||||
);
|
||||
}
|
||||
|
||||
pMesh.addPatches(patches);
|
||||
|
||||
if (!pMesh.write())
|
||||
{
|
||||
FatalErrorIn("CV3D::writeMesh(const Time& runTime)")
|
||||
<< "Failed writing polyMesh."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
112
applications/utilities/mesh/generation/CV3DMesher/CV3DMesher.C
Normal file
112
applications/utilities/mesh/generation/CV3DMesher/CV3DMesher.C
Normal file
@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
CV3DMesher
|
||||
|
||||
Description
|
||||
Conformal-Voronoi 3D automatic mesher
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "CV3D.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.clear();
|
||||
argList::validArgs.append("surface");
|
||||
argList::validOptions.insert("pointsFile", "<filename>");
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
// Read control dictionary
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
dictionary controlDict
|
||||
(
|
||||
IFstream(runTime.system()/args.executable() + "Dict")()
|
||||
);
|
||||
|
||||
label nIterations(readLabel(controlDict.lookup("nIterations")));
|
||||
|
||||
// Read the surface to conform to
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
querySurface surf(args.args()[1]);
|
||||
|
||||
Info<< nl
|
||||
<< "Read surface with " << surf.size() << " triangles from file "
|
||||
<< args.args()[1] << nl << endl;
|
||||
|
||||
// Read and triangulation
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
CV3D mesh(controlDict, surf);
|
||||
|
||||
if (args.options().found("pointsFile"))
|
||||
{
|
||||
fileName pointFileName(args.options()["pointsFile"]);
|
||||
mesh.insertPoints(pointFileName);
|
||||
mesh.insertSurfacePointPairs();
|
||||
mesh.boundaryConform();
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.insertGrid();
|
||||
mesh.insertSurfacePointPairs();
|
||||
mesh.boundaryConform();
|
||||
}
|
||||
|
||||
for (int iter=1; iter<=nIterations; iter++)
|
||||
{
|
||||
Info<< nl
|
||||
<< "Relaxation iteration " << iter << nl
|
||||
<< "~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
|
||||
|
||||
mesh.removeSurfacePointPairs();
|
||||
mesh.insertSurfacePointPairs();
|
||||
mesh.boundaryConform();
|
||||
}
|
||||
|
||||
mesh.write();
|
||||
|
||||
mesh.writeDual("dualMesh.obj");
|
||||
|
||||
mesh.writeMesh(runTime);
|
||||
|
||||
Info << nl << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
14
applications/utilities/mesh/generation/CV3DMesher/Make/files
Normal file
14
applications/utilities/mesh/generation/CV3DMesher/Make/files
Normal file
@ -0,0 +1,14 @@
|
||||
#include CGAL_FILES
|
||||
|
||||
querySurface.C
|
||||
CV3D.C
|
||||
controls.C
|
||||
tolerances.C
|
||||
CV3DIO.C
|
||||
CV3DMesher.C
|
||||
calcDualMesh.C
|
||||
insertFeaturePoints.C
|
||||
insertSurfaceNearestPointPairs.C
|
||||
insertSurfaceNearPointPairs.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/CV3DMesher
|
||||
@ -0,0 +1,18 @@
|
||||
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||
//EXE_DEBUG =
|
||||
|
||||
include $(GENERAL_RULES)/CGAL
|
||||
FFLAGS = -DCGAL_FILES='"${CGAL_PATH}/CGAL/files"'
|
||||
|
||||
EXE_INC = \
|
||||
${EXE_DEBUG} \
|
||||
${CGAL_INC} \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-ltriSurface \
|
||||
-ldynamicMesh
|
||||
419
applications/utilities/mesh/generation/CV3DMesher/calcDualMesh.C
Normal file
419
applications/utilities/mesh/generation/CV3DMesher/calcDualMesh.C
Normal file
@ -0,0 +1,419 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::calcDualMesh
|
||||
(
|
||||
pointField& points,
|
||||
faceList& faces,
|
||||
labelList& owner,
|
||||
labelList& neighbour,
|
||||
wordList& patchNames,
|
||||
labelList& patchSizes,
|
||||
labelList& patchStarts
|
||||
)
|
||||
{
|
||||
Info << nl << "Calculating Voronoi diagram." << endl;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dual points ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
points.setSize(number_of_cells());
|
||||
|
||||
label dualVerti = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_cells_iterator cit = finite_cells_begin();
|
||||
cit != finite_cells_end();
|
||||
++cit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
cit->vertex(0)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(1)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(2)->internalOrBoundaryPoint()
|
||||
|| cit->vertex(3)->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
cit->cellIndex() = dualVerti;
|
||||
points[dualVerti] = topoint(dual(cit));
|
||||
dualVerti++;
|
||||
}
|
||||
else
|
||||
{
|
||||
cit->cellIndex() = -1;
|
||||
}
|
||||
}
|
||||
|
||||
points.setSize(dualVerti);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~ dual cell indexing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// resets type and index information for Delaunay vertices
|
||||
// assigns an index to the vertices which will be the dual cell index used
|
||||
// for owner neighbour assignment
|
||||
|
||||
label dualCelli = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||
vit != finite_vertices_end();
|
||||
++vit
|
||||
)
|
||||
{
|
||||
if (vit->internalOrBoundaryPoint())
|
||||
{
|
||||
vit->type() = Vb::INTERNAL_POINT;
|
||||
vit->index() = dualCelli;
|
||||
dualCelli++;
|
||||
}
|
||||
else
|
||||
{
|
||||
vit->type() = Vb::FAR_POINT;
|
||||
vit->index() = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~ dual face and owner neighbour construction ~~~~~~~~~~~~~~~~~
|
||||
|
||||
label nPatches = 1;
|
||||
|
||||
patchNames.setSize(nPatches);
|
||||
|
||||
patchNames[0] = "CV3D_default_patch";
|
||||
|
||||
patchSizes.setSize(nPatches);
|
||||
|
||||
patchStarts.setSize(nPatches);
|
||||
|
||||
List<DynamicList<face> > patchFaces(nPatches, DynamicList<face>(0));
|
||||
|
||||
List<DynamicList<label> > patchOwners(nPatches, DynamicList<label>(0));
|
||||
|
||||
faces.setSize(number_of_edges());
|
||||
|
||||
owner.setSize(number_of_edges());
|
||||
|
||||
neighbour.setSize(number_of_edges());
|
||||
|
||||
label dualFacei = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||
eit != finite_edges_end();
|
||||
++eit
|
||||
)
|
||||
{
|
||||
if
|
||||
(
|
||||
eit->first->vertex(eit->second)->internalOrBoundaryPoint()
|
||||
|| eit->first->vertex(eit->third)->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
Cell_circulator ccStart = incident_cells(*eit);
|
||||
Cell_circulator cc = ccStart;
|
||||
|
||||
DynamicList<label> verticesOnFace;
|
||||
|
||||
do
|
||||
{
|
||||
if (!is_infinite(cc))
|
||||
{
|
||||
if (cc->cellIndex() < 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::CV3D::calcDualMesh"
|
||||
)<< "Dual face uses circumcenter defined by a Delaunay"
|
||||
" tetrahedron with no internal or boundary points."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
verticesOnFace.append(cc->cellIndex());
|
||||
}
|
||||
} while (++cc != ccStart);
|
||||
|
||||
verticesOnFace.shrink();
|
||||
|
||||
face newDualFace(verticesOnFace);
|
||||
|
||||
Cell_handle c = eit->first;
|
||||
Vertex_handle vA = c->vertex(eit->second);
|
||||
Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
label dcA = vA->index();
|
||||
|
||||
if (!vA->internalOrBoundaryPoint())
|
||||
{
|
||||
dcA = -1;
|
||||
}
|
||||
|
||||
label dcB = vB->index();
|
||||
|
||||
if (!vB->internalOrBoundaryPoint())
|
||||
{
|
||||
dcB = -1;
|
||||
}
|
||||
|
||||
label dcOwn = -1;
|
||||
label dcNei = -1;
|
||||
|
||||
if (dcA == -1 && dcB == -1)
|
||||
{
|
||||
FatalErrorIn("calcDualMesh")
|
||||
<< "Attempting to create a face joining "
|
||||
<< "two external dual cells "
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else if (dcA == -1 || dcB == -1)
|
||||
{
|
||||
// boundary face, find which is the owner
|
||||
|
||||
if (dcA == -1)
|
||||
{
|
||||
dcOwn = dcB;
|
||||
|
||||
// reverse face order to correctly orientate normal
|
||||
reverse(newDualFace);
|
||||
}
|
||||
else
|
||||
{
|
||||
dcOwn = dcA;
|
||||
}
|
||||
|
||||
// find which patch this face is on; Hardcoded for now.
|
||||
label patchIndex = 0;
|
||||
|
||||
patchFaces[patchIndex].append(newDualFace);
|
||||
patchOwners[patchIndex].append(dcOwn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// internal face, find the lower cell to be the owner
|
||||
|
||||
if (dcB > dcA)
|
||||
{
|
||||
dcOwn = dcA;
|
||||
dcNei = dcB;
|
||||
}
|
||||
else
|
||||
{
|
||||
dcOwn = dcB;
|
||||
dcNei = dcA;
|
||||
|
||||
// reverse face order to correctly orientate normal
|
||||
reverse(newDualFace);
|
||||
}
|
||||
|
||||
faces[dualFacei] = newDualFace;
|
||||
|
||||
owner[dualFacei] = dcOwn;
|
||||
|
||||
neighbour[dualFacei] = dcNei;
|
||||
|
||||
dualFacei++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label nInternalFaces = dualFacei;
|
||||
|
||||
faces.setSize(nInternalFaces);
|
||||
|
||||
owner.setSize(nInternalFaces);
|
||||
|
||||
neighbour.setSize(nInternalFaces);
|
||||
|
||||
// ~~~~~~~~ sort owner, reordinging neighbour and faces to match ~~~~~~~~~~~
|
||||
// two stage sort for upper triangular order: sort by owner first, then for
|
||||
// each block of owners sort by neighbour
|
||||
|
||||
labelList sortingIndices;
|
||||
|
||||
// Stage 1
|
||||
|
||||
{
|
||||
SortableList<label> sortedOwner(owner);
|
||||
|
||||
sortingIndices = sortedOwner.indices();
|
||||
}
|
||||
|
||||
{
|
||||
labelList copyOwner(owner.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyOwner[sI] = owner[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
owner = copyOwner;
|
||||
}
|
||||
|
||||
{
|
||||
labelList copyNeighbour(neighbour.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyNeighbour[sI] = neighbour[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
neighbour = copyNeighbour;
|
||||
}
|
||||
|
||||
{
|
||||
faceList copyFaces(faces.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyFaces[sI] = faces[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
faces = copyFaces;
|
||||
}
|
||||
|
||||
// Stage 2
|
||||
|
||||
sortingIndices = -1;
|
||||
|
||||
DynamicList<label> ownerCellJumps;
|
||||
|
||||
// Force first owner entry to be a jump
|
||||
ownerCellJumps.append(0);
|
||||
|
||||
for (label o = 1; o < owner.size(); o++)
|
||||
{
|
||||
if (owner[o] > owner[o-1])
|
||||
{
|
||||
ownerCellJumps.append(o);
|
||||
}
|
||||
}
|
||||
|
||||
ownerCellJumps.shrink();
|
||||
|
||||
forAll (ownerCellJumps, oCJ)
|
||||
{
|
||||
label start = ownerCellJumps[oCJ];
|
||||
|
||||
label length;
|
||||
|
||||
if (oCJ == ownerCellJumps.size() - 1)
|
||||
{
|
||||
length = owner.size() - start;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = ownerCellJumps[oCJ + 1] - start;
|
||||
}
|
||||
|
||||
SubList<label> neighbourBlock(neighbour, length, start);
|
||||
|
||||
SortableList<label> sortedNeighbourBlock(neighbourBlock);
|
||||
|
||||
forAll (sortedNeighbourBlock, sNB)
|
||||
{
|
||||
sortingIndices[start + sNB] =
|
||||
sortedNeighbourBlock.indices()[sNB] + start;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform sort
|
||||
|
||||
{
|
||||
labelList copyOwner(owner.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyOwner[sI] = owner[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
owner = copyOwner;
|
||||
}
|
||||
|
||||
{
|
||||
labelList copyNeighbour(neighbour.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyNeighbour[sI] = neighbour[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
neighbour = copyNeighbour;
|
||||
}
|
||||
|
||||
{
|
||||
faceList copyFaces(faces.size());
|
||||
|
||||
forAll (sortingIndices, sI)
|
||||
{
|
||||
copyFaces[sI] = faces[sortingIndices[sI]];
|
||||
}
|
||||
|
||||
faces = copyFaces;
|
||||
}
|
||||
|
||||
// ~~~~~~~~ add patch information ~~~~~~~~~~~
|
||||
|
||||
label nBoundaryFaces = 0;
|
||||
|
||||
forAll (patchFaces, p)
|
||||
{
|
||||
patchFaces[p].shrink();
|
||||
|
||||
patchOwners[p].shrink();
|
||||
|
||||
// TODO SORT BOUNDARY FACES AND NEIGHBOURS?
|
||||
|
||||
patchSizes[p] = patchFaces[p].size();
|
||||
|
||||
patchStarts[p] = nInternalFaces + nBoundaryFaces;
|
||||
|
||||
nBoundaryFaces += patchSizes[p];
|
||||
}
|
||||
|
||||
faces.setSize(nInternalFaces + nBoundaryFaces);
|
||||
|
||||
owner.setSize(nInternalFaces + nBoundaryFaces);
|
||||
|
||||
forAll (patchFaces, p)
|
||||
{
|
||||
forAll (patchFaces[p], f)
|
||||
{
|
||||
faces[dualFacei] = patchFaces[p][f];
|
||||
|
||||
owner[dualFacei] = patchOwners[p][f];
|
||||
|
||||
dualFacei++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
55
applications/utilities/mesh/generation/CV3DMesher/controls.C
Normal file
55
applications/utilities/mesh/generation/CV3DMesher/controls.C
Normal file
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CV3D::controls::controls(const dictionary& controlDict)
|
||||
:
|
||||
minCellSize(readScalar(controlDict.lookup("minCellSize"))),
|
||||
minCellSize2(Foam::sqr(minCellSize)),
|
||||
featAngle(readScalar(controlDict.lookup("featureAngle"))),
|
||||
maxQuadAngle(readScalar(controlDict.lookup("maxQuadAngle"))),
|
||||
insertSurfaceNearestPointPairs
|
||||
(
|
||||
controlDict.lookup("insertSurfaceNearestPointPairs")
|
||||
),
|
||||
insertSurfaceNearPointPairs
|
||||
(
|
||||
controlDict.lookup("insertSurfaceNearPointPairs")
|
||||
),
|
||||
writeInitialTriangulation(controlDict.lookup("writeInitialTriangulation")),
|
||||
writeFeatureTriangulation(controlDict.lookup("writeFeatureTriangulation")),
|
||||
writeNearestTriangulation(controlDict.lookup("writeNearestTriangulation")),
|
||||
writeInsertedPointPairs(controlDict.lookup("writeInsertedPointPairs")),
|
||||
writeFinalTriangulation(controlDict.lookup("writeFinalTriangulation")),
|
||||
randomiseInitialGrid(controlDict.lookup("randomiseInitialGrid")),
|
||||
randomPerturbation(readScalar(controlDict.lookup("randomPerturbation")))
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
154
applications/utilities/mesh/generation/CV3DMesher/indexedCell.H
Normal file
154
applications/utilities/mesh/generation/CV3DMesher/indexedCell.H
Normal file
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
indexedCell
|
||||
|
||||
Description
|
||||
An indexed form of CGAL::Triangulation_cell_base_3<K> used to keep
|
||||
track of the vertices in the triangulation.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedCell_H
|
||||
#define indexedCell_H
|
||||
|
||||
#include <CGAL/Triangulation_3.h>
|
||||
#include "indexedVertex.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class indexedCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Gt, class Cb=CGAL::Triangulation_cell_base_3<Gt> >
|
||||
class indexedCell
|
||||
:
|
||||
public Cb
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- The index for this triangle Cell
|
||||
// -1: triangle and changed and associated data needs updating
|
||||
// >=0: index of cells, set by external update algorithm
|
||||
int index_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum cellTypes
|
||||
{
|
||||
UNCHANGED = 0,
|
||||
CHANGED = -1,
|
||||
SAVE_CHANGED = -2
|
||||
};
|
||||
|
||||
typedef typename Cb::Vertex_handle Vertex_handle;
|
||||
typedef typename Cb::Cell_handle Cell_handle;
|
||||
|
||||
template < typename TDS2 >
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
|
||||
typedef indexedCell<Gt, Cb2> Other;
|
||||
};
|
||||
|
||||
|
||||
indexedCell()
|
||||
:
|
||||
Cb(),
|
||||
index_(CHANGED)
|
||||
{}
|
||||
|
||||
indexedCell
|
||||
(
|
||||
Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3
|
||||
)
|
||||
:
|
||||
Cb(v0, v1, v2, v3),
|
||||
index_(CHANGED)
|
||||
{}
|
||||
|
||||
indexedCell
|
||||
(
|
||||
Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Vertex_handle v3,
|
||||
Cell_handle n0,
|
||||
Cell_handle n1,
|
||||
Cell_handle n2,
|
||||
Cell_handle n3
|
||||
)
|
||||
:
|
||||
Cb(v0, v1, v2, v3, n0, n1, n2, n3),
|
||||
index_(CHANGED)
|
||||
{}
|
||||
|
||||
void set_vertex(int i, Vertex_handle v)
|
||||
{
|
||||
index_ = CHANGED;
|
||||
Cb::set_vertex(i, v);
|
||||
}
|
||||
|
||||
void set_vertices()
|
||||
{
|
||||
index_ = CHANGED;
|
||||
Cb::set_vertices();
|
||||
}
|
||||
|
||||
void set_vertices
|
||||
(
|
||||
Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3
|
||||
)
|
||||
{
|
||||
index_ = CHANGED;
|
||||
Cb::set_vertices(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
int& cellIndex()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
int cellIndex() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,261 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
indexedVertex
|
||||
|
||||
Description
|
||||
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep
|
||||
track of the vertices in the triangulation.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef indexedVertex_H
|
||||
#define indexedVertex_H
|
||||
|
||||
#include <CGAL/Triangulation_3.h>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class indexedVertex Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Gt, class Vb=CGAL::Triangulation_vertex_base_3<Gt> >
|
||||
class indexedVertex
|
||||
:
|
||||
public Vb
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- The index for this triangle vertex
|
||||
int index_;
|
||||
|
||||
//- Index of pair-point :
|
||||
// NEAR_BOUNDARY_POINT : internal near boundary point.
|
||||
// INTERNAL_POINT : internal point.
|
||||
// FAR_POINT : far-point.
|
||||
// >= 0 : part of point-pair. Index of other point.
|
||||
// Lowest numbered is inside one (master).
|
||||
int type_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum pointTypes
|
||||
{
|
||||
NEAR_BOUNDARY_POINT = -4,
|
||||
INTERNAL_POINT = -3,
|
||||
MIRROR_POINT = -2,
|
||||
FAR_POINT = -1
|
||||
};
|
||||
|
||||
typedef typename Vb::Vertex_handle Vertex_handle;
|
||||
typedef typename Vb::Cell_handle Cell_handle;
|
||||
typedef typename Vb::Point Point;
|
||||
|
||||
template<typename TDS2>
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
|
||||
typedef indexedVertex<Gt,Vb2> Other;
|
||||
};
|
||||
|
||||
|
||||
indexedVertex()
|
||||
:
|
||||
Vb(),
|
||||
index_(INTERNAL_POINT),
|
||||
type_(INTERNAL_POINT)
|
||||
{}
|
||||
|
||||
indexedVertex(const Point& p)
|
||||
:
|
||||
Vb(p),
|
||||
index_(INTERNAL_POINT),
|
||||
type_(INTERNAL_POINT)
|
||||
{}
|
||||
|
||||
indexedVertex(const Point& p, Cell_handle f)
|
||||
:
|
||||
Vb(f, p),
|
||||
index_(INTERNAL_POINT),
|
||||
type_(INTERNAL_POINT)
|
||||
{}
|
||||
|
||||
indexedVertex(Cell_handle f)
|
||||
:
|
||||
Vb(f),
|
||||
index_(INTERNAL_POINT),
|
||||
type_(INTERNAL_POINT)
|
||||
{}
|
||||
|
||||
|
||||
int& index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
int index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
|
||||
int& type()
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
int type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
|
||||
//- Is point a far-point
|
||||
inline bool farPoint() const
|
||||
{
|
||||
return type_ == FAR_POINT;
|
||||
}
|
||||
|
||||
//- Is point internal, i.e. not on boundary
|
||||
inline bool internalPoint() const
|
||||
{
|
||||
return type_ <= INTERNAL_POINT;
|
||||
}
|
||||
|
||||
//- Is point internal and near the boundary
|
||||
inline bool nearBoundary() const
|
||||
{
|
||||
return type_ == NEAR_BOUNDARY_POINT;
|
||||
}
|
||||
|
||||
//- Set the point to be near the boundary
|
||||
inline void setNearBoundary()
|
||||
{
|
||||
type_ = NEAR_BOUNDARY_POINT;
|
||||
}
|
||||
|
||||
//- Is point a mirror point
|
||||
inline bool mirrorPoint() const
|
||||
{
|
||||
return type_ == MIRROR_POINT;
|
||||
}
|
||||
|
||||
//- Either master or slave of pointPair.
|
||||
inline bool pairPoint() const
|
||||
{
|
||||
return type_ >= 0;
|
||||
}
|
||||
|
||||
//- Master of a pointPair is the lowest numbered one.
|
||||
inline bool ppMaster() const
|
||||
{
|
||||
if (type_ > index_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//- Slave of a pointPair is the highest numbered one.
|
||||
inline bool ppSlave() const
|
||||
{
|
||||
if (type_ >= 0 && type_ < index_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//- Either original internal point or master of pointPair.
|
||||
inline bool internalOrBoundaryPoint() const
|
||||
{
|
||||
return internalPoint() || ppMaster();
|
||||
}
|
||||
|
||||
//- Is point near the boundary or part of the boundary definition
|
||||
inline bool nearOrOnBoundary() const
|
||||
{
|
||||
return pairPoint() || mirrorPoint() || nearBoundary();
|
||||
}
|
||||
|
||||
//- Do the two given vertices consitute a boundary point-pair
|
||||
inline friend bool pointPair
|
||||
(
|
||||
const indexedVertex& v0,
|
||||
const indexedVertex& v1
|
||||
)
|
||||
{
|
||||
return v0.index_ == v1.type_ || v1.index_ == v0.type_;
|
||||
}
|
||||
|
||||
//- Do the three given vertices consitute a boundary triangle
|
||||
inline friend bool boundaryTriangle
|
||||
(
|
||||
const indexedVertex& v0,
|
||||
const indexedVertex& v1,
|
||||
const indexedVertex& v2
|
||||
)
|
||||
{
|
||||
return (v0.pairPoint() && pointPair(v1, v2))
|
||||
|| (v1.pairPoint() && pointPair(v2, v0))
|
||||
|| (v2.pairPoint() && pointPair(v0, v1));
|
||||
}
|
||||
|
||||
//- Do the three given vertices consitute an outside triangle
|
||||
inline friend bool outsideTriangle
|
||||
(
|
||||
const indexedVertex& v0,
|
||||
const indexedVertex& v1,
|
||||
const indexedVertex& v2
|
||||
)
|
||||
{
|
||||
return (v0.farPoint() || v0.ppSlave())
|
||||
|| (v1.farPoint() || v1.ppSlave())
|
||||
|| (v2.farPoint() || v2.ppSlave());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
#include "plane.H"
|
||||
#include "triSurfaceTools.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::insertFeaturePoints()
|
||||
{
|
||||
labelList featEdges(qSurf_.extractFeatures3D(controls_.featAngle));
|
||||
|
||||
const pointField& localPts = qSurf_.localPoints();
|
||||
|
||||
// forAll(featEdges, i)
|
||||
// {
|
||||
// label edgeI = featEdges[i];
|
||||
// const edge& featEdge = qSurf_.edges()[edgeI];
|
||||
//
|
||||
// // Get the feature point as the mid-point of the edge and convert to 2D
|
||||
// point featPt = featEdge.centre(qSurf_.localPoints());
|
||||
//
|
||||
// // Pick up the two faces adjacent to the feature edge
|
||||
// const labelList& eFaces = qSurf_.edgeFaces()[edgeI];
|
||||
//
|
||||
// label faceA = eFaces[0];
|
||||
// vector nA = qSurf_.faceNormals()[faceA];
|
||||
//
|
||||
// label faceB = eFaces[1];
|
||||
// vector nB = qSurf_.faceNormals()[faceB];
|
||||
//
|
||||
// // Intersect planes parallel to faceA and faceB offset by ppDist.
|
||||
// plane planeA(featPt - tols_.ppDist*nA, nA);
|
||||
// plane planeB(featPt - tols_.ppDist*nB, nB);
|
||||
// plane::ray interLine(planeA.planeIntersect(planeB));
|
||||
//
|
||||
// // The reference point is where ... TODO
|
||||
// point refPt =
|
||||
// (
|
||||
// interLine.refPoint()
|
||||
// );
|
||||
//
|
||||
// point faceAVert =
|
||||
// (
|
||||
// localPts[triSurfaceTools::oppositeVertex(qSurf_, faceA, edgeI)]
|
||||
// );
|
||||
//
|
||||
// // Determine convex or concave angle
|
||||
// if (((faceAVert - featPt) & nB) < 0)
|
||||
// {
|
||||
// // Convex. So refPt will be inside domain and hence a master point
|
||||
//
|
||||
// // Insert the master point refering the first slave
|
||||
// label masterPtIndex = insertPoint(refPt, number_of_vertices() + 1);
|
||||
//
|
||||
// // Insert the slave points by reflecting refPt in both faces.
|
||||
// // with each slave refering to the master
|
||||
//
|
||||
// point reflectedA = refPt + 2*((featPt - refPt) & nA)*nA;
|
||||
// insertPoint(reflectedA, masterPtIndex);
|
||||
//
|
||||
// point reflectedB = refPt + 2*((featPt - refPt) & nB)*nB;
|
||||
// insertPoint(reflectedB, masterPtIndex);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Concave. master and reflected points inside the domain.
|
||||
// // Generate reflected master to be outside.
|
||||
// point reflMasterPt = refPt + 2*(featPt - refPt);
|
||||
//
|
||||
// // Reflect refPt in both faces.
|
||||
// point reflectedA =
|
||||
// reflMasterPt + 2*((featPt - reflMasterPt) & nA)*nA;
|
||||
//
|
||||
// point reflectedB =
|
||||
// reflMasterPt + 2*((featPt - reflMasterPt) & nB)*nB;
|
||||
//
|
||||
// // Total angle around the concave feature
|
||||
//
|
||||
// scalar totalAngle =
|
||||
// 180*(mathematicalConstant::pi + acos(mag(nA & nB)))
|
||||
// /mathematicalConstant::pi;
|
||||
//
|
||||
//
|
||||
// // Number of quadrants the angle should be split into
|
||||
// int nQuads = int(totalAngle/controls_.maxQuadAngle) + 1;
|
||||
//
|
||||
// // The number of additional master points needed to obtain the
|
||||
// // required number of quadrants.
|
||||
// int nAddPoints = min(max(nQuads - 2, 0), 2);
|
||||
//
|
||||
// // index of reflMaster
|
||||
// label reflectedMaster = number_of_vertices() + 2 + nAddPoints;
|
||||
//
|
||||
// // Master A is inside.
|
||||
// label reflectedAI = insertPoint(reflectedA, reflectedMaster);
|
||||
//
|
||||
// // Master B is inside.
|
||||
// insertPoint(reflectedB, reflectedMaster);
|
||||
//
|
||||
// if (nAddPoints == 1)
|
||||
// {
|
||||
// // One additinal point is the reflection of the slave point,
|
||||
// // i.e. the original reference point
|
||||
// insertPoint(refPt, reflectedMaster);
|
||||
// }
|
||||
// else if (nAddPoints == 2)
|
||||
// {
|
||||
// point reflectedAa = refPt - ((featPt - reflMasterPt) & nB)*nB;
|
||||
// insertPoint(reflectedAa, reflectedMaster);
|
||||
//
|
||||
// point reflectedBb = refPt - ((featPt - reflMasterPt) & nA)*nA;
|
||||
// insertPoint(reflectedBb, reflectedMaster);
|
||||
// }
|
||||
//
|
||||
// // Slave is outside.
|
||||
// insertPoint(reflMasterPt, reflectedAI);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (controls_.writeFeatureTriangulation)
|
||||
{
|
||||
writePoints("feat_allPoints.obj", false);
|
||||
writePoints("feat_points.obj", true);
|
||||
// writeFaces("feat_allFaces.obj", false);
|
||||
// writeFaces("feat_faces.obj", true);
|
||||
writeTriangles("feat_triangles.obj", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,45 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::insertSurfaceNearPointPairs()
|
||||
{
|
||||
Info<< "insertSurfaceNearPointPairs: " << nl << endl;
|
||||
|
||||
label nNearPoints = 0;
|
||||
|
||||
// This needs a rethink from scratch in 3D.
|
||||
// Probably iterating around the facets rather than edges
|
||||
// Remember about the incident_edges, cells etc
|
||||
|
||||
Info<< nNearPoints << " point-pairs inserted" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::CV3D::insertSurfaceNearestPointPairs()
|
||||
{
|
||||
Info<< "insertSurfaceNearestPointPairs: " << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
262
applications/utilities/mesh/generation/CV3DMesher/querySurface.C
Normal file
262
applications/utilities/mesh/generation/CV3DMesher/querySurface.C
Normal file
@ -0,0 +1,262 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "querySurface.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::querySurface::querySurface(const fileName& surfaceFileName)
|
||||
:
|
||||
triSurface(surfaceFileName),
|
||||
rndGen_(12345),
|
||||
bb_(localPoints()),
|
||||
tree_
|
||||
(
|
||||
treeDataTriSurface(*this),
|
||||
bb_.extend(rndGen_, 1e-3), // slightly randomize bb
|
||||
8, // maxLevel
|
||||
4, //10, // leafsize
|
||||
10.0 //3.0 // duplicity
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::querySurface::~querySurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelList Foam::querySurface::extractFeatures2D
|
||||
(
|
||||
const scalar featAngle
|
||||
) const
|
||||
{
|
||||
scalar featCos = cos(mathematicalConstant::pi*featAngle/180.0);
|
||||
|
||||
const labelListList& edgeFaces = this->edgeFaces();
|
||||
const pointField& localPoints = this->localPoints();
|
||||
const edgeList& edges = this->edges();
|
||||
const vectorField& faceNormals = this->faceNormals();
|
||||
|
||||
DynamicList<label> featEdges(edges.size());
|
||||
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
if (magSqr(e.vec(localPoints) & vector(1,1,0)) < SMALL)
|
||||
{
|
||||
const labelList& eFaces = edgeFaces[edgeI];
|
||||
|
||||
if
|
||||
(
|
||||
eFaces.size() == 2
|
||||
&& (faceNormals[eFaces[0]] & faceNormals[eFaces[1]]) < featCos
|
||||
)
|
||||
{
|
||||
featEdges.append(edgeI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return featEdges.shrink();
|
||||
}
|
||||
|
||||
Foam::labelList Foam::querySurface::extractFeatures3D
|
||||
(
|
||||
const scalar featAngle
|
||||
) const
|
||||
{
|
||||
scalar featCos = cos(mathematicalConstant::pi*featAngle/180.0);
|
||||
|
||||
const labelListList& edgeFaces = this->edgeFaces();
|
||||
// const pointField& localPoints = this->localPoints();
|
||||
const edgeList& edges = this->edges();
|
||||
const vectorField& faceNormals = this->faceNormals();
|
||||
|
||||
DynamicList<label> featEdges(edges.size());
|
||||
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
// const edge& e = edges[edgeI];
|
||||
|
||||
const labelList& eFaces = edgeFaces[edgeI];
|
||||
|
||||
if
|
||||
(
|
||||
eFaces.size() == 2
|
||||
&& (faceNormals[eFaces[0]] & faceNormals[eFaces[1]]) < featCos
|
||||
)
|
||||
{
|
||||
featEdges.append(edgeI);
|
||||
}
|
||||
}
|
||||
|
||||
return featEdges.shrink();
|
||||
}
|
||||
|
||||
Foam::indexedOctree<Foam::treeDataTriSurface>::volumeType
|
||||
Foam::querySurface::insideOutside
|
||||
(
|
||||
const scalar searchSpan2,
|
||||
const point& pt
|
||||
) const
|
||||
{
|
||||
if (!bb_.contains(pt))
|
||||
{
|
||||
return indexedOctree<treeDataTriSurface>::OUTSIDE;
|
||||
}
|
||||
|
||||
pointIndexHit pHit = tree_.findNearest(pt, searchSpan2);
|
||||
|
||||
if (!pHit.hit())
|
||||
{
|
||||
return tree_.getVolumeType(pt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return indexedOctree<treeDataTriSurface>::MIXED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if point is inside surface
|
||||
bool Foam::querySurface::inside(const point& pt) const
|
||||
{
|
||||
if (!bb_.contains(pt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
(
|
||||
tree_.getVolumeType(pt) == indexedOctree<treeDataTriSurface>::INSIDE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Check if point is outside surface
|
||||
bool Foam::querySurface::outside(const point& pt) const
|
||||
{
|
||||
if (!bb_.contains(pt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return
|
||||
(
|
||||
tree_.getVolumeType(pt) == indexedOctree<treeDataTriSurface>::OUTSIDE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Check if point is inside surface by at least dist2
|
||||
bool Foam::querySurface::wellInside(const point& pt, const scalar dist2) const
|
||||
{
|
||||
if (!bb_.contains(pt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pointIndexHit pHit = tree_.findNearest(pt, dist2);
|
||||
|
||||
if (pHit.hit())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
tree_.getVolumeType(pt)
|
||||
== indexedOctree<treeDataTriSurface>::INSIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if point is outside surface by at least dist2
|
||||
bool Foam::querySurface::wellOutside(const point& pt, const scalar dist2) const
|
||||
{
|
||||
if (!bb_.contains(pt))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
pointIndexHit pHit = tree_.findNearest(pt, dist2);
|
||||
|
||||
if (pHit.hit())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
tree_.getVolumeType(pt)
|
||||
== indexedOctree<treeDataTriSurface>::OUTSIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::querySurface::writeTreeOBJ() const
|
||||
{
|
||||
OFstream str("tree.obj");
|
||||
label vertI = 0;
|
||||
|
||||
const List<indexedOctree<treeDataTriSurface>::node>& nodes = tree_.nodes();
|
||||
|
||||
forAll(nodes, nodeI)
|
||||
{
|
||||
const indexedOctree<treeDataTriSurface>::node& nod = nodes[nodeI];
|
||||
|
||||
const treeBoundBox& bb = nod.bb_;
|
||||
|
||||
const pointField points(bb.points());
|
||||
|
||||
label startVertI = vertI;
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
meshTools::writeOBJ(str, points[i]);
|
||||
vertI++;
|
||||
}
|
||||
|
||||
const edgeList edges(treeBoundBox::edges);
|
||||
|
||||
forAll(edges, i)
|
||||
{
|
||||
const edge& e = edges[i];
|
||||
|
||||
str << "l " << e[0]+startVertI+1 << ' ' << e[1]+startVertI+1
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
153
applications/utilities/mesh/generation/CV3DMesher/querySurface.H
Normal file
153
applications/utilities/mesh/generation/CV3DMesher/querySurface.H
Normal file
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
querySurface
|
||||
|
||||
Description
|
||||
Searchable triSurface using an octree to speed-up queries.
|
||||
|
||||
SourceFiles
|
||||
querySurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef querySurface_H
|
||||
#define querySurface_H
|
||||
|
||||
#include "triSurface.H"
|
||||
#include "treeDataTriSurface.H"
|
||||
#include "indexedOctree.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class querySurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class querySurface
|
||||
:
|
||||
public triSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
Random rndGen_;
|
||||
|
||||
// Bounding box of surface. Used for relative tolerances.
|
||||
treeBoundBox bb_;
|
||||
|
||||
// Search engine on surface
|
||||
indexedOctree<treeDataTriSurface> tree_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
querySurface(const querySurface&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const querySurface&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given file name of the surface
|
||||
querySurface(const fileName& surfaceFileName);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~querySurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const treeBoundBox& bb() const
|
||||
{
|
||||
return bb_;
|
||||
}
|
||||
|
||||
const indexedOctree<treeDataTriSurface>& tree() const
|
||||
{
|
||||
return tree_;
|
||||
}
|
||||
|
||||
|
||||
// Query
|
||||
|
||||
//- Extract feature edges/points(2D)
|
||||
// using the given feature angle in deg
|
||||
labelList extractFeatures2D(const scalar featAngle) const;
|
||||
|
||||
//- Extract feature edges/points(3D)
|
||||
// using the given feature angle in deg
|
||||
labelList extractFeatures3D(const scalar featAngle) const;
|
||||
|
||||
//- Returns inside, outside or mixed (= close to surface)
|
||||
indexedOctree<Foam::treeDataTriSurface>::volumeType insideOutside
|
||||
(
|
||||
const scalar searchSpan2,
|
||||
const point& pt
|
||||
) const;
|
||||
|
||||
//- Check if point is inside surface
|
||||
bool inside(const point& pt) const;
|
||||
|
||||
//- Check if point is outside surface
|
||||
bool outside(const point& pt) const;
|
||||
|
||||
//- Check if point is inside surface by at least dist2
|
||||
bool wellInside(const point& pt, const scalar dist2) const;
|
||||
|
||||
//- Check if point is outside surface by at least dist2
|
||||
bool wellOutside(const point& pt, const scalar dist2) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
void writeTreeOBJ() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//#include "querySurfaceI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "CV3D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CV3D::tolerances::tolerances
|
||||
(
|
||||
const dictionary& controlDict,
|
||||
const scalar minCellSize,
|
||||
const boundBox& bb
|
||||
)
|
||||
:
|
||||
span
|
||||
(
|
||||
max(mag(bb.max().x()), mag(bb.min().x()))
|
||||
+ max(mag(bb.max().y()), mag(bb.min().y()))
|
||||
+ max(mag(bb.max().z()), mag(bb.min().z()))
|
||||
),
|
||||
ppDist(readScalar(controlDict.lookup("ppDistCoeff"))*minCellSize),
|
||||
ppDist2(Foam::sqr(ppDist))
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@ CC = g++ -m64
|
||||
|
||||
include $(RULES)/c++$(WM_COMPILE_OPTION)
|
||||
|
||||
ptFLAGS = -DNoRepository -ftemplate-depth-40
|
||||
ptFLAGS = -DNoRepository -ftemplate-depth-60
|
||||
|
||||
c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user