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

This commit is contained in:
andy
2013-07-23 15:00:17 +01:00
40 changed files with 496 additions and 644 deletions

View File

@ -122,7 +122,7 @@ Foam::DelaunayMesh<Triangulation>::DelaunayMesh
if (indices.headerOk()) if (indices.headerOk())
{ {
vh->index() = indices[ptI]; vh->index() = indices[ptI];
vertexCount()++; vertexCount_++;
} }
else else
{ {

View File

@ -201,7 +201,6 @@ public:
inline void resetCellCount(); inline void resetCellCount();
inline label vertexCount() const; inline label vertexCount() const;
inline label& vertexCount();
inline void resetVertexCount(); inline void resetVertexCount();

View File

@ -124,12 +124,6 @@ Foam::label Foam::DelaunayMesh<Triangulation>::vertexCount() const
return vertexCount_; return vertexCount_;
} }
template<class Triangulation>
Foam::label& Foam::DelaunayMesh<Triangulation>::vertexCount()
{
return vertexCount_;
}
template<class Triangulation> template<class Triangulation>
void Foam::DelaunayMesh<Triangulation>::resetVertexCount() void Foam::DelaunayMesh<Triangulation>::resetVertexCount()

View File

@ -40,11 +40,15 @@ Foam::cellAspectRatioControl::cellAspectRatioControl
aspectRatioDict_.lookupOrDefault<vector> aspectRatioDict_.lookupOrDefault<vector>
( (
"aspectRatioDirection", "aspectRatioDirection",
vector(0, 0, 0) vector::zero
) )
) )
{ {
Info<< nl << "Cell Aspect Ratio Control" << nl // Normalise the direction
aspectRatioDirection_ /= mag(aspectRatioDirection_) + SMALL;
Info<< nl
<< "Cell Aspect Ratio Control" << nl
<< " Ratio : " << aspectRatio_ << nl << " Ratio : " << aspectRatio_ << nl
<< " Direction : " << aspectRatioDirection_ << " Direction : " << aspectRatioDirection_
<< endl; << endl;
@ -66,20 +70,18 @@ void Foam::cellAspectRatioControl::updateCellSizeAndFaceArea
scalar& targetCellSize scalar& targetCellSize
) const ) const
{ {
const scalar cosAngle = mag const scalar cosAngle =
( mag(vectorTools::cosPhi(alignmentDir, aspectRatioDirection_));
vectorTools::cosPhi(alignmentDir, aspectRatioDirection_)
);
// Change target face area based on aspect ratio // Change target face area based on aspect ratio
targetFaceArea +=
targetFaceArea targetFaceArea
+= targetFaceArea
*(aspectRatio_ - 1.0) *(aspectRatio_ - 1.0)
*(1.0 - cosAngle); *(1.0 - cosAngle);
// Change target cell size based on aspect ratio // Change target cell size based on aspect ratio
targetCellSize +=
targetCellSize targetCellSize
+= targetCellSize
*(aspectRatio_ - 1.0) *(aspectRatio_ - 1.0)
*cosAngle; *cosAngle;
@ -95,12 +97,11 @@ void Foam::cellAspectRatioControl::updateDeltaVector
vector& delta vector& delta
) const ) const
{ {
const scalar cosAngle = mag const scalar cosAngle =
( mag(vectorTools::cosPhi(alignmentDir, aspectRatioDirection_));
vectorTools::cosPhi(alignmentDir, aspectRatioDirection_)
);
delta += 0.5 delta +=
0.5
*delta *delta
*cosAngle *cosAngle
*(targetCellSize/rABMag) *(targetCellSize/rABMag)

View File

@ -56,7 +56,7 @@ class cellAspectRatioControl
const scalar aspectRatio_; const scalar aspectRatio_;
const vector aspectRatioDirection_; vector aspectRatioDirection_;
// Private Member Functions // Private Member Functions
@ -73,10 +73,7 @@ public:
// Constructors // Constructors
//- Construct from dictionary //- Construct from dictionary
cellAspectRatioControl cellAspectRatioControl(const dictionary& motionDict);
(
const dictionary& motionDict
);
//- Destructor //- Destructor

View File

@ -570,159 +570,8 @@ void Foam::conformalVoronoiMesh::buildCellSizeAndAlignmentMesh()
} }
void Foam::conformalVoronoiMesh::storeSizesAndAlignments()
{
DynamicList<Point> storePts(number_of_vertices());
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
vit++
)
{
if (vit->internalPoint())
{
storePts.append(vit->point());
}
}
storePts.shrink();
storeSizesAndAlignments(storePts);
}
void Foam::conformalVoronoiMesh::storeSizesAndAlignments
(
const List<Point>& storePts
)
{
// timeCheck("Start of storeSizesAndAlignments");
//
// Info << nl << "Store size and alignment" << endl;
//
// sizeAndAlignmentLocations_.setSize(storePts.size());
//
// storedSizes_.setSize(sizeAndAlignmentLocations_.size());
//
// storedAlignments_.setSize(sizeAndAlignmentLocations_.size());
//
// label i = 0;
//
// //checkCellSizing();
//
// for
// (
// List<Point>::const_iterator pit = storePts.begin();
// pit != storePts.end();
// ++pit
// )
// {
// pointFromPoint pt = topoint(*pit);
//
//// storedAlignments_[i] = requiredAlignment(pt);
////
//// storedSizes_[i] = cellShapeControls().cellSize(pt);
//
// cellShapeControls().cellSizeAndAlignment
// (
// pt,
// storedSizes_[i],
// storedAlignments_[i]
// );
//
// i++;
// }
//
// timeCheck("Sizes and alignments calculated, build tree");
//
// buildSizeAndAlignmentTree();
//
// timeCheck("Size and alignment tree built");
}
void Foam::conformalVoronoiMesh::updateSizesAndAlignments
(
const List<Point>& storePts
)
{
// This function is only used in serial, the background redistribution
// triggers this when unbalance is detected in parallel.
if
(
!Pstream::parRun()
&& runTime_.run()
&& runTime_.timeIndex()
)
{
storeSizesAndAlignments(storePts);
timeCheck("Updated sizes and alignments");
}
}
const Foam::indexedOctree<Foam::treeDataPoint>&
Foam::conformalVoronoiMesh::sizeAndAlignmentTree() const
{
if (sizeAndAlignmentTreePtr_.empty())
{
buildSizeAndAlignmentTree();
}
return sizeAndAlignmentTreePtr_();
}
void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment() void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()
{ {
// Info<< nl << "Looking up target cell alignment and size" << endl;
//
// const indexedOctree<treeDataPoint>& tree = sizeAndAlignmentTree();
//
// for
// (
// Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
// vit != finite_vertices_end();
// vit++
// )
// {
// if
// (
// vit->internalOrBoundaryPoint()
// || vit->referredInternalOrBoundaryPoint()
// )
// {
// pointFromPoint pt = topoint(vit->point());
//
// pointIndexHit info = tree.findNearest(pt, sqr(GREAT));
//
// if (info.hit())
// {
// vit->alignment() = storedAlignments_[info.index()];
//
// vit->targetCellSize() = storedSizes_[info.index()];
// }
// else
// {
// WarningIn
// (
// "void "
// "Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()"
// )
// << "Point " << pt << " did not find a nearest point "
// << " for alignment and size lookup." << endl;
//
// vit->alignment() = cellShapeControls().cellAlignment(pt);
//
// vit->targetCellSize() = cellShapeControls().cellSize(pt);
// }
// }
// }
Info<< nl << "Calculating target cell alignment and size" << endl; Info<< nl << "Calculating target cell alignment and size" << endl;
for for
@ -744,44 +593,6 @@ void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()
); );
} }
} }
// OFstream str(runTime_.path()/"alignments_internal.obj");
//
// for
// (
// Finite_vertices_iterator vit = finite_vertices_begin();
// vit != finite_vertices_end();
// ++vit
// )
// {
// if (!vit->farPoint())
// {
// // Write alignments
// const tensor& alignment = vit->alignment();
// pointFromPoint pt = topoint(vit->point());
//
// if
// (
// alignment.x() == triad::unset[0]
// || alignment.y() == triad::unset[0]
// || alignment.z() == triad::unset[0]
// )
// {
// Info<< "Bad alignment = " << vit->info();
//
// vit->alignment() = tensor::I;
//
// Info<< "New alignment = " << vit->info();
//
// continue;
// }
//
// meshTools::writeOBJ(str, pt, alignment.x() + pt);
// meshTools::writeOBJ(str, pt, alignment.y() + pt);
// meshTools::writeOBJ(str, pt, alignment.z() + pt);
// }
// }
} }
@ -1039,10 +850,6 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
featurePointLocations_(), featurePointLocations_(),
edgeLocationTreePtr_(), edgeLocationTreePtr_(),
surfacePtLocationTreePtr_(), surfacePtLocationTreePtr_(),
sizeAndAlignmentLocations_(),
storedSizes_(),
storedAlignments_(),
sizeAndAlignmentTreePtr_(),
surfaceConformationVertices_(), surfaceConformationVertices_(),
initialPointsMethod_ initialPointsMethod_
( (
@ -1133,10 +940,6 @@ void Foam::conformalVoronoiMesh::initialiseForMotion()
// (potentially) redistributed. // (potentially) redistributed.
storeSurfaceConformation(); storeSurfaceConformation();
// Use storeSizesAndAlignments with no feed points because all background
// points may have been distributed.
storeSizesAndAlignments();
// Report any Delaunay vertices that do not think that they are in the // Report any Delaunay vertices that do not think that they are in the
// domain the processor they are on. // domain the processor they are on.
// reportProcessorOccupancy(); // reportProcessorOccupancy();
@ -1836,8 +1639,6 @@ void Foam::conformalVoronoiMesh::move()
writeMesh(time().timeName()); writeMesh(time().timeName());
} }
updateSizesAndAlignments(pointsToInsert);
Info<< nl Info<< nl
<< "Total displacement = " << totalDisp << nl << "Total displacement = " << totalDisp << nl
<< "Total distance = " << totalDist << nl << "Total distance = " << totalDist << nl

