Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2012-03-01 17:49:21 +00:00
20 changed files with 1329 additions and 303 deletions

View File

@ -0,0 +1,3 @@
checkCvMesh.C
EXE = $(FOAM_APPBIN)/checkCvMesh

View File

@ -0,0 +1,14 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/mesh/autoMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-ldynamicMesh \
-ltriSurface \
-lautoMesh \
-lmeshTools

View File

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Application
checkCvMesh
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "autoSnapDriver.H"
#include "faceSet.H"
#include "motionSmoother.H"
#include "timeSelector.H"
using namespace Foam;
int main(int argc, char *argv[])
{
# include "addOverwriteOption.H"
# include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
runTime.functionObjects().off();
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Create mesh for time = " << runTime.timeName()
<< nl << endl;
mesh.readUpdate();
Info<< "Read mesh in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
// Check patches and faceZones are synchronised
mesh.boundaryMesh().checkParallelSync(true);
meshRefinement::checkCoupledFaceZones(mesh);
// Read meshing dictionary
IOdictionary cvMeshDict
(
IOobject
(
"cvMeshDict",
runTime.system(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
// mesh motion and mesh quality parameters
const dictionary& meshQualityDict
= cvMeshDict.subDict("meshQualityControls");
Info<< "Checking initial mesh ..." << endl;
faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100);
motionSmoother::checkMesh(false, mesh, meshQualityDict, wrongFaces);
const label nInitErrors = returnReduce
(
wrongFaces.size(),
sumOp<label>()
);
Info<< "Detected " << nInitErrors << " illegal faces"
<< " (concave, zero area or negative cell pyramid volume)"
<< endl;
if (nInitErrors > 0)
{
Info<< "Writing " << nInitErrors
<< " faces in error to set "
<< wrongFaces.name() << endl;
wrongFaces.instance() = mesh.pointsInstance();
wrongFaces.write();
}
Info<< nl << "End of time " << runTime.timeName() << nl << endl;
}
Info<< "End\n" << endl;
return 0;
}

View File

@ -724,6 +724,8 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
globalBackgroundBounds_ = treeBoundBox(bbMin, bbMax);
octreeNearestDistances_ = bFTreePtr_().calcNearestDistance();
if (cvMesh_.cvMeshControls().objOutput())
{
OFstream fStr
@ -795,6 +797,7 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
),
boundaryFacesPtr_(),
bFTreePtr_(),
octreeNearestDistances_(),
allBackgroundMeshBounds_(Pstream::nProcs()),
globalBackgroundBounds_(),
decomposeDict_
@ -1150,6 +1153,8 @@ bool Foam::backgroundMeshDecomposition::positionOnThisProcessor
const point& pt
) const
{
// return bFTreePtr_().findAnyOverlap(pt, 0.0);
return
bFTreePtr_().getVolumeType(pt)
== indexedOctree<treeDataBPatch>::INSIDE;
@ -1176,6 +1181,7 @@ bool Foam::backgroundMeshDecomposition::overlapsThisProcessor
const treeBoundBox& box
) const
{
// return !procBounds().contains(box);
return !bFTreePtr_().findBox(box).empty();
}
@ -1183,9 +1189,11 @@ bool Foam::backgroundMeshDecomposition::overlapsThisProcessor
bool Foam::backgroundMeshDecomposition::overlapsThisProcessor
(
const point& centre,
scalar radiusSqr
const scalar radiusSqr
) const
{
//return bFTreePtr_().findAnyOverlap(centre, radiusSqr);
return bFTreePtr_().findNearest(centre, radiusSqr).hit();
}
@ -1645,6 +1653,7 @@ Foam::labelListList Foam::backgroundMeshDecomposition::overlapsProcessors
// If the sphere finds a nearest element of the patch, then it overlaps
sphereOverlapsCandidate[sI] = bFTreePtr_().findNearest(c, rSqr).hit();
//sphereOverlapsCandidate[sI] = bFTreePtr_().findAnyOverlap(c, rSqr);
}
map().reverseDistribute

