Merge branch 'feature-topoSet-improvements' into 'develop'

Feature topo set improvements (issue #1060)

See merge request Development/OpenFOAM-plus!216
This commit is contained in:
Mattijs Janssens
2018-11-01 11:12:12 +00:00
174 changed files with 3690 additions and 1520 deletions

View File

@ -132,9 +132,9 @@ void printHelp(Ostream& os)
<< " clear - clears the set" << nl << " clear - clears the set" << nl
<< " invert - inverts the set" << nl << " invert - inverts the set" << nl
<< " remove - remove the set" << nl << " remove - remove the set" << nl
<< " new <source> - sets to set to the source set" << nl << " new <source> - use all elements from the source set" << nl
<< " add <source> - adds all elements from the source set" << nl << " add <source> - adds all elements from the source set" << nl
<< " delete <source> - deletes ,," << nl << " subtract <source> - subtract the source set elements" << nl
<< " subset <source> - combines current set with the source set" << " subset <source> - combines current set with the source set"
<< nl << nl
<< nl << nl

View File

@ -247,8 +247,8 @@ int main(int argc, char *argv[])
autoPtr<topoSet> currentSet; autoPtr<topoSet> currentSet;
if if
( (
(action == topoSetSource::NEW) action == topoSetSource::NEW
|| (action == topoSetSource::CLEAR) || action == topoSetSource::CLEAR
) )
{ {
currentSet = topoSet::New(setType, mesh, setName, 10000); currentSet = topoSet::New(setType, mesh, setName, 10000);
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{ {
case topoSetSource::NEW: case topoSetSource::NEW:
case topoSetSource::ADD: case topoSetSource::ADD:
case topoSetSource::DELETE: case topoSetSource::SUBTRACT:
{ {
const word sourceName(dict.get<word>("source")); const word sourceName(dict.get<word>("source"));

View File

@ -63,7 +63,9 @@ FoamFile
// source faceZoneToCell; // source faceZoneToCell;
// sourceInfo // sourceInfo
// { // {
// name ".*Zone"; // Name of faceZone, regular expressions allowed // zones (".*Zone"); // Name of faceZone, regular expressions allowed
// // OR zone ".*Zone"; // Name of faceZone, regular expressions allowed
// // OR name ".*Zone"; // Name of faceZone, regular expressions allowed
// option master; // master/slave // option master; // master/slave
// } // }
// //
@ -127,7 +129,7 @@ FoamFile
// source sphereToCell; // source sphereToCell;
// sourceInfo // sourceInfo
// { // {
// centre (0.2 0.2 -10); // origin (0.2 0.2 -10);
// radius 5.0; // radius 5.0;
// } // }
// //
@ -392,7 +394,7 @@ FoamFile
// sourceInfo // sourceInfo
// { // {
// surface searchableSphere; // surface searchableSphere;
// centre (0.05 0.05 0.005); // origin (0.05 0.05 0.005);
// radius 0.025; // radius 0.025;
// //name sphere.stl; // Optional name if surface triSurfaceMesh // //name sphere.stl; // Optional name if surface triSurfaceMesh
// } // }

View File

@ -97,7 +97,7 @@ int main(int argc, char *argv[])
( (
shapeSelector::shapeTypeNames.get("type", dict) shapeSelector::shapeTypeNames.get("type", dict)
); );
const vector centre(dict.get<vector>("centre")); const vector origin(dict.getCompat<vector>("origin", {{"centre", 1806}}));
const word fieldName(dict.get<word>("field")); const word fieldName(dict.get<word>("field"));
Info<< "Reading field " << fieldName << "\n" << endl; Info<< "Reading field " << fieldName << "\n" << endl;
@ -114,7 +114,7 @@ int main(int argc, char *argv[])
mesh mesh
); );
scalar f0 = 0.0; scalar f0 = 0;
scalarField f(mesh.points().size()); scalarField f(mesh.points().size());
Info<< "Processing type '" << shapeSelector::shapeTypeNames[surfType] Info<< "Processing type '" << shapeSelector::shapeTypeNames[surfType]
@ -126,15 +126,15 @@ int main(int argc, char *argv[])
{ {
const vector direction(dict.get<vector>("direction")); const vector direction(dict.get<vector>("direction"));
f = -(mesh.points() - centre) & (direction/mag(direction)); f = -(mesh.points() - origin) & (direction/mag(direction));
f0 = 0.0; f0 = 0;
break; break;
} }
case shapeSelector::shapeType::SPHERE: case shapeSelector::shapeType::SPHERE:
{ {
const scalar radius(dict.get<scalar>("radius")); const scalar radius(dict.get<scalar>("radius"));
f = -mag(mesh.points() - centre); f = -mag(mesh.points() - origin);
f0 = -radius; f0 = -radius;
break; break;
} }
@ -145,8 +145,8 @@ int main(int argc, char *argv[])
f = -sqrt f = -sqrt
( (
sqr(mag(mesh.points() - centre)) sqr(mag(mesh.points() - origin))
- sqr(mag((mesh.points() - centre) & direction)) - sqr(mag((mesh.points() - origin) & direction))
); );
f0 = -radius; f0 = -radius;
break; break;
@ -160,9 +160,9 @@ int main(int argc, char *argv[])
const scalarField xx const scalarField xx
( (
(mesh.points() - centre) & direction/mag(direction) (mesh.points() - origin) & direction/mag(direction)
); );
const scalarField zz((mesh.points() - centre) & up/mag(up)); const scalarField zz((mesh.points() - origin) & up/mag(up));
f = amplitude*Foam::sin(2*mathematical::pi*xx/period) - zz; f = amplitude*Foam::sin(2*mathematical::pi*xx/period) - zz;
f0 = 0; f0 = 0;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,13 +33,25 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(badQualityToCell, 0);
defineTypeNameAndDebug(badQualityToCell, 0); addToRunTimeSelectionTable(topoSetSource, badQualityToCell, word);
addToRunTimeSelectionTable(topoSetSource, badQualityToCell, istream);
addToRunTimeSelectionTable(topoSetSource, badQualityToCell, word); addToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, istream);
addToRunTimeSelectionTable(topoSetSource, badQualityToCell, istream); addNamedToRunTimeSelectionTable
(
topoSetCellSource,
badQualityToCell,
word,
badQuality
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
badQualityToCell,
istream,
badQuality
);
} }
@ -59,9 +71,8 @@ void Foam::badQualityToCell::combine(topoSet& set, const bool add) const
motionSmoother::checkMesh(false, mesh_, dict_, faces); motionSmoother::checkMesh(false, mesh_, dict_, faces);
faces.sync(mesh_); faces.sync(mesh_);
forAllConstIter(faceSet, faces, iter) for (const label facei : faces)
{ {
label facei = iter.key();
addOrDelete(set, mesh_.faceOwner()[facei], add); addOrDelete(set, mesh_.faceOwner()[facei], add);
if (mesh_.isInternalFace(facei)) if (mesh_.isInternalFace(facei))
{ {
@ -73,36 +84,28 @@ void Foam::badQualityToCell::combine(topoSet& set, const bool add) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::badQualityToCell::badQualityToCell Foam::badQualityToCell::badQualityToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
dict_(dict) dict_(dict)
{} {}
// Construct from Istream
Foam::badQualityToCell::badQualityToCell Foam::badQualityToCell::badQualityToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
dict_(is) dict_(is)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::badQualityToCell::~badQualityToCell()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::badQualityToCell::applyToSet void Foam::badQualityToCell::applyToSet
@ -111,14 +114,22 @@ void Foam::badQualityToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding bad-quality cells" << endl; if (verbose_)
{
Info<< " Adding bad-quality cells" << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing bad-quality cells" << endl; if (verbose_)
{
Info<< " Removing bad-quality cells" << endl;
}
combine(set, false); combine(set, false);
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,7 +35,7 @@ SourceFiles
#ifndef badQualityToCell_H #ifndef badQualityToCell_H
#define badQualityToCell_H #define badQualityToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "bitSet.H" #include "bitSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +49,7 @@ namespace Foam
class badQualityToCell class badQualityToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -74,35 +74,22 @@ public:
// Constructors // Constructors
//- Construct from dictionary //- Construct from dictionary
badQualityToCell badQualityToCell(const polyMesh& mesh, const dictionary& dict);
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream //- Construct from Istream
badQualityToCell badQualityToCell(const polyMesh& mesh, Istream& is);
(
const polyMesh& mesh,
Istream&
);
//- Destructor //- Destructor
virtual ~badQualityToCell(); virtual ~badQualityToCell() = default;
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,
topoSet& topoSet& set
) const; ) const;
}; };

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,13 +33,25 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(badQualityToFace, 0);
defineTypeNameAndDebug(badQualityToFace, 0); addToRunTimeSelectionTable(topoSetSource, badQualityToFace, word);
addToRunTimeSelectionTable(topoSetSource, badQualityToFace, istream);
addToRunTimeSelectionTable(topoSetSource, badQualityToFace, word); addToRunTimeSelectionTable(topoSetFaceSource, badQualityToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, badQualityToFace, istream);
addToRunTimeSelectionTable(topoSetSource, badQualityToFace, istream); addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
badQualityToFace,
word,
badQuality
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
badQualityToFace,
istream,
badQuality
);
} }
@ -59,9 +71,8 @@ void Foam::badQualityToFace::combine(topoSet& set, const bool add) const
motionSmoother::checkMesh(false, mesh_, dict_, faces); motionSmoother::checkMesh(false, mesh_, dict_, faces);
faces.sync(mesh_); faces.sync(mesh_);
forAllConstIter(faceSet, faces, iter) for (const label facei : faces)
{ {
label facei = iter.key();
addOrDelete(set, facei, add); addOrDelete(set, facei, add);
} }
} }
@ -69,36 +80,28 @@ void Foam::badQualityToFace::combine(topoSet& set, const bool add) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::badQualityToFace::badQualityToFace Foam::badQualityToFace::badQualityToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
dict_(dict) dict_(dict)
{} {}
// Construct from Istream
Foam::badQualityToFace::badQualityToFace Foam::badQualityToFace::badQualityToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
dict_(is) dict_(is)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::badQualityToFace::~badQualityToFace()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::badQualityToFace::applyToSet void Foam::badQualityToFace::applyToSet
@ -107,14 +110,22 @@ void Foam::badQualityToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding bad-quality faces" << endl; if (verbose_)
{
Info<< " Adding bad-quality faces" << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing bad-quality faces" << endl; if (verbose_)
{
Info<< " Removing bad-quality faces" << endl;
}
combine(set, false); combine(set, false);
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,7 +35,7 @@ SourceFiles
#ifndef badQualityToFace_H #ifndef badQualityToFace_H
#define badQualityToFace_H #define badQualityToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "bitSet.H" #include "bitSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +49,7 @@ namespace Foam
class badQualityToFace class badQualityToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -89,20 +89,15 @@ public:
//- Destructor //- Destructor
virtual ~badQualityToFace(); virtual ~badQualityToFace() = default;
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,
topoSet& topoSet& set
) const; ) const;
}; };

View File

@ -1,4 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude

View File

@ -75,7 +75,7 @@ cylindricalInletVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(p, iF, dict), fixedValueFvPatchField<vector>(p, iF, dict),
origin_(dict.lookupCompat("origin", {{"centre", 1712}})), origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
axis_(dict.lookup("axis")), axis_(dict.lookup("axis")),
axialVelocity_(Function1<scalar>::New("axialVelocity", dict)), axialVelocity_(Function1<scalar>::New("axialVelocity", dict)),
radialVelocity_(Function1<scalar>::New("radialVelocity", dict)), radialVelocity_(Function1<scalar>::New("radialVelocity", dict)),

View File

@ -84,13 +84,11 @@ SourceFiles
#ifndef directionalPressureGradientExplicitSource_H #ifndef directionalPressureGradientExplicitSource_H
#define directionalPressureGradientExplicitSource_H #define directionalPressureGradientExplicitSource_H
#include "cellSetOption.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "topoSetSource.H"
#include "cellSet.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "volFields.H"
#include "fvOption.H" #include "fvOption.H"
#include "cellSetOption.H"
#include "interpolationTable.H" #include "interpolationTable.H"

View File

@ -51,8 +51,6 @@ SourceFiles
#define meanVelocityForce_H #define meanVelocityForce_H
#include "autoPtr.H" #include "autoPtr.H"
#include "topoSetSource.H"
#include "cellSet.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "volFields.H"
#include "cellSetOption.H" #include "cellSetOption.H"

View File