View File

@ -177,19 +177,6 @@ private:
mutable DynamicList<Foam::point> existingSurfacePtLocations_; mutable DynamicList<Foam::point> existingSurfacePtLocations_;
//- Store locations where the cell size and alignments will be
// pre-calculated and looked up
pointField sizeAndAlignmentLocations_;
//- Stored cell size at sizeAndAlignmentLocations_
scalarField storedSizes_;
//- Stored alignments at sizeAndAlignmentLocations_
tensorField storedAlignments_;
//- Search tree for size and alignment lookup points
mutable autoPtr<indexedOctree<treeDataPoint> > sizeAndAlignmentTreePtr_;
//- Store the surface and feature edge conformation locations to be //- Store the surface and feature edge conformation locations to be
// reinserted // reinserted
List<Vb> surfaceConformationVertices_; List<Vb> surfaceConformationVertices_;
@ -271,40 +258,6 @@ private:
//- Return the local maximum surface protrusion distance //- Return the local maximum surface protrusion distance
inline scalar maxSurfaceProtrusion(const Foam::point& pt) const; inline scalar maxSurfaceProtrusion(const Foam::point& pt) const;
//- Insert Point and return its auto-generated index
inline bool insertPoint
(
const Point& P,
const indexedVertexEnum::vertexType type
);
//- Insert Foam::point with specified index and type
inline bool insertPoint
(
const Foam::point& p,
const indexedVertexEnum::vertexType type
);
//- Insert Point with specified index, type and original processor
inline bool insertReferredPoint
(
const Point& P,
const label index,
const indexedVertexEnum::vertexType type,
const label processor
);
inline bool insertReferredPoint(const Vb& P);
//- Insert Foam::point with specified index, type and original processor
inline bool insertReferredPoint
(
const Foam::point& p,
const label index,
const indexedVertexEnum::vertexType type,
const label processor
);
//- Insert Delaunay vertices using the CGAL range insertion method, //- Insert Delaunay vertices using the CGAL range insertion method,
// optionally check processor occupancy and distribute to other // optionally check processor occupancy and distribute to other
// processors // processors
@ -539,22 +492,6 @@ private:
void buildCellSizeAndAlignmentMesh(); void buildCellSizeAndAlignmentMesh();
//- Store data for sizeAndAlignmentLocations_, storedSizes_ and
// storedAlignments_ and initialise the sizeAndAlignmentTreePtr_,
// determining the appropriate sizeAndAlignmentLocations_
// automatically
void storeSizesAndAlignments();
//- Store data for sizeAndAlignmentLocations_, storedSizes_ and
// storedAlignments_ and initialise the sizeAndAlignmentTreePtr_
void storeSizesAndAlignments(const List<Point>& storePts);
//- Restore the sizes and alignments if required
void updateSizesAndAlignments(const List<Point>& storePts);
//- Demand driven construction of octree for and alignment points
const indexedOctree<treeDataPoint>& sizeAndAlignmentTree() const;
//- Set the size and alignment data for each vertex //- Set the size and alignment data for each vertex
void setVertexSizeAndAlignment(); void setVertexSizeAndAlignment();
@ -750,9 +687,6 @@ private:
const DynamicList<Foam::point>& existingSurfacePtLocations const DynamicList<Foam::point>& existingSurfacePtLocations
) const; ) const;
//- Build or rebuild the sizeAndAlignmentTree
void buildSizeAndAlignmentTree() const;
//- Process the surface conformation locations to decide which surface //- Process the surface conformation locations to decide which surface
// and edge conformation locations to add // and edge conformation locations to add
void addSurfaceAndEdgeHits void addSurfaceAndEdgeHits
@ -1063,10 +997,6 @@ public:
// const List<scalar>& radiusSqrs // const List<scalar>& radiusSqrs
// ) const; // ) const;
typedef K::Vector_3 CGALVector;
inline CGALVector toCGALVector(const Foam::vector& v) const;
// Access // Access