View File

@ -111,6 +111,8 @@ class backgroundMeshDecomposition
//- Search tree for the boundaryFaces_ patch
autoPtr<indexedOctree<treeDataBPatch> > bFTreePtr_;
List<scalar> octreeNearestDistances_;
//- The bounds of all background meshes on all processors
treeBoundBoxList allBackgroundMeshBounds_;
@ -225,16 +227,16 @@ public:
//- Are the given positions inside the domain of this decomposition
boolList positionOnThisProcessor(const List<point>& pts) const;
//- Does the given box overlap the faces of the bounday of this
//- Does the given box overlap the faces of the boundary of this
// processor
bool overlapsThisProcessor(const treeBoundBox& box) const;
//- Does the given sphere overlap the faces of the bounday of this
//- Does the given sphere overlap the faces of the boundary of this
// processor
bool overlapsThisProcessor
(
const point& centre,
scalar radiusSqr
const scalar radiusSqr
) const;
//- Find nearest intersection of line between start and end, (exposing
@ -289,6 +291,12 @@ public:
//- Return access to the underlying mesh
inline const fvMesh& mesh() const;
//- Return access to the underlying tree
inline const indexedOctree<treeDataBPatch>& tree() const;
//- Return access to the nearest distance of the octree nodes
inline const List<scalar>& octreeNearestDistances() const;
//- Return the boundBox of this processor
inline const treeBoundBox& procBounds() const;
};

View File

@ -30,6 +30,18 @@ const Foam::fvMesh& Foam::backgroundMeshDecomposition::mesh() const
return mesh_;
}
const Foam::indexedOctree<Foam::treeDataBPatch>&
Foam::backgroundMeshDecomposition::tree() const
{
return bFTreePtr_();
}
const Foam::List<Foam::scalar>&
Foam::backgroundMeshDecomposition::octreeNearestDistances() const
{
return octreeNearestDistances_;
}
const Foam::treeBoundBox& Foam::backgroundMeshDecomposition::procBounds() const
{

View File

@ -240,9 +240,9 @@ void Foam::conformalVoronoiMesh::insertPoints
{
label preDistributionSize(points.size());
DynamicList<Foam::point> transferPoints(points.size()/2);
DynamicList<Foam::point> transferPoints;
DynamicList<Point> pointsOnProcessor(points.size()/2);
DynamicList<Point> pointsOnProcessor;
for
(
@ -277,12 +277,16 @@ void Foam::conformalVoronoiMesh::insertPoints
decomposition_().distributePoints(transferPoints)
);
const label oldSize = points.size();
points.setSize(oldSize + transferPoints.size());
forAll(transferPoints, tPI)
{
points.append(toPoint(transferPoints[tPI]));
points[tPI + oldSize] = toPoint(transferPoints[tPI]);
}
label sizeChange = preDistributionSize - label(points.size());
label sizeChange = preDistributionSize - points.size();
// if (mag(sizeChange) > 0)
// {
@ -417,7 +421,6 @@ void Foam::conformalVoronoiMesh::insertPoints
// );
// }
rangeInsertWithInfo
(
pts.begin(),
@ -1246,6 +1249,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
// better balance the surface conformation load.
distributeBackground();
// conformToSurface();
buildSurfaceConformation(rmCoarse);
// The introduction of the surface conformation may have distorted the
@ -1313,7 +1318,7 @@ void Foam::conformalVoronoiMesh::move()
{
cit->cellIndex() = dualVertI;
dualVertices[dualVertI] = topoint(dual(cit));
dualVertices[dualVertI] = cit->dual();
dualVertI++;
}
@ -1511,7 +1516,6 @@ void Foam::conformalVoronoiMesh::move()
(
toPoint(0.5*(dVA + dVB))
);
}
}
else if
@ -1671,9 +1675,57 @@ void Foam::conformalVoronoiMesh::move()
insertPoints(pointsToInsert);
// Remove internal points that have been inserted outside the surface.
label internalPtIsOutside = 0;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->internalPoint())
{
bool inside
= geometryToConformTo_.inside(topoint(vit->point()));
if (!inside)
{
remove(vit);
internalPtIsOutside++;
}
}
}
Info<< " " << internalPtIsOutside
<< " internal points were inserted outside the domain. "
<< "They have been removed." << endl;
// Fix points that have not been significantly displaced
// for
// (
// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
// vit != finite_vertices_end();
// ++vit
// )
// {
// if (vit->internalPoint())
// {
// if
// (
// mag(displacementAccumulator[vit->index()])
// < 0.1*targetCellSize(topoint(vit->point()))
// )
// {
// vit->setVertexFixed();
// }
// }
// }
if (cvMeshControls().objOutput() && runTime_.outputTime())
{
writePoints("points_" + runTime_.timeName() + ".obj", false);
writePoints("points_" + runTime_.timeName() + ".obj", true);
}
timeCheck("Internal points inserted");