@ -134,6 +134,7 @@ searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C
searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
topoSets = sets/topoSets topoSets = sets/topoSets
$(topoSets)/cellBitSet.C
$(topoSets)/cellSet.C $(topoSets)/cellSet.C
$(topoSets)/topoSet.C $(topoSets)/topoSet.C
$(topoSets)/faceSet.C $(topoSets)/faceSet.C
@ -144,49 +145,56 @@ $(topoSets)/pointZoneSet.C
sets/topoSetSource/topoSetSource.C sets/topoSetSource/topoSetSource.C
cellSources = sets/cellSources cellSources = sets/cellSources
$(cellSources)/faceToCell/faceToCell.C $(cellSources)/topoSetCellSource/topoSetCellSource.C
$(cellSources)/fieldToCell/fieldToCell.C
$(cellSources)/pointToCell/pointToCell.C
$(cellSources)/shapeToCell/shapeToCell.C
$(cellSources)/boxToCell/boxToCell.C $(cellSources)/boxToCell/boxToCell.C
$(cellSources)/cellToCell/cellToCell.C
$(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C
$(cellSources)/cylinderToCell/cylinderToCell.C
$(cellSources)/faceToCell/faceToCell.C
$(cellSources)/faceZoneToCell/faceZoneToCell.C
$(cellSources)/fieldToCell/fieldToCell.C
$(cellSources)/labelToCell/labelToCell.C
$(cellSources)/nbrToCell/nbrToCell.C
$(cellSources)/nearestToCell/nearestToCell.C
$(cellSources)/noneToCell/noneToCell.C
$(cellSources)/pointToCell/pointToCell.C
$(cellSources)/regionToCell/regionToCell.C $(cellSources)/regionToCell/regionToCell.C
$(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C $(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C
$(cellSources)/labelToCell/labelToCell.C $(cellSources)/shapeToCell/shapeToCell.C
$(cellSources)/surfaceToCell/surfaceToCell.C $(cellSources)/searchableSurfaceToCell/searchableSurfaceToCell.C
$(cellSources)/cellToCell/cellToCell.C
$(cellSources)/nearestToCell/nearestToCell.C
$(cellSources)/nbrToCell/nbrToCell.C
$(cellSources)/zoneToCell/zoneToCell.C
$(cellSources)/sphereToCell/sphereToCell.C $(cellSources)/sphereToCell/sphereToCell.C
$(cellSources)/cylinderToCell/cylinderToCell.C $(cellSources)/surfaceToCell/surfaceToCell.C
$(cellSources)/faceZoneToCell/faceZoneToCell.C
$(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C
$(cellSources)/targetVolumeToCell/targetVolumeToCell.C $(cellSources)/targetVolumeToCell/targetVolumeToCell.C
$(cellSources)/zoneToCell/zoneToCell.C
faceSources = sets/faceSources faceSources = sets/faceSources
$(faceSources)/topoSetFaceSource/topoSetFaceSource.C
$(faceSources)/boundaryToFace/boundaryToFace.C
$(faceSources)/boxToFace/boxToFace.C
$(faceSources)/cellToFace/cellToFace.C
$(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C
$(faceSources)/cylinderToFace/cylinderToFace.C
$(faceSources)/faceToFace/faceToFace.C $(faceSources)/faceToFace/faceToFace.C
$(faceSources)/labelToFace/labelToFace.C $(faceSources)/labelToFace/labelToFace.C
$(faceSources)/cellToFace/cellToFace.C $(faceSources)/noneToFace/noneToFace.C
$(faceSources)/normalToFace/normalToFace.C $(faceSources)/normalToFace/normalToFace.C
$(faceSources)/pointToFace/pointToFace.C
$(faceSources)/patchToFace/patchToFace.C $(faceSources)/patchToFace/patchToFace.C
$(faceSources)/boundaryToFace/boundaryToFace.C $(faceSources)/pointToFace/pointToFace.C
$(faceSources)/zoneToFace/zoneToFace.C
$(faceSources)/boxToFace/boxToFace.C
$(faceSources)/regionToFace/regionToFace.C $(faceSources)/regionToFace/regionToFace.C
$(faceSources)/cylinderToFace/cylinderToFace.C $(faceSources)/zoneToFace/zoneToFace.C
$(faceSources)/cylinderAnnulusToFace/cylinderAnnulusToFace.C
pointSources = sets/pointSources pointSources = sets/pointSources
$(pointSources)/labelToPoint/labelToPoint.C $(pointSources)/topoSetPointSource/topoSetPointSource.C
$(pointSources)/pointToPoint/pointToPoint.C $(pointSources)/boxToPoint/boxToPoint.C
$(pointSources)/cellToPoint/cellToPoint.C $(pointSources)/cellToPoint/cellToPoint.C
$(pointSources)/faceToPoint/faceToPoint.C $(pointSources)/faceToPoint/faceToPoint.C
$(pointSources)/boxToPoint/boxToPoint.C $(pointSources)/labelToPoint/labelToPoint.C
$(pointSources)/nearestToPoint/nearestToPoint.C
$(pointSources)/noneToPoint/noneToPoint.C
$(pointSources)/pointToPoint/pointToPoint.C
$(pointSources)/surfaceToPoint/surfaceToPoint.C $(pointSources)/surfaceToPoint/surfaceToPoint.C
$(pointSources)/zoneToPoint/zoneToPoint.C $(pointSources)/zoneToPoint/zoneToPoint.C
$(pointSources)/nearestToPoint/nearestToPoint.C
faceZoneSources = sets/faceZoneSources faceZoneSources = sets/faceZoneSources
$(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C $(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C

View File

@ -57,18 +57,18 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest
{ {
pointIndexHit info(false, sample, -1); pointIndexHit info(false, sample, -1);
const vector n(sample - centre_); const vector n(sample - origin_);
scalar magN = mag(n); scalar magN = mag(n);
if (nearestDistSqr >= sqr(magN - radius_)) if (nearestDistSqr >= sqr(magN - radius_))
{ {
if (magN < ROOTVSMALL) if (magN < ROOTVSMALL)
{ {
info.rawPoint() = centre_ + vector(1,0,0)*radius_; info.rawPoint() = origin_ + vector(1,0,0)*radius_;
} }
else else
{ {
info.rawPoint() = centre_ + n/magN*radius_; info.rawPoint() = origin_ + n/magN*radius_;
} }
info.setHit(); info.setHit();
info.setIndex(0); info.setIndex(0);
@ -95,7 +95,7 @@ void Foam::searchableSphere::findLineAll
if (magSqrDir > ROOTVSMALL) if (magSqrDir > ROOTVSMALL)
{ {
const vector toCentre(centre_-start); const vector toCentre(origin_ - start);
scalar magSqrToCentre = magSqr(toCentre); scalar magSqrToCentre = magSqr(toCentre);
dir /= Foam::sqrt(magSqrDir); dir /= Foam::sqrt(magSqrDir);
@ -135,18 +135,18 @@ void Foam::searchableSphere::findLineAll
Foam::searchableSphere::searchableSphere Foam::searchableSphere::searchableSphere
( (
const IOobject& io, const IOobject& io,
const point& centre, const point& origin,
const scalar radius const scalar radius
) )
: :
searchableSurface(io), searchableSurface(io),
centre_(centre), origin_(origin),
radius_(radius) radius_(radius)
{ {
bounds() = boundBox bounds() = boundBox
( (
centre_ - radius_*vector::one, origin_ - radius_*vector::one,
centre_ + radius_*vector::one origin_ + radius_*vector::one
); );
} }
@ -157,23 +157,20 @@ Foam::searchableSphere::searchableSphere
const dictionary& dict const dictionary& dict
) )
: :
searchableSurface(io), searchableSphere
centre_(dict.get<point>("centre")),
radius_(dict.get<scalar>("radius"))
{
bounds() = boundBox
( (
centre_ - radius_*vector::one, io,
centre_ + radius_*vector::one dict.getCompat<vector>("origin", {{"centre", -1806}}),
); dict.get<scalar>("radius")
} )
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::searchableSphere::overlaps(const boundBox& bb) const bool Foam::searchableSphere::overlaps(const boundBox& bb) const
{ {
return bb.overlaps(centre_, sqr(radius_)); return bb.overlaps(origin_, sqr(radius_));
} }
@ -181,8 +178,8 @@ const Foam::wordList& Foam::searchableSphere::regions() const
{ {
if (regions_.empty()) if (regions_.empty())
{ {
regions_.setSize(1); regions_.resize(1);
regions_[0] = "region0"; regions_.first() = "region0";
} }
return regions_; return regions_;
} }
@ -195,10 +192,10 @@ void Foam::searchableSphere::boundingSpheres
scalarField& radiusSqr scalarField& radiusSqr
) const ) const
{ {
centres.setSize(1); centres.resize(1);
centres[0] = centre_; centres[0] = origin_;
radiusSqr.setSize(1); radiusSqr.resize(1);
radiusSqr[0] = Foam::sqr(radius_); radiusSqr[0] = Foam::sqr(radius_);
// Add a bit to make sure all points are tested inside // Add a bit to make sure all points are tested inside
@ -336,7 +333,7 @@ void Foam::searchableSphere::getNormal
{ {
if (info[i].hit()) if (info[i].hit())
{ {
normal[i] = normalised(info[i].hitPoint() - centre_); normal[i] = normalised(info[i].hitPoint() - origin_);
} }
else else
{ {
@ -362,7 +359,7 @@ void Foam::searchableSphere::getVolumeType
volType[pointi] = volType[pointi] =
( (
(magSqr(pt - centre_) <= rad2) (magSqr(pt - origin_) <= rad2)
? volumeType::INSIDE : volumeType::OUTSIDE ? volumeType::INSIDE : volumeType::OUTSIDE
); );
} }

View File

@ -29,10 +29,11 @@ Description
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
type | sphere / searchableSphere | selector | type | sphere / searchableSphere | selector |
centre | The sphere centre | yes | origin | The origin (centre) of the sphere | yes |
radius | The (outside) radius of sphere | yes | radius | The (outside) radius of sphere | yes |
centre | Alternative for 'origin' | no |
\endtable \endtable
SourceFiles SourceFiles
@ -64,7 +65,7 @@ private:
// Private Member Data // Private Member Data
//- Centre point of the sphere //- Centre point of the sphere
const point centre_; const point origin_;
//- The outer radius of the sphere //- The outer radius of the sphere
const scalar radius_; const scalar radius_;
@ -151,7 +152,7 @@ public:
// Usually the element centres (should be of length size()). // Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const virtual tmp<pointField> coordinates() const
{ {
return tmp<pointField>::New(1, centre_); return tmp<pointField>::New(1, origin_);
} }
//- Get bounding spheres (centre and radius squared), one per element. //- Get bounding spheres (centre and radius squared), one per element.

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(boxToCell, 0); defineTypeNameAndDebug(boxToCell, 0);
addToRunTimeSelectionTable(topoSetSource, boxToCell, word); addToRunTimeSelectionTable(topoSetSource, boxToCell, word);
addToRunTimeSelectionTable(topoSetSource, boxToCell, istream); addToRunTimeSelectionTable(topoSetSource, boxToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, boxToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, boxToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
boxToCell,
word,
box
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
boxToCell,
istream,
box
);
} }
@ -73,29 +89,37 @@ Foam::boxToCell::boxToCell
const treeBoundBoxList& bbs const treeBoundBoxList& bbs
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
bbs_(bbs) bbs_(bbs)
{} {}
Foam::boxToCell::boxToCell
(
const polyMesh& mesh,
treeBoundBoxList&& bbs
)
:
topoSetCellSource(mesh),
bbs_(std::move(bbs))
{}
Foam::boxToCell::boxToCell Foam::boxToCell::boxToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
bbs_() bbs_()
{ {
if (dict.found("box")) // Look for 'boxes' or 'box'
if (!dict.readIfPresent("boxes", bbs_))
{ {
bbs_.resize(1); bbs_.resize(1);
dict.readEntry("box", bbs_.first()); dict.readEntry("box", bbs_.first());
} }
else
{
dict.readEntry("boxes", bbs_);
}
} }
@ -105,8 +129,8 @@ Foam::boxToCell::boxToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
bbs_(1, treeBoundBox(checkIs(is))) bbs_(one(), treeBoundBox(checkIs(is)))
{} {}
@ -118,15 +142,23 @@ void Foam::boxToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with center within boxes " << bbs_ << endl; if (verbose_)
{
Info<< " Adding cells with centre within boxes "
<< bbs_ << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with center within boxes " << bbs_ << endl; if (verbose_)
{
Info<< " Removing cells with centre within boxes "
<< bbs_ << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,17 +25,18 @@ Class
Foam::boxToCell Foam::boxToCell
Description Description
A topoSetSource to select cells based on cell centres inside box(es). A topoSetCellSource to select cells based on cell centres inside box(es).
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
box | A single bounding box | partly | box | A single bounding box | partly |
boxes | Multiple bounding boxes | partly | boxes | Multiple bounding boxes | partly |
\endtable \endtable
Note Note
Must specify either "box" or "boxes" Must specify either "box" or "boxes".
The selection of multiple boxes has precedence.
SourceFiles SourceFiles
boxToCell.C boxToCell.C
@ -45,7 +46,7 @@ SourceFiles
#ifndef boxToCell_H #ifndef boxToCell_H
#define boxToCell_H #define boxToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ namespace Foam
class boxToCell class boxToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -82,12 +83,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying bounding boxes
boxToCell boxToCell(const polyMesh& mesh, const treeBoundBoxList& bbs);
(
const polyMesh& mesh, //- Construct from components, moving bounding boxes
const treeBoundBoxList& bbs boxToCell(const polyMesh& mesh, treeBoundBoxList&& bbs);
);
//- Construct from dictionary //- Construct from dictionary
boxToCell(const polyMesh& mesh, const dictionary& dict); boxToCell(const polyMesh& mesh, const dictionary& dict);
@ -102,11 +102,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(cellToCell, 0); defineTypeNameAndDebug(cellToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cellToCell, word); addToRunTimeSelectionTable(topoSetSource, cellToCell, word);
addToRunTimeSelectionTable(topoSetSource, cellToCell, istream); addToRunTimeSelectionTable(topoSetSource, cellToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, cellToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, cellToCell, istream);
} }
@ -54,7 +56,7 @@ Foam::cellToCell::cellToCell
const word& setName const word& setName
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(setName) setName_(setName)
{} {}
@ -65,8 +67,11 @@ Foam::cellToCell::cellToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cellToCell
setName_(dict.get<word>("set")) (
mesh,
dict.get<word>("set")
)
{} {}
@ -76,7 +81,7 @@ Foam::cellToCell::cellToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(checkIs(is)) setName_(checkIs(is))
{} {}
@ -89,25 +94,31 @@ void Foam::cellToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all elements of cellSet " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding all elements of cellSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
cellSet loadedSet(mesh_, setName_); cellSet loadedSet(mesh_, setName_);
set.addSet(loadedSet); set.addSet(loadedSet);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all elements of cellSet " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all elements of cellSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
cellSet loadedSet(mesh_, setName_); cellSet loadedSet(mesh_, setName_);
set.deleteSet(loadedSet); set.subtractSet(loadedSet);
} }
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cellToCell Foam::cellToCell
Description Description
A topoSetSource to select the cells from another cellSet. A topoSetCellSource to select the cells from another cellSet.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -41,7 +41,7 @@ SourceFiles
#ifndef cellToCell_H #ifndef cellToCell_H
#define cellToCell_H #define cellToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +54,7 @@ namespace Foam
class cellToCell class cellToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -72,11 +72,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
cellToCell cellToCell(const polyMesh& mesh, const word& setName);
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary //- Construct from dictionary
cellToCell(const polyMesh& mesh, const dictionary& dict); cellToCell(const polyMesh& mesh, const dictionary& dict);
@ -91,11 +87,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,32 @@ namespace Foam
defineTypeNameAndDebug(cylinderAnnulusToCell, 0); defineTypeNameAndDebug(cylinderAnnulusToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, word); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, word);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, istream); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, istream);
addToRunTimeSelectionTable
(
topoSetCellSource,
cylinderAnnulusToCell,
word
);
addToRunTimeSelectionTable
(
topoSetCellSource,
cylinderAnnulusToCell,
istream
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
cylinderAnnulusToCell,
word,
cylinderAnnulus
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
cylinderAnnulusToCell,
istream,
cylinderAnnulus
);
} }
@ -85,7 +111,7 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
const scalar innerRadius const scalar innerRadius
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
point1_(point1), point1_(point1),
point2_(point2), point2_(point2),
outerRadius_(outerRadius), outerRadius_(outerRadius),
@ -99,11 +125,14 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cylinderAnnulusToCell
point1_(dict.get<point>("p1")), (
point2_(dict.get<point>("p2")), mesh,
outerRadius_(dict.get<scalar>("outerRadius")), dict.get<point>("p1"),
innerRadius_(dict.get<scalar>("innerRadius")) dict.get<point>("p2"),
dict.get<scalar>("outerRadius"),
dict.get<scalar>("innerRadius")
)
{} {}
@ -113,7 +142,7 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
point1_(checkIs(is)), point1_(checkIs(is)),
point2_(checkIs(is)), point2_(checkIs(is)),
outerRadius_(readScalar(checkIs(is))), outerRadius_(readScalar(checkIs(is))),
@ -129,23 +158,29 @@ void Foam::cylinderAnnulusToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with centre within cylinder annulus," if (verbose_)
<< " with p1 = " {
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ Info<< " Adding cells with centre within cylinder annulus,"
<< ", inner radius = " << innerRadius_ << " with p1 = " << point1_ << ", p2 = " << point2_
<< endl; << ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with centre within cylinder annulus," if (verbose_)
<< " with p1 = " {
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ Info<< " Removing cells with centre within cylinder annulus,"
<< ", inner radius = " << innerRadius_ << " with p1 = " << point1_ << ", p2 = " << point2_
<< endl; << ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cylinderAnnulusToCell Foam::cylinderAnnulusToCell
Description Description
A topoSetSource to select cells based on cell centres inside a A topoSetCellSource to select cells based on cell centres inside a
cylinder annulus. cylinder annulus.
\heading Dictionary parameters \heading Dictionary parameters
@ -45,7 +45,7 @@ SourceFiles
#ifndef cylinderAnnulusToCell_H #ifndef cylinderAnnulusToCell_H
#define cylinderAnnulusToCell_H #define cylinderAnnulusToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ namespace Foam
class cylinderAnnulusToCell class cylinderAnnulusToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -99,7 +99,7 @@ public:
const point& point1, const point& point1,
const point& point2, const point& point2,
const scalar outerRadius, const scalar outerRadius,
const scalar innerRadius const scalar innerRadius = 0
); );
//- Construct from dictionary //- Construct from dictionary
@ -115,11 +115,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(cylinderToCell, 0); defineTypeNameAndDebug(cylinderToCell, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word); addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word);
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream); addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, cylinderToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, cylinderToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
cylinderToCell,
word,
cylinder
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
cylinderToCell,
istream,
cylinder
);
} }
@ -82,7 +98,7 @@ Foam::cylinderToCell::cylinderToCell
const scalar radius const scalar radius
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
point1_(point1), point1_(point1),
point2_(point2), point2_(point2),
radius_(radius) radius_(radius)
@ -95,10 +111,13 @@ Foam::cylinderToCell::cylinderToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cylinderToCell
point1_(dict.get<point>("p1")), (
point2_(dict.get<point>("p2")), mesh,
radius_(dict.get<scalar>("radius")) dict.get<point>("p1"),
dict.get<point>("p2"),
dict.get<scalar>("radius")
)
{} {}
@ -108,7 +127,7 @@ Foam::cylinderToCell::cylinderToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
point1_(checkIs(is)), point1_(checkIs(is)),
point2_(checkIs(is)), point2_(checkIs(is)),
radius_(readScalar(checkIs(is))) radius_(readScalar(checkIs(is)))
@ -123,19 +142,25 @@ void Foam::cylinderToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with centre within cylinder, with p1 = " if (verbose_)
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_ {
<< endl; Info<< " Adding cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with centre within cylinder, with p1 = " if (verbose_)
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_ {
<< endl; Info<< " Removing cells with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cylinderToCell Foam::cylinderToCell
Description Description
A topoSetSource to select cells based on cell centres inside a cylinder. A topoSetCellSource to select cells with their centres inside a cylinder.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -43,7 +43,7 @@ SourceFiles
#ifndef cylinderToCell_H #ifndef cylinderToCell_H
#define cylinderToCell_H #define cylinderToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class cylinderToCell class cylinderToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -109,11 +109,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(faceToCell, 0); defineTypeNameAndDebug(faceToCell, 0);
addToRunTimeSelectionTable(topoSetSource, faceToCell, word); addToRunTimeSelectionTable(topoSetSource, faceToCell, word);
addToRunTimeSelectionTable(topoSetSource, faceToCell, istream); addToRunTimeSelectionTable(topoSetSource, faceToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, faceToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, faceToCell, istream);
} }
@ -133,7 +135,7 @@ Foam::faceToCell::faceToCell
const faceAction option const faceAction option
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -145,9 +147,12 @@ Foam::faceToCell::faceToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), faceToCell
setName_(dict.get<word>("set")), (
option_(faceActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
faceActionNames_.get("option", dict)
)
{} {}
@ -157,7 +162,7 @@ Foam::faceToCell::faceToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(faceActionNames_.read(checkIs(is))) option_(faceActionNames_.read(checkIs(is)))
{} {}
@ -171,17 +176,23 @@ void Foam::faceToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells according to faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding cells according to faceSet " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells according to faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing cells according to faceSet " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::faceToCell Foam::faceToCell
Description Description
A topoSetSource to select cells based on usage in a face set. A topoSetCellSource to select cells based on usage in a face set.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef faceToCell_H #ifndef faceToCell_H
#define faceToCell_H #define faceToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class faceToCell class faceToCell
: :
public topoSetSource public topoSetCellSource
{ {
public: public:
//- Enumeration defining the valid options //- Enumeration defining the valid options
@ -118,11 +118,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,8 @@ namespace Foam
defineTypeNameAndDebug(faceZoneToCell, 0); defineTypeNameAndDebug(faceZoneToCell, 0);
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word); addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream); addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, faceZoneToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, faceZoneToCell, istream);
} }
@ -65,7 +67,7 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
for (const faceZone& zone : mesh_.faceZones()) for (const faceZone& zone : mesh_.faceZones())
{ {
if (zoneName_.match(zone.name())) if (selectedZones_.match(zone.name()))
{ {
hasMatched = true; hasMatched = true;
@ -76,9 +78,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
: zone.slaveCells() : zone.slaveCells()
); );
Info<< " Found matching zone " << zone.name() if (verbose_)
<< " with " << cellLabels.size() << " cells on selected side." {
<< endl; Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells on "
<< faceActionNames_[option_] << " side" << endl;
}
for (const label celli : cellLabels) for (const label celli : cellLabels)
{ {
@ -94,7 +99,8 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
if (!hasMatched) if (!hasMatched)
{ {
WarningInFunction WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << nl << "Cannot find any faceZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names: " << flatOutput(mesh_.faceZones().names()) << "Valid names: " << flatOutput(mesh_.faceZones().names())
<< endl; << endl;
} }
@ -106,12 +112,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
Foam::faceZoneToCell::faceZoneToCell Foam::faceZoneToCell::faceZoneToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& zoneName, const wordRe& zoneName,
const faceAction option const faceAction option
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(zoneName), selectedZones_(one(), zoneName),
option_(option) option_(option)
{} {}
@ -122,10 +128,18 @@ Foam::faceZoneToCell::faceZoneToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(dict.get<wordRe>("name")), selectedZones_(),
option_(faceActionNames_.get("option", dict)) option_(faceActionNames_.get("option", dict))
{} {
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::faceZoneToCell::faceZoneToCell Foam::faceZoneToCell::faceZoneToCell
@ -134,8 +148,8 @@ Foam::faceZoneToCell::faceZoneToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(checkIs(is)), selectedZones_(one(), wordRe(checkIs(is))),
option_(faceActionNames_.read(checkIs(is))) option_(faceActionNames_.read(checkIs(is)))
{} {}
@ -148,17 +162,25 @@ void Foam::faceZoneToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all " << faceActionNames_[option_] if (verbose_)
<< " cells of faceZone " << zoneName_ << " ..." << endl; {
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all " << faceActionNames_[option_] if (verbose_)
<< " cells of faceZone " << zoneName_ << " ..." << endl; {
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,15 +25,20 @@ Class
Foam::faceZoneToCell Foam::faceZoneToCell
Description Description
A topoSetSource to select cells based on side of faceZone. A topoSetCellSource to select cells based on side of faceZone.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
name | The face zone name or regex | yes | option | Selection type (master / slave) | yes |
option | Selection type (master / slave) | yes | zone | The face zone name or regex | possibly |
zones | The face zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable \endtable
Note
Selection of multiple zones has precedence.
SourceFiles SourceFiles
faceZoneToCell.C faceZoneToCell.C
@ -42,8 +47,8 @@ SourceFiles
#ifndef faceZoneToCell_H #ifndef faceZoneToCell_H
#define faceZoneToCell_H #define faceZoneToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "wordRe.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +61,7 @@ namespace Foam
class faceZoneToCell class faceZoneToCell
: :
public topoSetSource public topoSetCellSource
{ {
public: public:
//- Enumeration defining the valid options //- Enumeration defining the valid options
@ -75,8 +80,8 @@ private:
//- Add usage string //- Add usage string
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name/regular expression of faceZone //- Matcher for face zones
wordRe zoneName_; wordRes selectedZones_;
//- Option //- Option
faceAction option_; faceAction option_;
@ -98,7 +103,7 @@ public:
faceZoneToCell faceZoneToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& zoneName, const wordRe& zoneName,
const faceAction option const faceAction option
); );
@ -115,11 +120,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -38,6 +38,22 @@ namespace Foam
defineTypeNameAndDebug(fieldToCell, 0); defineTypeNameAndDebug(fieldToCell, 0);
addToRunTimeSelectionTable(topoSetSource, fieldToCell, word); addToRunTimeSelectionTable(topoSetSource, fieldToCell, word);
addToRunTimeSelectionTable(topoSetSource, fieldToCell, istream); addToRunTimeSelectionTable(topoSetSource, fieldToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, fieldToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, fieldToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
fieldToCell,
word,
field
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
fieldToCell,
istream,
field
);
} }
@ -58,32 +74,40 @@ void Foam::fieldToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
Info<< " Field min:" << min(field) if (verbose_)
<< " max:" << max(field) << endl;
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{ {
Info<< " Adding all cells with value of field " << fieldName_ Info << " Field min:" << min(field) << " max:" << max(field) << nl;
<< " within range " << min_ << ".." << max_ << endl; }
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
if (verbose_)
{
Info<< " Adding all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
}
forAll(field, celli) forAll(field, celli)
{ {
if (field[celli] >= min_ && field[celli] <= max_) if (field[celli] >= min_ && field[celli] <= max_)
{ {
set.insert(celli); set.set(celli);
} }
} }
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells with value of field " << fieldName_ if (verbose_)
<< " within range " << min_ << ".." << max_ << endl; {
Info<< " Removing all cells with value of field " << fieldName_
<< " within range " << min_ << ".." << max_ << endl;
}
forAll(field, celli) forAll(field, celli)
{ {
if (field[celli] >= min_ && field[celli] <= max_) if (field[celli] >= min_ && field[celli] <= max_)
{ {
set.erase(celli); set.unset(celli);
} }
} }
} }
@ -100,7 +124,7 @@ Foam::fieldToCell::fieldToCell
const scalar max const scalar max
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
fieldName_(fieldName), fieldName_(fieldName),
min_(min), min_(min),
max_(max) max_(max)
@ -113,10 +137,13 @@ Foam::fieldToCell::fieldToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), fieldToCell
fieldName_(dict.get<word>("field")), (
min_(dict.get<scalar>("min")), mesh,
max_(dict.get<scalar>("max")) dict.get<word>("field"),
dict.get<scalar>("min"),
dict.get<scalar>("max")
)
{} {}
@ -126,7 +153,7 @@ Foam::fieldToCell::fieldToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
fieldName_(checkIs(is)), fieldName_(checkIs(is)),
min_(readScalar(checkIs(is))), min_(readScalar(checkIs(is))),
max_(readScalar(checkIs(is))) max_(readScalar(checkIs(is)))

View File

@ -25,7 +25,7 @@ Class
Foam::fieldToCell Foam::fieldToCell
Description Description
A topoSetSource to select cells based on field values. A topoSetCellSource to select cells based on field values.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -43,7 +43,7 @@ SourceFiles
#ifndef fieldToCell_H #ifndef fieldToCell_H
#define fieldToCell_H #define fieldToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "scalarField.H" #include "scalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -57,7 +57,7 @@ namespace Foam
class fieldToCell class fieldToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -115,11 +115,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(labelToCell, 0); defineTypeNameAndDebug(labelToCell, 0);
addToRunTimeSelectionTable(topoSetSource, labelToCell, word); addToRunTimeSelectionTable(topoSetSource, labelToCell, word);
addToRunTimeSelectionTable(topoSetSource, labelToCell, istream); addToRunTimeSelectionTable(topoSetSource, labelToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, labelToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, labelToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
labelToCell,
word,
label
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
labelToCell,
istream,
label
);
} }
@ -53,19 +69,29 @@ Foam::labelToCell::labelToCell
const labelList& labels const labelList& labels
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
labels_(labels) labels_(labels)
{} {}
Foam::labelToCell::labelToCell
(
const polyMesh& mesh,
labelList&& labels
)
:
topoSetCellSource(mesh),
labels_(std::move(labels))
{}
Foam::labelToCell::labelToCell Foam::labelToCell::labelToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), labelToCell(mesh, dict.get<labelList>("value"))
labels_(dict.get<labelList>("value"))
{} {}
@ -75,7 +101,7 @@ Foam::labelToCell::labelToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
labels_(checkIs(is)) labels_(checkIs(is))
{ {
check(labels_, mesh.nCells()); check(labels_, mesh.nCells());
@ -90,15 +116,23 @@ void Foam::labelToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells mentioned in dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Adding cells mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, true); addOrDelete(set, labels_, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells mentioned in dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Removing cells mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, false); addOrDelete(set, labels_, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::labelToCell Foam::labelToCell
Description Description
A topoSetSource to select cells based on explicitly given labels. A topoSetCellSource to select cells based on explicitly given labels.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -41,7 +41,7 @@ SourceFiles
#ifndef labelToCell_H #ifndef labelToCell_H
#define labelToCell_H #define labelToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +54,7 @@ namespace Foam
class labelToCell class labelToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -73,12 +73,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying labels
labelToCell labelToCell(const polyMesh& mesh, const labelList& labels);
(
const polyMesh& mesh, //- Construct from components, moving labels
const labelList& labels labelToCell(const polyMesh& mesh, labelList&& labels);
);
//- Construct from dictionary //- Construct from dictionary
labelToCell(const polyMesh& mesh, const dictionary& dict); labelToCell(const polyMesh& mesh, const dictionary& dict);
@ -93,11 +92,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(nbrToCell, 0); defineTypeNameAndDebug(nbrToCell, 0);
addToRunTimeSelectionTable(topoSetSource, nbrToCell, word); addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream); addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, nbrToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, nbrToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
nbrToCell,
word,
nbr
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
nbrToCell,
istream,
nbr
);
} }
@ -101,7 +117,7 @@ Foam::nbrToCell::nbrToCell
const label minNbrs const label minNbrs
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
minNbrs_(minNbrs) minNbrs_(minNbrs)
{} {}
@ -112,8 +128,7 @@ Foam::nbrToCell::nbrToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), nbrToCell(mesh, dict.get<label>("neighbours"))
minNbrs_(dict.get<label>("neighbours"))
{} {}
@ -123,7 +138,7 @@ Foam::nbrToCell::nbrToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
minNbrs_(readLabel(checkIs(is))) minNbrs_(readLabel(checkIs(is)))
{} {}
@ -136,17 +151,23 @@ void Foam::nbrToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with only " << minNbrs_ << " or less" if (verbose_)
" neighbouring cells" << " ..." << endl; {
Info<< " Adding cells with only " << minNbrs_
<< " or fewer neighbouring cells" << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with only " << minNbrs_ << " or less" if (verbose_)
" neighbouring cells" << " ..." << endl; {
Info<< " Removing cells with only " << minNbrs_
<< " or fewer neighbouring cells" << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::nbrToCell Foam::nbrToCell
Description Description
A topoSetSource to select cells based on number of neighbouring cells A topoSetCellSource to select cells based on number of neighbouring cells
(i.e. number of internal or coupled faces) (i.e. number of internal or coupled faces)
\heading Dictionary parameters \heading Dictionary parameters
@ -42,7 +42,7 @@ SourceFiles
#ifndef nbrToCell_H #ifndef nbrToCell_H
#define nbrToCell_H #define nbrToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ namespace Foam
class nbrToCell class nbrToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -81,11 +81,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
nbrToCell nbrToCell(const polyMesh& mesh, const label minNbrs);
(
const polyMesh& mesh,
const label minNbrs
);
//- Construct from dictionary //- Construct from dictionary
nbrToCell(const polyMesh& mesh, const dictionary& dict); nbrToCell(const polyMesh& mesh, const dictionary& dict);
@ -100,11 +96,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,22 @@ namespace Foam
defineTypeNameAndDebug(nearestToCell, 0); defineTypeNameAndDebug(nearestToCell, 0);
addToRunTimeSelectionTable(topoSetSource, nearestToCell, word); addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream); addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, nearestToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, nearestToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
nearestToCell,
word,
nearest
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
nearestToCell,
istream,
nearest
);
} }
@ -87,19 +103,33 @@ Foam::nearestToCell::nearestToCell
const pointField& points const pointField& points
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
points_(points) points_(points)
{} {}
Foam::nearestToCell::nearestToCell
(
const polyMesh& mesh,
pointField&& points
)
:
topoSetCellSource(mesh),
points_(std::move(points))
{}
Foam::nearestToCell::nearestToCell Foam::nearestToCell::nearestToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), nearestToCell
points_(dict.get<pointField>("points")) (
mesh,
dict.get<pointField>("points")
)
{} {}
@ -109,7 +139,7 @@ Foam::nearestToCell::nearestToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
points_(checkIs(is)) points_(checkIs(is))
{} {}
@ -122,15 +152,21 @@ void Foam::nearestToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells nearest to " << points_ << endl; if (verbose_)
{
Info<< " Adding cells nearest to " << points_ << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells nearest to " << points_ << endl; if (verbose_)
{
Info<< " Removing cells nearest to " << points_ << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::nearestToCell Foam::nearestToCell
Description Description
A topoSetSource to select cells nearest to points. A topoSetCellSource to select cells nearest to points.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -41,7 +41,7 @@ SourceFiles
#ifndef nearestToCell_H #ifndef nearestToCell_H
#define nearestToCell_H #define nearestToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +54,7 @@ namespace Foam
class nearestToCell class nearestToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -78,12 +78,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying points
nearestToCell nearestToCell(const polyMesh& mesh, const pointField& points);
(
const polyMesh& mesh, //- Construct from components, moving points
const pointField& points nearestToCell(const polyMesh& mesh, pointField&& points);
);
//- Construct from dictionary //- Construct from dictionary
nearestToCell(const polyMesh& mesh, const dictionary& dict); nearestToCell(const polyMesh& mesh, const dictionary& dict);
@ -98,11 +97,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(pointToCell, 0); defineTypeNameAndDebug(pointToCell, 0);
addToRunTimeSelectionTable(topoSetSource, pointToCell, word); addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
addToRunTimeSelectionTable(topoSetSource, pointToCell, istream); addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, pointToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, pointToCell, istream);
} }
@ -116,7 +118,7 @@ Foam::pointToCell::pointToCell
const pointAction option const pointAction option
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -128,9 +130,12 @@ Foam::pointToCell::pointToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), pointToCell
setName_(dict.get<word>("set")), (
option_(pointActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
pointActionNames_.get("option", dict)
)
{} {}
@ -140,7 +145,7 @@ Foam::pointToCell::pointToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(pointActionNames_.read(checkIs(is))) option_(pointActionNames_.read(checkIs(is)))
{} {}
@ -154,17 +159,23 @@ void Foam::pointToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells according to pointSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding cells according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells according to pointSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing cells according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::pointToCell Foam::pointToCell
Description Description
A topoSetSource to select cells based on usage of points. A topoSetCellSource to select cells based on usage of points.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef pointToCell_H #ifndef pointToCell_H
#define pointToCell_H #define pointToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class pointToCell class pointToCell
: :
public topoSetSource public topoSetCellSource
{ {
public: public:
//- Enumeration defining the valid options //- Enumeration defining the valid options
@ -115,11 +115,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -37,6 +37,8 @@ namespace Foam
defineTypeNameAndDebug(regionToCell, 0); defineTypeNameAndDebug(regionToCell, 0);
addToRunTimeSelectionTable(topoSetSource, regionToCell, word); addToRunTimeSelectionTable(topoSetSource, regionToCell, word);
addToRunTimeSelectionTable(topoSetSource, regionToCell, istream); addToRunTimeSelectionTable(topoSetSource, regionToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, regionToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, regionToCell, istream);
} }
@ -155,7 +157,7 @@ void Foam::regionToCell::unselectOutsideRegions
regionSplit cellRegion(mesh_, blockedFace); regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints_ // Determine regions containing insidePoints_
boolList keepRegion(findRegions(true, cellRegion)); boolList keepRegion(findRegions(verbose_, cellRegion));
// Go back to bool per cell // Go back to bool per cell
forAll(cellRegion, celli) forAll(cellRegion, celli)
@ -266,7 +268,7 @@ void Foam::regionToCell::erode
regionSplit cellRegion(mesh_, blockedFace); regionSplit cellRegion(mesh_, blockedFace);
// Determine regions containing insidePoints // Determine regions containing insidePoints
boolList keepRegion(findRegions(true, cellRegion)); boolList keepRegion(findRegions(verbose_, cellRegion));
// Extract cells in regions that are not to be kept. // Extract cells in regions that are not to be kept.
@ -386,7 +388,7 @@ Foam::regionToCell::regionToCell
const label nErode const label nErode
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(setName), setName_(setName),
insidePoints_(insidePoints), insidePoints_(insidePoints),
nErode_(nErode) nErode_(nErode)
@ -399,7 +401,7 @@ Foam::regionToCell::regionToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(dict.lookupOrDefault<word>("set", "none")), setName_(dict.lookupOrDefault<word>("set", "none")),
insidePoints_ insidePoints_
( (
@ -415,7 +417,7 @@ Foam::regionToCell::regionToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
insidePoints_(checkIs(is)), insidePoints_(checkIs(is)),
nErode_(readLabel(checkIs(is))) nErode_(readLabel(checkIs(is)))
@ -430,17 +432,25 @@ void Foam::regionToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all cells of connected region containing points " if (verbose_)
<< insidePoints_ << " ..." << endl; {
Info<< " Adding all cells of connected region "
<< "containing points "
<< insidePoints_ << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells of connected region containing points " if (verbose_)
<< insidePoints_ << " ..." << endl; {
Info<< " Removing all cells of connected region "
<< "containing points "
<< insidePoints_ << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,8 +25,8 @@ Class
Foam::regionToCell Foam::regionToCell
Description Description
TopoSetSource. Select cells belonging to topological connected region A topoSetCellSource to select cells belonging to a topological connected
(that contains given points) region (that contains given points)
In dictionary input: In dictionary input:
\verbatim \verbatim
@ -43,10 +43,10 @@ Description
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
insidePoints | Points inside regions | yes | insidePoints | Points inside regions | yes |
nErode | Cell layers to erode to detect holes | no | 0 nErode | Cell layers to erode to detect holes | no | 0
set | Restrict to named cellSet | no | '' set | Restrict to named cellSet | no | ""
\endtable \endtable
SourceFiles SourceFiles
@ -57,7 +57,7 @@ SourceFiles
#ifndef regionToCell_H #ifndef regionToCell_H
#define regionToCell_H #define regionToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "boolList.H" #include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +73,7 @@ class regionSplit;
class regionToCell class regionToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -146,11 +146,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,22 @@ namespace Foam
defineTypeNameAndDebug(rotatedBoxToCell, 0); defineTypeNameAndDebug(rotatedBoxToCell, 0);
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word); addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word);
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream); addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, rotatedBoxToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, rotatedBoxToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
rotatedBoxToCell,
word,
rotatedBox
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
rotatedBoxToCell,
istream,
rotatedBox
);
} }
@ -117,7 +133,7 @@ Foam::rotatedBoxToCell::rotatedBoxToCell
const vector& k const vector& k
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
origin_(origin), origin_(origin),
i_(i), i_(i),
j_(j), j_(j),
@ -131,17 +147,20 @@ Foam::rotatedBoxToCell::rotatedBoxToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), rotatedBoxToCell
origin_(dict.get<point>("origin")), (
i_(dict.get<vector>("i")), mesh,
j_(dict.get<vector>("j")), dict.get<point>("origin"),
k_(dict.get<vector>("k")) dict.get<vector>("i"),
dict.get<vector>("j"),
dict.get<vector>("k")
)
{} {}
Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is) Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is)
: :
topoSetSource(mesh), topoSetCellSource(mesh),
origin_(is), origin_(is),
i_(is), i_(is),
j_(is), j_(is),
@ -157,15 +176,23 @@ void Foam::rotatedBoxToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with center within rotated box " << endl; if (verbose_)
{
Info<< " Adding cells with centre within rotated box"
<< endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with center within rotated box " << endl; if (verbose_)
{
Info<< " Removing cells with centre within rotated box"
<< endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::rotatedBoxToCell Foam::rotatedBoxToCell
Description Description
A topoSetSource to select cells based on cell centres inside A topoSetCellSource to select cells based on cell centres inside
rotated/skewed box (parallelopiped?). rotated/skewed box (parallelopiped?).
Box defined as origin and i,j,k vectors. Box defined as origin and i,j,k vectors.
@ -55,7 +55,7 @@ SourceFiles
#ifndef rotatedBoxToCell_H #ifndef rotatedBoxToCell_H
#define rotatedBoxToCell_H #define rotatedBoxToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,7 +69,7 @@ namespace Foam
class rotatedBoxToCell class rotatedBoxToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -120,11 +120,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "searchableSurfaceToCell.H"
#include "polyMesh.H"
#include "Time.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(searchableSurfaceToCell, 0);
addToRunTimeSelectionTable
(
topoSetSource,
searchableSurfaceToCell,
word
);
addToRunTimeSelectionTable
(
topoSetCellSource,
searchableSurfaceToCell,
word
);
addNamedToRunTimeSelectionTable
(
topoSetSource,
searchableSurfaceToCell,
word,
surface
);
}
Foam::topoSetSource::addToUsageTable Foam::searchableSurfaceToCell::usage_
(
searchableSurfaceToCell::typeName,
"\n Usage: searchableSurfaceToCell surface\n\n"
" Select cells with centre enclosed by the surface"
"\n"
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::searchableSurfaceToCell::combine(topoSet& set, const bool add) const
{
if (!surf_)
{
return;
}
const searchableSurface& s = *surf_;
// Add cells within the enclosing volumes
const label len = mesh_.nCells();
List<volumeType> volTypes;
s.getVolumeType(mesh_.cellCentres(), volTypes);
for (label celli=0; celli < len; ++celli)
{
if (volTypes[celli] == volumeType::INSIDE)
{
addOrDelete(set, celli, add);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableSurfaceToCell::searchableSurfaceToCell
(
const word& surfaceType,
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetCellSource(mesh),
surf_
(
searchableSurface::New
(
surfaceType,
IOobject
(
dict.lookupOrDefault("name", mesh.objectRegistry::db().name()),
mesh.time().constant(), // Instance
"triSurface", // Local
mesh.time(), // Registry
IOobject::MUST_READ,
IOobject::NO_WRITE
),
dict
)
)
{
// Check/warn for non-enclosed
if (surf_ && !surf_->hasVolumeType())
{
WarningInFunction
<< nl << "The surface '" << surf_->name() << "' of type '"
<< surf_->type() << "' appears to be unclosed ... ignoring"
<< nl << endl;
surf_.clear();
}
}
Foam::searchableSurfaceToCell::searchableSurfaceToCell
(
const polyMesh& mesh,
const dictionary& dict
)
:
searchableSurfaceToCell
(
dict.get<word>("surface"),
mesh,
dict
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::searchableSurfaceToCell::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if (!surf_ || !surf_->hasVolumeType())
{
return;
}
if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{
if (verbose_)
{
Info<< " Adding cells enclosed by searchableSurface"
<< "..." << endl;
}
combine(set, true);
}
else if (action == topoSetSource::SUBTRACT)
{
if (verbose_)
{
Info<< " Removing cells enclosed by searchableSurface"
<< "..." << endl;
}
combine(set, false);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::searchableSurfaceToCell
Description
A topoSetSource to select cells based on cell centres within a
searchableSurface.
\heading Dictionary parameters
\table
Property | Description | Required | Default
surface | The searchable surface type | yes |
name | Name for the IOobject | no | mesh-name
\endtable
SourceFiles
searchableSurfaceToCell.C
\*---------------------------------------------------------------------------*/
#ifndef searchableSurfaceToCell_H
#define searchableSurfaceToCell_H
#include "topoSetCellSource.H"
#include "searchableSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class searchableSurfaceToCell Declaration
\*---------------------------------------------------------------------------*/
class searchableSurfaceToCell
:
public topoSetCellSource
{
// Private Data
//- Add usage string
static addToUsageTable usage_;
//- The searchableSurface
autoPtr<searchableSurface> surf_;
// Private Member Functions
void combine(topoSet& set, const bool add) const;
public:
//- Runtime type information
TypeName("searchableSurfaceToCell");
// Constructors
//- Construct surface-type from dictionary
searchableSurfaceToCell
(
const word& surfaceType,
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from dictionary
searchableSurfaceToCell
(
const polyMesh& mesh,
const dictionary& dict
);
//- Destructor
virtual ~searchableSurfaceToCell() = default;
// Member Functions
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -37,6 +37,8 @@ namespace Foam
defineTypeNameAndDebug(shapeToCell, 0); defineTypeNameAndDebug(shapeToCell, 0);
addToRunTimeSelectionTable(topoSetSource, shapeToCell, word); addToRunTimeSelectionTable(topoSetSource, shapeToCell, word);
addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream); addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, shapeToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, shapeToCell, istream);
} }
@ -94,7 +96,7 @@ Foam::shapeToCell::shapeToCell
const word& shapeName const word& shapeName
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
type_(shapeName) type_(shapeName)
{ {
if (!cellModel::ptr(type_) && type_ != "splitHex") if (!cellModel::ptr(type_) && type_ != "splitHex")
@ -111,15 +113,8 @@ Foam::shapeToCell::shapeToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), shapeToCell(mesh, dict.get<word>("type"))
type_(dict.get<word>("type")) {}
{
if (!cellModel::ptr(type_) && type_ != "splitHex")
{
FatalErrorInFunction
<< "Illegal cell type " << type_ << exit(FatalError);
}
}
Foam::shapeToCell::shapeToCell Foam::shapeToCell::shapeToCell
@ -128,7 +123,7 @@ Foam::shapeToCell::shapeToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
type_(checkIs(is)) type_(checkIs(is))
{ {
if (!cellModel::ptr(type_) && type_ != "splitHex") if (!cellModel::ptr(type_) && type_ != "splitHex")
@ -147,15 +142,23 @@ void Foam::shapeToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all cells of type " << type_ << " ..." << endl; if (verbose_)
{
Info<< " Adding all cells of type " << type_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells of type " << type_ << " ..." << endl; if (verbose_)
{
Info<< " Removing all cells of type " << type_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::shapeToCell Foam::shapeToCell
Description Description
A topoSetSource to select cells based on cell shape. A topoSetCellSource to select cells based on cell shape.
Handles all known ones from static collection in cellModel Handles all known ones from static collection in cellModel
and splitHex with 10 degrees feature angle. and splitHex with 10 degrees feature angle.
@ -44,7 +44,7 @@ SourceFiles
#ifndef shapeToCell_H #ifndef shapeToCell_H
#define shapeToCell_H #define shapeToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -57,7 +57,7 @@ namespace Foam
class shapeToCell class shapeToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -90,11 +90,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
shapeToCell shapeToCell(const polyMesh& mesh, const word& shapeName);
(
const polyMesh& mesh,
const word& shapeName
);
//- Construct from dictionary //- Construct from dictionary
shapeToCell(const polyMesh& mesh, const dictionary& dict); shapeToCell(const polyMesh& mesh, const dictionary& dict);
@ -109,11 +105,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(sphereToCell, 0); defineTypeNameAndDebug(sphereToCell, 0);
addToRunTimeSelectionTable(topoSetSource, sphereToCell, word); addToRunTimeSelectionTable(topoSetSource, sphereToCell, word);
addToRunTimeSelectionTable(topoSetSource, sphereToCell, istream); addToRunTimeSelectionTable(topoSetSource, sphereToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, sphereToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, sphereToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
sphereToCell,
word,
sphere
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
sphereToCell,
istream,
sphere
);
} }
@ -55,7 +71,7 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const
forAll(ctrs, celli) forAll(ctrs, celli)
{ {
if (magSqr(ctrs[celli] - centre_) <= rad2) if (magSqr(ctrs[celli] - origin_) <= rad2)
{ {
addOrDelete(set, celli, add); addOrDelete(set, celli, add);
} }
@ -68,12 +84,12 @@ void Foam::sphereToCell::combine(topoSet& set, const bool add) const
Foam::sphereToCell::sphereToCell Foam::sphereToCell::sphereToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const point& centre, const point& origin,
const scalar radius const scalar radius
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
centre_(centre), origin_(origin),
radius_(radius) radius_(radius)
{} {}
@ -84,9 +100,12 @@ Foam::sphereToCell::sphereToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), sphereToCell
centre_(dict.get<point>("centre")), (
radius_(dict.get<scalar>("radius")) mesh,
dict.getCompat<vector>("origin", {{"centre", -1806}}),
dict.get<scalar>("radius")
)
{} {}
@ -96,8 +115,8 @@ Foam::sphereToCell::sphereToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
centre_(checkIs(is)), origin_(checkIs(is)),
radius_(readScalar(checkIs(is))) radius_(readScalar(checkIs(is)))
{} {}
@ -110,17 +129,23 @@ void Foam::sphereToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells with centre within sphere, with centre = " if (verbose_)
<< centre_ << " and radius = " << radius_ << endl; {
Info<< " Adding cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells with centre within sphere, with centre = " if (verbose_)
<< centre_ << " and radius = " << radius_ << endl; {
Info<< " Removing cells within a sphere with centre = "
<< origin_ << " and radius = " << radius_ << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,13 +25,14 @@ Class
Foam::sphereToCell Foam::sphereToCell
Description Description
A topoSetSource to select cells based on cell centres inside sphere. A topoSetCellSource to select cells based on cell centres inside sphere.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
centre | The sphere centre | yes | origin | The origin (centre) of the sphere | yes |
radius | The (outside) radius of sphere | yes | radius | The (outside) radius of sphere | yes |
centre | Alternative for 'origin' | no |
\endtable \endtable
SourceFiles SourceFiles
@ -42,7 +43,7 @@ SourceFiles
#ifndef sphereToCell_H #ifndef sphereToCell_H
#define sphereToCell_H #define sphereToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +56,7 @@ namespace Foam
class sphereToCell class sphereToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -64,7 +65,7 @@ class sphereToCell
static addToUsageTable usage_; static addToUsageTable usage_;
//- Centre point of the sphere //- Centre point of the sphere
point centre_; point origin_;
//- The outer radius of the sphere //- The outer radius of the sphere
scalar radius_; scalar radius_;
@ -87,7 +88,7 @@ public:
sphereToCell sphereToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const point& centre, const point& origin,
const scalar radius const scalar radius
); );
@ -104,11 +105,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -40,6 +40,8 @@ namespace Foam
defineTypeNameAndDebug(surfaceToCell, 0); defineTypeNameAndDebug(surfaceToCell, 0);
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, word); addToRunTimeSelectionTable(topoSetSource, surfaceToCell, word);
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, istream); addToRunTimeSelectionTable(topoSetSource, surfaceToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, surfaceToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, surfaceToCell, istream);
} }
@ -72,25 +74,22 @@ Foam::label Foam::surfaceToCell::getNearest
Map<label>& cache Map<label>& cache
) )
{ {
Map<label>::const_iterator iter = cache.find(pointi); const auto iter = cache.cfind(pointi);
if (iter != cache.end()) if (iter.found())
{ {
// Found cached answer return *iter; // Return cached value
return iter();
} }
else
{
pointIndexHit inter = querySurf.nearest(pt, span);
// Triangle label (can be -1) pointIndexHit inter = querySurf.nearest(pt, span);
label triI = inter.index();
// Store triangle on point // Triangle label (can be -1)
cache.insert(pointi, triI); const label trii = inter.index();
return triI; // Store triangle on point
} cache.insert(pointi, trii);
return trii;
} }
@ -148,7 +147,6 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
{ {
cpuTime timer; cpuTime timer;
if (useSurfaceOrientation_ && (includeInside_ || includeOutside_)) if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
{ {
const meshSearch queryMesh(mesh_); const meshSearch queryMesh(mesh_);
@ -156,8 +154,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
//- Calculate for each searchPoint inside/outside status. //- Calculate for each searchPoint inside/outside status.
boolList isInside(querySurf().calcInside(mesh_.cellCentres())); boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
Info<< " Marked inside/outside using surface orientation in = " if (verbose_)
<< timer.cpuTimeIncrement() << " s" << endl << endl; {
Info<< " Marked inside/outside using surface orientation in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
forAll(isInside, celli) forAll(isInside, celli)
{ {
@ -208,8 +209,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
); );
Info<< " Marked inside/outside using surface intersection in = " if (verbose_)
<< timer.cpuTimeIncrement() << " s" << endl << endl; {
Info<< " Marked inside/outside using surface intersection in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
//- Add/remove cells using set //- Add/remove cells using set
forAll(cellType, celli) forAll(cellType, celli)
@ -252,8 +256,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
if (curvature_ < -1) if (curvature_ < -1)
{ {
Info<< " Selecting cells with cellCentre closer than " if (verbose_)
<< nearDist_ << " to surface" << endl; {
Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface" << endl;
}
// No need to test curvature. Insert near cells into set. // No need to test curvature. Insert near cells into set.
@ -269,17 +276,22 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
} }
} }
Info<< " Determined nearest surface point in = " if (verbose_)
<< timer.cpuTimeIncrement() << " s" << endl << endl; {
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
} }
else else
{ {
// Test near cells for curvature // Test near cells for curvature
Info<< " Selecting cells with cellCentre closer than " if (verbose_)
<< nearDist_ << " to surface and curvature factor" {
<< " less than " << curvature_ << endl; Info<< " Selecting cells with cellCentre closer than "
<< nearDist_ << " to surface and curvature factor"
<< " less than " << curvature_ << endl;
}
// Cache for nearest surface triangle for a point // Cache for nearest surface triangle for a point
Map<label> pointToNearest(mesh_.nCells()/10); Map<label> pointToNearest(mesh_.nCells()/10);
@ -309,8 +321,11 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
} }
} }
Info<< " Determined nearest surface point in = " if (verbose_)
<< timer.cpuTimeIncrement() << " s" << endl << endl; {
Info<< " Determined nearest surface point in = "
<< timer.cpuTimeIncrement() << " s" << nl << endl;
}
} }
} }
} }
@ -364,7 +379,7 @@ Foam::surfaceToCell::surfaceToCell
const scalar curvature const scalar curvature
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
surfName_(surfName), surfName_(surfName),
outsidePoints_(outsidePoints), outsidePoints_(outsidePoints),
includeCut_(includeCut), includeCut_(includeCut),
@ -396,7 +411,7 @@ Foam::surfaceToCell::surfaceToCell
const scalar curvature const scalar curvature
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
surfName_(surfName), surfName_(surfName),
outsidePoints_(outsidePoints), outsidePoints_(outsidePoints),
includeCut_(includeCut), includeCut_(includeCut),
@ -419,7 +434,7 @@ Foam::surfaceToCell::surfaceToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
surfName_(dict.get<fileName>("file").expand()), surfName_(dict.get<fileName>("file").expand()),
outsidePoints_(dict.get<pointField>("outsidePoints")), outsidePoints_(dict.get<pointField>("outsidePoints")),
includeCut_(dict.get<bool>("includeCut")), includeCut_(dict.get<bool>("includeCut")),
@ -452,7 +467,7 @@ Foam::surfaceToCell::surfaceToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
surfName_(checkIs(is)), surfName_(checkIs(is)),
outsidePoints_(checkIs(is)), outsidePoints_(checkIs(is)),
includeCut_(readBool(checkIs(is))), includeCut_(readBool(checkIs(is))),
@ -489,17 +504,23 @@ void Foam::surfaceToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells in relation to surface " << surfName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding cells in relation to surface " << surfName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells in relation to surface " << surfName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing cells in relation to surface " << surfName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::surfaceToCell Foam::surfaceToCell
Description Description
A topoSetSource to select cells based on relation to surface. A topoSetCellSource to select cells based on relation to surface.
Selects: Selects:
- all cells inside/outside/cut by surface - all cells inside/outside/cut by surface
@ -58,7 +58,7 @@ SourceFiles
#ifndef surfaceToCell_H #ifndef surfaceToCell_H
#define surfaceToCell_H #define surfaceToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "Map.H" #include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,7 +74,7 @@ class triSurface;
class surfaceToCell class surfaceToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -209,11 +209,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -38,6 +38,22 @@ namespace Foam
defineTypeNameAndDebug(targetVolumeToCell, 0); defineTypeNameAndDebug(targetVolumeToCell, 0);
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word);
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
targetVolumeToCell,
word,
targetVolume
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
targetVolumeToCell,
istream,
targetVolume
);
} }
@ -103,14 +119,16 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
return; return;
} }
bitSet maskSet(mesh_.nCells(), true); bitSet maskSet(mesh_.nCells(), true);
label nTotCells = mesh_.globalData().nTotalCells(); label nTotCells = mesh_.globalData().nTotalCells();
if (maskSetName_.size()) if (maskSetName_.size())
{ {
// Read cellSet // Read cellSet
Info<< " Operating on subset defined by cellSet " << maskSetName_ if (verbose_)
<< endl; {
Info<< " Operating on subset defined by cellSet "
<< maskSetName_ << endl;
}
maskSet = false; maskSet = false;
cellSet subset(mesh_, maskSetName_); cellSet subset(mesh_, maskSetName_);
@ -138,7 +156,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
label maxPointi = -1; label maxPointi = -1;
forAll(points, pointi) forAll(points, pointi)
{ {
scalar c = (points[pointi] & normal_); const scalar c = (points[pointi] & normal_);
if (c > maxComp) if (c > maxComp)
{ {
maxComp = c; maxComp = c;
@ -247,9 +265,11 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
} }
Info<< " Selected " << nSelected << " with actual volume " if (verbose_)
<< selectedVol << endl; {
Info<< " Selected " << nSelected << " with actual volume "
<< selectedVol << endl;
}
// Loop over selected cells only // Loop over selected cells only
for (const label celli : selected) for (const label celli : selected)
@ -265,12 +285,14 @@ Foam::targetVolumeToCell::targetVolumeToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const scalar vol, const scalar vol,
const vector& normal const vector& normal,
const word& maskSetName
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
vol_(vol), vol_(vol),
normal_(normal) normal_(normal),
maskSetName_(maskSetName)
{} {}
@ -280,10 +302,13 @@ Foam::targetVolumeToCell::targetVolumeToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), targetVolumeToCell
vol_(dict.get<scalar>("volume")), (
normal_(dict.get<vector>("normal")), mesh,
maskSetName_(dict.lookupOrDefault<word>("set", "")) dict.get<scalar>("volume"),
dict.get<vector>("normal"),
dict.lookupOrDefault<word>("set", "")
)
{} {}
@ -293,7 +318,7 @@ Foam::targetVolumeToCell::targetVolumeToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
vol_(readScalar(checkIs(is))), vol_(readScalar(checkIs(is))),
normal_(checkIs(is)) normal_(checkIs(is))
{} {}
@ -307,17 +332,25 @@ void Foam::targetVolumeToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding cells up to target volume " << vol_ if (verbose_)
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl; {
Info<< " Adding cells up to target volume " << vol_
<< " out of total volume "
<< gSum(mesh_.cellVolumes()) << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing cells up to target volume " << vol_ if (verbose_)
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl; {
Info<< " Removing cells up to target volume " << vol_
<< " out of total volume "
<< gSum(mesh_.cellVolumes()) << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::targetVolumeToCell Foam::targetVolumeToCell
Description Description
A topoSetSource to select cells based on the wanted volume of selected A topoSetCellSource to select cells based on the wanted volume of selected
cells. Adapts a plane until it has enough. cells. Adapts a plane until it has enough.
\heading Dictionary parameters \heading Dictionary parameters
@ -44,7 +44,7 @@ SourceFiles
#ifndef targetVolumeToCell_H #ifndef targetVolumeToCell_H
#define targetVolumeToCell_H #define targetVolumeToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,7 +60,7 @@ class bitSet;
class targetVolumeToCell class targetVolumeToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -105,7 +105,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const scalar vol, const scalar vol,
const vector& normal const vector& normal,
const word& maskSetName = ""
); );
//- Construct from dictionary //- Construct from dictionary
@ -121,11 +122,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "topoSetCellSource.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(topoSetCellSource, 0);
defineRunTimeSelectionTable(topoSetCellSource, word);
defineRunTimeSelectionTable(topoSetCellSource, istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::topoSetCellSource::topoSetCellSource(const polyMesh& mesh)
:
topoSetSource(mesh)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New
(
const word& sourceType,
const polyMesh& mesh,
const dictionary& dict
)
{
auto cstrIter = wordConstructorTablePtr_->cfind(sourceType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown topoSetCellSource type "
<< sourceType << nl << nl
<< "Valid types :" << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<topoSetCellSource>(cstrIter()(mesh, dict));
}
Foam::autoPtr<Foam::topoSetCellSource> Foam::topoSetCellSource::New
(
const word& sourceType,
const polyMesh& mesh,
Istream& is
)
{
auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown topoSetCellSource type "
<< sourceType << nl << nl
<< "Valid types :" << endl
<< istreamConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<topoSetCellSource>(cstrIter()(mesh, is));
}
// ************************************************************************* //

View File

@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::topoSetCellSource
Description
Base class of a topoSet source for selecting cells.
SourceFiles
topoSetCellSource.C
\*---------------------------------------------------------------------------*/
#ifndef topoSetCellSource_H
#define topoSetCellSource_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class topoSetCellSource Declaration
\*---------------------------------------------------------------------------*/
class topoSetCellSource
:
public topoSetSource
{
public:
//- Runtime type information
TypeName("topoSetCellSource");
// Declare run-time constructor selection table
// For the dictionary constructor
declareRunTimeSelectionTable
(
autoPtr,
topoSetCellSource,
word,
(
const polyMesh& mesh,
const dictionary& dict
),
(mesh, dict)
);
// For the Istream constructor
declareRunTimeSelectionTable
(
autoPtr,
topoSetCellSource,
istream,
(
const polyMesh& mesh,
Istream& is
),
(mesh, is)
);
// Constructors
//- Construct from components
explicit topoSetCellSource(const polyMesh& mesh);
// Selectors
//- Return a reference to the selected source type
static autoPtr<topoSetCellSource> New
(
const word& sourceType,
const polyMesh& mesh,
const dictionary& dict
);
//- Return a reference to the selected source type
static autoPtr<topoSetCellSource> New
(
const word& sourceType,
const polyMesh& mesh,
Istream& is
);
//- Destructor
virtual ~topoSetCellSource() = default;
// Member Functions
virtual topoSetSource::sourceType setType() const
{
return CELLSETSOURCE;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(zoneToCell, 0); defineTypeNameAndDebug(zoneToCell, 0);
addToRunTimeSelectionTable(topoSetSource, zoneToCell, word); addToRunTimeSelectionTable(topoSetSource, zoneToCell, word);
addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream); addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream);
addToRunTimeSelectionTable(topoSetCellSource, zoneToCell, word);
addToRunTimeSelectionTable(topoSetCellSource, zoneToCell, istream);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
zoneToCell,
word,
zone
);
addNamedToRunTimeSelectionTable
(
topoSetCellSource,
zoneToCell,
istream,
zone
);
} }
@ -54,14 +70,17 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
for (const cellZone& zone : mesh_.cellZones()) for (const cellZone& zone : mesh_.cellZones())
{ {
if (zoneName_.match(zone.name())) if (selectedZones_.match(zone.name()))
{ {
hasMatched = true; hasMatched = true;
const labelList& cellLabels = zone; const labelList& cellLabels = zone;
Info<< " Found matching zone " << zone.name() if (verbose_)
<< " with " << cellLabels.size() << " cells." << endl; {
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells." << endl;
}
for (const label celli : cellLabels) for (const label celli : cellLabels)
{ {
@ -77,7 +96,8 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
if (!hasMatched) if (!hasMatched)
{ {
WarningInFunction WarningInFunction
<< "Cannot find any cellZone named " << zoneName_ << nl << "Cannot find any cellZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names: " << flatOutput(mesh_.cellZones().names()) << "Valid names: " << flatOutput(mesh_.cellZones().names())
<< endl; << endl;
} }
@ -89,11 +109,11 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
Foam::zoneToCell::zoneToCell Foam::zoneToCell::zoneToCell
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& zoneName const wordRe& zoneName
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(zoneName) selectedZones_(one(), zoneName)
{} {}
@ -103,9 +123,17 @@ Foam::zoneToCell::zoneToCell
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(dict.get<wordRe>("name")) selectedZones_()
{} {
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::zoneToCell::zoneToCell Foam::zoneToCell::zoneToCell
@ -114,8 +142,8 @@ Foam::zoneToCell::zoneToCell
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetCellSource(mesh),
zoneName_(checkIs(is)) selectedZones_(one(), wordRe(checkIs(is)))
{} {}
@ -127,17 +155,23 @@ void Foam::zoneToCell::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all cells of cellZone " << zoneName_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding all cells of cell zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells of cellZone " << zoneName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all cells of cell zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,14 +25,19 @@ Class
Foam::zoneToCell Foam::zoneToCell
Description Description
A topoSetSource to select cells based on cellZone. A topoSetCellSource to select cells based on one or more cellZones.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
name | The cell zone name or regex | yes | zone | The cell zone name or regex | possibly |
zones | The cell zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable \endtable
Note
Selection of multiple zones has precedence.
SourceFiles SourceFiles
zoneToCell.C zoneToCell.C
@ -41,8 +46,8 @@ SourceFiles
#ifndef zoneToCell_H #ifndef zoneToCell_H
#define zoneToCell_H #define zoneToCell_H
#include "topoSetSource.H" #include "topoSetCellSource.H"
#include "wordRe.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,12 +55,12 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class zoneToCell Declaration Class zoneToCell Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class zoneToCell class zoneToCell
: :
public topoSetSource public topoSetCellSource
{ {
// Private data // Private data
@ -63,8 +68,8 @@ class zoneToCell
//- Add usage string //- Add usage string
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name/regular expression of cellZone //- Matcher for zones
wordRe zoneName_; wordRes selectedZones_;
// Private Member Functions // Private Member Functions
@ -80,11 +85,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
zoneToCell zoneToCell(const polyMesh& mesh, const wordRe& zoneName);
(
const polyMesh& mesh,
const word& zoneName
);
//- Construct from dictionary //- Construct from dictionary
zoneToCell(const polyMesh& mesh, const dictionary& dict); zoneToCell(const polyMesh& mesh, const dictionary& dict);
@ -99,11 +100,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -96,52 +96,56 @@ void Foam::setToCellZone::applyToSet
} }
else else
{ {
cellZoneSet& fzSet = refCast<cellZoneSet>(set); cellZoneSet& zoneSet = refCast<cellZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all cells from cellSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding all cells from cellSet " << setName_
<< " ..." << endl;
}
// Load the sets // Load the sets
cellSet fSet(mesh_, setName_); cellSet fSet(mesh_, setName_);
// Start off from copy // Start off from copy
DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<label> newAddressing(zoneSet.addressing());
forAllConstIter(cellSet, fSet, iter) for (const label celli : fSet)
{ {
label celli = iter.key(); if (!zoneSet.found(celli))
if (!fzSet.found(celli))
{ {
newAddressing.append(celli); newAddressing.append(celli);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.updateSet(); zoneSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells from cellSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing all cells from cellSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
cellSet loadedSet(mesh_, setName_); cellSet loadedSet(mesh_, setName_);
// Start off empty // Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size()); DynamicList<label> newAddressing(zoneSet.addressing().size());
forAll(fzSet.addressing(), i) forAll(zoneSet.addressing(), i)
{ {
if (!loadedSet.found(fzSet.addressing()[i])) if (!loadedSet.found(zoneSet.addressing()[i]))
{ {
newAddressing.append(fzSet.addressing()[i]); newAddressing.append(zoneSet.addressing()[i]);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.updateSet(); zoneSet.updateSet();
} }
} }
} }

View File

@ -72,17 +72,13 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
setToCellZone setToCellZone(const polyMesh& mesh, const word& setName);
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary //- Construct from dictionary
setToCellZone(const polyMesh& mesh, const dictionary& dict); setToCellZone(const polyMesh& mesh, const dictionary& dict);
//- Construct from Istream //- Construct from Istream
setToCellZone(const polyMesh& mesh, Istream& is ); setToCellZone(const polyMesh& mesh, Istream& is);
//- Destructor //- Destructor

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(boundaryToFace, 0); defineTypeNameAndDebug(boundaryToFace, 0);
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, word); addToRunTimeSelectionTable(topoSetSource, boundaryToFace, word);
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, istream); addToRunTimeSelectionTable(topoSetSource, boundaryToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, boundaryToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, boundaryToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
boundaryToFace,
word,
boundary
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
boundaryToFace,
istream,
boundary
);
} }
@ -65,7 +81,7 @@ void Foam::boundaryToFace::combine(topoSet& set, const bool add) const
Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh) Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh)
: :
topoSetSource(mesh) topoSetFaceSource(mesh)
{} {}
@ -75,7 +91,7 @@ Foam::boundaryToFace::boundaryToFace
const dictionary& const dictionary&
) )
: :
topoSetSource(mesh) topoSetFaceSource(mesh)
{} {}
@ -85,7 +101,7 @@ Foam::boundaryToFace::boundaryToFace
Istream& Istream&
) )
: :
topoSetSource(mesh) topoSetFaceSource(mesh)
{} {}
@ -97,15 +113,21 @@ void Foam::boundaryToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all boundary faces ..." << endl; if (verbose_)
{
Info<< " Adding all boundary faces ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all boundary faces ..." << endl; if (verbose_)
{
Info<< " Removing all boundary faces ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::boundaryToFace Foam::boundaryToFace
Description Description
A topoSetSource to select all external (boundary) faces. A topoSetFaceSource to select all external (boundary) faces.
\heading Dictionary parameters \heading Dictionary parameters
None None
@ -38,7 +38,7 @@ SourceFiles
#ifndef boundaryToFace_H #ifndef boundaryToFace_H
#define boundaryToFace_H #define boundaryToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,7 +51,7 @@ namespace Foam
class boundaryToFace class boundaryToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -87,11 +87,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(boxToFace, 0); defineTypeNameAndDebug(boxToFace, 0);
addToRunTimeSelectionTable(topoSetSource, boxToFace, word); addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
addToRunTimeSelectionTable(topoSetSource, boxToFace, istream); addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, boxToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, boxToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
boxToFace,
word,
box
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
boxToFace,
istream,
box
);
} }
@ -73,29 +89,37 @@ Foam::boxToFace::boxToFace
const treeBoundBoxList& bbs const treeBoundBoxList& bbs
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
bbs_(bbs) bbs_(bbs)
{} {}
Foam::boxToFace::boxToFace
(
const polyMesh& mesh,
treeBoundBoxList&& bbs
)
:
topoSetFaceSource(mesh),
bbs_(std::move(bbs))
{}
Foam::boxToFace::boxToFace Foam::boxToFace::boxToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
bbs_() bbs_()
{ {
if (dict.found("box")) // Look for 'boxes' or 'box'
if (!dict.readIfPresent("boxes", bbs_))
{ {
bbs_.resize(1); bbs_.resize(1);
dict.readEntry("box", bbs_.first()); dict.readEntry("box", bbs_.first());
} }
else
{
dict.readEntry("boxes", bbs_);
}
} }
@ -105,8 +129,8 @@ Foam::boxToFace::boxToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
bbs_(1, treeBoundBox(checkIs(is))) bbs_(one(), treeBoundBox(checkIs(is)))
{} {}
@ -118,15 +142,23 @@ void Foam::boxToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces with centre within boxes " << bbs_ << endl; if (verbose_)
{
Info<< " Adding faces with centre within boxes "
<< bbs_ << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces with centre within boxes " << bbs_ << endl; if (verbose_)
{
Info<< " Removing faces with centre within boxes "
<< bbs_ << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,17 +25,18 @@ Class
Foam::boxToFace Foam::boxToFace
Description Description
A topoSetSource to select faces based on face centres inside box. A topoSetFaceSource to select faces based on face centres inside box.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
box | A single bounding box | partly | box | A single bounding box | partly |
boxes | Multiple bounding boxes | partly | boxes | Multiple bounding boxes | partly |
\endtable \endtable
Note Note
Must specify either "box" or "boxes" Must specify either "box" or "boxes".
The selection of multiple boxes has precedence.
SourceFiles SourceFiles
boxToFace.C boxToFace.C
@ -45,7 +46,7 @@ SourceFiles
#ifndef boxToFace_H #ifndef boxToFace_H
#define boxToFace_H #define boxToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ namespace Foam
class boxToFace class boxToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -82,12 +83,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying bounding boxes
boxToFace boxToFace(const polyMesh& mesh, const treeBoundBoxList& bbs);
(
const polyMesh& mesh, //- Construct from components, moving bounding boxes
const treeBoundBoxList& bbs boxToFace(const polyMesh& mesh, treeBoundBoxList&& bbs);
);
//- Construct from dictionary //- Construct from dictionary
boxToFace(const polyMesh& mesh, const dictionary& dict); boxToFace(const polyMesh& mesh, const dictionary& dict);
@ -102,11 +102,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -37,6 +37,8 @@ namespace Foam
defineTypeNameAndDebug(cellToFace, 0); defineTypeNameAndDebug(cellToFace, 0);
addToRunTimeSelectionTable(topoSetSource, cellToFace, word); addToRunTimeSelectionTable(topoSetSource, cellToFace, word);
addToRunTimeSelectionTable(topoSetSource, cellToFace, istream); addToRunTimeSelectionTable(topoSetSource, cellToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, cellToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, cellToFace, istream);
} }
@ -153,7 +155,7 @@ Foam::cellToFace::cellToFace
const cellAction option const cellAction option
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -165,9 +167,12 @@ Foam::cellToFace::cellToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cellToFace
setName_(dict.get<word>("set")), (
option_(cellActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
cellActionNames_.get("option", dict)
)
{} {}
@ -177,7 +182,7 @@ Foam::cellToFace::cellToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(cellActionNames_.read(checkIs(is))) option_(cellActionNames_.read(checkIs(is)))
{} {}
@ -191,17 +196,23 @@ void Foam::cellToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces according to cellSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding faces according to cellSet " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces according to cellSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing faces according to cellSet " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cellToFace Foam::cellToFace
Description Description
A topoSetSource to select a faceSet from cells. A topoSetFaceSource to select a faceSet from a cellSet.
Either use 'all' cell faces, or only faces that have cells Either use 'all' cell faces, or only faces that have cells
on 'both' sides. on 'both' sides.
@ -48,7 +48,7 @@ SourceFiles
#ifndef cellToFace_H #ifndef cellToFace_H
#define cellToFace_H #define cellToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,7 +62,7 @@ namespace Foam
class cellToFace class cellToFace
: :
public topoSetSource public topoSetFaceSource
{ {
public: public:
//- Enumeration defining the valid options //- Enumeration defining the valid options
@ -121,11 +121,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,32 @@ namespace Foam
defineTypeNameAndDebug(cylinderAnnulusToFace, 0); defineTypeNameAndDebug(cylinderAnnulusToFace, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, word); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, word);
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, istream); addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToFace, istream);
addToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderAnnulusToFace,
word
);
addToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderAnnulusToFace,
istream
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderAnnulusToFace,
word,
cylinderAnnulus
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderAnnulusToFace,
istream,
cylinderAnnulus
);
} }
@ -85,7 +111,7 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace
const scalar innerRadius const scalar innerRadius
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
point1_(point1), point1_(point1),
point2_(point2), point2_(point2),
outerRadius_(outerRadius), outerRadius_(outerRadius),
@ -99,11 +125,14 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cylinderAnnulusToFace
point1_(dict.get<point>("p1")), (
point2_(dict.get<point>("p2")), mesh,
outerRadius_(dict.get<scalar>("outerRadius")), dict.get<point>("p1"),
innerRadius_(dict.get<scalar>("innerRadius")) dict.get<point>("p2"),
dict.get<scalar>("outerRadius"),
dict.get<scalar>("innerRadius")
)
{} {}
@ -113,7 +142,7 @@ Foam::cylinderAnnulusToFace::cylinderAnnulusToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
point1_(checkIs(is)), point1_(checkIs(is)),
point2_(checkIs(is)), point2_(checkIs(is)),
outerRadius_(readScalar(checkIs(is))), outerRadius_(readScalar(checkIs(is))),
@ -129,23 +158,31 @@ void Foam::cylinderAnnulusToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces with centre within cylinder annulus," if (verbose_)
<< " with p1 = " {
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ Info<< " Adding faces with centre within cylinder annulus,"
<< ", inner radius = " << innerRadius_ << " with p1 = "
<< endl; << point1_ << ", p2 = " << point2_
<< ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces with centre within cylinder annulus," if (verbose_)
<< " with p1 = " {
<< point1_ << ", p2 = " << point2_ << ", radius = " << outerRadius_ Info<< " Removing faces with centre within cylinder annulus,"
<< ", inner radius = " << innerRadius_ << " with p1 = "
<< endl; << point1_ << ", p2 = " << point2_
<< ", radius = " << outerRadius_
<< ", inner radius = " << innerRadius_
<< endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cylinderAnnulusToFace Foam::cylinderAnnulusToFace
Description Description
A topoSetSource to select faces based on face centres inside a A topoSetFaceSource to select faces based on face centres inside a
cylinder annulus. cylinder annulus.
\heading Dictionary parameters \heading Dictionary parameters
@ -45,7 +45,7 @@ SourceFiles
#ifndef cylinderAnnulusToFace_H #ifndef cylinderAnnulusToFace_H
#define cylinderAnnulusToFace_H #define cylinderAnnulusToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,7 +58,7 @@ namespace Foam
class cylinderAnnulusToFace class cylinderAnnulusToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -115,11 +115,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(cylinderToFace, 0); defineTypeNameAndDebug(cylinderToFace, 0);
addToRunTimeSelectionTable(topoSetSource, cylinderToFace, word); addToRunTimeSelectionTable(topoSetSource, cylinderToFace, word);
addToRunTimeSelectionTable(topoSetSource, cylinderToFace, istream); addToRunTimeSelectionTable(topoSetSource, cylinderToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, cylinderToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, cylinderToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderToFace,
word,
cylinder
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
cylinderToFace,
istream,
cylinder
);
} }
@ -82,7 +98,7 @@ Foam::cylinderToFace::cylinderToFace
const scalar radius const scalar radius
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
point1_(point1), point1_(point1),
point2_(point2), point2_(point2),
radius_(radius) radius_(radius)
@ -95,10 +111,13 @@ Foam::cylinderToFace::cylinderToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cylinderToFace
point1_(dict.get<point>("p1")), (
point2_(dict.get<point>("p2")), mesh,
radius_(dict.get<scalar>("radius")) dict.get<point>("p1"),
dict.get<point>("p2"),
dict.get<scalar>("radius")
)
{} {}
@ -108,7 +127,7 @@ Foam::cylinderToFace::cylinderToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
point1_(checkIs(is)), point1_(checkIs(is)),
point2_(checkIs(is)), point2_(checkIs(is)),
radius_(readScalar(checkIs(is))) radius_(readScalar(checkIs(is)))
@ -123,19 +142,25 @@ void Foam::cylinderToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces with centre within cylinder, with p1 = " if (verbose_)
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_ {
<< endl; Info<< " Adding faces with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces with centre within cylinder, with p1 = " if (verbose_)
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_ {
<< endl; Info<< " Removing faces with centre within cylinder, with p1 = "
<< point1_ << ", p2 = " << point2_ << ", radius = " << radius_
<< endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cylinderToFace Foam::cylinderToFace
Description Description
A topoSetSource to select faces based on face centres inside a cylinder. A topoSetFaceSource to select faces based on face centres inside a cylinder.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -43,7 +43,7 @@ SourceFiles
#ifndef cylinderToFace_H #ifndef cylinderToFace_H
#define cylinderToFace_H #define cylinderToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class cylinderToFace class cylinderToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -109,11 +109,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return CELLSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(faceToFace, 0); defineTypeNameAndDebug(faceToFace, 0);
addToRunTimeSelectionTable(topoSetSource, faceToFace, word); addToRunTimeSelectionTable(topoSetSource, faceToFace, word);
addToRunTimeSelectionTable(topoSetSource, faceToFace, istream); addToRunTimeSelectionTable(topoSetSource, faceToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, faceToFace, istream);
} }
@ -54,7 +56,7 @@ Foam::faceToFace::faceToFace
const word& setName const word& setName
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(setName) setName_(setName)
{} {}
@ -65,8 +67,11 @@ Foam::faceToFace::faceToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), faceToFace
setName_(dict.get<word>("set")) (
mesh,
dict.get<word>("set")
)
{} {}
@ -76,7 +81,7 @@ Foam::faceToFace::faceToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(checkIs(is)) setName_(checkIs(is))
{} {}
@ -89,25 +94,31 @@ void Foam::faceToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from faceSet " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
set.addSet(loadedSet); set.addSet(loadedSet);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from faceSet " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
set.deleteSet(loadedSet); set.subtractSet(loadedSet);
} }
} }

