diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C index 1d7770f050e8c322797f0166ef2185bc4f085b93..20b57d80b38a5ab7cb491961ba7dc6e05d64c2cd 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -135,145 +135,12 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh -( - const word& name, - const polyMesh& mesh, - const word& surfaceName, - const samplingSource sampleSource -) -: - sampledSurface(name, mesh), - surface_ - ( - IOobject - ( - surfaceName, - mesh.time().constant(), // instance - "triSurface", // local - mesh, // registry - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ), - sampleSource_(sampleSource), - needsUpdate_(true), - sampleElements_(0), - samplePoints_(0) -{} - - -Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -: - sampledSurface(name, mesh, dict), - surface_ - ( - IOobject - ( - dict.lookup("surface"), - mesh.time().constant(), // instance - "triSurface", // local - mesh, // registry - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ), - sampleSource_(samplingSourceNames_[dict.lookup("source")]), - needsUpdate_(true), - sampleElements_(0), - samplePoints_(0) -{} - - -Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh -( - const word& name, - const polyMesh& mesh, - const triSurface& surface, - const word& sampleSourceName -) -: - sampledSurface(name, mesh), - surface_ - ( - IOobject - ( - name, - mesh.time().constant(), // instance - "triSurface", // local - mesh, // registry - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - surface - ), - sampleSource_(samplingSourceNames_[sampleSourceName]), - needsUpdate_(true), - sampleElements_(0), - samplePoints_(0) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::sampledTriSurfaceMesh::~sampledTriSurfaceMesh() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::sampledTriSurfaceMesh::needsUpdate() const -{ - return needsUpdate_; -} - - -bool Foam::sampledTriSurfaceMesh::expire() -{ - // already marked as expired - if (needsUpdate_) - { - return false; - } - - sampledSurface::clearGeom(); - MeshStorage::clear(); - - boundaryTreePtr_.clear(); - sampleElements_.clear(); - samplePoints_.clear(); - - needsUpdate_ = true; - return true; -} - - -bool Foam::sampledTriSurfaceMesh::update() +bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher) { - if (!needsUpdate_) - { - return false; - } - - // Find the cells the triangles of the surface are in. // Does approximation by looking at the face centres only const pointField& fc = surface_.faceCentres(); - // Mesh search engine, no triangulation of faces. - meshSearch meshSearcher(mesh(), polyMesh::FACEPLANES); - - List<nearInfo> nearest(fc.size()); // Global numbering for cells/faces - only used to uniquely identify local @@ -611,6 +478,157 @@ bool Foam::sampledTriSurfaceMesh::update() } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh +( + const word& name, + const polyMesh& mesh, + const word& surfaceName, + const samplingSource sampleSource +) +: + sampledSurface(name, mesh), + surface_ + ( + IOobject + ( + surfaceName, + mesh.time().constant(), // instance + "triSurface", // local + mesh, // registry + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ), + sampleSource_(sampleSource), + needsUpdate_(true), + sampleElements_(0), + samplePoints_(0) +{} + + +Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh +( + const word& name, + const polyMesh& mesh, + const dictionary& dict +) +: + sampledSurface(name, mesh, dict), + surface_ + ( + IOobject + ( + dict.lookup("surface"), + mesh.time().constant(), // instance + "triSurface", // local + mesh, // registry + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ), + sampleSource_(samplingSourceNames_[dict.lookup("source")]), + needsUpdate_(true), + sampleElements_(0), + samplePoints_(0) +{} + + +Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh +( + const word& name, + const polyMesh& mesh, + const triSurface& surface, + const word& sampleSourceName +) +: + sampledSurface(name, mesh), + surface_ + ( + IOobject + ( + name, + mesh.time().constant(), // instance + "triSurface", // local + mesh, // registry + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + surface + ), + sampleSource_(samplingSourceNames_[sampleSourceName]), + needsUpdate_(true), + sampleElements_(0), + samplePoints_(0) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sampledTriSurfaceMesh::~sampledTriSurfaceMesh() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::sampledTriSurfaceMesh::needsUpdate() const +{ + return needsUpdate_; +} + + +bool Foam::sampledTriSurfaceMesh::expire() +{ + // already marked as expired + if (needsUpdate_) + { + return false; + } + + sampledSurface::clearGeom(); + MeshStorage::clear(); + + boundaryTreePtr_.clear(); + sampleElements_.clear(); + samplePoints_.clear(); + + needsUpdate_ = true; + return true; +} + + +bool Foam::sampledTriSurfaceMesh::update() +{ + if (!needsUpdate_) + { + return false; + } + + // Mesh search engine, no triangulation of faces. + meshSearch meshSearcher(mesh(), polyMesh::FACEPLANES); + + return update(meshSearcher); +} + + +bool Foam::sampledTriSurfaceMesh::update(const treeBoundBox& bb) +{ + if (!needsUpdate_) + { + return false; + } + + // Mesh search engine on subset, no triangulation of faces. + meshSearch meshSearcher(mesh(), bb, polyMesh::FACEPLANES); + + return update(meshSearcher); +} + + Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::sample ( const volScalarField& vField diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H index 1ea10b01e9b5f195ec7bce5e757a392440ad396b..7ef68570c43b0a67ac48c7b13005de6ca249bc0a 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H @@ -72,6 +72,7 @@ namespace Foam { class treeDataFace; +class meshSearch; /*---------------------------------------------------------------------------*\ Class sampledTriSurfaceMesh Declaration @@ -136,6 +137,8 @@ private: tmp<Field<Type> > interpolateField(const interpolation<Type>&) const; + bool update(const meshSearch& meshSearcher); + public: //- Runtime type information @@ -189,6 +192,10 @@ public: // Do nothing (and return false) if no update was needed virtual bool update(); + //- Update the surface using a bound box to limit the searching. + // For direct use, i.e. not through sample. + // Do nothing (and return false) if no update was needed + bool update(const treeBoundBox&); //- Points of surface virtual const pointField& points() const