From 4f3e88c164dba950766438e7018ba144cd773a5a Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Fri, 22 Feb 2019 13:06:34 +0100 Subject: [PATCH] DEFEATURE: remove surfMesh samplers - superseded by sampledSurfaces - this functionality was originally added to allow sampling of volume fields onto a surface in order to perform calculations on them. However, the sampling framework essentially mirrored the sampledSurface, but was less complete. It is now possible to store sampled surfaces on a registry and do calculation with their fields. This is the preferred method, and thus removing the surfMeshSample duplicate code. --- src/sampling/Make/files | 6 - .../sampledSurfaces/sampledSurfaces.H | 3 - .../surfMeshSampleDistanceSurface.C | 137 ------- .../surfMeshSampleDistanceSurface.H | 154 ------- .../surfMeshSampleDistanceSurfaceTemplates.C | 72 ---- .../plane/surfMeshSamplePlane.C | 243 ----------- .../plane/surfMeshSamplePlane.H | 205 ---------- .../plane/surfMeshSamplePlaneTemplates.C | 72 ---- .../surfMeshSample/surfMeshSample.C | 217 ---------- .../surfMeshSample/surfMeshSample.H | 312 -------------- .../surfMeshSample/surfMeshSampleTemplates.C | 162 -------- .../surfMeshSamplers/surfMeshSamplers.C | 383 ------------------ .../surfMeshSamplers/surfMeshSamplers.H | 251 ------------ .../surfMeshSamplersTemplates.C | 65 --- .../triSurfaceMesh/surfMeshSampleDiscrete.C | 155 ------- .../triSurfaceMesh/surfMeshSampleDiscrete.H | 192 --------- .../surfMeshSampleDiscreteTemplates.C | 79 ---- 17 files changed, 2708 deletions(-) delete mode 100644 src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C delete mode 100644 src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.H delete mode 100644 src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C delete mode 100644 src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C delete mode 100644 src/sampling/surfMeshSample/plane/surfMeshSamplePlane.H delete mode 100644 src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C delete mode 100644 src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.C delete mode 100644 src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.H delete mode 100644 src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C delete mode 100644 src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C delete mode 100644 src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.H delete mode 100644 src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplersTemplates.C delete mode 100644 src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C delete mode 100644 src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.H delete mode 100644 src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 83403b64a29..ecb8c167419 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -33,12 +33,6 @@ surface/isoSurface/isoSurfaceTopo.C surface/thresholdCellFaces/thresholdCellFaces.C surface/triSurfaceMesh/discreteSurface.C -surfMeshSample/surfMeshSample/surfMeshSample.C -surfMeshSample/surfMeshSamplers/surfMeshSamplers.C -surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C -surfMeshSample/plane/surfMeshSamplePlane.C -surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C - sampledSurface/sampledNone/sampledNone.C sampledSurface/sampledPatch/sampledPatch.C sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 668ef0ebe42..f2b9c889726 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -118,9 +118,6 @@ Note The interpolationScheme is only used if interpolate=true is used by any of the surfaces. -See also - Foam::surfMeshSamplers - SourceFiles sampledSurfaces.C diff --git a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C b/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C deleted file mode 100644 index db7b61d3223..00000000000 --- a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C +++ /dev/null @@ -1,137 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSampleDistanceSurface.H" -#include "dictionary.H" -#include "polyMesh.H" -#include "volFields.H" -#include "coordinateSystem.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfMeshSampleDistanceSurface, 0); - addNamedToRunTimeSelectionTable - ( - surfMeshSample, - surfMeshSampleDistanceSurface, - word, - distanceSurface - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::surfMeshSampleDistanceSurface::surfMeshSampleDistanceSurface -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -: - surfMeshSample(name, mesh, dict), - SurfaceSource(name, mesh, dict), - needsUpdate_(true) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::surfMeshSampleDistanceSurface::needsUpdate() const -{ - return needsUpdate_; -} - - -bool Foam::surfMeshSampleDistanceSurface::expire() -{ - // Already marked as expired - if (needsUpdate_) - { - return false; - } - - needsUpdate_ = true; - return true; -} - - -bool Foam::surfMeshSampleDistanceSurface::update() -{ - if (!needsUpdate_) - { - return false; - } - - SurfaceSource::createGeometry(); - - // Transfer content - getOrCreateSurfMesh().transfer - ( - SurfaceSource::surface() - ); - - if (debug) - { - print(Pout); - Pout<< endl; - } - - needsUpdate_ = false; - return true; -} - - -bool Foam::surfMeshSampleDistanceSurface::sample -( - const word& fieldName, - const word& sampleScheme -) const -{ - return - ( - sampleType<scalar>(fieldName, sampleScheme) - || sampleType<vector>(fieldName, sampleScheme) - || sampleType<sphericalTensor>(fieldName, sampleScheme) - || sampleType<symmTensor>(fieldName, sampleScheme) - || sampleType<tensor>(fieldName, sampleScheme) - ); -} - - -void Foam::surfMeshSampleDistanceSurface::print(Ostream& os) const -{ - os << "distanceSurface: " << name() << " :" - << " surface:" << surfaceName() - << " distance:" << distance() - << " faces:" << surface().faces().size() - << " points:" << surface().points().size(); -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.H b/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.H deleted file mode 100644 index 9c8353e7d10..00000000000 --- a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.H +++ /dev/null @@ -1,154 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2018 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 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/>. - -Class - Foam::surfMeshSampleDistanceSurface - -Description - Sampling surfFields onto a surfMesh based on a plane. - The cuttingPlane algorithm 'cuts' the mesh. - The plane is triangulated by default. - -Note - Does not actually cut until update() called. - -SourceFiles - surfMeshSampleDistanceSurface.C - surfMeshSampleDistanceSurfaceTemplates.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfMeshSampleDistanceSurface_H -#define surfMeshSampleDistanceSurface_H - -#include "surfMeshSample.H" -#include "distanceSurface.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class surfMeshSampleDistanceSurface Declaration -\*---------------------------------------------------------------------------*/ - -class surfMeshSampleDistanceSurface -: - public surfMeshSample, - private distanceSurface -{ - // Private typedefs for convenience - typedef distanceSurface SurfaceSource; - - // Private data - - //- Track if the surface needs an update - mutable bool needsUpdate_; - - - // Private Member Functions - - //- Sample field on surface - template<class Type> - tmp<Field<Type>> sampleOnFaces - ( - const interpolation<Type>& sampler - ) const; - - - //- Sample field on surface. - template<class Type> - bool sampleType - ( - const word& fieldName, - const word& sampleScheme - ) const; - - -public: - - //- Runtime type information - TypeName("surfMeshSampleDistanceSurface"); - - - // Constructors - - //- Construct from dictionary - surfMeshSampleDistanceSurface - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ); - - - //- Destructor - virtual ~surfMeshSampleDistanceSurface() = default; - - - // Member Functions - - //- The surface is from surfMesh - using surfMeshSample::surface; - - //- Does the surface need an update? - virtual bool needsUpdate() const; - - //- Mark the surface as needing an update. - // May also free up unneeded data. - // Return false if surface was already marked as expired. - virtual bool expire(); - - //- Update the surface as required. - // Do nothing (and return false) if no update was needed - virtual bool update(); - - //- Sample the volume field onto surface - virtual bool sample - ( - const word& fieldName, - const word& sampleScheme = "cell" - ) const; - - - //- Write - virtual void print(Ostream& os) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "surfMeshSampleDistanceSurfaceTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C b/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C deleted file mode 100644 index 7e1834f5d51..00000000000 --- a/src/sampling/surfMeshSample/distanceSurface/surfMeshSampleDistanceSurfaceTemplates.C +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSampleDistanceSurface.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::tmp<Foam::Field<Type>> -Foam::surfMeshSampleDistanceSurface::sampleOnFaces -( - const interpolation<Type>& sampler -) const -{ - return surfMeshSample::sampleOnFaces - ( - sampler, - SurfaceSource::meshCells(), - surface().faces(), - surface().points() - ); -} - - -template<class Type> -bool Foam::surfMeshSampleDistanceSurface::sampleType -( - const word& fieldName, - const word& sampleScheme -) const -{ - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - const auto* volFldPtr = mesh().findObject<VolFieldType>(fieldName); - - if (!volFldPtr) - { - return false; - } - - auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr); - - getOrCreateSurfField<Type>(*volFldPtr).field() = - sampleOnFaces(*samplerPtr); - - return true; -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C b/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C deleted file mode 100644 index 9a907c5fc4a..00000000000 --- a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.C +++ /dev/null @@ -1,243 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2019 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSamplePlane.H" -#include "dictionary.H" -#include "polyMesh.H" -#include "volFields.H" -#include "cartesianCS.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfMeshSamplePlane, 0); - addNamedToRunTimeSelectionTable - ( - surfMeshSample, - surfMeshSamplePlane, - word, - plane - ); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::bitSet Foam::surfMeshSamplePlane::cellSelection(const bool warn) const -{ - return cuttingPlane::cellSelection - ( - mesh(), - bounds_, - zoneNames_, - name(), - warn - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::surfMeshSamplePlane::surfMeshSamplePlane -( - const word& name, - const polyMesh& mesh, - const plane& planeDesc, - const wordRes& zones, - const bool triangulate -) -: - surfMeshSample(name, mesh), - SurfaceSource(planeDesc), - zoneNames_(zones), - bounds_(), - triangulate_(triangulate), - needsUpdate_(true) -{ - if (debug) - { - if (!zoneNames_.empty()) - { - Info<< "cellZones " << flatOutput(zoneNames_); - - if (-1 == mesh.cellZones().findIndex(zoneNames_)) - { - Info<< " not found!"; - } - Info<< endl; - } - } -} - - -Foam::surfMeshSamplePlane::surfMeshSamplePlane -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -: - surfMeshSample(name, mesh, dict), - SurfaceSource(plane(dict)), - zoneNames_(), - bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)), - triangulate_(dict.lookupOrDefault("triangulate", true)), - needsUpdate_(true) -{ - if (!dict.readIfPresent("zones", zoneNames_) && dict.found("zone")) - { - zoneNames_.resize(1); - dict.readEntry("zone", zoneNames_.first()); - } - - - // Make plane relative to the coordinateSystem (Cartesian) - // allow lookup from global coordinate systems - if (dict.found(coordinateSystem::typeName_())) - { - coordSystem::cartesian cs - ( - coordinateSystem::New(mesh, dict, coordinateSystem::typeName_()) - ); - plane& pln = planeDesc(); - - const point orig = cs.globalPosition(pln.origin()); - const vector norm = cs.globalVector(pln.normal()); - - if (debug) - { - Info<< "plane " << name << " :" - << " origin:" << origin() - << " normal:" << normal() - << " defined within a local coordinateSystem" << endl; - } - - // Reassign the plane - pln = plane(orig, norm); - } - - if (debug) - { - Info<< "plane " << name << " :" - << " origin:" << origin() - << " normal:" << normal(); - - if (bounds_.valid()) - { - Info<< " bounds:" << bounds_; - } - - if (!zoneNames_.empty()) - { - Info<< " cellZones " << flatOutput(zoneNames_); - - if (-1 == mesh.cellZones().findIndex(zoneNames_)) - { - Info<< " not found!"; - } - } - Info<< endl; - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::surfMeshSamplePlane::needsUpdate() const -{ - return needsUpdate_; -} - - -bool Foam::surfMeshSamplePlane::expire() -{ - // Already marked as expired - if (needsUpdate_) - { - return false; - } - - needsUpdate_ = true; - return true; -} - - -bool Foam::surfMeshSamplePlane::update() -{ - if (!needsUpdate_) - { - return false; - } - - performCut(mesh(), triangulate_, cellSelection(true)); - - if (debug) - { - print(Pout); - Pout<< endl; - } - - // Transfer content - getOrCreateSurfMesh().transfer - ( - static_cast<SurfaceSource&>(*this) - ); - - needsUpdate_ = false; - return true; -} - - -bool Foam::surfMeshSamplePlane::sample -( - const word& fieldName, - const word& sampleScheme -) const -{ - return - ( - sampleType<scalar>(fieldName, sampleScheme) - || sampleType<vector>(fieldName, sampleScheme) - || sampleType<sphericalTensor>(fieldName, sampleScheme) - || sampleType<symmTensor>(fieldName, sampleScheme) - || sampleType<tensor>(fieldName, sampleScheme) - ); -} - - -void Foam::surfMeshSamplePlane::print(Ostream& os) const -{ - os << "surfMeshSamplePlane: " << name() << " :" - << " base:" << plane::origin() - << " normal:" << plane::normal() - << " triangulate:" << triangulate_ - << " faces:" << SurfaceSource::surfFaces().size() - << " points:" << SurfaceSource::points().size(); -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.H b/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.H deleted file mode 100644 index 083ad16cea3..00000000000 --- a/src/sampling/surfMeshSample/plane/surfMeshSamplePlane.H +++ /dev/null @@ -1,205 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -Class - Foam::surfMeshSamplePlane - -Description - Sampling surfFields onto a surfMesh based on a plane. - The cuttingPlane algorithm 'cuts' the mesh. - The plane is triangulated by default. - - Example of function object partial specification: - \verbatim - surfaces - ( - surface1 - { - type plane; - planeType pointAndNormal; - pointAndNormalDict - { - ... - } - } - ); - \endverbatim - - Where the sub-entries comprise: - \table - Property | Description | Required | Default - type | plane | yes | - planeType | plane description (pointAndNormal etc) | yes | - triangulate | triangulate faces | no | true - bounds | limit with bounding box | no | - zone | limit to cell zone (name or regex) | no | - zones | limit to cell zones (names, regexs) | no | - coordinateSystem | define plane within given coordinate system | no | - \endtable - -Note - Does not actually cut until update() called. - -SourceFiles - surfMeshSamplePlane.C - surfMeshSamplePlaneTemplates.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfMeshSamplePlane_H -#define surfMeshSamplePlane_H - -#include "surfMeshSample.H" -#include "cuttingPlane.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class surfMeshSamplePlane Declaration -\*---------------------------------------------------------------------------*/ - -class surfMeshSamplePlane -: - public surfMeshSample, - private cuttingPlane -{ - // Private typedefs for convenience - typedef cuttingPlane SurfaceSource; - - // Private data - - //- The zone or zones in which cutting is to occur - wordRes zoneNames_; - - //- Optional bounding box to trim against - const boundBox bounds_; - - //- Triangulate faces or not - const bool triangulate_; - - //- Track if the surface needs an update - mutable bool needsUpdate_; - - - // Private Member Functions - - //- Define cell selection from zones and bounding box. - // Optionally check and warn if the plane does not intersect - // with the bounds of the mesh (or submesh) or if the bounding box - // does not overlap with the mesh (or submesh) - bitSet cellSelection(const bool warn=false) const; - - - //- Sample field on surface - template<class Type> - tmp<Field<Type>> sampleOnFaces - ( - const interpolation<Type>& sampler - ) const; - - - //- Sample field on surface. - template<class Type> - bool sampleType - ( - const word& fieldName, - const word& sampleScheme - ) const; - - -public: - - //- Runtime type information - TypeName("surfMeshSamplePlane"); - - - // Constructors - - //- Construct from components - surfMeshSamplePlane - ( - const word& name, - const polyMesh& mesh, - const plane& planeDesc, - const wordRes& zones = wordRes(), - const bool triangulate = true - ); - - //- Construct from dictionary - surfMeshSamplePlane - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ); - - - //- Destructor - virtual ~surfMeshSamplePlane() = default; - - - // Member Functions - - //- Does the surface need an update? - virtual bool needsUpdate() const; - - //- Mark the surface as needing an update. - // May also free up unneeded data. - // Return false if surface was already marked as expired. - virtual bool expire(); - - //- Update the surface as required. - // Do nothing (and return false) if no update was needed - virtual bool update(); - - //- Sample the volume field onto surface - virtual bool sample - ( - const word& fieldName, - const word& sampleScheme = "cell" - ) const; - - - //- Write - virtual void print(Ostream& os) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "surfMeshSamplePlaneTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C b/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C deleted file mode 100644 index fbcd7a64411..00000000000 --- a/src/sampling/surfMeshSample/plane/surfMeshSamplePlaneTemplates.C +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSamplePlane.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::tmp<Foam::Field<Type>> -Foam::surfMeshSamplePlane::sampleOnFaces -( - const interpolation<Type>& sampler -) const -{ - return surfMeshSample::sampleOnFaces - ( - sampler, - SurfaceSource::meshCells(), - surface().faces(), - surface().points() - ); -} - - -template<class Type> -bool Foam::surfMeshSamplePlane::sampleType -( - const word& fieldName, - const word& sampleScheme -) const -{ - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - const auto* volFldPtr = mesh().findObject<VolFieldType>(fieldName); - - if (!volFldPtr) - { - return false; - } - - auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr); - - getOrCreateSurfField<Type>(*volFldPtr).field() = - sampleOnFaces(*samplerPtr); - - return true; -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.C b/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.C deleted file mode 100644 index 8ed1f3229e7..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.C +++ /dev/null @@ -1,217 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2019 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSample.H" -#include "MeshedSurfaces.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfMeshSample, 0); - defineRunTimeSelectionTable(surfMeshSample, word); -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -Foam::surfMesh& -Foam::surfMeshSample::getOrCreateSurfMesh() const -{ - if (!mesh().foundObject<surfMesh>(name())) - { - surfMesh* ptr = new surfMesh - ( - IOobject - ( - name(), - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - meshedSurface(), // Create as empty surface - name() - ); - - mesh().objectRegistry::store(ptr); - } - - return const_cast<surfMesh&>(surface()); -} - - -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // - -Foam::autoPtr<Foam::surfMeshSample> -Foam::surfMeshSample::New -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -{ - const word sampleType(dict.get<word>("type")); - - auto cstrIter = wordConstructorTablePtr_->cfind(sampleType); - - if (!cstrIter.found()) - { - FatalErrorInFunction - << "Unknown sample type " - << sampleType << nl << nl - << "Valid sample types : " << endl - << wordConstructorTablePtr_->sortedToc() - << exit(FatalError); - } - - return autoPtr<surfMeshSample>(cstrIter()(name, mesh, dict)); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::surfMeshSample::surfMeshSample -( - const word& name, - const polyMesh& mesh -) -: - name_(name), - mesh_(mesh), - enabled_(true) -{} - - -Foam::surfMeshSample::surfMeshSample -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -: - name_(dict.lookupOrDefault<word>("name", name)), - mesh_(mesh), - enabled_(dict.lookupOrDefault("enabled", true)) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::surfMeshSample::create() const -{ - getOrCreateSurfMesh(); -} - - -const Foam::surfMesh& Foam::surfMeshSample::surface() const -{ - return mesh().lookupObject<surfMesh>(name()); -} - - -// Demonstration of using separate tmp registry -// -// Foam::label Foam::surfMeshSample::sample -// ( -// const objectRegistry& store, -// const UList<word>& fields -// ) const -// { -// label count = 0; -// forAll(fields, fieldi) -// { -// const word& fieldName = fields[fieldi]; -// bool ok = -// ( -// sampleAndStore(store, fieldName) -// && -// ( -// transferField<scalar>(store, fieldName) -// || transferField<vector>(store, fieldName) -// || transferField<sphericalTensor>(store, fieldName) -// || transferField<symmTensor>(store, fieldName) -// || transferField<tensor>(store, fieldName) -// ) -// ); -// -// if (ok) -// { -// ++count; -// } -// } -// -// return count; -// } - - -Foam::label Foam::surfMeshSample::sample -( - const UList<word>& fieldNames, - const word& sampleScheme -) const -{ - label count = 0; - for (const word& fieldName : fieldNames) - { - if (sample(fieldName, sampleScheme)) - { - ++count; - } - } - - return count; -} - - -Foam::label Foam::surfMeshSample::write(const wordRes& select) const -{ - label count = - ( - writeFields<scalar>(select) - + writeFields<vector>(select) - + writeFields<sphericalTensor>(select) - + writeFields<symmTensor>(select) - + writeFields<tensor>(select) - ); - - if (count) - { - surface().write(); - } - - return count; -} - - - -void Foam::surfMeshSample::print(Ostream& os) const -{ - os << type(); -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.H b/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.H deleted file mode 100644 index c7ed6707b5b..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSample.H +++ /dev/null @@ -1,312 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2019 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 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/>. - -Class - Foam::surfMeshSample - -Group - grpUtilitiesFunctionObjects - -Description - An abstract class for surfMesh with sampling. - - Dictionary entries: - \table - Property | Description | Required | Default - enabled | Enable/disable the surface? | no | yes - \endtable - -SourceFiles - surfMeshSample.C - surfMeshSampleTemplates.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfMeshSample_H -#define surfMeshSample_H - -#include "surfMesh.H" -#include "surfFields.H" - -#include "pointField.H" -#include "word.H" -#include "labelList.H" -#include "faceList.H" -#include "typeInfo.H" -#include "runTimeSelectionTables.H" -#include "autoPtr.H" -#include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "polyMesh.H" -#include "interpolation.H" -#include "error.H" -#include "IOobjectList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class surfMeshSample; - -/*---------------------------------------------------------------------------*\ - Class surfMeshSample Declaration -\*---------------------------------------------------------------------------*/ - -class surfMeshSample -{ - // Private Data - - //- Name for surfMesh lookup - word name_; - - //- Mesh reference - const polyMesh& mesh_; - - //- Should surface sampling be enabled? - bool enabled_; - - -protected: - - // Protected Member Functions - - //- General loop for sampling elements to faces - template<class Type> - static tmp<Field<Type>> sampleOnFaces - ( - const interpolation<Type>& sampler, - const labelUList& elements, - const faceList& fcs, - const pointField& pts - ); - - - //- Get existing or create new surfMesh - surfMesh& getOrCreateSurfMesh() const; - - //- Get existing or create new surfField. - // Create with same name and dimensions as the 'parent' volField. - template<class Type> - DimensionedField<Type, surfGeoMesh>& - getOrCreateSurfField - ( - const GeometricField<Type, fvPatchField, volMesh>& vField - ) const; - - - // //- Transfer field from object registry to surfField - // template<class Type> - // bool transferField - // ( - // const objectRegistry& store, - // const word& fieldName - // ) const; - - - //- Write the given fields - template<class Type> - label writeFields(const wordRes& select) const; - -public: - - //- Runtime type information - TypeName("surfMeshSample"); - - - //- Declare run-time constructor selection table - declareRunTimeSelectionTable - ( - autoPtr, - surfMeshSample, - word, - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ), - (name, mesh, dict) - ); - - - // iNew helper class - - //- Class for PtrList read-construction - class iNew - { - //- Reference to the volume mesh - const polyMesh& mesh_; - - public: - - iNew(const polyMesh& mesh) - : - mesh_(mesh) - {} - - autoPtr<surfMeshSample> operator()(Istream& is) const - { - word name(is); - dictionary dict(is); - - return surfMeshSample::New(name, mesh_, dict); - } - }; - - - // Constructors - - //- Construct from name, mesh - surfMeshSample - ( - const word& name, - const polyMesh& mesh - ); - - //- Construct from dictionary - surfMeshSample - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ); - - - //- Clone - autoPtr<surfMeshSample> clone() const - { - NotImplemented; - return nullptr; - } - - - - // Selectors - - //- Return a reference to the selected surface - static autoPtr<surfMeshSample> New - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ); - - - //- Destructor - virtual ~surfMeshSample() = default; - - - // Member Functions - - // Access - - //- Access to the underlying mesh - const polyMesh& mesh() const - { - return mesh_; - } - - //- Name of surface - const word& name() const - { - return name_; - } - - //- Sampling is enabled - bool enabled() const - { - return enabled_; - } - - //- Create surfMesh if required. - void create() const; - - //- Return existing surfMesh. - virtual const surfMesh& surface() const; - - - //- Does the surface need an update? - virtual bool needsUpdate() const = 0; - - //- Mark the surface as needing an update. - // May also free up unneeded data. - // Return false if surface was already marked as expired. - virtual bool expire() = 0; - - //- Update the surface as required. - // Do nothing (and return false) if no update was needed - virtual bool update() = 0; - - - // Edit - - //- Rename - virtual void rename(const word& newName) - { - name_ = newName; - } - - - // Execute - - //- Sample from specified volume field to obtain surface field. - virtual bool sample - ( - const word& fieldName, - const word& sampleScheme = "cell" - ) const = 0; - - //- Sample from specified volume fields to obtain surface fields. - virtual label sample - ( - const UList<word>& fieldNames, - const word& sampleScheme = "cell" - ) const; - - - // Write - - //- Write specified fields - virtual label write(const wordRes& fieldSelection) const; - - //- Write - virtual void print(Ostream& os) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "surfMeshSampleTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C b/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C deleted file mode 100644 index 95d969da542..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSample/surfMeshSampleTemplates.C +++ /dev/null @@ -1,162 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSample.H" -#include "dimensionedType.H" - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::tmp<Foam::Field<Type>> -Foam::surfMeshSample::sampleOnFaces -( - const interpolation<Type>& sampler, - const labelUList& elements, - const faceList& fcs, - const pointField& pts -) -{ - const label len = elements.size(); - - if (len != fcs.size()) - { - FatalErrorInFunction - << "size mismatch: " - << "sampled elements (" << len - << ") != faces (" << fcs.size() << ')' - << exit(FatalError); - } - - auto tvalues = tmp<Field<Type>>::New(len); - auto& values = tvalues.ref(); - - for (label i=0; i < len; ++i) - { - const label celli = elements[i]; - const point pt = fcs[i].centre(pts); - - values[i] = sampler.interpolate(pt, celli); - } - - return tvalues; -} - - -template<class Type> -Foam::DimensionedField<Type, Foam::surfGeoMesh>& -Foam::surfMeshSample::getOrCreateSurfField -( - const GeometricField<Type, fvPatchField, volMesh>& vField -) const -{ - typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - - const surfMesh& surf = surface(); - const word& fieldName = vField.name(); - - SurfFieldType* ptr = surf.getObjectPtr<SurfFieldType>(fieldName); - if (!ptr) - { - ptr = new SurfFieldType - ( - IOobject - ( - fieldName, - surf.time().timeName(), - surf, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - surf, - dimensioned<Type>(vField.dimensions(), Zero) - ); - ptr->writeOpt() = IOobject::NO_WRITE; - - surf.store(ptr); - } - - return *ptr; -} - - -// // Older code for transferring an IOField to a surfField between -// // different registries -// template<class Type> -// bool Foam::surfMeshSample::transferField -// ( -// const objectRegistry& store, -// const word& fieldName -// ) const -// { -// typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; -// typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; -// typedef IOField<Type> TmpFieldType; -// -// // foundObject includes a type check -// bool ok = -// ( -// mesh_.foundObject<VolFieldType>(fieldName) -// && store.foundObject<TmpFieldType>(fieldName) -// ); -// -// if (ok) -// { -// SurfFieldType& sfield = getOrCreateSurfField -// ( -// mesh_.lookupObject<VolFieldType>(fieldName) -// ); -// -// TmpFieldType& iofield = -// store.lookupObjectRef<TmpFieldType>(fieldName); -// -// sfield.transfer(iofield); -// store.checkOut(iofield); -// } -// -// return ok; -// } - - -template<class Type> -Foam::label Foam::surfMeshSample::writeFields -( - const wordRes& select -) const -{ - typedef DimensionedField<Type, surfGeoMesh> SurfFieldType; - const surfMesh& s = surface(); - - const wordList fieldNames(s.sortedNames<SurfFieldType>(select)); - - for (const word& fieldName : fieldNames) - { - s.lookupObject<SurfFieldType>(fieldName).write(); - } - - return fieldNames.size(); -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C b/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C deleted file mode 100644 index a31760524a0..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.C +++ /dev/null @@ -1,383 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2019 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSamplers.H" -#include "volFields.H" -#include "dictionary.H" -#include "Time.H" -#include "IOmanip.H" -#include "volPointInterpolation.H" -#include "PatchTools.H" -#include "mapPolyMesh.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfMeshSamplers, 0); - addToRunTimeSelectionTable - ( - functionObject, - surfMeshSamplers, - dictionary - ); -} // End namespace Foam - - -bool Foam::surfMeshSamplers::verbose_ = false; - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// //- Temporary object registry for passing around values -// const objectRegistry& tmpRegistry() const; -// -// //- Temporary object registry for passing around values -// const objectRegistry& tmpRegistry(const word& subName) const; - -// const Foam::objectRegistry& -// Foam::surfMeshSamplers::tmpRegistry() const -// { -// // Sub-registry for sampling, choose name for fewer collisions -// return mesh_.thisDb().subRegistry -// ( -// "$tmp$" + type() + "$" + name(), -// true, -// false -// ); -// } -// -// -// const Foam::objectRegistry& -// Foam::surfMeshSamplers::tmpRegistry(const word& subName) const -// { -// return tmpRegistry().subRegistry(subName, true, false); -// } - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::surfMeshSamplers::surfMeshSamplers -( - const word& name, - const Time& runTime, - const dictionary& dict -) -: - functionObjects::fvMeshFunctionObject(name, runTime, dict), - PtrList<surfMeshSample>(), - fieldSelection_(), - sampleFaceScheme_() -{ - read(dict); -} - - -Foam::surfMeshSamplers::surfMeshSamplers -( - const word& name, - const objectRegistry& obr, - const dictionary& dict -) -: - functionObjects::fvMeshFunctionObject(name, obr, dict), - PtrList<surfMeshSample>(), - fieldSelection_(), - sampleFaceScheme_() -{ - read(dict); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::surfMeshSamplers::verbose(const bool verbosity) -{ - verbose_ = verbosity; -} - - -bool Foam::surfMeshSamplers::execute() -{ - if (empty()) - { - return true; - } - - // The acceptable fields - wordHashSet acceptable; - acceptable.insert(acceptType<scalar>()); - acceptable.insert(acceptType<vector>()); - acceptable.insert(acceptType<sphericalTensor>()); - acceptable.insert(acceptType<symmTensor>()); - acceptable.insert(acceptType<tensor>()); - - const wordList fields = acceptable.sortedToc(); - if (!fields.empty()) - { - for (surfMeshSample& s : surfaces()) - { - // Potentially monitor the update for writing geometry? - if (s.needsUpdate()) - { - s.update(); - } - - s.sample(fields, sampleFaceScheme_); - } - } - - clearObjects(removeFieldsOnExecute_); - - return true; -} - - -bool Foam::surfMeshSamplers::write() -{ - // Write sampled fields (on surface) - // - // Doesn't bother checking which fields have been generated here - // or elsewhere - - for (const surfMeshSample& s : surfaces()) - { - s.write(fieldSelection_); - } - - clearObjects(removeFieldsOnWrite_); - - return true; -} - - -bool Foam::surfMeshSamplers::read(const dictionary& dict) -{ - fvMeshFunctionObject::read(dict); - - PtrList<surfMeshSample>::clear(); - fieldSelection_.clear(); - removeFieldsOnExecute_.clear(); - removeFieldsOnWrite_.clear(); - - dict.readIfPresent("removeFieldsOnExecute", removeFieldsOnExecute_); - dict.readIfPresent("removeFieldsOnWrite", removeFieldsOnWrite_); - - const bool createOnRead = dict.lookupOrDefault("createOnRead", false); - - sampleFaceScheme_ = - dict.lookupOrDefault<word>("sampleScheme", "cell"); - - const entry* eptr = dict.findEntry("surfaces"); - - if (eptr && eptr->isDict()) - { - PtrList<surfMeshSample> surfs(eptr->dict().size()); - - label surfi = 0; - - for (const entry& dEntry : eptr->dict()) - { - if (dEntry.isDict()) - { - autoPtr<surfMeshSample> surf = - surfMeshSample::New - ( - dEntry.keyword(), - mesh_, - dEntry.dict() - ); - - if (surf.valid() && surf->enabled()) - { - surfs.set(surfi, surf); - ++surfi; - } - } - } - - surfs.resize(surfi); - surfaces().transfer(surfs); - } - else if (eptr) - { - PtrList<surfMeshSample> surfs - ( - eptr->stream(), - surfMeshSample::iNew(mesh_) - ); - - forAll(surfs, surfi) - { - if (!surfs[surfi].enabled()) - { - surfs.set(surfi, nullptr); - } - } - - surfs.resize(surfs.squeezeNull()); - - surfaces().transfer(surfs); - } - - - auto& surfs = surfaces(); - if (surfs.size()) - { - dict.readEntry("fields", fieldSelection_); - fieldSelection_.uniq(); - - Info<< type() << " fields: " << flatOutput(fieldSelection_) << nl; - Info<< nl; - - // Need to initialize corresponding surfMesh for others in the chain. - // This can simply be a zero-sized placeholder, or the real surface with - // faces. - - label surfi = 0; - for (surfMeshSample& s : surfs) - { - if (!surfi) - { - Info<< "Sampled surface:" << nl; - } - Info<< " " << s.name() << nl; - - if (createOnRead) - { - s.update(); - } - else - { - s.create(); - } - - ++surfi; - } - - Info<< nl; - } - - if (removeFieldsOnExecute_.size()) - { - Info<< type() << " Remove fields on-execute : " - << removeFieldsOnExecute_ << nl; - } - if (removeFieldsOnWrite_.size()) - { - Info<< type() << " Remove fields on-write :" - << removeFieldsOnWrite_ << nl; - } - - // Ensure all surfaces are expired (unsampled) - expire(); - - return true; -} - - -void Foam::surfMeshSamplers::updateMesh(const mapPolyMesh& mpm) -{ - if (&mpm.mesh() == &mesh_) - { - expire(); - } - - // pointMesh and interpolation will have been reset in mesh.update -} - - -void Foam::surfMeshSamplers::movePoints(const polyMesh& m) -{ - if (&m == &mesh_) - { - expire(); - } -} - - -void Foam::surfMeshSamplers::readUpdate(const polyMesh::readUpdateState state) -{ - if (state != polyMesh::UNCHANGED) - { - expire(); - } -} - - -bool Foam::surfMeshSamplers::needsUpdate() const -{ - for (const surfMeshSample& s : surfaces()) - { - if (s.needsUpdate()) - { - return true; - } - } - - return false; -} - - -bool Foam::surfMeshSamplers::expire() -{ - label nChanged = 0; - - for (surfMeshSample& s : surfaces()) - { - if (s.expire()) - { - ++nChanged; - } - } - - // True if any surfaces just expired - return nChanged; -} - - -bool Foam::surfMeshSamplers::update() -{ - if (!needsUpdate()) - { - return false; - } - - label nUpdated = 0; - - for (surfMeshSample& s : surfaces()) - { - if (s.update()) - { - ++nUpdated; - } - } - - return nUpdated; -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.H b/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.H deleted file mode 100644 index 9e44f2999aa..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplers.H +++ /dev/null @@ -1,251 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2019 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 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/>. - -Class - Foam::surfMeshSamplers - -Description - Set of surfaces to sample from a volume field onto surfField that resides - on a surfMesh object. - - The execute() method is used to sample, and the write() method to write. - It is fairly common to use for sampling only and have the write disabled. - - \verbatim - surfaces - { - type surfMeshes; - libs ("libsampling.so"); - - // Sample at every time-step - executeControl timeStep; - executeInterval 1; - - // Disable writing (or write at same frequency as fields) - writeControl none; - writeInterval 1; - - // Fields to be sampled - fields (p U); - - // Scheme to obtain face centre value - sampleScheme cell; - - // Optional: create surface immediately on read - // The default is to create a placeholder without any faces. - createOnRead false; - - // Optional: remove derived fields created prior - removeFieldsOnExecute ( someDerivedField ); - - surfaces - ( - f0surf - { - type sampledTriSurfaceMesh; - surface f0surf.obj; - source cells; - } - ); - } - \endverbatim - - Entries: - \table - Property | Description | Required | Default - type | surfMeshes | yes | - surfaces | list or dictionary of sample surfaces | recommended | - fields | word/regex list of fields to sampled | yes | - derived | additional derived fields pTotal/rhoU | no | - rhoRef | reference density for derived fields (incompressible) | no | 1 - sampleScheme | scheme to obtain face centre value | no | cell - createOnRead | Create surface immediately on read | no | false - removeFieldsOnExecute | List of fields to remove as "consumed" | no | - removeFieldsOnWrite | List of fields to remove as "consumed" | no | - \endtable - -Note - The default is to create a placeholder surMesh without any faces on - construction. This behaviour can be changed by the createOnRead option. - -See also - Foam::sampledSurfaces - -SourceFiles - surfMeshSamplers.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfMeshSamplers_H -#define surfMeshSamplers_H - -#include "fvMeshFunctionObject.H" -#include "surfMeshSample.H" -#include "volFieldsFwd.H" -#include "surfaceFieldsFwd.H" -#include "wordRes.H" -#include "IOobjectList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class surfMeshSamplers Declaration -\*---------------------------------------------------------------------------*/ - -class surfMeshSamplers -: - public functionObjects::fvMeshFunctionObject, - public PtrList<surfMeshSample> -{ - // Static Data Members - - //- Output verbosity - static bool verbose_; - - - // Private Data - - //- Names of fields to sample - wordRes fieldSelection_; - - //- List of fields to remove as "consumed" - wordList removeFieldsOnExecute_; - - //- List of fields to remove as "consumed" - wordList removeFieldsOnWrite_; - - //- Sample scheme to obtain face values - word sampleFaceScheme_; - - - // Private Member Functions - - //- Access the sampling surfaces - inline const PtrList<surfMeshSample>& surfaces() const - { - return static_cast<const PtrList<surfMeshSample>&>(*this); - } - - //- Access the sampling surfaces - inline PtrList<surfMeshSample>& surfaces() - { - return static_cast<PtrList<surfMeshSample>&>(*this); - } - - - //- Filter acceptable fields types - template<class Type> - wordList acceptType() const; - - - //- No copy construct - surfMeshSamplers(const surfMeshSamplers&) = delete; - - //- No copy assignment - void operator=(const surfMeshSamplers&) = delete; - - -public: - - //- Runtime type information - TypeName("surfMeshes"); - - - // Constructors - - //- Construct from name, Time and dictionary - surfMeshSamplers - ( - const word& name, - const Time& runTime, - const dictionary& dict - ); - - //- Construct from name, objectRegistry and dictionary - surfMeshSamplers - ( - const word& name, - const objectRegistry& obr, - const dictionary& dict - ); - - - //- Destructor - virtual ~surfMeshSamplers() = default; - - - // Member Functions - - //- Do any of the surfaces need an update? - virtual bool needsUpdate() const; - - //- Mark the surfaces as needing an update. - // May also free up unneeded data. - // Return false if all surfaces were already marked as expired. - virtual bool expire(); - - //- Update the surfaces as required and merge surface points (parallel). - // Return false if no surfaces required an update. - virtual bool update(); - - //- set verbosity level - void verbose(const bool verbosity = true); - - //- Read the surfMeshSamplers dictionary - virtual bool read(const dictionary&); - - //- Execute, does sampling - virtual bool execute(); - - //- Write sampled values - virtual bool write(); - - //- Update for changes of mesh - expires the surfaces - virtual void updateMesh(const mapPolyMesh&); - - //- Update for mesh point-motion - expires the surfaces - virtual void movePoints(const polyMesh&); - - //- Update for changes of mesh due to readUpdate - expires the surfaces - virtual void readUpdate(const polyMesh::readUpdateState state); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "surfMeshSamplersTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplersTemplates.C b/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplersTemplates.C deleted file mode 100644 index 2ae1119e0d0..00000000000 --- a/src/sampling/surfMeshSample/surfMeshSamplers/surfMeshSamplersTemplates.C +++ /dev/null @@ -1,65 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSamplers.H" -#include "volFields.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::wordList -Foam::surfMeshSamplers::acceptType() const -{ - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - return mesh_.names<VolFieldType>(fieldSelection_); -} - - -#if 0 -template<class Type> -Foam::wordList -Foam::surfMeshSamplers::acceptType -( - const IOobjectList& objects, - bool fromFiles -) const -{ - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - if (fromFiles_) - { - // This should actually be in the caller: - // IOobjectList objects1 = objects.lookup(fieldSelection_); - - return objects.names(VolFieldType::typeName, fieldSelection_); - } - - return mesh_.names<VolFieldType>(fieldSelection_); -} -#endif - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C b/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C deleted file mode 100644 index dce44e0e63c..00000000000 --- a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C +++ /dev/null @@ -1,155 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSampleDiscrete.H" -#include "MeshedSurfaces.H" - -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfMeshSampleDiscrete, 0); - - // Add under name "sampledTriSurfaceMesh" - // for symmetry with regular sampledSurface - addNamedToRunTimeSelectionTable - ( - surfMeshSample, - surfMeshSampleDiscrete, - word, - sampledTriSurfaceMesh - ); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::surfMeshSampleDiscrete::transferContent() -{ - getOrCreateSurfMesh().transfer - ( - static_cast<SurfaceSource&>(*this) - ); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete -( - const word& name, - const polyMesh& mesh, - const word& surfaceName, - const discreteSurface::samplingSource sampleSource -) -: - surfMeshSample(name, mesh), - SurfaceSource(mesh, surfaceName, sampleSource, false) // no interpolate -{} - - -Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete -( - const word& name, - const polyMesh& mesh, - const dictionary& dict -) -: - surfMeshSample(name, mesh), - SurfaceSource(mesh, dict, false) // no interpolate -{} - - -Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete -( - const word& name, - const polyMesh& mesh, - const triSurface& surface, - const word& sampleSourceName -) -: - surfMeshSample(name, mesh), - SurfaceSource(name, mesh, surface, sampleSourceName, false) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::surfMeshSampleDiscrete::needsUpdate() const -{ - return SurfaceSource::needsUpdate(); -} - - -bool Foam::surfMeshSampleDiscrete::expire() -{ - return SurfaceSource::expire(); -} - - -bool Foam::surfMeshSampleDiscrete::update() -{ - if (SurfaceSource::update()) - { - transferContent(); - return true; - } - - return false; -} - - -bool Foam::surfMeshSampleDiscrete::update(const treeBoundBox& bb) -{ - if (SurfaceSource::update(bb)) - { - transferContent(); - return true; - } - - return false; -} - - -bool Foam::surfMeshSampleDiscrete::sample -( - const word& fieldName, - const word& sampleScheme -) const -{ - return - ( - sampleType<scalar>(fieldName, sampleScheme) - || sampleType<vector>(fieldName, sampleScheme) - || sampleType<sphericalTensor>(fieldName, sampleScheme) - || sampleType<symmTensor>(fieldName, sampleScheme) - || sampleType<tensor>(fieldName, sampleScheme) - ); -} - - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.H b/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.H deleted file mode 100644 index c7a9b90b9dd..00000000000 --- a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.H +++ /dev/null @@ -1,192 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -Class - Foam::surfMeshSampleDiscrete - -Description - Sampling surfFields onto a surfMesh based on a triSurfaceMesh. - - This is often embedded as part of a surfMeshSamplers function object. - -Usage - Example of function object partial specification: - \verbatim - surfaces - ( - surface1 - { - type sampledTriSurfaceMesh; - surface something.obj; - source cells; - } - ); - \endverbatim - - Where the sub-entries comprise: - \table - Property | Description | Required | Default - type | sampledTriSurfaceMesh | yes | - surface | surface name in triSurface/ | yes | - source | cells/insideCells/boundaryFaces | yes | - \endtable - -See Also - discreteSurface, surfMeshSample - -SourceFiles - surfMeshSampleDiscrete.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfMeshSampleDiscrete_H -#define surfMeshSampleDiscrete_H - -#include "surfMeshSample.H" -#include "discreteSurface.H" -#include "triSurfaceMesh.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class surfMeshSampleDiscrete; - -/*---------------------------------------------------------------------------*\ - Class surfMeshSampleDiscrete Declaration -\*---------------------------------------------------------------------------*/ - -class surfMeshSampleDiscrete -: - public surfMeshSample, - private discreteSurface -{ - // Private typedefs for convenience - typedef discreteSurface SurfaceSource; - - - // Private Member Functions - - //- Transfer mesh content from SurfaceSource to surfMesh - void transferContent(); - - //- Sample field (from volume field) onto surface faces - template<class Type> - tmp<Field<Type>> sampleOnFaces - ( - const interpolation<Type>& sampler - ) const; - - //- Sample field on surface. - template<class Type> - bool sampleType - ( - const word& fieldName, - const word& sampleScheme - ) const; - - -public: - - //- Runtime type information - TypeName("surfMeshSampleDiscrete"); - - - // Constructors - - //- Construct from components - surfMeshSampleDiscrete - ( - const word& name, - const polyMesh& mesh, - const word& surfaceName, - const discreteSurface::samplingSource sampleSource - ); - - //- Construct from dictionary - surfMeshSampleDiscrete - ( - const word& name, - const polyMesh& mesh, - const dictionary& dict - ); - - //- Construct from triSurface - surfMeshSampleDiscrete - ( - const word& name, - const polyMesh& mesh, - const triSurface& surface, - const word& sampleSourceName - ); - - - //- Destructor - virtual ~surfMeshSampleDiscrete() = default; - - - // Member Functions - - //- Does the surface need an update? - virtual bool needsUpdate() const; - - //- Mark the surface as needing an update. - // May also free up unneeded data. - // Return false if surface was already marked as expired. - virtual bool expire(); - - //- Update the surface as required. - // 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& bb); - - //- Sample the volume field onto surface - virtual bool sample - ( - const word& fieldName, - const word& sampleScheme = "cell" - ) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "surfMeshSampleDiscreteTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C b/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C deleted file mode 100644 index d3f120cac49..00000000000 --- a/src/sampling/surfMeshSample/triSurfaceMesh/surfMeshSampleDiscreteTemplates.C +++ /dev/null @@ -1,79 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 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 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/>. - -\*---------------------------------------------------------------------------*/ - -#include "surfMeshSampleDiscrete.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::tmp<Foam::Field<Type>> -Foam::surfMeshSampleDiscrete::sampleOnFaces -( - const interpolation<Type>& sampler -) const -{ - if (onBoundary()) - { - return SurfaceSource::sampleOnFaces(sampler); - } - - // Sample cells - return surfMeshSample::sampleOnFaces - ( - sampler, - sampleElements(), //< sampleElements == meshCells - surface().faces(), - surface().points() - ); -} - - -template<class Type> -bool Foam::surfMeshSampleDiscrete::sampleType -( - const word& fieldName, - const word& sampleScheme -) const -{ - typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; - - const auto* volFldPtr = - SurfaceSource::mesh().findObject<VolFieldType>(fieldName); - - if (!volFldPtr) - { - return false; - } - - auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr); - - getOrCreateSurfField<Type>(*volFldPtr).field() = - sampleOnFaces(*samplerPtr); - - return true; -} - - -// ************************************************************************* // -- GitLab