View File

@ -48,7 +48,6 @@ SourceFiles
#define CGAL_INEXACT
#include "CGALTriangulation3Ddefs.H"
#include <CGAL/Spatial_sort_traits_adapter_3.h>
#include "uint.H"
#include "ulong.H"
#include "searchableSurfaces.H"
@ -595,6 +594,12 @@ private:
Foam::point& b
) const;
label removeProcessorBoundarySeeds(bool reinsertBoundPts);
void seedProcessorBoundarySurfaces(bool seedProcessors);
label numberOfUnusedReferredPoints() const;
//- Build the parallelInterfaces of the mesh
void buildParallelInterface
(
@ -1240,7 +1245,7 @@ public:
Traits_for_spatial_sort<Triangulation>()
);
typename Triangulation::Cell_handle hint;
typename Triangulation::Vertex_handle hint;
for
(
@ -1250,16 +1255,9 @@ public:
++p
)
{
typename Triangulation::Locate_type lt;
typename Triangulation::Cell_handle c;
label li, lj;
c = T.locate(*(p->first), lt, li, lj, hint);
const size_t checkInsertion = T.number_of_vertices();
typename Triangulation::Vertex_handle v
= T.insert(*(p->first), lt, c, li, lj);
hint = T.insert(*(p->first), hint);
if (checkInsertion != T.number_of_vertices() - 1)
{
@ -1278,12 +1276,11 @@ public:
// type directly (note that this routine never gets
// called for referredPoints so type will never be
// -procI
type += T.number_of_vertices() - 1;
type += checkInsertion;
}
v->index() = indices[oldIndex]
+ T.number_of_vertices() - 1;
v->type() = type;
hint->index() = indices[oldIndex] + checkInsertion;
hint->type() = type;
}
}
}

View File