View File

@ -25,7 +25,7 @@ Class
Foam::faceToFace Foam::faceToFace
Description Description
A topoSetSource to select faces based on usage in another faceSet. A topoSetFaceSource to select faces based on usage in another faceSet.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -41,7 +41,7 @@ SourceFiles
#ifndef faceToFace_H #ifndef faceToFace_H
#define faceToFace_H #define faceToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +54,7 @@ namespace Foam
class faceToFace class faceToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -72,11 +72,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
faceToFace faceToFace(const polyMesh& mesh, const word& setName);
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary //- Construct from dictionary
faceToFace(const polyMesh& mesh, const dictionary& dict); faceToFace(const polyMesh& mesh, const dictionary& dict);
@ -91,11 +87,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(labelToFace, 0); defineTypeNameAndDebug(labelToFace, 0);
addToRunTimeSelectionTable(topoSetSource, labelToFace, word); addToRunTimeSelectionTable(topoSetSource, labelToFace, word);
addToRunTimeSelectionTable(topoSetSource, labelToFace, istream); addToRunTimeSelectionTable(topoSetSource, labelToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, labelToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, labelToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
labelToFace,
word,
label
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
labelToFace,
istream,
label
);
} }
@ -53,19 +69,33 @@ Foam::labelToFace::labelToFace
const labelList& labels const labelList& labels
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
labels_(labels) labels_(labels)
{} {}
Foam::labelToFace::labelToFace
(
const polyMesh& mesh,
labelList&& labels
)
:
topoSetFaceSource(mesh),
labels_(std::move(labels))
{}
Foam::labelToFace::labelToFace Foam::labelToFace::labelToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), labelToFace
labels_(dict.get<labelList>("value")) (
mesh,
dict.get<labelList>("value")
)
{} {}
@ -75,7 +105,7 @@ Foam::labelToFace::labelToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
labels_(checkIs(is)) labels_(checkIs(is))
{ {
check(labels_, mesh.nFaces()); check(labels_, mesh.nFaces());
@ -90,15 +120,23 @@ void Foam::labelToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces mentioned in dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Adding faces mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, true); addOrDelete(set, labels_, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces mentioned dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Removing faces mentioned dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, false); addOrDelete(set, labels_, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::labelToFace Foam::labelToFace
Description Description
A topoSetSource to select faces given explicitly provided face labels. A topoSetFaceSource to select faces given explicitly provided face labels.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef labelToFace_H #ifndef labelToFace_H
#define labelToFace_H #define labelToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ namespace Foam
class labelToFace class labelToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -74,12 +74,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying labels
labelToFace labelToFace(const polyMesh& mesh, const labelList& labels);
(
const polyMesh& mesh, //- Construct from components, moving labels
const labelList& labels labelToFace(const polyMesh& mesh, labelList&& labels);
);
//- Construct from dictionary //- Construct from dictionary
labelToFace(const polyMesh& mesh, const dictionary& dict); labelToFace(const polyMesh& mesh, const dictionary& dict);
@ -94,11 +93,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,22 @@ namespace Foam
defineTypeNameAndDebug(normalToFace, 0); defineTypeNameAndDebug(normalToFace, 0);
addToRunTimeSelectionTable(topoSetSource, normalToFace, word); addToRunTimeSelectionTable(topoSetSource, normalToFace, word);
addToRunTimeSelectionTable(topoSetSource, normalToFace, istream); addToRunTimeSelectionTable(topoSetSource, normalToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, normalToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, normalToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
normalToFace,
word,
normal
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
normalToFace,
istream,
normal
);
} }
@ -53,8 +69,6 @@ void Foam::normalToFace::setNormal()
{ {
normal_.normalise(); normal_.normalise();
Info<< " normalToFace : Normalized vector to " << normal_ << endl;
if (tol_ < -1 || tol_ > 1) if (tol_ < -1 || tol_ > 1)
{ {
FatalErrorInFunction FatalErrorInFunction
@ -73,7 +87,7 @@ Foam::normalToFace::normalToFace
const scalar tol const scalar tol
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
normal_(normal), normal_(normal),
tol_(tol) tol_(tol)
{ {
@ -83,9 +97,12 @@ Foam::normalToFace::normalToFace
Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict) Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict)
: :
topoSetSource(mesh), normalToFace
normal_(dict.get<vector>("normal")), (
tol_(dict.get<scalar>("cos")) mesh,
dict.get<vector>("normal"),
dict.get<scalar>("cos")
)
{ {
setNormal(); setNormal();
} }
@ -93,7 +110,7 @@ Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict)
Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is) Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is)
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
normal_(checkIs(is)), normal_(checkIs(is)),
tol_(readScalar(checkIs(is))) tol_(readScalar(checkIs(is)))
{ {
@ -109,10 +126,13 @@ void Foam::normalToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces according to normal being aligned with " if (verbose_)
<< normal_ << " (to within " << tol_ << ") ..." << endl; {
Info<< " Adding faces according to normal being aligned with "
<< normal_ << " (to within " << tol_ << ") ..." << endl;
}
forAll(mesh_.faceAreas(), facei) forAll(mesh_.faceAreas(), facei)
{ {
@ -120,21 +140,22 @@ void Foam::normalToFace::applyToSet
if (mag(1 - (n & normal_)) < tol_) if (mag(1 - (n & normal_)) < tol_)
{ {
set.insert(facei); set.set(facei);
} }
} }
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces according to normal being aligned with " if (verbose_)
<< normal_ << " (to within " << tol_ << ") ..." << endl; {
Info<< " Removing faces according to normal being aligned with "
<< normal_ << " (to within " << tol_ << ") ..." << endl;
}
DynamicList<label> toBeRemoved(set.size()/10); DynamicList<label> toBeRemoved(set.size()/10);
forAllConstIter(topoSet, set, iter) for (const label facei : static_cast<const labelHashSet&>(set))
{ {
const label facei = iter.key();
const vector n = normalised(mesh_.faceAreas()[facei]); const vector n = normalised(mesh_.faceAreas()[facei]);
if (mag(1 - (n & normal_)) < tol_) if (mag(1 - (n & normal_)) < tol_)
@ -143,7 +164,7 @@ void Foam::normalToFace::applyToSet
} }
} }
set.erase(toBeRemoved); set.unset(toBeRemoved);
} }
} }

