diff --git a/src/meshTools/searchableSurface/searchableBox.H b/src/meshTools/searchableSurface/searchableBox.H index 1c51311511..a593d85065 100644 --- a/src/meshTools/searchableSurface/searchableBox.H +++ b/src/meshTools/searchableSurface/searchableBox.H @@ -121,6 +121,12 @@ public: return true; } + //- Range of local indices that can be returned. + virtual label size() const + { + return 6; + } + // Single point queries. diff --git a/src/meshTools/searchableSurface/searchableSphere.H b/src/meshTools/searchableSurface/searchableSphere.H index 61b114de4e..ecafdbf2e5 100644 --- a/src/meshTools/searchableSurface/searchableSphere.H +++ b/src/meshTools/searchableSurface/searchableSphere.H @@ -36,8 +36,8 @@ SourceFiles #ifndef searchableSphere_H #define searchableSphere_H -#include "searchableSurface.H" #include "treeBoundBox.H" +#include "searchableSurface.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -127,6 +127,12 @@ public: return true; } + //- Range of local indices that can be returned. + virtual label size() const + { + return 1; + } + // Multiple point queries. diff --git a/src/meshTools/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurface/searchableSurface.H index f9dc8b1289..6c788448d6 100644 --- a/src/meshTools/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurface/searchableSurface.H @@ -56,6 +56,7 @@ namespace Foam // Forward declaration of classes class objectRegistry; +class mapDistribute; class treeBoundBox; /*---------------------------------------------------------------------------*\ @@ -180,6 +181,15 @@ public: //- Whether supports volume type below. virtual bool hasVolumeType() const = 0; + //- Range of local indices that can be returned. + virtual label size() const = 0; + + //- Range of global indices that can be returned. + virtual label globalSize() const + { + return size(); + } + // Single point queries. @@ -296,16 +306,18 @@ public: // Other - ////- Get bounding box. - //const boundBox& bounds() const = 0; - - ////- Set bounding box. - //void setBounds - //( - // const boundBox&, - // autoPtr& faceMap, - // autoPtr& pointMap - //) = 0; + //- Set bounds of surface. Bounds currently set as list of + // bounding boxes. The bounds are hints to the surface as for + // the range of queries it can expect. faceMap/pointMap can be + // set if the surface has done any redistribution. + virtual void distribute + ( + const List&, + const bool keepNonLocal, + autoPtr& faceMap, + autoPtr& pointMap + ) + {} }; diff --git a/src/meshTools/searchableSurface/searchableSurfaces.H b/src/meshTools/searchableSurface/searchableSurfaces.H index 4e6c1bc2ed..0735c3d9d7 100644 --- a/src/meshTools/searchableSurface/searchableSurfaces.H +++ b/src/meshTools/searchableSurface/searchableSurfaces.H @@ -149,7 +149,7 @@ public: const pointField& start, const pointField& end, labelListList& surfaces, - List >& surfaceHits + List >& ) const; //- Find nearest. Return -1 (and a miss()) or surface and nearest diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index a426741960..8b4c1cccc8 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -28,6 +28,8 @@ License #include "Random.H" #include "addToRunTimeSelectionTable.H" #include "EdgeMap.H" +#include "triSurfaceFields.H" +#include "Time.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -299,57 +301,6 @@ const Foam::wordList& Foam::triSurfaceMesh::regions() const } -//Foam::pointIndexHit Foam::triSurfaceMesh::findNearest -//( -// const point& sample, -// const scalar nearestDistSqr -//) const -//{ -// return tree().findNearest(sample, nearestDistSqr); -//} -// -// -//Foam::pointIndexHit Foam::triSurfaceMesh::findNearestOnEdge -//( -// const point& sample, -// const scalar nearestDistSqr -//) const -//{ -// return = edgeTree().findNearest(sample, nearestDistSqr); -//} -// -// -//Foam::pointIndexHit Foam::triSurfaceMesh::findNearest -//( -// const linePointRef& ln, -// treeBoundBox& tightest, -// point& linePoint -//) const -//{ -// return tree().findNearest(ln, tightest, linePoint); -//} -// -// -//Foam::pointIndexHit Foam::triSurfaceMesh::findLine -//( -// const point& start, -// const point& end -//) const -//{ -// return tree().findLine(start, end); -//} -// -// -//Foam::pointIndexHit Foam::triSurfaceMesh::findLineAny -//( -// const point& start, -// const point& end -//) const -//{ -// return tree().findLineAny(start, end); -//} - - // Find out if surface is closed. bool Foam::triSurfaceMesh::hasVolumeType() const { @@ -545,6 +496,29 @@ void Foam::triSurfaceMesh::getNormal } +void Foam::triSurfaceMesh::getField +( + const word& fieldName, + const List& info, + labelList& values +) const +{ + const triSurfaceLabelField& fld = lookupObject + ( + fieldName + ); + + values.setSize(info.size()); + forAll(info, i) + { + if (info[i].hit()) + { + values[i] = fld[info[i].index()]; + } + } +} + + void Foam::triSurfaceMesh::getVolumeType ( const pointField& points, @@ -564,4 +538,31 @@ void Foam::triSurfaceMesh::getVolumeType } +//- Write using given format, version and compression +bool Foam::triSurfaceMesh::writeObject +( + IOstream::streamFormat fmt, + IOstream::versionNumber ver, + IOstream::compressionType cmp +) const +{ + fileName fullPath(searchableSurface::objectPath()); + + if (!mkDir(fullPath.path())) + { + return false; + } + + triSurface::write(fullPath); + + if (!file(fullPath)) + { + return false; + } + + //return objectRegistry::writeObject(fmt, ver, cmp); + return true; +} + + // ************************************************************************* // diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.H b/src/meshTools/searchableSurface/triSurfaceMesh.H index 8a0709386c..12582c4e83 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.H +++ b/src/meshTools/searchableSurface/triSurfaceMesh.H @@ -36,6 +36,7 @@ SourceFiles #ifndef triSurfaceMesh_H #define triSurfaceMesh_H +#include "treeBoundBox.H" #include "searchableSurface.H" #include "objectRegistry.H" #include "indexedOctree.H" @@ -142,8 +143,11 @@ public: //- Whether supports volume type below. I.e. whether is closed. virtual bool hasVolumeType() const; - - // Multiple point queries. + //- Range of local indices that can be returned. + virtual label size() const + { + return triSurface::size(); + } virtual void findNearest ( @@ -196,6 +200,30 @@ public: List& ) const; + //- Set bounds of surface. Bounds currently set as list of + // bounding boxes. The bounds are hints to the surface as for + // the range of queries it can expect. faceMap/pointMap can be + // set if the surface has done any redistribution. + virtual void distribute + ( + const List&, + const bool keepNonLocal, + autoPtr& faceMap, + autoPtr& pointMap + ) + {} + + // Other + + //- Specific to triSurfaceMesh: from a set of hits (points and + // indices) get the specified field. Misses do not get set. + virtual void getField + ( + const word& fieldName, + const List&, + labelList& values + ) const; + // regIOobject implementation @@ -205,6 +233,14 @@ public: return false; } + //- Write using given format, version and compression + virtual bool writeObject + ( + IOstream::streamFormat fmt, + IOstream::versionNumber ver, + IOstream::compressionType cmp + ) const; + };