@ -1890,7 +1890,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices
{
cit->cellIndex() = dualVertI;
pts[dualVertI] = topoint(dual(cit));
pts[dualVertI] = cit->dual();
if
(

View File

@ -125,7 +125,7 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
os << "# cell index: " << label(c->cellIndex()) << endl;
os << "# circumradius "
<< mag(topoint(dual(c)) - topoint(c->vertex(0)->point()))
<< mag(c->dual() - topoint(c->vertex(0)->point()))
<< endl;
for (int i = 0; i < 4; i++)
@ -144,7 +144,7 @@ void Foam::conformalVoronoiMesh::drawDelaunayCell
os << "# cicumcentre " << endl;
meshTools::writeOBJ(os, topoint(dual(c)));
meshTools::writeOBJ(os, c->dual());
os << "l " << 1 + offset << " " << 5 + offset << endl;
}
@ -167,7 +167,7 @@ void Foam::conformalVoronoiMesh::writePoints
++vit
)
{
if (!internalOnly || vit->internalOrBoundaryPoint())
if (!internalOnly || vit->internalPoint())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
@ -241,7 +241,7 @@ void Foam::conformalVoronoiMesh::writeProcessorInterface
{
if (!cit->farCell())
{
points[cit->cellIndex()] = topoint(dual(cit));
points[cit->cellIndex()] = cit->dual();
}
}

View File

@ -51,6 +51,7 @@ SourceFiles
#include "Swap.H"
#include "InfoProxy.H"
#include "tetCell.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -154,6 +155,8 @@ public:
inline int cellIndex() const;
inline const Foam::point& dual();
inline bool farCell() const;
inline int& filterCount();
@ -163,6 +166,11 @@ public:
//- Is the Delaunay cell real, i.e. any real vertex
inline bool real() const;
//- Does the Delaunay cell have a far point
inline bool hasFarPoint() const;
inline bool hasInternalPoint() const;
//- Does the Dual vertex form part of a processor patch
inline bool parallelDualVertex() const;
@ -190,6 +198,8 @@ public:
// least one Delaunay vertex outside and at least one inside
inline bool boundaryDualVertex() const;
inline bool nearProcBoundary() const;
// Info

View File

@ -86,6 +86,24 @@ int CGAL::indexedCell<Gt, Cb>::cellIndex() const
}
template<class Gt, class Cb>
const Foam::point& CGAL::indexedCell<Gt, Cb>::dual()
{
#ifdef CGAL_INEXACT
return reinterpret_cast<const Foam::point&>(this->circumcenter());
#else
const typename Gt::Point_3& P = this->circumcenter();
return
(
CGAL::to_double(P.x()),
CGAL::to_double(P.y()),
CGAL::to_double(P.z())
);
#endif
}
template<class Gt, class Cb>
inline bool CGAL::indexedCell<Gt, Cb>::farCell() const
{
@ -112,10 +130,45 @@ inline bool CGAL::indexedCell<Gt, Cb>::real() const
{
return
(
this->vertex(0)->real()
|| this->vertex(1)->real()
|| this->vertex(2)->real()
|| this->vertex(3)->real()
(
this->vertex(0)->real()
|| this->vertex(1)->real()
|| this->vertex(2)->real()
|| this->vertex(3)->real()
)
&&
!(
this->vertex(0)->farPoint()
|| this->vertex(1)->farPoint()
|| this->vertex(2)->farPoint()
|| this->vertex(3)->farPoint()
)
);
}
template<class Gt, class Cb>
inline bool CGAL::indexedCell<Gt, Cb>::hasFarPoint() const
{
return
(
this->vertex(0)->farPoint()
|| this->vertex(1)->farPoint()
|| this->vertex(2)->farPoint()
|| this->vertex(3)->farPoint()
);
}
template<class Gt, class Cb>
inline bool CGAL::indexedCell<Gt, Cb>::hasInternalPoint() const
{
return
(
this->vertex(0)->internalPoint()
|| this->vertex(1)->internalPoint()
|| this->vertex(2)->internalPoint()
|| this->vertex(3)->internalPoint()
);
}
@ -285,4 +338,17 @@ inline bool CGAL::indexedCell<Gt, Cb>::boundaryDualVertex() const
}
template<class Gt, class Cb>
inline bool CGAL::indexedCell<Gt, Cb>::nearProcBoundary() const
{
return
(
this->vertex(0)->nearProcBoundary()
|| this->vertex(1)->nearProcBoundary()
|| this->vertex(2)->nearProcBoundary()
|| this->vertex(3)->nearProcBoundary()
);
}
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //

View File

@ -29,7 +29,6 @@ License
\*---------------------------------------------------------------------------*/
#include "indexedVertex.H"
//#include "conformalVoronoiMesh.H"
#include "point.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //

View File

