Skip to content
Snippets Groups Projects
Commit ae21118b authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: new searchableSurfaceToCell source (#1060)

parent 266b2e05
Branches
Tags
1 merge request!216Feature topo set improvements (issue #1060)
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
......
...@@ -162,6 +162,7 @@ $(cellSources)/pointToCell/pointToCell.C ...@@ -162,6 +162,7 @@ $(cellSources)/pointToCell/pointToCell.C
$(cellSources)/regionToCell/regionToCell.C $(cellSources)/regionToCell/regionToCell.C
$(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C $(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C
$(cellSources)/shapeToCell/shapeToCell.C $(cellSources)/shapeToCell/shapeToCell.C
$(cellSources)/searchableSurfaceToCell/searchableSurfaceToCell.C
$(cellSources)/sphereToCell/sphereToCell.C $(cellSources)/sphereToCell/sphereToCell.C
$(cellSources)/surfaceToCell/surfaceToCell.C $(cellSources)/surfaceToCell/surfaceToCell.C
$(cellSources)/targetVolumeToCell/targetVolumeToCell.C $(cellSources)/targetVolumeToCell/targetVolumeToCell.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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);
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
...@@ -58,6 +58,7 @@ Foam::topoSetSource::addToUsageTable Foam::searchableSurfaceToFaceZone::usage_ ...@@ -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 ...@@ -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 ...@@ -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()
......
...@@ -75,6 +75,15 @@ public: ...@@ -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: ...@@ -89,7 +98,7 @@ public:
// Member Functions // Member Functions
virtual sourceType setType() const virtual topoSetSource::sourceType setType() const
{ {
return FACEZONESOURCE; return FACEZONESOURCE;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment