diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index cb8d07babc..c69f609c39 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -118,9 +118,7 @@ sets ); -// Surface sampling definition: choice of -// plane : values on plane defined by point, normal. -// patch : values on patch. +// Surface sampling definition // // 1] patches are not triangulated by default // 2] planes are always triangulated @@ -209,6 +207,28 @@ surfaces // regularise false; // Optional: do not simplify } + distance + { + // Isosurface from signed/unsigned distance to surface + type distanceSurface; + signed true; + + // Definition of surface + surfaceType triSurfaceMesh; + surfaceName integrationPlane.stl; + // Distance to surface + distance 0.0; + + interpolate false; + } + + triSurfaceSampling + { + // Sampling on triSurface + type sampledTriSurfaceMesh; + surface integrationPlane.stl; + interpolate true; + } ); diff --git a/src/sampling/Make/files b/src/sampling/Make/files index e9d78df7a0..2c7920d29e 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -38,6 +38,7 @@ sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C +sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C sampledSurface/thresholdCellFaces/thresholdCellFaces.C sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C new file mode 100644 index 0000000000..6543cb530c --- /dev/null +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -0,0 +1,353 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 "sampledTriSurfaceMesh.H" +#include "dictionary.H" +#include "polyMesh.H" +#include "polyPatch.H" +#include "volFields.H" +#include "meshSearch.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(sampledTriSurfaceMesh, 0); + addToRunTimeSelectionTable + ( + sampledSurface, + sampledTriSurfaceMesh, + word + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh +( + const word& name, + const polyMesh& mesh, + const word& surfaceName +) +: + sampledSurface(name, mesh), + surface_ + ( + IOobject + ( + name, + mesh.time().constant(), // instance + "triSurface", // local + mesh, // registry + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + needsUpdate_(true), + cellLabels_(0), + pointMap_(0), + faceMap_(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 + ) + ), + needsUpdate_(true), + cellLabels_(0), + pointMap_(0), + faceMap_(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(); + cellLabels_.clear(); + pointMap_.clear(); + faceMap_.clear(); + + needsUpdate_ = true; + return true; +} + + +bool Foam::sampledTriSurfaceMesh::update() +{ + 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(); + + cellLabels_.setSize(fc.size()); + + meshSearch meshSearcher(mesh(), false); + + forAll(fc, triI) + { + cellLabels_[triI] = meshSearcher.findCell + ( + fc[triI], + -1, // seed + true // use tree + ); + + } + + + boolList include(surface_.size(), true); + + label nNotFound = 0; + + forAll(cellLabels_, triI) + { + if (cellLabels_[triI] == -1) + { + include[triI] = false; + nNotFound++; + } + } + label nTotalNotFound = returnReduce(nNotFound, sumOp