@ -45,6 +45,7 @@ SourceFiles
#include <CGAL/Triangulation_3.h>
#include "tensor.H"
#include "InfoProxy.H"
#include "point.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -101,6 +102,8 @@ class indexedVertex
//- Specify whether the vertex is fixed or movable.
bool vertexFixed_;
bool nearProcBoundary_;
public:
@ -198,6 +201,12 @@ public:
//- Set the point to be near the boundary
inline void setNearBoundary();
//- Is point internal and near a proc boundary
inline bool nearProcBoundary() const;
//- Set the point to be near a proc boundary
inline void setNearProcBoundary();
//- Either master or slave of pointPair.
inline bool pairPoint() const;
@ -227,7 +236,7 @@ public:
inline bool isVertexFixed() const;
//- Fix the vertex so that it can't be moved
inline void setVertexFixed() const;
inline void setVertexFixed();
// inline void operator=(const Delaunay::Finite_vertices_iterator vit)
// {

View File

@ -38,7 +38,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex()
type_(vtInternal),
alignment_(),
targetCellSize_(0.0),
vertexFixed_(false)
vertexFixed_(false),
nearProcBoundary_(false)
{}
@ -50,7 +51,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p)
type_(vtInternal),
alignment_(),
targetCellSize_(0.0),
vertexFixed_(false)
vertexFixed_(false),
nearProcBoundary_(false)
{}
@ -67,7 +69,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex
type_(type),
alignment_(),
targetCellSize_(0.0),
vertexFixed_(false)
vertexFixed_(false),
nearProcBoundary_(false)
{}
@ -79,7 +82,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p, Cell_handle f)
type_(vtInternal),
alignment_(),
targetCellSize_(0.0),
vertexFixed_(false)
vertexFixed_(false),
nearProcBoundary_(false)
{}
@ -91,7 +95,8 @@ inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(Cell_handle f)
type_(vtInternal),
alignment_(),
targetCellSize_(0.0),
vertexFixed_(false)
vertexFixed_(false),
nearProcBoundary_(false)
{}
@ -251,6 +256,20 @@ inline void CGAL::indexedVertex<Gt, Vb>::setNearBoundary()
}
template<class Gt, class Vb>
inline bool CGAL::indexedVertex<Gt, Vb>::nearProcBoundary() const
{
return nearProcBoundary_;
}
template<class Gt, class Vb>
inline void CGAL::indexedVertex<Gt, Vb>::setNearProcBoundary()
{
nearProcBoundary_ = true;
}
template<class Gt, class Vb>
inline bool CGAL::indexedVertex<Gt, Vb>::pairPoint() const
{
@ -331,7 +350,7 @@ inline bool CGAL::indexedVertex<Gt, Vb>::isVertexFixed() const
template<class Gt, class Vb>
inline void CGAL::indexedVertex<Gt, Vb>::setVertexFixed() const
inline void CGAL::indexedVertex<Gt, Vb>::setVertexFixed()
{
vertexFixed_ = true;
}

View File

@ -285,7 +285,9 @@ public:
) const;
//- Find the nearest points on each feature edge that is within
// a given distance from the sample point
// a given distance from the sample point. Will need to check for
// a hit or a miss because near edges may not have a nearest point
// on them which is perpendicular to the sample point.
void findAllNearestEdges
(
const point& sample,

View File

@ -379,6 +379,124 @@ Foam::label Foam::indexedOctree<Type>::compactContents
}
template <class Type>
bool Foam::indexedOctree<Type>::quickCircumsphereRejection
(
const label nodeI,
const point& cc,
const scalar crSqr,
const List<scalar>& nearestDistances
) const
{
const node& nod = nodes_[nodeI];
volumeType nodeType = volumeType(nodeTypes_.get(nodeI<<3));
//scalar boxDist = nearestDistances[nodeI] + 0.5*nod.bb_.mag();
scalar boxDist = crSqr + magSqr(cc - nod.bb_.midpoint());
if
(
nodeType == INSIDE
//&& (crSqr < sqr(boxDist))
&& (boxDist < sqr(nearestDistances[nodeI]))
)
{
return true;
}
else
{
direction octant = nod.bb_.subOctant(cc);
labelBits index = nod.subNodes_[octant];
if (isNode(index))
{
return quickCircumsphereRejection
(
getNode(index),
cc,
crSqr,
nearestDistances
);
}
else
{
return false;
}
}
}
template <class Type>
bool Foam::indexedOctree<Type>::quickCircumsphereRejection
(
const point& cc,
const scalar crSqr,
const List<scalar>& nearestDistances
) const
{
if (nodes_.size())
{
return quickCircumsphereRejection
(
0,
cc,
crSqr,
nearestDistances
);
}
return false;
}
template <class Type>
Foam::scalar
Foam::indexedOctree<Type>::calcNearestDistance
(
const label nodeI
) const
{
const node& nod = nodes_[nodeI];
const point& nodeCentre = nod.bb_.midpoint();
scalar nearestDistance = 0.0;
pointIndexHit pHit = findNearest(nodeCentre, sqr(GREAT));
if (pHit.hit())
{
nearestDistance = mag(pHit.hitPoint() - nodeCentre);
}
else
{
WarningIn("Foam::indexedOctree<Type>::calcNearestDistance(const label)")
<< "Cannot calculate distance of nearest point on surface from "
<< "the midpoint of the octree node. Returning distance of zero."
<< endl;
}
return nearestDistance;
}
template <class Type>
Foam::List<Foam::scalar>
Foam::indexedOctree<Type>::calcNearestDistance() const
{
List<scalar> nearestDistances(nodes_.size());
forAll(nearestDistances, nodeI)
{
nearestDistances[nodeI] = calcNearestDistance(nodeI);
}
return nearestDistances;
}
// Pre-calculates wherever possible the volume status per node/subnode.
// Recurses to determine status of lowest level boxes. Level above is
// combination of octants below.
@ -540,6 +658,67 @@ Foam::indexedOctree<Type>::getSide
// ~~~~~~~~~~~~~~
//
//template <class Type>
//bool Foam::indexedOctree<Type>::findAnyOverlap
//(
// const label nodeI,
// const point& sample,
// const scalar nearestDistSqr
//) const
//{
// const node& nod = nodes_[nodeI];
//
// // Determine order to walk through octants
// FixedList<direction, 8> octantOrder;
// nod.bb_.searchOrder(sample, octantOrder);
//
// // Go into all suboctants (one containing sample first) and update
// // nearest.
// for (direction i = 0; i < 8; i++)
// {
// direction octant = octantOrder[i];
//
// labelBits index = nod.subNodes_[octant];
//
// if (isNode(index))
// {
// label subNodeI = getNode(index);
//
// const treeBoundBox& subBb = nodes_[subNodeI].bb_;
//
// if (overlaps(subBb.min(), subBb.max(), nearestDistSqr, sample))
// {
// return findAnyOverlap
// (
// subNodeI,
// sample,
// nearestDistSqr
// );
// }
// }
// else if (isContent(index))
// {
// if
// (
// overlaps
// (
// nod.bb_,
// octant,
// nearestDistSqr,
// sample
// )
// )
// {
// return true;
// }
// }
// }
//
// return false;
//}
// Find nearest point starting from nodeI
template <class Type>
void Foam::indexedOctree<Type>::findNearest
@ -1614,7 +1793,6 @@ void Foam::indexedOctree<Type>::traverseNode
}
}
const node& nod = nodes_[nodeI];
labelBits index = nod.subNodes_[octant];
@ -1781,6 +1959,11 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
label i = 0;
for (; i < 100000; i++)
{
// if (isLineInsideOrOutside(nodeI, treeStart, treeEnd))
// {
// return hitInfo;
// }
// Ray-trace to end of current node. Updates point (either on triangle
// in case of hit or on node bounding box in case of miss)
@ -1935,6 +2118,38 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
}
//template <class Type>
//bool Foam::indexedOctree<Type>::isLineInsideOrOutside
//(
// const label nodeI,
// const point& start,
// const point& end
//) const
//{
// const node& nod = nodes_[nodeI];
//
// direction startOctant = nod.bb_.subOctant(start);
// direction endOctant = nod.bb_.subOctant(end);
//
// if (startOctant == endOctant)
// {
// volumeType startOctantType
// = volumeType(nodeTypes_.get((nodeI<<3) + startOctant));
//
// if
// (
// startOctantType == INSIDE || startOctantType == OUTSIDE
// )
// {
// //Info<< nodeI << " | " << start << " " << end << endl;
// return true;
// }
// }
//
// return false;
//}
// Find first intersection
template <class Type>
Foam::pointIndexHit Foam::indexedOctree<Type>::findLine
@ -2559,6 +2774,27 @@ Foam::scalar& Foam::indexedOctree<Type>::perturbTol()
}
//template <class Type>
//bool Foam::indexedOctree<Type>::findAnyOverlap
//(
// const point& sample,
// const scalar startDistSqr
//) const
//{
// if (nodes_.size())
// {
// return findAnyOverlap
// (
// 0,
// sample,
// startDistSqr
// );
// }
//
// return false;
//}
template <class Type>
Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
(

View File

@ -201,6 +201,16 @@ private:
label& compactI
);
scalar calcNearestDistance(const label nodeI) const;
bool quickCircumsphereRejection
(
const label nodeI,
const point& cc,
const scalar crSqr,
const List<scalar>& nearestDistances
) const;
//- Determine inside/outside per node (mixed if cannot be
// determined). Only valid for closed shapes.
volumeType calcVolumeType(const label nodeI) const;
@ -320,6 +330,13 @@ private:
const bool verbose = false
) const;
// bool isLineInsideOrOutside
// (
// const label nodeI,
// const point& start,
// const point& end
// ) const;
//- Find any or nearest intersection of line between start and end.
pointIndexHit findLine
(
@ -532,6 +549,19 @@ public:
const scalar nearestDistSqr
) const;
// bool findAnyOverlap
// (
// const point& sample,
// const scalar nearestDistSqr
// ) const;
//
// bool findAnyOverlap
// (
// const label nodeI,
// const point& sample,
// const scalar nearestDistSqr
// ) const;
//- Low level: calculate nearest starting from subnode.
void findNearest
(
@ -628,6 +658,16 @@ public:
CompareOp& cop
) const;
//- Return a list containing the nearest distance of nodes to any
// shapes
List<scalar> calcNearestDistance() const;
bool quickCircumsphereRejection
(
const point& cc,
const scalar crSqr,
const List<scalar>& nearestDistances
) const;
// Write