View File

@ -25,7 +25,7 @@ Class
Foam::normalToFace Foam::normalToFace
Description Description
A topoSetSource to select faces based on normal. A topoSetFaceSource to select faces based on normal.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef normalToFace_H #ifndef normalToFace_H
#define normalToFace_H #define normalToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ namespace Foam
class normalToFace class normalToFace
: :
public topoSetSource public topoSetFaceSource
{ {
private: private:
@ -104,11 +104,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(patchToFace, 0); defineTypeNameAndDebug(patchToFace, 0);
addToRunTimeSelectionTable(topoSetSource, patchToFace, word); addToRunTimeSelectionTable(topoSetSource, patchToFace, word);
addToRunTimeSelectionTable(topoSetSource, patchToFace, istream); addToRunTimeSelectionTable(topoSetSource, patchToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, patchToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, patchToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
patchToFace,
word,
patch
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
patchToFace,
istream,
patch
);
} }
@ -51,7 +67,7 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
{ {
labelHashSet patchIDs = mesh_.boundaryMesh().patchSet labelHashSet patchIDs = mesh_.boundaryMesh().patchSet
( (
List<wordRe>(1, patchName_), selectedPatches_,
true, // warn if not found true, // warn if not found
true // use patch groups if available true // use patch groups if available
); );
@ -60,8 +76,11 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
{ {
const polyPatch& pp = mesh_.boundaryMesh()[patchi]; const polyPatch& pp = mesh_.boundaryMesh()[patchi];
Info<< " Found matching patch " << pp.name() if (verbose_)
<< " with " << pp.size() << " faces." << endl; {
Info<< " Found matching patch " << pp.name()
<< " with " << pp.size() << " faces." << endl;
}
for for
( (
@ -77,8 +96,10 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
if (patchIDs.empty()) if (patchIDs.empty())
{ {
WarningInFunction WarningInFunction
<< "Cannot find any patch named " << patchName_ << endl << "Cannot find any patches matching "
<< "Valid names are " << mesh_.boundaryMesh().names() << endl; << flatOutput(selectedPatches_) << nl
<< "Valid names are " << flatOutput(mesh_.boundaryMesh().names())
<< endl;
} }
} }
@ -88,11 +109,11 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
Foam::patchToFace::patchToFace Foam::patchToFace::patchToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& patchName const wordRe& patchName
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
patchName_(patchName) selectedPatches_(one(), patchName)
{} {}
@ -102,9 +123,17 @@ Foam::patchToFace::patchToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
patchName_(dict.get<wordRe>("name")) selectedPatches_()
{} {
// Look for 'patches' and 'patch', but accept 'name' as well
if (!dict.readIfPresent("patches", selectedPatches_))
{
selectedPatches_.resize(1);
selectedPatches_.first() =
dict.getCompat<wordRe>("patch", {{"name", 1806}});
}
}
Foam::patchToFace::patchToFace Foam::patchToFace::patchToFace
@ -113,8 +142,8 @@ Foam::patchToFace::patchToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
patchName_(checkIs(is)) selectedPatches_(one(), wordRe(checkIs(is)))
{} {}
@ -126,16 +155,23 @@ void Foam::patchToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces of patch " << patchName_ << " ..." << endl; if (verbose_)
{
Info<< " Adding all faces of patches "
<< flatOutput(selectedPatches_) << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces of patch " << patchName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all faces of patches "
<< flatOutput(selectedPatches_) << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,14 +25,19 @@ Class
Foam::patchToFace Foam::patchToFace
Description Description
A topoSetSource to select faces based on usage in patches. A topoSetFaceSource to select faces based on usage in patches.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
name | Patch name or regex to select | yes | patch | The face zone name or regex | possibly |
patches | The face zone names or regexs | possibly |
name | Older specification for 'patch' | no |
\endtable \endtable
Note
Selection of multiple patches has precedence.
SourceFiles SourceFiles
patchToFace.C patchToFace.C
@ -41,8 +46,8 @@ SourceFiles
#ifndef patchToFace_H #ifndef patchToFace_H
#define patchToFace_H #define patchToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "wordRe.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +60,7 @@ namespace Foam
class patchToFace class patchToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -63,8 +68,8 @@ class patchToFace
//- Add usage string //- Add usage string
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name/regular expression of patch //- Matcher for patches
wordRe patchName_; wordRes selectedPatches_;
// Private Member Functions // Private Member Functions
@ -80,11 +85,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
patchToFace patchToFace(const polyMesh& mesh, const wordRe& patchName);
(
const polyMesh& mesh,
const word& patchName
);
//- Construct from dictionary //- Construct from dictionary
patchToFace(const polyMesh& mesh, const dictionary& dict); patchToFace(const polyMesh& mesh, const dictionary& dict);
@ -99,11 +100,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,22 @@ namespace Foam
defineTypeNameAndDebug(pointToFace, 0); defineTypeNameAndDebug(pointToFace, 0);
addToRunTimeSelectionTable(topoSetSource, pointToFace, word); addToRunTimeSelectionTable(topoSetSource, pointToFace, word);
addToRunTimeSelectionTable(topoSetSource, pointToFace, istream); addToRunTimeSelectionTable(topoSetSource, pointToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, pointToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, pointToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
pointToFace,
word,
point
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
pointToFace,
istream,
point
);
} }
@ -147,7 +163,7 @@ Foam::pointToFace::pointToFace
const pointAction option const pointAction option
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -159,9 +175,12 @@ Foam::pointToFace::pointToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), pointToFace
setName_(dict.get<word>("set")), (
option_(pointActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
pointActionNames_.get("option", dict)
)
{} {}
@ -171,7 +190,7 @@ Foam::pointToFace::pointToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(pointActionNames_.read(checkIs(is))) option_(pointActionNames_.read(checkIs(is)))
{} {}
@ -185,17 +204,23 @@ void Foam::pointToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding faces according to pointSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding faces according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing faces according to pointSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing faces according to pointSet " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::pointToFace Foam::pointToFace
Description Description
A topoSetSource to select faces based on use of points. A topoSetFaceSource to select faces based on use of points.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef pointToFace_H #ifndef pointToFace_H
#define pointToFace_H #define pointToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class pointToFace class pointToFace
: :
public topoSetSource public topoSetFaceSource
{ {
public: public:
@ -118,11 +118,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -40,6 +40,22 @@ namespace Foam
defineTypeNameAndDebug(regionToFace, 0); defineTypeNameAndDebug(regionToFace, 0);
addToRunTimeSelectionTable(topoSetSource, regionToFace, word); addToRunTimeSelectionTable(topoSetSource, regionToFace, word);
addToRunTimeSelectionTable(topoSetSource, regionToFace, istream); addToRunTimeSelectionTable(topoSetSource, regionToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, regionToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, regionToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
regionToFace,
word,
region
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
regionToFace,
istream,
region
);
} }
@ -108,8 +124,11 @@ void Foam::regionToFace::markZone
void Foam::regionToFace::combine(topoSet& set, const bool add) const void Foam::regionToFace::combine(topoSet& set, const bool add) const
{ {
Info<< " Loading subset " << setName_ if (verbose_)
<< " to delimit search region." << endl; {
Info<< " Loading subset " << setName_
<< " to delimit search region." << endl;
}
faceSet subSet(mesh_, setName_); faceSet subSet(mesh_, setName_);
@ -146,10 +165,13 @@ void Foam::regionToFace::combine(topoSet& set, const bool add) const
// Globally reduce // Globally reduce
combineReduce(ni, mappedPatchBase::nearestEqOp()); combineReduce(ni, mappedPatchBase::nearestEqOp());
Info<< " Found nearest face at " << ni.first().rawPoint() if (verbose_)
<< " on processor " << ni.second().second() {
<< " face " << ni.first().index() Info<< " Found nearest face at " << ni.first().rawPoint()
<< " distance " << Foam::sqrt(ni.second().first()) << endl; << " on processor " << ni.second().second()
<< " face " << ni.first().index()
<< " distance " << Foam::sqrt(ni.second().first()) << endl;
}
labelList faceRegion(patch.size(), -1); labelList faceRegion(patch.size(), -1);
markZone markZone
@ -180,7 +202,7 @@ Foam::regionToFace::regionToFace
const point& nearPoint const point& nearPoint
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(setName), setName_(setName),
nearPoint_(nearPoint) nearPoint_(nearPoint)
{} {}
@ -192,7 +214,7 @@ Foam::regionToFace::regionToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(dict.get<word>("set")), setName_(dict.get<word>("set")),
nearPoint_(dict.get<point>("nearPoint")) nearPoint_(dict.get<point>("nearPoint"))
{} {}
@ -204,7 +226,7 @@ Foam::regionToFace::regionToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
nearPoint_(checkIs(is)) nearPoint_(checkIs(is))
{} {}
@ -218,21 +240,25 @@ void Foam::regionToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces of connected region of set " if (verbose_)
<< setName_ {
<< " starting from point " Info<< " Adding all faces of connected region of set "
<< nearPoint_ << " ..." << endl; << setName_ << " starting from point " << nearPoint_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all cells of connected region of set " if (verbose_)
<< setName_ {
<< " starting from point " Info<< " Removing all cells of connected region of set "
<< nearPoint_ << " ..." << endl; << setName_ << " starting from point " << nearPoint_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,8 +25,8 @@ Class
Foam::regionToFace Foam::regionToFace
Description Description
A topoSetSource to select faces belonging to topological connected region A topoSetFaceSource to select faces belonging to a topological connected
(that contains given point) region (that contains given point)
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -43,7 +43,7 @@ SourceFiles
#ifndef regionToFace_H #ifndef regionToFace_H
#define regionToFace_H #define regionToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "indirectPrimitivePatch.H" #include "indirectPrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -57,7 +57,7 @@ namespace Foam
class regionToFace class regionToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -113,11 +113,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "topoSetFaceSource.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(topoSetFaceSource, 0);
defineRunTimeSelectionTable(topoSetFaceSource, word);
defineRunTimeSelectionTable(topoSetFaceSource, istream);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::topoSetFaceSource::topoSetFaceSource(const polyMesh& mesh)
:
topoSetSource(mesh)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New
(
const word& sourceType,
const polyMesh& mesh,
const dictionary& dict
)
{
auto cstrIter = wordConstructorTablePtr_->cfind(sourceType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown topoSetFaceSource type "
<< sourceType << nl << nl
<< "Valid types :" << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<topoSetFaceSource>(cstrIter()(mesh, dict));
}
Foam::autoPtr<Foam::topoSetFaceSource> Foam::topoSetFaceSource::New
(
const word& sourceType,
const polyMesh& mesh,
Istream& is
)
{
auto cstrIter = istreamConstructorTablePtr_->cfind(sourceType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown topoSetFaceSource type "
<< sourceType << nl << nl
<< "Valid types :" << endl
<< istreamConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<topoSetFaceSource>(cstrIter()(mesh, is));
}
// ************************************************************************* //

View File

@ -0,0 +1,133 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::topoSetFaceSource
Description
Base class of a topoSet source for selecting faces.
SourceFiles
topoSetFaceSource.C
\*---------------------------------------------------------------------------*/
#ifndef topoSetFaceSource_H
#define topoSetFaceSource_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class topoSetFaceSource Declaration
\*---------------------------------------------------------------------------*/
class topoSetFaceSource
:
public topoSetSource
{
public:
//- Runtime type information
TypeName("topoSetFaceSource");
// Declare run-time constructor selection table
// For the dictionary constructor
declareRunTimeSelectionTable
(
autoPtr,
topoSetFaceSource,
word,
(
const polyMesh& mesh,
const dictionary& dict
),
(mesh, dict)
);
// For the Istream constructor
declareRunTimeSelectionTable
(
autoPtr,
topoSetFaceSource,
istream,
(
const polyMesh& mesh,
Istream& is
),
(mesh, is)
);
// Constructors
//- Construct from components
explicit topoSetFaceSource(const polyMesh& mesh);
// Selectors
//- Return a reference to the selected source type
static autoPtr<topoSetFaceSource> New
(
const word& sourceType,
const polyMesh& mesh,
const dictionary& dict
);
//- Return a reference to the selected source type
static autoPtr<topoSetFaceSource> New
(
const word& sourceType,
const polyMesh& mesh,
Istream& is
);
//- Destructor
virtual ~topoSetFaceSource() = default;
// Member Functions
virtual topoSetSource::sourceType setType() const
{
return FACESETSOURCE;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(zoneToFace, 0); defineTypeNameAndDebug(zoneToFace, 0);
addToRunTimeSelectionTable(topoSetSource, zoneToFace, word); addToRunTimeSelectionTable(topoSetSource, zoneToFace, word);
addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream); addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream);
addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, word);
addToRunTimeSelectionTable(topoSetFaceSource, zoneToFace, istream);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
zoneToFace,
word,
zone
);
addNamedToRunTimeSelectionTable
(
topoSetFaceSource,
zoneToFace,
istream,
zone
);
} }
@ -54,14 +70,17 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
for (const faceZone& zone : mesh_.faceZones()) for (const faceZone& zone : mesh_.faceZones())
{ {
if (zoneName_.match(zone.name())) if (selectedZones_.match(zone.name()))
{ {
hasMatched = true; hasMatched = true;
const labelList& faceLabels = zone; const labelList& faceLabels = zone;
Info<< " Found matching zone " << zone.name() if (verbose_)
<< " with " << faceLabels.size() << " faces." << endl; {
Info<< " Found matching zone " << zone.name()
<< " with " << faceLabels.size() << " faces." << endl;
}
for (const label facei : faceLabels) for (const label facei : faceLabels)
{ {
@ -77,8 +96,10 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
if (!hasMatched) if (!hasMatched)
{ {
WarningInFunction WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << endl << "Cannot find any faceZone matching "
<< "Valid names are " << mesh_.faceZones().names() << endl; << flatOutput(selectedZones_) << nl
<< "Valid names are " << flatOutput(mesh_.faceZones().names())
<< endl;
} }
} }
@ -88,11 +109,11 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
Foam::zoneToFace::zoneToFace Foam::zoneToFace::zoneToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& zoneName const wordRe& zoneName
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
zoneName_(zoneName) selectedZones_(one(), zoneName)
{} {}
@ -102,9 +123,17 @@ Foam::zoneToFace::zoneToFace
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
zoneName_(dict.get<wordRe>("name")) selectedZones_()
{} {
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::zoneToFace::zoneToFace Foam::zoneToFace::zoneToFace
@ -113,8 +142,8 @@ Foam::zoneToFace::zoneToFace
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetFaceSource(mesh),
zoneName_(checkIs(is)) selectedZones_(one(), wordRe(checkIs(is)))
{} {}
@ -126,17 +155,23 @@ void Foam::zoneToFace::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces of faceZone " << zoneName_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding all faces of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces of faceZone " << zoneName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all faces of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,14 +25,19 @@ Class
Foam::zoneToFace Foam::zoneToFace
Description Description
A topoSetSource to select faces based on faceZone. A topoSetFaceSource to select faces based on one of more faceZones.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
name | The face zone name or regex | yes | zone | The face zone name or regex | possibly |
zones | The face zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable \endtable
Note
Selection of multiple zones has precedence.
SourceFiles SourceFiles
zoneToFace.C zoneToFace.C
@ -41,8 +46,8 @@ SourceFiles
#ifndef zoneToFace_H #ifndef zoneToFace_H
#define zoneToFace_H #define zoneToFace_H
#include "topoSetSource.H" #include "topoSetFaceSource.H"
#include "wordRe.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,12 +55,12 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class zoneToFace Declaration Class zoneToFace Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class zoneToFace class zoneToFace
: :
public topoSetSource public topoSetFaceSource
{ {
// Private data // Private data
@ -63,8 +68,8 @@ class zoneToFace
//- Add usage string //- Add usage string
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name/regular expression of the faceZone //- Matcher for zones
wordRe zoneName_; wordRes selectedZones_;
// Private Member Functions // Private Member Functions
@ -80,11 +85,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
zoneToFace zoneToFace(const polyMesh& mesh, const wordRe& zoneName);
(
const polyMesh& mesh,
const word& zoneName
);
//- Construct from dictionary //- Construct from dictionary
zoneToFace(const polyMesh& mesh, const dictionary& dict); zoneToFace(const polyMesh& mesh, const dictionary& dict);
@ -99,11 +100,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return FACESETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -96,53 +96,59 @@ void Foam::faceZoneToFaceZone::applyToSet
} }
else else
{ {
faceZoneSet& fSet = refCast<faceZoneSet>(set); faceZoneSet& zoneSet = refCast<faceZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from faceZone " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding all faces from faceZone " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceZoneSet loadedSet(mesh_, setName_); faceZoneSet loadedSet(mesh_, setName_);
DynamicList<label> newAddressing(fSet.addressing()); DynamicList<label> newAddressing(zoneSet.addressing());
DynamicList<bool> newFlipMap(fSet.flipMap()); DynamicList<bool> newFlipMap(zoneSet.flipMap());
forAll(loadedSet.addressing(), i) forAll(loadedSet.addressing(), i)
{ {
if (!fSet.found(loadedSet.addressing()[i])) if (!zoneSet.found(loadedSet.addressing()[i]))
{ {
newAddressing.append(loadedSet.addressing()[i]); newAddressing.append(loadedSet.addressing()[i]);
newFlipMap.append(loadedSet.flipMap()[i]); newFlipMap.append(loadedSet.flipMap()[i]);
} }
} }
fSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fSet.updateSet(); zoneSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from faceZone " << setName_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing all faces from faceZone " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceZoneSet loadedSet(mesh_, setName_); faceZoneSet loadedSet(mesh_, setName_);
DynamicList<label> newAddressing(fSet.addressing().size()); DynamicList<label> newAddressing(zoneSet.addressing().size());
DynamicList<bool> newFlipMap(fSet.flipMap().size()); DynamicList<bool> newFlipMap(zoneSet.flipMap().size());
forAll(fSet.addressing(), i) forAll(zoneSet.addressing(), i)
{ {
if (!loadedSet.found(fSet.addressing()[i])) if (!loadedSet.found(zoneSet.addressing()[i]))
{ {
newAddressing.append(fSet.addressing()[i]); newAddressing.append(zoneSet.addressing()[i]);
newFlipMap.append(fSet.flipMap()[i]); newFlipMap.append(zoneSet.flipMap()[i]);
} }
} }
fSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fSet.updateSet(); zoneSet.updateSet();
} }
} }
} }

View File

@ -58,6 +58,7 @@ Foam::topoSetSource::addToUsageTable Foam::searchableSurfaceToFaceZone::usage_
Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
( (
const word& surfaceType,
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
@ -67,7 +68,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
( (
searchableSurface::New searchableSurface::New
( (
dict.get<word>("surface"), surfaceType,
IOobject IOobject
( (
dict.lookupOrDefault("name", mesh.objectRegistry::db().name()), dict.lookupOrDefault("name", mesh.objectRegistry::db().name()),
@ -83,6 +84,21 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
{} {}
Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
(
const polyMesh& mesh,
const dictionary& dict
)
:
searchableSurfaceToFaceZone
(
dict.get<word>("surface"),
mesh,
dict
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableSurfaceToFaceZone::~searchableSurfaceToFaceZone() Foam::searchableSurfaceToFaceZone::~searchableSurfaceToFaceZone()
@ -162,10 +178,13 @@ void Foam::searchableSurfaceToFaceZone::applyToSet
// Select intersected faces // Select intersected faces
// ~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from surface " if (verbose_)
<< surfacePtr_().name() << " ..." << endl; {
Info<< " Adding all faces from surface "
<< surfacePtr_().name() << " ..." << endl;
}
DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<label> newAddressing(fzSet.addressing());
DynamicList<bool> newFlipMap(fzSet.flipMap()); DynamicList<bool> newFlipMap(fzSet.flipMap());
@ -184,10 +203,13 @@ void Foam::searchableSurfaceToFaceZone::applyToSet
fzSet.flipMap().transfer(newFlipMap); fzSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); fzSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from surface " if (verbose_)
<< surfacePtr_().name() << " ..." << endl; {
Info<< " Removing all faces from surface "
<< surfacePtr_().name() << " ..." << endl;
}
// Start off empty // Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size()); DynamicList<label> newAddressing(fzSet.addressing().size());

View File

@ -75,6 +75,15 @@ public:
// Constructors // Constructors
//- Construct surface-type from dictionary
searchableSurfaceToFaceZone
(
const word& surfaceType,
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from dictionary //- Construct from dictionary
searchableSurfaceToFaceZone searchableSurfaceToFaceZone
( (
@ -89,7 +98,7 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const virtual topoSetSource::sourceType setType() const
{ {
return FACEZONESOURCE; return FACEZONESOURCE;
} }

View File

@ -100,27 +100,30 @@ void Foam::setAndNormalToFaceZone::applyToSet
} }
else else
{ {
faceZoneSet& fzSet = refCast<faceZoneSet>(set); faceZoneSet& zoneSet = refCast<faceZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the sets // Load the sets
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
labelHashSet& faceIds = loadedSet; labelHashSet& faceIds = loadedSet;
// Start off from copy // Start off from copy
DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<label> newAddressing(zoneSet.addressing());
DynamicList<bool> newFlipMap(fzSet.flipMap()); DynamicList<bool> newFlipMap(zoneSet.flipMap());
const faceList& faces = mesh_.faces(); const faceList& faces = mesh_.faces();
const pointField& points = mesh_.points(); const pointField& points = mesh_.points();
for (const label facei : faceIds) for (const label facei : faceIds)
{ {
if (!fzSet.found(facei)) if (!zoneSet.found(facei))
{ {
newAddressing.append(facei); newAddressing.append(facei);
@ -136,33 +139,36 @@ void Foam::setAndNormalToFaceZone::applyToSet
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
// Start off empty // Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size()); DynamicList<label> newAddressing(zoneSet.addressing().size());
DynamicList<bool> newFlipMap(fzSet.flipMap().size()); DynamicList<bool> newFlipMap(zoneSet.flipMap().size());
forAll(fzSet.addressing(), i) forAll(zoneSet.addressing(), i)
{ {
if (!loadedSet.found(fzSet.addressing()[i])) if (!loadedSet.found(zoneSet.addressing()[i]))
{ {
newAddressing.append(fzSet.addressing()[i]); newAddressing.append(zoneSet.addressing()[i]);
newFlipMap.append(fzSet.flipMap()[i]); newFlipMap.append(zoneSet.flipMap()[i]);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
} }
} }

View File

@ -97,57 +97,63 @@ void Foam::setToFaceZone::applyToSet
} }
else else
{ {
faceZoneSet& fzSet = refCast<faceZoneSet>(set); faceZoneSet& zoneSet = refCast<faceZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the sets // Load the sets
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
const labelHashSet& faceLabels = loadedSet; const labelHashSet& faceLabels = loadedSet;
// Start off from copy // Start off from copy
DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<label> newAddressing(zoneSet.addressing());
DynamicList<bool> newFlipMap(fzSet.flipMap()); DynamicList<bool> newFlipMap(zoneSet.flipMap());
for (const label facei : faceLabels) for (const label facei : faceLabels)
{ {
if (!fzSet.found(facei)) if (!zoneSet.found(facei))
{ {
newAddressing.append(facei); newAddressing.append(facei);
newFlipMap.append(false); newFlipMap.append(false);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing all faces from faceSet " << setName_
<< " ..." << endl;
}
// Load the set // Load the set
faceSet loadedSet(mesh_, setName_); faceSet loadedSet(mesh_, setName_);
// Start off empty // Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size()); DynamicList<label> newAddressing(zoneSet.addressing().size());
DynamicList<bool> newFlipMap(fzSet.flipMap().size()); DynamicList<bool> newFlipMap(zoneSet.flipMap().size());
forAll(fzSet.addressing(), i) forAll(zoneSet.addressing(), i)
{ {
if (!loadedSet.found(fzSet.addressing()[i])) if (!loadedSet.found(zoneSet.addressing()[i]))
{ {
newAddressing.append(fzSet.addressing()[i]); newAddressing.append(zoneSet.addressing()[i]);
newFlipMap.append(fzSet.flipMap()[i]); newFlipMap.append(zoneSet.flipMap()[i]);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
} }
} }

View File

@ -30,8 +30,8 @@ Description
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
faceSet | Name of input faceSet | yes | faceSet | Name of input faceSet | yes |
\endtable \endtable
Note Note

View File

@ -106,26 +106,29 @@ void Foam::setsToFaceZone::applyToSet
} }
else else
{ {
faceZoneSet& fzSet = refCast<faceZoneSet>(set); faceZoneSet& zoneSet = refCast<faceZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding all faces from faceSet " << faceSetName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding all faces from faceSet " << faceSetName_
<< " ..." << endl;
}
// Load the sets // Load the sets
faceSet fSet(mesh_, faceSetName_); faceSet fSet(mesh_, faceSetName_);
cellSet cSet(mesh_, cellSetName_); cellSet cSet(mesh_, cellSetName_);
// Start off from copy // Start off from copy
DynamicList<label> newAddressing(fzSet.addressing()); DynamicList<label> newAddressing(zoneSet.addressing());
DynamicList<bool> newFlipMap(fzSet.flipMap()); DynamicList<bool> newFlipMap(zoneSet.flipMap());
forAllConstIter(faceSet, fSet, iter) forAllConstIter(faceSet, fSet, iter)
{ {
label facei = iter.key(); label facei = iter.key();
if (!fzSet.found(facei)) if (!zoneSet.found(facei))
{ {
bool flipFace = false; bool flipFace = false;
@ -176,33 +179,36 @@ void Foam::setsToFaceZone::applyToSet
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing all faces from faceSet " << faceSetName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing all faces from faceSet " << faceSetName_
<< " ..." << endl;
}
// Load the set // Load the set
faceZoneSet loadedSet(mesh_, faceSetName_); faceZoneSet loadedSet(mesh_, faceSetName_);
// Start off empty // Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size()); DynamicList<label> newAddressing(zoneSet.addressing().size());
DynamicList<bool> newFlipMap(fzSet.flipMap().size()); DynamicList<bool> newFlipMap(zoneSet.flipMap().size());
forAll(fzSet.addressing(), i) forAll(zoneSet.addressing(), i)
{ {
if (!loadedSet.found(fzSet.addressing()[i])) if (!loadedSet.found(zoneSet.addressing()[i]))
{ {
newAddressing.append(fzSet.addressing()[i]); newAddressing.append(zoneSet.addressing()[i]);
newFlipMap.append(fzSet.flipMap()[i]); newFlipMap.append(zoneSet.flipMap()[i]);
} }
} }
fzSet.addressing().transfer(newAddressing); zoneSet.addressing().transfer(newAddressing);
fzSet.flipMap().transfer(newFlipMap); zoneSet.flipMap().transfer(newFlipMap);
fzSet.updateSet(); zoneSet.updateSet();
} }
} }
} }

View File

@ -29,10 +29,10 @@ Description
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
cellSet | Name of input cellSet | yes | cellSet | Name of input cellSet | yes |
faceSet | Name of input faceSet | yes | faceSet | Name of input faceSet | yes |
flip | Force flip of faces | no | false flip | Force flip of faces | no | false
\endtable \endtable
SourceFiles SourceFiles

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(boxToPoint, 0); defineTypeNameAndDebug(boxToPoint, 0);
addToRunTimeSelectionTable(topoSetSource, boxToPoint, word); addToRunTimeSelectionTable(topoSetSource, boxToPoint, word);
addToRunTimeSelectionTable(topoSetSource, boxToPoint, istream); addToRunTimeSelectionTable(topoSetSource, boxToPoint, istream);
addToRunTimeSelectionTable(topoSetPointSource, boxToPoint, word);
addToRunTimeSelectionTable(topoSetPointSource, boxToPoint, istream);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
boxToPoint,
word,
box
);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
boxToPoint,
istream,
box
);
} }
@ -73,29 +89,37 @@ Foam::boxToPoint::boxToPoint
const treeBoundBoxList& bbs const treeBoundBoxList& bbs
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
bbs_(bbs) bbs_(bbs)
{} {}
Foam::boxToPoint::boxToPoint
(
const polyMesh& mesh,
treeBoundBoxList&& bbs
)
:
topoSetPointSource(mesh),
bbs_(std::move(bbs))
{}
Foam::boxToPoint::boxToPoint Foam::boxToPoint::boxToPoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
bbs_() bbs_()
{ {
if (dict.found("box")) // Look for 'boxes' or 'box'
if (!dict.readIfPresent("boxes", bbs_))
{ {
bbs_.resize(1); bbs_.resize(1);
dict.readEntry("box", bbs_.first()); dict.readEntry("box", bbs_.first());
} }
else
{
dict.readEntry("boxes", bbs_);
}
} }
@ -105,8 +129,8 @@ Foam::boxToPoint::boxToPoint
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
bbs_(1, treeBoundBox(checkIs(is))) bbs_(one(), treeBoundBox(checkIs(is)))
{} {}
@ -118,17 +142,23 @@ void Foam::boxToPoint::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding points that are within boxes " << bbs_ << " ..." if (verbose_)
<< endl; {
Info<< " Adding points that are within boxes " << bbs_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing points that are within boxes " << bbs_ << " ..." if (verbose_)
<< endl; {
Info<< " Removing points that are within boxes " << bbs_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,17 +25,18 @@ Class
Foam::boxToPoint Foam::boxToPoint
Description Description
A topoSetSource to select points based on whether they are inside box. A topoSetPointSource to select points based on whether they are inside box.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
box | A single bounding box | partly | box | A single bounding box | partly |
boxes | Multiple bounding boxes | partly | boxes | Multiple bounding boxes | partly |
\endtable \endtable
Note Note
Must specify either "box" or "boxes" Must specify either "box" or "boxes".
The selection of multiple boxes has precedence.
SourceFiles SourceFiles
boxToPoint.C boxToPoint.C
@ -45,7 +46,7 @@ SourceFiles
#ifndef boxToPoint_H #ifndef boxToPoint_H
#define boxToPoint_H #define boxToPoint_H
#include "topoSetSource.H" #include "topoSetPointSource.H"
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ namespace Foam
class boxToPoint class boxToPoint
: :
public topoSetSource public topoSetPointSource
{ {
// Private data // Private data
@ -83,12 +84,11 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copying bounding boxes
boxToPoint boxToPoint(const polyMesh& mesh, const treeBoundBoxList& bbs);
(
const polyMesh& mesh, //- Construct from components, moving bounding boxes
const treeBoundBoxList& bbs boxToPoint(const polyMesh& mesh, treeBoundBoxList&& bbs);
);
//- Construct from dictionary //- Construct from dictionary
boxToPoint(const polyMesh& mesh, const dictionary& dict); boxToPoint(const polyMesh& mesh, const dictionary& dict);
@ -103,11 +103,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return POINTSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(cellToPoint, 0); defineTypeNameAndDebug(cellToPoint, 0);
addToRunTimeSelectionTable(topoSetSource, cellToPoint, word); addToRunTimeSelectionTable(topoSetSource, cellToPoint, word);
addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream); addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream);
addToRunTimeSelectionTable(topoSetPointSource, cellToPoint, word);
addToRunTimeSelectionTable(topoSetPointSource, cellToPoint, istream);
} }
@ -90,7 +92,7 @@ Foam::cellToPoint::cellToPoint
const cellAction option const cellAction option
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -102,9 +104,12 @@ Foam::cellToPoint::cellToPoint
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), cellToPoint
setName_(dict.get<word>("set")), (
option_(cellActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
cellActionNames_.get("option", dict)
)
{} {}
@ -114,7 +119,7 @@ Foam::cellToPoint::cellToPoint
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(cellActionNames_.read(checkIs(is))) option_(cellActionNames_.read(checkIs(is)))
{} {}
@ -128,15 +133,23 @@ void Foam::cellToPoint::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding from " << setName_ << " ..." << endl; if (verbose_)
{
Info<< " Adding from " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing from " << setName_ << " ..." << endl; if (verbose_)
{
Info<< " Removing from " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::cellToPoint Foam::cellToPoint
Description Description
A topoSetSource to select points based on usage in cells. A topoSetPointSource to select points based on usage in cells.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef cellToPoint_H #ifndef cellToPoint_H
#define cellToPoint_H #define cellToPoint_H
#include "topoSetSource.H" #include "topoSetPointSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class cellToPoint class cellToPoint
: :
public topoSetSource public topoSetPointSource
{ {
public: public:
@ -114,11 +114,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return POINTSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,8 @@ namespace Foam
defineTypeNameAndDebug(faceToPoint, 0); defineTypeNameAndDebug(faceToPoint, 0);
addToRunTimeSelectionTable(topoSetSource, faceToPoint, word); addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream); addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
addToRunTimeSelectionTable(topoSetPointSource, faceToPoint, word);
addToRunTimeSelectionTable(topoSetPointSource, faceToPoint, istream);
} }
Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_ Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
@ -84,7 +86,7 @@ Foam::faceToPoint::faceToPoint
const faceAction option const faceAction option
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
setName_(setName), setName_(setName),
option_(option) option_(option)
{} {}
@ -96,9 +98,12 @@ Foam::faceToPoint::faceToPoint
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), faceToPoint
setName_(dict.get<word>("set")), (
option_(faceActionNames_.get("option", dict)) mesh,
dict.get<word>("set"),
faceActionNames_.get("option", dict)
)
{} {}
@ -108,7 +113,7 @@ Foam::faceToPoint::faceToPoint
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
setName_(checkIs(is)), setName_(checkIs(is)),
option_(faceActionNames_.read(checkIs(is))) option_(faceActionNames_.read(checkIs(is)))
{} {}
@ -122,17 +127,23 @@ void Foam::faceToPoint::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding points from face in faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Adding points from face in faceSet " << setName_
<< " ..." << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing points from face in faceSet " << setName_ if (verbose_)
<< " ..." << endl; {
Info<< " Removing points from face in faceSet " << setName_
<< " ..." << endl;
}
combine(set, false); combine(set, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::faceToPoint Foam::faceToPoint
Description Description
A topoSetSource to select points based on usage in faces. A topoSetPointSource to select points based on usage in faces.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -42,7 +42,7 @@ SourceFiles
#ifndef faceToPoint_H #ifndef faceToPoint_H
#define faceToPoint_H #define faceToPoint_H
#include "topoSetSource.H" #include "topoSetPointSource.H"
#include "Enum.H" #include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ namespace Foam
class faceToPoint class faceToPoint
: :
public topoSetSource public topoSetPointSource
{ {
public: public:
@ -114,11 +114,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return POINTSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -34,6 +34,22 @@ namespace Foam
defineTypeNameAndDebug(labelToPoint, 0); defineTypeNameAndDebug(labelToPoint, 0);
addToRunTimeSelectionTable(topoSetSource, labelToPoint, word); addToRunTimeSelectionTable(topoSetSource, labelToPoint, word);
addToRunTimeSelectionTable(topoSetSource, labelToPoint, istream); addToRunTimeSelectionTable(topoSetSource, labelToPoint, istream);
addToRunTimeSelectionTable(topoSetPointSource, labelToPoint, word);
addToRunTimeSelectionTable(topoSetPointSource, labelToPoint, istream);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
labelToPoint,
word,
label
);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
labelToPoint,
istream,
label
);
} }
@ -53,19 +69,29 @@ Foam::labelToPoint::labelToPoint
const labelList& labels const labelList& labels
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
labels_(labels) labels_(labels)
{} {}
Foam::labelToPoint::labelToPoint
(
const polyMesh& mesh,
labelList&& labels
)
:
topoSetPointSource(mesh),
labels_(std::move(labels))
{}
Foam::labelToPoint::labelToPoint Foam::labelToPoint::labelToPoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), labelToPoint(mesh, dict.get<labelList>("value"))
labels_(dict.get<labelList>("value"))
{} {}
@ -75,7 +101,7 @@ Foam::labelToPoint::labelToPoint
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
labels_(checkIs(is)) labels_(checkIs(is))
{ {
check(labels_, mesh.nPoints()); check(labels_, mesh.nPoints());
@ -90,15 +116,23 @@ void Foam::labelToPoint::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding points mentioned in dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Adding points mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, true); addOrDelete(set, labels_, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing points mentioned in dictionary" << " ..." << endl; if (verbose_)
{
Info<< " Removing points mentioned in dictionary"
<< " ..." << endl;
}
addOrDelete(set, labels_, false); addOrDelete(set, labels_, false);
} }

View File

@ -25,7 +25,7 @@ Class
Foam::labelToPoint Foam::labelToPoint
Description Description
A topoSetSource to select points given explicitly provided labels. A topoSetPointSource to select points given explicitly provided labels.
\heading Dictionary parameters \heading Dictionary parameters
\table \table
@ -41,7 +41,7 @@ SourceFiles
#ifndef labelToPoint_H #ifndef labelToPoint_H
#define labelToPoint_H #define labelToPoint_H
#include "topoSetSource.H" #include "topoSetPointSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,7 +54,7 @@ namespace Foam
class labelToPoint class labelToPoint
: :
public topoSetSource public topoSetPointSource
{ {
// Private data // Private data
@ -73,12 +73,11 @@ public:
// Constructors // Constructors
//- Copy construct from components //- Construct from components, copying labels
labelToPoint labelToPoint(const polyMesh& mesh, const labelList& labels);
(
const polyMesh& mesh, //- Construct from components, moving labels
const labelList& labels labelToPoint(const polyMesh& mesh, labelList&& labels);
);
//- Construct from dictionary //- Construct from dictionary
labelToPoint(const polyMesh& mesh, const dictionary& dict); labelToPoint(const polyMesh& mesh, const dictionary& dict);
@ -93,11 +92,6 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const
{
return POINTSETSOURCE;
}
virtual void applyToSet virtual void applyToSet
( (
const topoSetSource::setAction action, const topoSetSource::setAction action,

View File

@ -35,6 +35,22 @@ namespace Foam
defineTypeNameAndDebug(nearestToPoint, 0); defineTypeNameAndDebug(nearestToPoint, 0);
addToRunTimeSelectionTable(topoSetSource, nearestToPoint, word); addToRunTimeSelectionTable(topoSetSource, nearestToPoint, word);
addToRunTimeSelectionTable(topoSetSource, nearestToPoint, istream); addToRunTimeSelectionTable(topoSetSource, nearestToPoint, istream);
addToRunTimeSelectionTable(topoSetPointSource, nearestToPoint, word);
addToRunTimeSelectionTable(topoSetPointSource, nearestToPoint, istream);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
nearestToPoint,
word,
nearest
);
addNamedToRunTimeSelectionTable
(
topoSetPointSource,
nearestToPoint,
istream,
nearest
);
} }
@ -106,19 +122,29 @@ Foam::nearestToPoint::nearestToPoint
const pointField& points const pointField& points
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
points_(points) points_(points)
{} {}
Foam::nearestToPoint::nearestToPoint
(
const polyMesh& mesh,
pointField&& points
)
:
topoSetPointSource(mesh),
points_(std::move(points))
{}
Foam::nearestToPoint::nearestToPoint Foam::nearestToPoint::nearestToPoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict
) )
: :
topoSetSource(mesh), nearestToPoint(mesh, dict.get<pointField>("points"))
points_(dict.get<pointField>("points"))
{} {}
@ -128,7 +154,7 @@ Foam::nearestToPoint::nearestToPoint
Istream& is Istream& is
) )
: :
topoSetSource(mesh), topoSetPointSource(mesh),
points_(checkIs(is)) points_(checkIs(is))
{} {}
@ -141,15 +167,21 @@ void Foam::nearestToPoint::applyToSet
topoSet& set topoSet& set
) const ) const
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if (action == topoSetSource::ADD || action == topoSetSource::NEW)
{ {
Info<< " Adding points nearest to " << points_ << endl; if (verbose_)
{
Info<< " Adding points nearest to " << points_ << endl;
}
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::SUBTRACT)
{ {
Info<< " Removing points nearest to " << points_ << endl; if (verbose_)
{
Info<< " Removing points nearest to " << points_ << endl;
}
combine(set, false); combine(set, false);
} }

Some files were not shown because too many files have changed in this diff Show More