View File

@ -211,11 +211,6 @@ void Foam::conformalVoronoiMesh::checkDuals()
List<Point> duals(number_of_finite_cells()); List<Point> duals(number_of_finite_cells());
typedef CGAL::Exact_predicates_exact_constructions_kernel EK2;
typedef CGAL::Regular_triangulation_euclidean_traits_3<EK2> EK;
typedef CGAL::Cartesian_converter<baseK::Kernel, EK2> To_exact;
typedef CGAL::Cartesian_converter<EK2, baseK::Kernel> Back_from_exact;
// PackedBoolList bPoints(number_of_finite_cells()); // PackedBoolList bPoints(number_of_finite_cells());
// indexDualVertices(duals, bPoints); // indexDualVertices(duals, bPoints);
@ -1787,7 +1782,6 @@ void Foam::conformalVoronoiMesh::indexDualVertices
OBJstream snapping1("snapToSurface1.obj"); OBJstream snapping1("snapToSurface1.obj");
OBJstream snapping2("snapToSurface2.obj"); OBJstream snapping2("snapToSurface2.obj");
OFstream tetToSnapTo("tetsToSnapTo.obj"); OFstream tetToSnapTo("tetsToSnapTo.obj");
label offset = 0;
for for
( (

View File

@ -76,10 +76,6 @@ void Foam::conformalVoronoiMesh::conformToSurface()
{ {
sync(decomposition_().procBounds()); sync(decomposition_().procBounds());
} }
// Use storeSizesAndAlignments with no feed points because all
// background points may have been distributed.
storeSizesAndAlignments();
} }
// Do not store the surface conformation until after it has been // Do not store the surface conformation until after it has been
@ -2055,38 +2051,6 @@ void Foam::conformalVoronoiMesh::buildSurfacePtLocationTree
} }
void Foam::conformalVoronoiMesh::buildSizeAndAlignmentTree() const
{
if (sizeAndAlignmentLocations_.empty())
{
FatalErrorIn("buildSizeAndAlignmentTree()")
<< "sizeAndAlignmentLocations empty, must be populated before "
<< "sizeAndAlignmentTree can be built."
<< exit(FatalError);
}
treeBoundBox overallBb
(
geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4)
);
overallBb.min() -= Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += Foam::point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
sizeAndAlignmentTreePtr_.reset
(
new indexedOctree<treeDataPoint>
(
treeDataPoint(sizeAndAlignmentLocations_),
overallBb, // overall search domain
10, // max levels
20.0, // maximum ratio of cubes v.s. cells
100.0 // max. duplicity; n/a since no bounding boxes.
)
);
}
void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
( (
const Foam::point& vit, const Foam::point& vit,

View File

@ -236,94 +236,6 @@ inline Foam::scalar Foam::conformalVoronoiMesh::maxSurfaceProtrusion
} }
inline bool Foam::conformalVoronoiMesh::insertPoint
(
const Foam::point& p,
const indexedVertexEnum::vertexType type
)
{
return insertPoint(toPoint<Point>(p), type);
}
inline bool Foam::conformalVoronoiMesh::insertPoint
(
const Point& P,
const indexedVertexEnum::vertexType type
)
{
uint nVert = number_of_vertices();
Vertex_handle vh = insert(P);
bool pointInserted = true;
if (nVert == number_of_vertices())
{
Pout<< "Failed to insert point : " << topoint(P)
<< " of type " << type << endl;
pointInserted = false;
}
else
{
vh->index() = getNewVertexIndex();
vh->type() = type;
}
return pointInserted;
}
inline bool Foam::conformalVoronoiMesh::insertReferredPoint(const Vb& P)
{
return insertReferredPoint(P.point(), P.index(), P.type(), P.procIndex());
}
inline bool Foam::conformalVoronoiMesh::insertReferredPoint
(
const Foam::point& p,
const label index,
const indexedVertexEnum::vertexType type,
const label processor
)
{
return insertReferredPoint(toPoint<Point>(p), index, type, processor);
}
inline bool Foam::conformalVoronoiMesh::insertReferredPoint
(
const Point& P,
const label index,
const indexedVertexEnum::vertexType type,
const label processor
)
{
uint nVert = number_of_vertices();
Vertex_handle vh = insert(P);
bool pointInserted = true;
if (nVert == number_of_vertices())
{
Pout<< "Failed to insert point " << topoint(P)
<< " type: " << type << " index: " << index
<< " proc: " << processor << endl;
pointInserted = false;
}
else
{
vh->index() = index;
vh->type() = type;
vh->procIndex() = processor;
}
return pointInserted;
}
inline void Foam::conformalVoronoiMesh::createPointPair inline void Foam::conformalVoronoiMesh::createPointPair
( (
const scalar ppDist, const scalar ppDist,
@ -663,13 +575,6 @@ inline bool Foam::conformalVoronoiMesh::isProcBoundaryEdge
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::conformalVoronoiMesh::CGALVector
Foam::conformalVoronoiMesh::toCGALVector(const Foam::vector& v) const
{
return CGALVector(v.x(), v.y(), v.z());
}
inline const Foam::Time& Foam::conformalVoronoiMesh::time() const inline const Foam::Time& Foam::conformalVoronoiMesh::time() const
{ {
return runTime_; return runTime_;

View File

@ -108,17 +108,15 @@ int CGAL::indexedCell<Gt, Cb>::cellIndex() const
#ifdef CGAL_INEXACT #ifdef CGAL_INEXACT
template<class Gt, class Cb> template<class Gt, class Cb>
const Foam::point& CGAL::indexedCell<Gt, Cb>::dual() const Foam::point& CGAL::indexedCell<Gt, Cb>::dual()
{ {
// if (Foam::foamyHexMeshChecks::coplanarTet(*this, 1e-20) == 0)
// {
// Do exact calc
// }
return reinterpret_cast<const Foam::point&>(this->circumcenter()); return reinterpret_cast<const Foam::point&>(this->circumcenter());
} }
#else #else
template<class Gt, class Cb> template<class Gt, class Cb>
const Foam::point CGAL::indexedCell<Gt, Cb>::dual() const Foam::point CGAL::indexedCell<Gt, Cb>::dual()
{ {
@ -131,6 +129,7 @@ int CGAL::indexedCell<Gt, Cb>::cellIndex() const
CGAL::to_double(P.z()) CGAL::to_double(P.z())
); );
} }
#endif #endif

View File

@ -25,8 +25,7 @@ Class
pointFeatureEdgesTypes pointFeatureEdgesTypes
Description Description
struct for holding information on the types of feature edges attached to Holds information on the types of feature edges attached to feature points.
feature points
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -5,12 +5,19 @@
| \\ / A nd | Web: www.OpenFOAM.org | | \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object foamyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge; #inputMode merge;
surfaceConformation surfaceConformation
{ {
locationInMesh (0 0 0);
pointPairDistanceCoeff 0.1; pointPairDistanceCoeff 0.1;
mixedFeaturePointPPDistanceCoeff 5.0; mixedFeaturePointPPDistanceCoeff 5.0;
featurePointExclusionDistanceCoeff 0.65; featurePointExclusionDistanceCoeff 0.65;
@ -115,20 +122,18 @@ polyMeshFiltering
} }
backgroundMeshDecomposition
{
minLevels 1;
sampleResolution 4;
spanScale 20;
maxCellWeightCoeff 20;
}
meshQualityControls meshQualityControls
{ {
maxNonOrtho 65; #include "meshQualityDict"
maxBoundarySkewness 50;
maxInternalSkewness 10;
maxConcave 80;
minVol -1E30;
minTetQuality 1e-30;
minArea -1;
minTwist 0.02;
minDeterminant 0.001;
minFaceWeight 0.02;
minVolRatio 0.01;
minTriangleTwist -1;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -829,4 +829,26 @@ Foam::label Foam::face::trianglesQuads
} }
Foam::label Foam::longestEdge(const face& f, const pointField& pts)
{
const edgeList& eds = f.edges();
label longestEdgeI = -1;
scalar longestEdgeLength = -SMALL;
forAll(eds, edI)
{
scalar edgeLength = eds[edI].mag(pts);
if (edgeLength > longestEdgeLength)
{
longestEdgeI = edI;
longestEdgeLength = edgeLength;
}
}
return longestEdgeI;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -408,6 +408,12 @@ public:
}; };
// Global functions
//- Find the longest edge on a face. Face point labels index into pts.
label longestEdge(const face& f, const pointField& pts);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -154,8 +154,15 @@ bool Foam::pointZone::checkParallelSync(const bool report) const
forAll(maxZone, pointI) forAll(maxZone, pointI)
{ {
// Check point in zone on both sides // Check point in same (or no) zone on all processors
if (maxZone[pointI] != minZone[pointI]) if
(
(
maxZone[pointI] != -1
|| minZone[pointI] != labelMax
)
&& (maxZone[pointI] != minZone[pointI])
)
{ {
if (report && !error) if (report && !error)
{ {
@ -167,7 +174,8 @@ bool Foam::pointZone::checkParallelSync(const bool report) const
<< (minZone[pointI] == labelMax ? -1 : minZone[pointI]) << (minZone[pointI] == labelMax ? -1 : minZone[pointI])
<< " on some processors and in zone " << " on some processors and in zone "
<< maxZone[pointI] << maxZone[pointI]
<< " on some other processors." << " on some other processors." << nl
<< "(suppressing further warnings)"
<< endl; << endl;
} }
error = true; error = true;

View File

@ -108,12 +108,6 @@ public:
return this->operator[](1); return this->operator[](1);
} }
//- Return reverse pair
inline Pair<Type> reversePair() const
{
return Pair<Type>(second(), first());
}
//- Return other //- Return other
inline const Type& other(const Type& a) const inline const Type& other(const Type& a) const
{ {
@ -147,11 +141,11 @@ public:
// - -1: same pair, but reversed order // - -1: same pair, but reversed order
static inline int compare(const Pair<Type>& a, const Pair<Type>& b) static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
{ {
if (a[0] == b[0] && a[1] == b[1]) if (a == b)
{ {
return 1; return 1;
} }
else if (a[0] == b[1] && a[1] == b[0]) else if (a == reverse(b))
{ {
return -1; return -1;
} }
@ -160,21 +154,32 @@ public:
return 0; return 0;
} }
} }
};
// Friend Operators template<class Type>
Pair<Type> reverse(const Pair<Type>& p)
{
return Pair<Type>(p.second(), p.first());
}
friend bool operator==(const Pair<Type>& a, const Pair<Type>& b)
template<class Type>
bool operator==(const Pair<Type>& a, const Pair<Type>& b)
{ {
return (a.first() == b.first() && a.second() == b.second()); return (a.first() == b.first() && a.second() == b.second());
} }
friend bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
template<class Type>
bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
{ {
return !(a == b); return !(a == b);
} }
friend bool operator<(const Pair<Type>& a, const Pair<Type>& b)
template<class Type>
bool operator<(const Pair<Type>& a, const Pair<Type>& b)
{ {
return return
( (
@ -186,7 +191,27 @@ public:
) )
); );
} }
};
template<class Type>
bool operator<=(const Pair<Type>& a, const Pair<Type>& b)
{
return !(b < a);
}
template<class Type>
bool operator>(const Pair<Type>& a, const Pair<Type>& b)
{
return (b < a);
}
template<class Type>
bool operator>=(const Pair<Type>& a, const Pair<Type>& b)
{
return !(a < b);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,20 +47,6 @@ namespace Foam
template<class Type1, class Type2> template<class Type1, class Type2>
class Tuple2; class Tuple2;
template<class Type1, class Type2>
inline bool operator==
(
const Tuple2<Type1, Type2>&,
const Tuple2<Type1, Type2>&
);
template<class Type1, class Type2>
inline bool operator!=
(
const Tuple2<Type1, Type2>&,
const Tuple2<Type1, Type2>&
);
template<class Type1, class Type2> template<class Type1, class Type2>
inline Istream& operator>>(Istream&, Tuple2<Type1, Type2>&); inline Istream& operator>>(Istream&, Tuple2<Type1, Type2>&);
@ -129,27 +115,6 @@ public:
return s_; return s_;
} }
//- Return reverse pair
inline Tuple2<Type2, Type1> reverseTuple2() const
{
return Tuple2<Type2, Type1>(second(), first());
}
// Friend Operators
friend bool operator== <Type1, Type2>
(
const Tuple2<Type1, Type2>& a,
const Tuple2<Type1, Type2>& b
);
friend bool operator!= <Type1, Type2>
(
const Tuple2<Type1, Type2>& a,
const Tuple2<Type1, Type2>& b
);
// IOstream operators // IOstream operators
@ -169,6 +134,14 @@ public:
}; };
//- Return reverse of a tuple2
template<class Type1, class Type2>
inline Tuple2<Type2, Type1> reverse(const Tuple2<Type1, Type2>& t)
{
return Tuple2<Type2, Type1>(t.second(), t.first());
}
template<class Type1, class Type2> template<class Type1, class Type2>
inline bool operator== inline bool operator==
( (

View File

@ -282,6 +282,11 @@ void Foam::triad::align(const vector& v)
Foam::triad Foam::triad::sortxyz() const Foam::triad Foam::triad::sortxyz() const
{ {
if (!this->set())
{
return *this;
}
triad t; triad t;
if if

View File

@ -42,32 +42,6 @@ defineTypeNameAndDebug(edgeCollapser, 0);
} }
Foam::label Foam::edgeCollapser::longestEdge
(
const face& f,
const pointField& pts
)
{
const edgeList& eds = f.edges();
label longestEdgeI = -1;
scalar longestEdgeLength = -SMALL;
forAll(eds, edI)
{
scalar edgeLength = eds[edI].mag(pts);
if (edgeLength > longestEdgeLength)
{
longestEdgeI = edI;
longestEdgeLength = edgeLength;
}
}
return longestEdgeI;
}
Foam::HashSet<Foam::label> Foam::edgeCollapser::checkBadFaces Foam::HashSet<Foam::label> Foam::edgeCollapser::checkBadFaces
( (
const polyMesh& mesh, const polyMesh& mesh,

View File

@ -262,9 +262,6 @@ public:
// Check // Check
//- Find the longest edge in a face
static label longestEdge(const face& f, const pointField& pts);
//- Calls motionSmoother::checkMesh and returns a set of bad faces //- Calls motionSmoother::checkMesh and returns a set of bad faces
static HashSet<label> checkBadFaces static HashSet<label> checkBadFaces
( (

View File

@ -450,7 +450,7 @@ Foam::Map<Foam::labelPair> Foam::meshRefinement::getZoneBafflePatches
labelPair patches = zPatches; labelPair patches = zPatches;
if (fZone.flipMap()[i]) if (fZone.flipMap()[i])
{ {
patches = patches.reversePair(); patches = reverse(patches);
} }
if (!bafflePatch.insert(faceI, patches)) if (!bafflePatch.insert(faceI, patches))

View File

@ -605,8 +605,10 @@ void Foam::refinementSurfaces::setMinLevelFields
// searchableBox (size=6) // searchableBox (size=6)
if (geom.regions().size() > 1 && geom.globalSize() > 10) if (geom.regions().size() > 1 && geom.globalSize() > 10)
{ {
// Representative local coordinates // Representative local coordinates and bounding sphere
const pointField ctrs(geom.coordinates()); pointField ctrs;
scalarField radiusSqr;
geom.boundingSpheres(ctrs, radiusSqr);
labelList minLevelField(ctrs.size(), -1); labelList minLevelField(ctrs.size(), -1);
{ {
@ -614,12 +616,7 @@ void Foam::refinementSurfaces::setMinLevelFields
// distributed surface where local indices differ from global // distributed surface where local indices differ from global
// ones (needed for getRegion call) // ones (needed for getRegion call)
List<pointIndexHit> info; List<pointIndexHit> info;
geom.findNearest geom.findNearest(ctrs, radiusSqr, info);
(
ctrs,
scalarField(ctrs.size(), sqr(GREAT)),
info
);
// Get per element the region // Get per element the region
labelList region; labelList region;
@ -628,7 +625,7 @@ void Foam::refinementSurfaces::setMinLevelFields
// From the region get the surface-wise refinement level // From the region get the surface-wise refinement level
forAll(minLevelField, i) forAll(minLevelField, i)
{ {
if (info[i].hit()) if (info[i].hit()) //Note: should not be necessary
{ {
minLevelField[i] = minLevel(surfI, region[i]); minLevelField[i] = minLevel(surfI, region[i]);
} }

View File

@ -249,6 +249,41 @@ Foam::tmp<Foam::pointField> Foam::searchableBox::coordinates() const
} }
void Foam::searchableBox::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(size());
radiusSqr.setSize(size());
radiusSqr = 0.0;
const pointField pts(treeBoundBox::points());
const faceList& fcs = treeBoundBox::faces;
forAll(fcs, i)
{
const face& f = fcs[i];
centres[i] = f.centre(pts);
forAll(f, fp)
{
const point& pt = pts[f[fp]];
radiusSqr[i] = Foam::max
(
radiusSqr[i],
Foam::magSqr(pt-centres[i])
);
}
}
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
Foam::tmp<Foam::pointField> Foam::searchableBox::points() const Foam::tmp<Foam::pointField> Foam::searchableBox::points() const
{ {
return treeBoundBox::points(); return treeBoundBox::points();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -129,6 +129,14 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const; virtual tmp<pointField> coordinates() const;
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const; virtual tmp<pointField> points() const;

View File

@ -47,6 +47,23 @@ Foam::tmp<Foam::pointField> Foam::searchableCylinder::coordinates() const
} }
void Foam::searchableCylinder::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(1);
centres[0] = 0.5*(point1_ + point2_);
radiusSqr.setSize(1);
radiusSqr[0] = Foam::magSqr(point1_-centres[0]) + Foam::sqr(radius_);
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
Foam::tmp<Foam::pointField> Foam::searchableCylinder::points() const Foam::tmp<Foam::pointField> Foam::searchableCylinder::points() const
{ {
tmp<pointField> tPts(new pointField(2)); tmp<pointField> tPts(new pointField(2));

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -154,6 +154,14 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const; virtual tmp<pointField> coordinates() const;
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const; virtual tmp<pointField> points() const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -134,6 +134,20 @@ const Foam::wordList& Foam::searchablePlane::regions() const
} }
void Foam::searchablePlane::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(1);
centres[0] = refPoint();
radiusSqr.setSize(1);
radiusSqr[0] = Foam::sqr(GREAT);
}
void Foam::searchablePlane::findNearest void Foam::searchablePlane::findNearest
( (
const pointField& samples, const pointField& samples,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -130,6 +130,15 @@ public:
return tCtrs; return tCtrs;
} }
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
// Note: radius limited to sqr(GREAT)
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const virtual tmp<pointField> points() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -274,6 +274,71 @@ const Foam::wordList& Foam::searchablePlate::regions() const
} }
Foam::tmp<Foam::pointField> Foam::searchablePlate::coordinates() const
{
return tmp<pointField>(new pointField(1, origin_ + 0.5*span_));
}
void Foam::searchablePlate::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(1);
centres[0] = origin_ + 0.5*span_;
radiusSqr.setSize(1);
radiusSqr[0] = Foam::magSqr(0.5*span_);
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
Foam::tmp<Foam::pointField> Foam::searchablePlate::points() const
{
tmp<pointField> tPts(new pointField(4));
pointField& pts = tPts();
pts[0] = origin_;
pts[2] = origin_ + span_;
if (span_.x() < span_.y() && span_.x() < span_.z())
{
pts[1] = origin_ + point(0, span_.y(), 0);
pts[3] = origin_ + point(0, 0, span_.z());
}
else if (span_.y() < span_.z())
{
pts[1] = origin_ + point(span_.x(), 0, 0);
pts[3] = origin_ + point(0, 0, span_.z());
}
else
{
pts[1] = origin_ + point(span_.x(), 0, 0);
pts[3] = origin_ + point(0, span_.y(), 0);
}
return tPts;
}
bool Foam::searchablePlate::overlaps(const boundBox& bb) const
{
return
(
(origin_.x() + span_.x()) >= bb.min().x()
&& origin_.x() <= bb.max().x()
&& (origin_.y() + span_.y()) >= bb.min().y()
&& origin_.y() <= bb.max().y()
&& (origin_.z() + span_.z()) >= bb.min().z()
&& origin_.z() <= bb.max().z()
);
}
void Foam::searchablePlate::findNearest void Foam::searchablePlate::findNearest
( (
const pointField& samples, const pointField& samples,

View File

@ -145,53 +145,21 @@ public:
//- Get representative set of element coordinates //- Get representative set of element coordinates
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const virtual tmp<pointField> coordinates() const;
{
tmp<pointField> tCtrs(new pointField(1, origin_ + 0.5*span_)); //- Get bounding spheres (centre and radius squared), one per element.
return tCtrs; // Any point on element is guaranteed to be inside.
} virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const virtual tmp<pointField> points() const;
{
tmp<pointField> tPts(new pointField(4));
pointField& pts = tPts();
pts[0] = origin_;
pts[2] = origin_ + span_;
if (span_.x() < span_.y() && span_.x() < span_.z())
{
pts[1] = origin_ + point(0, span_.y(), 0);
pts[3] = origin_ + point(0, 0, span_.z());
}
else if (span_.y() < span_.z())
{
pts[1] = origin_ + point(span_.x(), 0, 0);
pts[3] = origin_ + point(0, 0, span_.z());
}
else
{
pts[1] = origin_ + point(span_.x(), 0, 0);
pts[3] = origin_ + point(0, span_.y(), 0);
}
return tPts;
}
//- Does any part of the surface overlap the supplied bound box? //- Does any part of the surface overlap the supplied bound box?
virtual bool overlaps(const boundBox& bb) const virtual bool overlaps(const boundBox& bb) const;
{
return
(
(origin_.x() + span_.x()) >= bb.min().x()
&& origin_.x() <= bb.max().x()
&& (origin_.y() + span_.y()) >= bb.min().y()
&& origin_.y() <= bb.max().y()
&& (origin_.z() + span_.z()) >= bb.min().z()
&& origin_.z() <= bb.max().z()
);
}
// Multiple point queries. // Multiple point queries.

View File

@ -185,6 +185,23 @@ const Foam::wordList& Foam::searchableSphere::regions() const
void Foam::searchableSphere::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(1);
centres[0] = centre_;
radiusSqr.setSize(1);
radiusSqr[0] = Foam::sqr(radius_);
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
void Foam::searchableSphere::findNearest void Foam::searchableSphere::findNearest
( (
const pointField& samples, const pointField& samples,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,7 +60,7 @@ private:
//- Centre point //- Centre point
const point centre_; const point centre_;
//- Radius squared //- Radius
const scalar radius_; const scalar radius_;
//- Names of regions //- Names of regions
@ -139,6 +139,14 @@ public:
return tCtrs; return tCtrs;
} }
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const virtual tmp<pointField> points() const
{ {

View File

@ -190,6 +190,14 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const = 0; virtual tmp<pointField> coordinates() const = 0;
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const = 0;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const = 0; virtual tmp<pointField> points() const = 0;

View File

@ -354,6 +354,42 @@ Foam::searchableSurfaceCollection::coordinates() const
} }
void Foam::searchableSurfaceCollection::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres.setSize(size());
radiusSqr.setSize(centres.size());
// Append individual coordinates
label coordI = 0;
forAll(subGeom_, surfI)
{
scalar maxScale = cmptMax(scale_[surfI]);
pointField subCentres;
scalarField subRadiusSqr;
subGeom_[surfI].boundingSpheres(subCentres, subRadiusSqr);
forAll(subCentres, i)
{
centres[coordI++] = transform_[surfI].globalPosition
(
cmptMultiply
(
subCentres[i],
scale_[surfI]
)
);
radiusSqr[coordI++] = maxScale*subRadiusSqr[i];
}
}
}
Foam::tmp<Foam::pointField> Foam::tmp<Foam::pointField>
Foam::searchableSurfaceCollection::points() const Foam::searchableSurfaceCollection::points() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -176,6 +176,14 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const; virtual tmp<pointField> coordinates() const;
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const; virtual tmp<pointField> points() const;

View File

@ -156,6 +156,17 @@ public:
return surface().coordinates(); return surface().coordinates();
} }
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
surface().boundingSpheres(centres, radiusSqr);
}
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const virtual tmp<pointField> points() const
{ {

View File

@ -145,10 +145,12 @@ bool Foam::triSurfaceMesh::addFaceToEdge
bool Foam::triSurfaceMesh::isSurfaceClosed() const bool Foam::triSurfaceMesh::isSurfaceClosed() const
{ {
const pointField& pts = triSurface::points();
// Construct pointFaces. Let's hope surface has compact point // Construct pointFaces. Let's hope surface has compact point
// numbering ... // numbering ...
labelListList pointFaces; labelListList pointFaces;
invertManyToMany(points()().size(), *this, pointFaces); invertManyToMany(pts.size(), *this, pointFaces);
// Loop over all faces surrounding point. Count edges emanating from point. // Loop over all faces surrounding point. Count edges emanating from point.
// Every edge should be used by two faces exactly. // Every edge should be used by two faces exactly.
@ -241,7 +243,9 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
minQuality_(-1), minQuality_(-1),
surfaceClosed_(-1) surfaceClosed_(-1)
{ {
bounds() = boundBox(points()); const pointField& pts = triSurface::points();
bounds() = boundBox(pts);
} }
@ -287,7 +291,9 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
minQuality_(-1), minQuality_(-1),
surfaceClosed_(-1) surfaceClosed_(-1)
{ {
bounds() = boundBox(points()); const pointField& pts = triSurface::points();
bounds() = boundBox(pts);
} }
@ -347,7 +353,9 @@ Foam::triSurfaceMesh::triSurfaceMesh
triSurface::scalePoints(scaleFactor); triSurface::scalePoints(scaleFactor);
} }
bounds() = boundBox(points()); const pointField& pts = triSurface::points();
bounds() = boundBox(pts);
// Have optional minimum quality for normal calculation // Have optional minimum quality for normal calculation
if (dict.readIfPresent("minQuality", minQuality_) && minQuality_ > 0) if (dict.readIfPresent("minQuality", minQuality_) && minQuality_ > 0)
@ -393,6 +401,34 @@ Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::coordinates() const
} }
void Foam::triSurfaceMesh::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres = coordinates();
radiusSqr.setSize(size());
radiusSqr = 0.0;
const pointField& pts = triSurface::points();
forAll(*this, faceI)
{
const labelledTri& f = triSurface::operator[](faceI);
const point& fc = centres[faceI];
forAll(f, fp)
{
const point& pt = pts[f[fp]];
radiusSqr[faceI] = max(radiusSqr[faceI], Foam::magSqr(fc-pt));
}
}
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::points() const Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::points() const
{ {
return triSurface::points(); return triSurface::points();
@ -606,6 +642,7 @@ void Foam::triSurfaceMesh::getNormal
) const ) const
{ {
const triSurface& s = static_cast<const triSurface&>(*this); const triSurface& s = static_cast<const triSurface&>(*this);
const pointField& pts = s.points();
normal.setSize(info.size()); normal.setSize(info.size());
@ -621,9 +658,9 @@ void Foam::triSurfaceMesh::getNormal
if (info[i].hit()) if (info[i].hit())
{ {
label faceI = info[i].index(); label faceI = info[i].index();
normal[i] = s[faceI].normal(points()); normal[i] = s[faceI].normal(pts);
scalar qual = s[faceI].tri(points()).quality(); scalar qual = s[faceI].tri(pts).quality();
if (qual < minQuality_) if (qual < minQuality_)
{ {
@ -633,11 +670,11 @@ void Foam::triSurfaceMesh::getNormal
forAll(fFaces, j) forAll(fFaces, j)
{ {
label nbrI = fFaces[j]; label nbrI = fFaces[j];
scalar nbrQual = s[nbrI].tri(points()).quality(); scalar nbrQual = s[nbrI].tri(pts).quality();
if (nbrQual > qual) if (nbrQual > qual)
{ {
qual = nbrQual; qual = nbrQual;
normal[i] = s[nbrI].normal(points()); normal[i] = s[nbrI].normal(pts);
} }
} }
} }
@ -662,7 +699,7 @@ void Foam::triSurfaceMesh::getNormal
//normal[i] = faceNormals()[faceI]; //normal[i] = faceNormals()[faceI];
//- Uncached //- Uncached
normal[i] = s[faceI].normal(points()); normal[i] = s[faceI].normal(pts);
normal[i] /= mag(normal[i]) + VSMALL; normal[i] /= mag(normal[i]) + VSMALL;
} }
else else

View File

@ -187,6 +187,14 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const; virtual tmp<pointField> coordinates() const;
//- Get bounding spheres (centre and radius squared). Any point
// on surface is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface. //- Get the points that define the surface.
virtual tmp<pointField> points() const; virtual tmp<pointField> points() const;