View File

@ -546,6 +546,49 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
}
featurePointNormals_ = featurePointNormals;
// Create featurePointEdges_
// For each feature point, stores a list of edges which are arranged in
// order according to their connectivity
// featurePointEdges_.setSize(nonFeatureStart_);
//
// Info<< sFeatEds.size() << " " << surf.pointEdges().size() << " "
// << edges().size() << endl;
//
// forAll(sFeatEds, eI)
// {
// Info<< "Edge " << eI << " " << sFeatEds[eI] << " "
// << edges()[eI] << endl;
// }
//
// const edgeList& edges = eds;
//
// for (label i = 0; i < nonFeatureStart_; i++)
// {
// const labelList& ptEds = surf.pointEdges()[i];
//
// DynamicList<label> tmpFtEdges;
//
// forAll(ptEds, eI)
// {
// const label edgeI = ptEds[eI];
// const edge& e = sFeatEds[edgeI];
//
// Info<< "Edges: " << edgeI << " " << e << endl;
//
// forAll(sFeatEds, fEdgeI)
// {
// if (edges[fEdgeI] == e)
// {
// tmpFtEdges.append(fEdgeI);
// }
// }
// }
//
// featurePointEdges_[i] = tmpFtEdges;
// }
}
@ -821,7 +864,7 @@ void Foam::extendedFeatureEdgeMesh::allNearestFeatureEdges
if (!hitPoint.hit())
{
nearHit = pointIndexHit(true, hitPoint.missPoint(), hitIndex);
nearHit = pointIndexHit(false, hitPoint.missPoint(), hitIndex);
}
else
{