From cfead3c2c05b1b3f80d40f730815d712ad9871a2 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Mon, 6 Jan 2020 12:46:50 +0000 Subject: [PATCH] sampledSet: Added cellSet and faceSet sampled sets Added sets for sampling the cell-centres and face-centres of a cellSet or faceSet. Example usage: sets ( c0 { type cellSet; set c0; axis xyz; } f0 { type faceSet; set f0; axis xyz; } ); --- src/sampling/Make/files | 2 + .../cellSetSampledSet/cellSetSampledSet.C | 88 ++++++++++++++ .../cellSetSampledSet/cellSetSampledSet.H | 115 ++++++++++++++++++ .../faceSetSampledSet/faceSetSampledSet.C | 88 ++++++++++++++ .../faceSetSampledSet/faceSetSampledSet.H | 115 ++++++++++++++++++ 5 files changed, 408 insertions(+) create mode 100644 src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.C create mode 100644 src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.H create mode 100644 src/sampling/sampledSet/faceSetSampledSet/faceSetSampledSet.C create mode 100644 src/sampling/sampledSet/faceSetSampledSet/faceSetSampledSet.H diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 99bafc9da9..a76630c8e1 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -17,6 +17,8 @@ sampledSet/boundaryRandom/boundaryRandom.C sampledSet/points/points.C sampledSet/sphereRandom/sphereRandom.C sampledSet/triSurfaceMeshSampledSet/triSurfaceMeshSampledSet.C +sampledSet/cellSetSampledSet/cellSetSampledSet.C +sampledSet/faceSetSampledSet/faceSetSampledSet.C cuttingPlane/cuttingPlane.C diff --git a/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.C b/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.C new file mode 100644 index 0000000000..e376c2891b --- /dev/null +++ b/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "cellSetSampledSet.H" +#include "cellSet.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace sampledSets +{ + defineTypeNameAndDebug(cellSetSampledSet, 0); + addToRunTimeSelectionTable(sampledSet, cellSetSampledSet, word); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::sampledSets::cellSetSampledSet::genSamples() +{ + const labelList cells(cellSet(mesh(), setName_).toc()); + + setSamples + ( + List(IndirectList(mesh().cellCentres(), cells)), + cells, + labelList(cells.size(), -1), + labelList(cells.size(), 0), + scalarList(identity(cells.size())) + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sampledSets::cellSetSampledSet::cellSetSampledSet +( + const word& name, + const polyMesh& mesh, + const meshSearch& searchEngine, + const dictionary& dict +) +: + sampledSet(name, mesh, searchEngine, dict), + setName_(dict.lookup("set")) +{ + genSamples(); + + if (debug) + { + write(Info); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sampledSets::cellSetSampledSet::~cellSetSampledSet() +{} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.H b/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.H new file mode 100644 index 0000000000..c5aa93917c --- /dev/null +++ b/src/sampling/sampledSet/cellSetSampledSet/cellSetSampledSet.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ 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 . + +Class + Foam::sampledSets::cellSetSampledSet + +Description + Samples at the cell-centres of a given cell set + +Usage + \table + Property | Description | Req'd? | Default + set | Name of the cell set | yes | + \endtable + + Example specification: + \verbatim + { + type cellSet; + set c0; + } + \endverbatim + +SourceFiles + cellSetSampledSet.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cellSetSampledSet_H +#define cellSetSampledSet_H + +#include "sampledSet.H" +#include "DynamicList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace sampledSets +{ + +/*---------------------------------------------------------------------------*\ + Class cellSetSampledSet Declaration +\*---------------------------------------------------------------------------*/ + +class cellSetSampledSet +: + public sampledSet +{ + // Private Data + + //- Name of the cell set + const word setName_; + + + // Private Member Functions + + //- Uses calcSamples to obtain samples. Copies them into *this. + void genSamples(); + + +public: + + //- Runtime type information + TypeName("cellSet"); + + + // Constructors + + //- Construct from dictionary + cellSetSampledSet + ( + const word& name, + const polyMesh& mesh, + const meshSearch& searchEngine, + const dictionary& dict + ); + + + // Destructor + + virtual ~cellSetSampledSet(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace sampledSets +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSet/faceSetSampledSet/faceSetSampledSet.C b/src/sampling/sampledSet/faceSetSampledSet/faceSetSampledSet.C new file mode 100644 index 0000000000..7675658196 --- /dev/null +++ b/src/sampling/sampledSet/faceSetSampledSet/faceSetSampledSet.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "faceSetSampledSet.H" +#include "faceSet.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace sampledSets +{ + defineTypeNameAndDebug(faceSetSampledSet, 0); + addToRunTimeSelectionTable(sampledSet, faceSetSampledSet, word); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::sampledSets::faceSetSampledSet::genSamples() +{ + const labelList faces(faceSet(mesh(), setName_).toc()); + + setSamples + ( + List(IndirectList(mesh().faceCentres(), faces)), + labelList(IndirectList