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

ENH: new searchableSurfaceToCell source (#1060)

parent 42bcc328
No related branches found
No related tags found
No related merge requests found
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
......
......@@ -161,6 +161,7 @@ $(cellSources)/noneToCell/noneToCell.C
$(cellSources)/pointToCell/pointToCell.C
$(cellSources)/regionToCell/regionToCell.C
$(cellSources)/rotatedBoxToCell/rotatedBoxToCell.C
$(cellSources)/searchableSurfaceToCell/searchableSurfaceToCell.C
$(cellSources)/sphereToCell/sphereToCell.C
$(cellSources)/surfaceToCell/surfaceToCell.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_
Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
(
const word& surfaceType,
const polyMesh& mesh,
const dictionary& dict
)
......@@ -67,7 +68,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
(
searchableSurface::New
(
dict.get<word>("surface"),
surfaceType,
IOobject
(
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 * * * * * * * * * * * * * * * //
Foam::searchableSurfaceToFaceZone::~searchableSurfaceToFaceZone()
......
......@@ -75,6 +75,15 @@ public:
// Constructors
//- Construct surface-type from dictionary
searchableSurfaceToFaceZone
(
const word& surfaceType,
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from dictionary
searchableSurfaceToFaceZone
(
......@@ -89,7 +98,7 @@ public:
// Member Functions
virtual sourceType setType() const
virtual topoSetSource::sourceType setType() const
{
return FACEZONESOURCE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment