mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
functionObjects: renamed faceSource -> surfaceRegion, cellSource -> volRegion
The use of the term 'source' in the context of post-processing is confusing and does not properly describe the process of region selection. The new names 'surfaceRegion' and 'volRegion' better describe the purpose of the functionObjects which is to provide field processing functionality limited to a specified region of space, either a surface or volume. The keyword 'source' is renamed 'regionType' which better describes the purpose which is to specify the method by which the surface or volume region is selected. The keyword to select the name of the surface or volume region is renamed from 'sourceName' to 'name' consistent with the other name-changes above.
This commit is contained in:
@ -49,4 +49,4 @@ Current tools
|
|||||||
- scalarTransport for plugin scalar transport calculations
|
- scalarTransport for plugin scalar transport calculations
|
||||||
- visualization post-processing VTK files for cutting planes, streamlines,...
|
- visualization post-processing VTK files for cutting planes, streamlines,...
|
||||||
|
|
||||||
- faceSource configuration for some of the tools above
|
- surfaceRegion configuration for some of the tools above
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#includeEtc "caseDicts/postProcessing/flowRate/surfaceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/flowRate/sursurfaceRegion.cfg"
|
||||||
|
|
||||||
fields (U);
|
fields (U);
|
||||||
operation areaNormalIntegrate;
|
operation areaNormalIntegrate;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
type cellSource;
|
type volRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
@ -15,7 +15,7 @@ writeInterval 1;
|
|||||||
writeFields false;
|
writeFields false;
|
||||||
log false;
|
log false;
|
||||||
|
|
||||||
source all;
|
regionType all;
|
||||||
operation max;
|
operation max;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
@ -15,7 +15,7 @@ writeInterval 1;
|
|||||||
writeFields false;
|
writeFields false;
|
||||||
log false;
|
log false;
|
||||||
|
|
||||||
source all;
|
regionType all;
|
||||||
operation max;
|
operation max;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -17,13 +17,13 @@ log false;
|
|||||||
|
|
||||||
source1
|
source1
|
||||||
{
|
{
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/faceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/surfaceRegion.cfg"
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
fields (p);
|
fields (p);
|
||||||
}
|
}
|
||||||
source2
|
source2
|
||||||
{
|
{
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/faceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/surfaceRegion.cfg"
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
fields (p);
|
fields (p);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
source1
|
source1
|
||||||
{
|
{
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName $patch1;
|
name $patch1;
|
||||||
}
|
}
|
||||||
source2
|
source2
|
||||||
{
|
{
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName $patch2;
|
name $patch2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
source1
|
source1
|
||||||
{
|
{
|
||||||
source sampledSurface;
|
regionType sampledSurface;
|
||||||
|
|
||||||
sampledSurfaceDict
|
sampledSurfaceDict
|
||||||
{
|
{
|
||||||
type sampledTriSurfaceMesh;
|
type sampledTriSurfaceMesh;
|
||||||
source cells;
|
regionType cells;
|
||||||
interpolate true;
|
interpolate true;
|
||||||
surface $triSurface1;
|
surface $triSurface1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/faceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/surfaceRegion.cfg"
|
||||||
|
|
||||||
source faceZone;
|
regionType faceZone;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -6,9 +6,9 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/faceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/surfaceRegion.cfg"
|
||||||
|
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName $patch;
|
name $patch;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -16,7 +16,7 @@ patchAverage
|
|||||||
fields (<field names>);
|
fields (<field names>);
|
||||||
|
|
||||||
operation average;
|
operation average;
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/patchSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/patch.cfg"
|
||||||
|
|
||||||
log true;
|
log true;
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ patchIntegrate
|
|||||||
fields (<field names>);
|
fields (<field names>);
|
||||||
|
|
||||||
operation areaIntegrate;
|
operation areaIntegrate;
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/patchSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/patch.cfg"
|
||||||
|
|
||||||
log true;
|
log true;
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
@ -6,9 +6,9 @@
|
|||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#includeEtc "caseDicts/postProcessing/faceSource/faceSource.cfg"
|
#includeEtc "caseDicts/postProcessing/surfaceRegion/surfaceRegion.cfg"
|
||||||
|
|
||||||
source sampledSurface;
|
regionType sampledSurface;
|
||||||
|
|
||||||
sampledSurfaceDict
|
sampledSurfaceDict
|
||||||
{
|
{
|
||||||
@ -8,8 +8,8 @@ fieldMinMax/fieldMinMax.C
|
|||||||
fieldValues/fieldValue/fieldValue.C
|
fieldValues/fieldValue/fieldValue.C
|
||||||
fieldValues/fieldValue/fieldValueNew.C
|
fieldValues/fieldValue/fieldValueNew.C
|
||||||
fieldValues/fieldValueDelta/fieldValueDelta.C
|
fieldValues/fieldValueDelta/fieldValueDelta.C
|
||||||
fieldValues/cellSource/cellSource.C
|
fieldValues/volRegion/volRegion.C
|
||||||
fieldValues/faceSource/faceSource.C
|
fieldValues/surfaceRegion/surfaceRegion.C
|
||||||
|
|
||||||
nearWallFields/nearWallFields.C
|
nearWallFields/nearWallFields.C
|
||||||
nearWallFields/findCellParticle.C
|
nearWallFields/findCellParticle.C
|
||||||
|
|||||||
@ -48,7 +48,7 @@ functions
|
|||||||
{
|
{
|
||||||
faceObj1
|
faceObj1
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
enabled true;
|
enabled true;
|
||||||
@ -64,7 +64,7 @@ functions
|
|||||||
source patch;
|
source patch;
|
||||||
|
|
||||||
// if patch or faceZone: name of patch or faceZone
|
// if patch or faceZone: name of patch or faceZone
|
||||||
sourceName movingWall;
|
name movingWall;
|
||||||
|
|
||||||
//// if sampledSurface: dictionary with a sampledSurface
|
//// if sampledSurface: dictionary with a sampledSurface
|
||||||
//// Note: will not sample surface fields.
|
//// Note: will not sample surface fields.
|
||||||
@ -90,14 +90,14 @@ functions
|
|||||||
|
|
||||||
faceObj2
|
faceObj2
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
enabled true;
|
enabled true;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log true;
|
log true;
|
||||||
writeFields true;
|
writeFields true;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
name f0;
|
||||||
operation sum;
|
operation sum;
|
||||||
|
|
||||||
fields
|
fields
|
||||||
@ -108,14 +108,14 @@ functions
|
|||||||
|
|
||||||
cellObj1
|
cellObj1
|
||||||
{
|
{
|
||||||
type cellSource;
|
type volRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
enabled true;
|
enabled true;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log true;
|
log true;
|
||||||
writeFields true;
|
writeFields true;
|
||||||
source cellZone;
|
source cellZone;
|
||||||
sourceName c0;
|
name c0;
|
||||||
operation volAverage;
|
operation volAverage;
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|||||||
@ -51,7 +51,7 @@ Foam::functionObjects::fieldValue::fieldValue
|
|||||||
:
|
:
|
||||||
writeFiles(name, runTime, dict, name),
|
writeFiles(name, runTime, dict, name),
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
sourceName_(word::null),
|
name_(word::null),
|
||||||
resultDict_(fileName("name"), dictionary::null)
|
resultDict_(fileName("name"), dictionary::null)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
@ -69,7 +69,7 @@ Foam::functionObjects::fieldValue::fieldValue
|
|||||||
:
|
:
|
||||||
writeFiles(name, obr, dict, name),
|
writeFiles(name, obr, dict, name),
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
sourceName_(word::null),
|
name_(word::null),
|
||||||
resultDict_(fileName("name"), dictionary::null)
|
resultDict_(fileName("name"), dictionary::null)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
|
|||||||
@ -70,7 +70,7 @@ protected:
|
|||||||
dictionary dict_;
|
dictionary dict_;
|
||||||
|
|
||||||
//- Name of source object
|
//- Name of source object
|
||||||
word sourceName_;
|
word name_;
|
||||||
|
|
||||||
//- List of field names to operate on
|
//- List of field names to operate on
|
||||||
wordList fields_;
|
wordList fields_;
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
inline const dictionary& dict() const;
|
inline const dictionary& dict() const;
|
||||||
|
|
||||||
//- Return the source name
|
//- Return the source name
|
||||||
inline const word& sourceName() const;
|
inline const word& name() const;
|
||||||
|
|
||||||
//- Return the list of field names
|
//- Return the list of field names
|
||||||
inline const wordList& fields() const;
|
inline const wordList& fields() const;
|
||||||
|
|||||||
@ -34,9 +34,9 @@ inline const Foam::dictionary& Foam::functionObjects::fieldValue::dict() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::word& Foam::functionObjects::fieldValue::sourceName() const
|
inline const Foam::word& Foam::functionObjects::fieldValue::name() const
|
||||||
{
|
{
|
||||||
return sourceName_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "faceSource.H"
|
#include "surfaceRegion.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "cyclicPolyPatch.H"
|
#include "cyclicPolyPatch.H"
|
||||||
#include "emptyPolyPatch.H"
|
#include "emptyPolyPatch.H"
|
||||||
@ -42,9 +42,9 @@ namespace functionObjects
|
|||||||
{
|
{
|
||||||
namespace fieldValues
|
namespace fieldValues
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(faceSource, 0);
|
defineTypeNameAndDebug(surfaceRegion, 0);
|
||||||
addToRunTimeSelectionTable(fieldValue, faceSource, dictionary);
|
addToRunTimeSelectionTable(fieldValue, surfaceRegion, dictionary);
|
||||||
addToRunTimeSelectionTable(functionObject, faceSource, dictionary);
|
addToRunTimeSelectionTable(functionObject, surfaceRegion, dictionary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ namespace fieldValues
|
|||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::faceSource::sourceType,
|
Foam::functionObjects::fieldValues::surfaceRegion::regionTypes,
|
||||||
3
|
3
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ const char* Foam::NamedEnum
|
|||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::faceSource::operationType,
|
Foam::functionObjects::fieldValues::surfaceRegion::operationType,
|
||||||
15
|
15
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
@ -87,29 +87,29 @@ const char* Foam::NamedEnum
|
|||||||
|
|
||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::faceSource::sourceType,
|
Foam::functionObjects::fieldValues::surfaceRegion::regionTypes,
|
||||||
3
|
3
|
||||||
> Foam::functionObjects::fieldValues::faceSource::sourceTypeNames_;
|
> Foam::functionObjects::fieldValues::surfaceRegion::regionTypeNames_;
|
||||||
|
|
||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::faceSource::operationType,
|
Foam::functionObjects::fieldValues::surfaceRegion::operationType,
|
||||||
15
|
15
|
||||||
> Foam::functionObjects::fieldValues::faceSource::operationTypeNames_;
|
> Foam::functionObjects::fieldValues::surfaceRegion::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::setFaceZoneFaces()
|
void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
|
||||||
{
|
{
|
||||||
label zoneId = mesh().faceZones().findZoneID(sourceName_);
|
label zoneId = mesh().faceZones().findZoneID(name_);
|
||||||
|
|
||||||
if (zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):" << nl
|
||||||
<< " Unknown face zone name: " << sourceName_
|
<< " Unknown face zone name: " << name_
|
||||||
<< ". Valid face zones are: " << mesh().faceZones().names()
|
<< ". Valid face zones are: " << mesh().faceZones().names()
|
||||||
<< nl << exit(FatalError);
|
<< nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -185,16 +185,16 @@ void Foam::functionObjects::fieldValues::faceSource::setFaceZoneFaces()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::setPatchFaces()
|
void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
|
||||||
{
|
{
|
||||||
const label patchid = mesh().boundaryMesh().findPatchID(sourceName_);
|
const label patchid = mesh().boundaryMesh().findPatchID(name_);
|
||||||
|
|
||||||
if (patchid < 0)
|
if (patchid < 0)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):" << nl
|
||||||
<< " Unknown patch name: " << sourceName_
|
<< " Unknown patch name: " << name_
|
||||||
<< ". Valid patch names are: "
|
<< ". Valid patch names are: "
|
||||||
<< mesh().boundaryMesh().names() << nl
|
<< mesh().boundaryMesh().names() << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -222,7 +222,7 @@ void Foam::functionObjects::fieldValues::faceSource::setPatchFaces()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::sampledSurfaceFaces
|
void Foam::functionObjects::fieldValues::surfaceRegion::sampledSurfaceFaces
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
@ -238,7 +238,7 @@ void Foam::functionObjects::fieldValues::faceSource::sampledSurfaceFaces
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::combineMeshGeometry
|
void Foam::functionObjects::fieldValues::surfaceRegion::combineMeshGeometry
|
||||||
(
|
(
|
||||||
faceList& faces,
|
faceList& faces,
|
||||||
pointField& points
|
pointField& points
|
||||||
@ -359,7 +359,7 @@ void Foam::functionObjects::fieldValues::faceSource::combineMeshGeometry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::combineSurfaceGeometry
|
void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
|
||||||
(
|
(
|
||||||
faceList& faces,
|
faceList& faces,
|
||||||
pointField& points
|
pointField& points
|
||||||
@ -398,7 +398,8 @@ void Foam::functionObjects::fieldValues::faceSource::combineSurfaceGeometry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::functionObjects::fieldValues::faceSource::totalArea() const
|
Foam::scalar
|
||||||
|
Foam::functionObjects::fieldValues::surfaceRegion::totalArea() const
|
||||||
{
|
{
|
||||||
scalar totalArea;
|
scalar totalArea;
|
||||||
|
|
||||||
@ -417,14 +418,14 @@ Foam::scalar Foam::functionObjects::fieldValues::faceSource::totalArea() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::initialise
|
void Foam::functionObjects::fieldValues::surfaceRegion::initialise
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
dict.lookup("sourceName") >> sourceName_;
|
dict.lookup("name") >> name_;
|
||||||
|
|
||||||
switch (source_)
|
switch (regionType_)
|
||||||
{
|
{
|
||||||
case stFaceZone:
|
case stFaceZone:
|
||||||
{
|
{
|
||||||
@ -445,9 +446,9 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):"
|
||||||
<< nl << " Unknown source type. Valid source types are:"
|
<< nl << " Unknown region type. Valid region types are:"
|
||||||
<< sourceTypeNames_.sortedToc() << nl << exit(FatalError);
|
<< regionTypeNames_.sortedToc() << nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,8 +456,8 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):" << nl
|
||||||
<< " Source has no faces" << exit(FatalError);
|
<< " Region has no faces" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surfacePtr_.valid())
|
if (surfacePtr_.valid())
|
||||||
@ -476,7 +477,7 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
|||||||
{
|
{
|
||||||
Info<< " weight field = " << weightFieldName_ << nl;
|
Info<< " weight field = " << weightFieldName_ << nl;
|
||||||
|
|
||||||
if (source_ == stSampledSurface)
|
if (regionType_ == stSampledSurface)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "Cannot use weightField for a sampledSurface"
|
<< "Cannot use weightField for a sampledSurface"
|
||||||
@ -532,13 +533,13 @@ void Foam::functionObjects::fieldValues::faceSource::initialise
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::faceSource::writeFileHeader
|
void Foam::functionObjects::fieldValues::surfaceRegion::writeFileHeader
|
||||||
(
|
(
|
||||||
const label i
|
const label i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
writeCommented(file(), "Source : ");
|
writeCommented(file(), "Region type : ");
|
||||||
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
file() << regionTypeNames_[regionType_] << " " << name_ << endl;
|
||||||
writeCommented(file(), "Faces : ");
|
writeCommented(file(), "Faces : ");
|
||||||
file() << nFaces_ << endl;
|
file() << nFaces_ << endl;
|
||||||
writeCommented(file(), "Area : ");
|
writeCommented(file(), "Area : ");
|
||||||
@ -562,7 +563,7 @@ void Foam::functionObjects::fieldValues::faceSource::writeFileHeader
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
Foam::scalar Foam::functionObjects::fieldValues::faceSource::processValues
|
Foam::scalar Foam::functionObjects::fieldValues::surfaceRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<scalar>& values,
|
const Field<scalar>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -593,7 +594,7 @@ Foam::scalar Foam::functionObjects::fieldValues::faceSource::processValues
|
|||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
Foam::vector Foam::functionObjects::fieldValues::faceSource::processValues
|
Foam::vector Foam::functionObjects::fieldValues::surfaceRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<vector>& values,
|
const Field<vector>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -639,7 +640,7 @@ Foam::vector Foam::functionObjects::fieldValues::faceSource::processValues
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::faceSource::faceSource
|
Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
@ -648,7 +649,7 @@ Foam::functionObjects::fieldValues::faceSource::faceSource
|
|||||||
:
|
:
|
||||||
fieldValue(name, runTime, dict, typeName),
|
fieldValue(name, runTime, dict, typeName),
|
||||||
surfaceWriterPtr_(NULL),
|
surfaceWriterPtr_(NULL),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
weightFieldName_("none"),
|
weightFieldName_("none"),
|
||||||
orientWeightField_(false),
|
orientWeightField_(false),
|
||||||
@ -669,7 +670,7 @@ Foam::functionObjects::fieldValues::faceSource::faceSource
|
|||||||
read(dict);
|
read(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::faceSource::faceSource
|
Foam::functionObjects::fieldValues::surfaceRegion::surfaceRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
@ -678,7 +679,7 @@ Foam::functionObjects::fieldValues::faceSource::faceSource
|
|||||||
:
|
:
|
||||||
fieldValue(name, obr, dict, typeName),
|
fieldValue(name, obr, dict, typeName),
|
||||||
surfaceWriterPtr_(NULL),
|
surfaceWriterPtr_(NULL),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
weightFieldName_("none"),
|
weightFieldName_("none"),
|
||||||
orientWeightField_(false),
|
orientWeightField_(false),
|
||||||
@ -702,13 +703,13 @@ Foam::functionObjects::fieldValues::faceSource::faceSource
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::faceSource::~faceSource()
|
Foam::functionObjects::fieldValues::surfaceRegion::~surfaceRegion()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldValues::faceSource::read
|
bool Foam::functionObjects::fieldValues::surfaceRegion::read
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
@ -720,7 +721,7 @@ bool Foam::functionObjects::fieldValues::faceSource::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldValues::faceSource::write
|
bool Foam::functionObjects::fieldValues::surfaceRegion::write
|
||||||
(
|
(
|
||||||
const bool postProcess
|
const bool postProcess
|
||||||
)
|
)
|
||||||
@ -22,13 +22,13 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::functionObjects::fieldValues::faceSource
|
Foam::functionObjects::fieldValues::surfaceRegion
|
||||||
|
|
||||||
Group
|
Group
|
||||||
grpFieldFunctionObjects
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
Description
|
Description
|
||||||
This function object provides a 'face source' variant of the fieldValues
|
This function object provides a 'face regionType' variant of the fieldValues
|
||||||
function object. Given a list of user-specified fields and a selection
|
function object. Given a list of user-specified fields and a selection
|
||||||
of mesh (or general surface) faces, a number of operations can be
|
of mesh (or general surface) faces, a number of operations can be
|
||||||
performed, such as sums, averages and integrations.
|
performed, such as sums, averages and integrations.
|
||||||
@ -39,16 +39,16 @@ Description
|
|||||||
|
|
||||||
Example of function object specification:
|
Example of function object specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
faceSource1
|
surfaceRegion1
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
...
|
...
|
||||||
log yes;
|
log yes;
|
||||||
writeFields true;
|
writeFields true;
|
||||||
surfaceFormat none;
|
surfaceFormat none;
|
||||||
source faceZone;
|
regionType faceZone;
|
||||||
sourceName f0;
|
name f0;
|
||||||
operation sum;
|
operation sum;
|
||||||
weightField alpha1;
|
weightField alpha1;
|
||||||
fields
|
fields
|
||||||
@ -63,13 +63,13 @@ Description
|
|||||||
\heading Function object usage
|
\heading Function object usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | type name: faceSource | yes |
|
type | type name: surfaceRegion | yes |
|
||||||
log | write data to standard output | no | no
|
log | write data to standard output | no | no
|
||||||
writeFields | write the output values | yes |
|
writeFields | write the output values | yes |
|
||||||
writeArea | Write the area of the faceSource | no |
|
writeArea | Write the area of the surfaceRegion | no |
|
||||||
surfaceFormat | output value format | no |
|
surfaceFormat | output value format | no |
|
||||||
source | face source: see below | yes |
|
regionType | face regionType: see below | yes |
|
||||||
sourceName | name of face source if required | no |
|
name | name of face regionType if required | no |
|
||||||
operation | operation to perform | yes |
|
operation | operation to perform | yes |
|
||||||
weightField | name of field to apply weighting | no |
|
weightField | name of field to apply weighting | no |
|
||||||
orientedWeightField | name of oriented field to apply weighting | no |
|
orientedWeightField | name of oriented field to apply weighting | no |
|
||||||
@ -79,10 +79,10 @@ Description
|
|||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
\linebreak
|
\linebreak
|
||||||
Where \c source is defined by
|
Where \c regionType is defined by
|
||||||
\plaintable
|
\plaintable
|
||||||
faceZone | requires a 'sourceName' entry to specify the faceZone
|
faceZone | requires a 'name' entry to specify the faceZone
|
||||||
patch | requires a 'sourceName' entry to specify the patch
|
patch | requires a 'name' entry to specify the patch
|
||||||
sampledSurface | requires a 'sampledSurfaceDict' sub-dictionary
|
sampledSurface | requires a 'sampledSurfaceDict' sub-dictionary
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
@ -130,13 +130,13 @@ SeeAlso
|
|||||||
Foam::functionObject
|
Foam::functionObject
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
faceSource.C
|
surfaceRegion.C
|
||||||
faceSourceTemplates.C
|
surfaceRegionTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_faceSource_H
|
#ifndef functionObjects_surfaceRegion_H
|
||||||
#define functionObjects_faceSource_H
|
#define functionObjects_surfaceRegion_H
|
||||||
|
|
||||||
#include "fieldValue.H"
|
#include "fieldValue.H"
|
||||||
#include "NamedEnum.H"
|
#include "NamedEnum.H"
|
||||||
@ -155,10 +155,10 @@ namespace fieldValues
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class faceSource Declaration
|
Class surfaceRegion Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class faceSource
|
class surfaceRegion
|
||||||
:
|
:
|
||||||
public fieldValue
|
public fieldValue
|
||||||
{
|
{
|
||||||
@ -167,16 +167,16 @@ public:
|
|||||||
|
|
||||||
// Public data types
|
// Public data types
|
||||||
|
|
||||||
//- Source type enumeration
|
//- region type enumeration
|
||||||
enum sourceType
|
enum regionTypes
|
||||||
{
|
{
|
||||||
stFaceZone,
|
stFaceZone,
|
||||||
stPatch,
|
stPatch,
|
||||||
stSampledSurface
|
stSampledSurface
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Source type names
|
//- region type names
|
||||||
static const NamedEnum<sourceType, 3> sourceTypeNames_;
|
static const NamedEnum<regionTypes, 3> regionTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
//- Operation type enumeration
|
//- Operation type enumeration
|
||||||
@ -230,7 +230,7 @@ private:
|
|||||||
pointField& points
|
pointField& points
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Calculate and return total area of the faceSource: sum(magSf)
|
//- Calculate and return total area of the surfaceRegion: sum(magSf)
|
||||||
scalar totalArea() const;
|
scalar totalArea() const;
|
||||||
|
|
||||||
|
|
||||||
@ -241,8 +241,8 @@ protected:
|
|||||||
//- Surface writer
|
//- Surface writer
|
||||||
autoPtr<surfaceWriter> surfaceWriterPtr_;
|
autoPtr<surfaceWriter> surfaceWriterPtr_;
|
||||||
|
|
||||||
//- Source type
|
//- region type
|
||||||
sourceType source_;
|
regionTypes regionType_;
|
||||||
|
|
||||||
//- Operation to apply to values
|
//- Operation to apply to values
|
||||||
operationType operation_;
|
operationType operation_;
|
||||||
@ -259,10 +259,10 @@ protected:
|
|||||||
//- Scale factor - optional
|
//- Scale factor - optional
|
||||||
scalar scaleFactor_;
|
scalar scaleFactor_;
|
||||||
|
|
||||||
//- Total area of the faceSource
|
//- Total area of the surfaceRegion
|
||||||
scalar totalArea_;
|
scalar totalArea_;
|
||||||
|
|
||||||
//- Optionally write the area of the faceSource
|
//- Optionally write the area of the surfaceRegion
|
||||||
bool writeArea_;
|
bool writeArea_;
|
||||||
|
|
||||||
//- Global number of faces
|
//- Global number of faces
|
||||||
@ -333,13 +333,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Run-time type information
|
//- Run-time type information
|
||||||
TypeName("faceSource");
|
TypeName("surfaceRegion");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from name, Time and dictionary
|
//- Construct from name, Time and dictionary
|
||||||
faceSource
|
surfaceRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
@ -347,7 +347,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from name, objectRegistry and dictionary
|
//- Construct from name, objectRegistry and dictionary
|
||||||
faceSource
|
surfaceRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
@ -356,13 +356,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~faceSource();
|
virtual ~surfaceRegion();
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|
||||||
//- Return the source type
|
//- Return the region type
|
||||||
inline const sourceType& source() const;
|
inline const regionTypes& regionType() const;
|
||||||
|
|
||||||
//- Return the local list of face IDs
|
//- Return the local list of face IDs
|
||||||
inline const labelList& faceId() const;
|
inline const labelList& faceId() const;
|
||||||
@ -408,7 +408,7 @@ public:
|
|||||||
|
|
||||||
//- Specialisation for scalar
|
//- Specialisation for scalar
|
||||||
template<>
|
template<>
|
||||||
scalar faceSource::processValues
|
scalar surfaceRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<scalar>& values,
|
const Field<scalar>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -418,7 +418,7 @@ scalar faceSource::processValues
|
|||||||
|
|
||||||
//- Specialisation for vector
|
//- Specialisation for vector
|
||||||
template<>
|
template<>
|
||||||
vector faceSource::processValues
|
vector surfaceRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<vector>& values,
|
const Field<vector>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -434,12 +434,12 @@ vector faceSource::processValues
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "faceSourceI.H"
|
#include "surfaceRegionI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "faceSourceTemplates.C"
|
#include "surfaceRegionTemplates.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -23,33 +23,33 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "faceSource.H"
|
#include "surfaceRegion.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline const Foam::functionObjects::fieldValues::faceSource::sourceType&
|
inline const Foam::functionObjects::fieldValues::surfaceRegion::regionTypes&
|
||||||
Foam::functionObjects::fieldValues::faceSource::source() const
|
Foam::functionObjects::fieldValues::surfaceRegion::regionType() const
|
||||||
{
|
{
|
||||||
return source_;
|
return regionType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelList&
|
inline const Foam::labelList&
|
||||||
Foam::functionObjects::fieldValues::faceSource::faceId() const
|
Foam::functionObjects::fieldValues::surfaceRegion::faceId() const
|
||||||
{
|
{
|
||||||
return faceId_;
|
return faceId_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelList&
|
inline const Foam::labelList&
|
||||||
Foam::functionObjects::fieldValues::faceSource::facePatch() const
|
Foam::functionObjects::fieldValues::surfaceRegion::facePatch() const
|
||||||
{
|
{
|
||||||
return facePatchId_;
|
return facePatchId_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelList&
|
inline const Foam::labelList&
|
||||||
Foam::functionObjects::fieldValues::faceSource::faceSign() const
|
Foam::functionObjects::fieldValues::surfaceRegion::faceSign() const
|
||||||
{
|
{
|
||||||
return faceSign_;
|
return faceSign_;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "faceSource.H"
|
#include "surfaceRegion.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "sampledSurface.H"
|
#include "sampledSurface.H"
|
||||||
@ -33,7 +33,7 @@ License
|
|||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::functionObjects::fieldValues::faceSource::validField
|
bool Foam::functionObjects::fieldValues::surfaceRegion::validField
|
||||||
(
|
(
|
||||||
const word& fieldName
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
@ -41,7 +41,7 @@ bool Foam::functionObjects::fieldValues::faceSource::validField
|
|||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||||
|
|
||||||
if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ bool Foam::functionObjects::fieldValues::faceSource::validField
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::faceSource::getFieldValues
|
Foam::functionObjects::fieldValues::surfaceRegion::getFieldValues
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const bool mustGet,
|
const bool mustGet,
|
||||||
@ -66,7 +66,7 @@ Foam::functionObjects::fieldValues::faceSource::getFieldValues
|
|||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||||
|
|
||||||
if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
|
||||||
{
|
{
|
||||||
return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
|
return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ Foam::functionObjects::fieldValues::faceSource::getFieldValues
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::functionObjects::fieldValues::faceSource::processSameTypeValues
|
Type Foam::functionObjects::fieldValues::surfaceRegion::processSameTypeValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -254,7 +254,7 @@ Type Foam::functionObjects::fieldValues::faceSource::processSameTypeValues
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::functionObjects::fieldValues::faceSource::processValues
|
Type Foam::functionObjects::fieldValues::surfaceRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const vectorField& Sf,
|
const vectorField& Sf,
|
||||||
@ -269,7 +269,7 @@ Type Foam::functionObjects::fieldValues::faceSource::processValues
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::functionObjects::fieldValues::faceSource::writeValues
|
bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const scalarField& weightField,
|
const scalarField& weightField,
|
||||||
@ -321,7 +321,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues
|
|||||||
surfaceWriterPtr_->write
|
surfaceWriterPtr_->write
|
||||||
(
|
(
|
||||||
outputDir,
|
outputDir,
|
||||||
word(sourceTypeNames_[source_]) + "_" + sourceName_,
|
word(regionTypeNames_[regionType_]) + "_" + name_,
|
||||||
points,
|
points,
|
||||||
faces,
|
faces,
|
||||||
fieldName,
|
fieldName,
|
||||||
@ -345,7 +345,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues
|
|||||||
file()<< tab << result;
|
file()<< tab << result;
|
||||||
|
|
||||||
Log << " " << operationTypeNames_[operation_]
|
Log << " " << operationTypeNames_[operation_]
|
||||||
<< "(" << sourceName_ << ") of " << fieldName
|
<< "(" << name_ << ") of " << fieldName
|
||||||
<< " = " << result << endl;
|
<< " = " << result << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ bool Foam::functionObjects::fieldValues::faceSource::writeValues
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::faceSource::filterField
|
Foam::functionObjects::fieldValues::surfaceRegion::filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||||
const bool applyOrientation
|
const bool applyOrientation
|
||||||
@ -377,7 +377,7 @@ Foam::functionObjects::fieldValues::faceSource::filterField
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):"
|
||||||
<< nl
|
<< nl
|
||||||
<< " Unable to process internal faces for volume field "
|
<< " Unable to process internal faces for volume field "
|
||||||
<< field.name() << nl << abort(FatalError);
|
<< field.name() << nl << abort(FatalError);
|
||||||
@ -398,7 +398,7 @@ Foam::functionObjects::fieldValues::faceSource::filterField
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::faceSource::filterField
|
Foam::functionObjects::fieldValues::surfaceRegion::filterField
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
|
||||||
const bool applyOrientation
|
const bool applyOrientation
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "cellSource.H"
|
#include "volRegion.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
@ -36,9 +36,9 @@ namespace functionObjects
|
|||||||
{
|
{
|
||||||
namespace fieldValues
|
namespace fieldValues
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(cellSource, 0);
|
defineTypeNameAndDebug(volRegion, 0);
|
||||||
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary);
|
addToRunTimeSelectionTable(fieldValue, volRegion, dictionary);
|
||||||
addToRunTimeSelectionTable(functionObject, cellSource, dictionary);
|
addToRunTimeSelectionTable(functionObject, volRegion, dictionary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ template<>
|
|||||||
const char*
|
const char*
|
||||||
Foam::NamedEnum
|
Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::cellSource::sourceType,
|
Foam::functionObjects::fieldValues::volRegion::regionTypes,
|
||||||
2
|
2
|
||||||
>::names[] = {"cellZone", "all"};
|
>::names[] = {"cellZone", "all"};
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ template<>
|
|||||||
const char*
|
const char*
|
||||||
Foam::NamedEnum
|
Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::cellSource::operationType,
|
Foam::functionObjects::fieldValues::volRegion::operationType,
|
||||||
11
|
11
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
@ -74,33 +74,33 @@ Foam::NamedEnum
|
|||||||
|
|
||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::cellSource::sourceType,
|
Foam::functionObjects::fieldValues::volRegion::regionTypes,
|
||||||
2
|
2
|
||||||
> Foam::functionObjects::fieldValues::cellSource::sourceTypeNames_;
|
> Foam::functionObjects::fieldValues::volRegion::regionTypeNames_;
|
||||||
|
|
||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::fieldValues::cellSource::operationType,
|
Foam::functionObjects::fieldValues::volRegion::operationType,
|
||||||
11
|
11
|
||||||
> Foam::functionObjects::fieldValues::cellSource::operationTypeNames_;
|
> Foam::functionObjects::fieldValues::volRegion::operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::cellSource::setCellZoneCells()
|
void Foam::functionObjects::fieldValues::volRegion::setCellZoneCells()
|
||||||
{
|
{
|
||||||
switch (source_)
|
switch (regionType_)
|
||||||
{
|
{
|
||||||
case stCellZone:
|
case stCellZone:
|
||||||
{
|
{
|
||||||
dict().lookup("sourceName") >> sourceName_;
|
dict().lookup("name") >> name_;
|
||||||
|
|
||||||
label zoneId = mesh().cellZones().findZoneID(sourceName_);
|
label zoneId = mesh().cellZones().findZoneID(name_);
|
||||||
|
|
||||||
if (zoneId < 0)
|
if (zoneId < 0)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unknown cell zone name: " << sourceName_
|
<< "Unknown cell zone name: " << name_
|
||||||
<< ". Valid cell zones are: " << mesh().cellZones().names()
|
<< ". Valid cell zones are: " << mesh().cellZones().names()
|
||||||
<< nl << exit(FatalError);
|
<< nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -120,19 +120,19 @@ void Foam::functionObjects::fieldValues::cellSource::setCellZoneCells()
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unknown source type. Valid source types are:"
|
<< "Unknown region type. Valid region types are:"
|
||||||
<< sourceTypeNames_ << nl << exit(FatalError);
|
<< regionTypeNames_ << nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Selected source size = " << cellId_.size() << endl;
|
Pout<< "Selected region size = " << cellId_.size() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::functionObjects::fieldValues::cellSource::volume() const
|
Foam::scalar Foam::functionObjects::fieldValues::volRegion::volume() const
|
||||||
{
|
{
|
||||||
return gSum(filterField(mesh().V()));
|
return gSum(filterField(mesh().V()));
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ Foam::scalar Foam::functionObjects::fieldValues::cellSource::volume() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::cellSource::initialise
|
void Foam::functionObjects::fieldValues::volRegion::initialise
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
@ -151,14 +151,14 @@ void Foam::functionObjects::fieldValues::cellSource::initialise
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< type() << " " << name() << ": "
|
<< type() << " " << name() << ": "
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):" << nl
|
||||||
<< " Source has no cells" << exit(FatalError);
|
<< " Region has no cells" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_ = volume();
|
volume_ = volume();
|
||||||
|
|
||||||
Info<< type() << " " << name() << ":"
|
Info<< type() << " " << name() << ":"
|
||||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
<< regionTypeNames_[regionType_] << "(" << name_ << "):" << nl
|
||||||
<< " total cells = " << nCells_ << nl
|
<< " total cells = " << nCells_ << nl
|
||||||
<< " total volume = " << volume_
|
<< " total volume = " << volume_
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
@ -172,13 +172,13 @@ void Foam::functionObjects::fieldValues::cellSource::initialise
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::fieldValues::cellSource::writeFileHeader
|
void Foam::functionObjects::fieldValues::volRegion::writeFileHeader
|
||||||
(
|
(
|
||||||
const label i
|
const label i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
writeCommented(file(), "Source : ");
|
writeCommented(file(), "Region type : ");
|
||||||
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
file() << regionTypeNames_[regionType_] << " " << name_ << endl;
|
||||||
writeCommented(file(), "Cells : ");
|
writeCommented(file(), "Cells : ");
|
||||||
file() << nCells_ << endl;
|
file() << nCells_ << endl;
|
||||||
writeCommented(file(), "Volume : ");
|
writeCommented(file(), "Volume : ");
|
||||||
@ -203,7 +203,7 @@ void Foam::functionObjects::fieldValues::cellSource::writeFileHeader
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::cellSource::cellSource
|
Foam::functionObjects::fieldValues::volRegion::volRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
@ -211,7 +211,7 @@ Foam::functionObjects::fieldValues::cellSource::cellSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fieldValue(name, runTime, dict, typeName),
|
fieldValue(name, runTime, dict, typeName),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
nCells_(0),
|
nCells_(0),
|
||||||
cellId_(),
|
cellId_(),
|
||||||
@ -228,7 +228,7 @@ Foam::functionObjects::fieldValues::cellSource::cellSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::cellSource::cellSource
|
Foam::functionObjects::fieldValues::volRegion::volRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
@ -236,7 +236,7 @@ Foam::functionObjects::fieldValues::cellSource::cellSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fieldValue(name, obr, dict, typeName),
|
fieldValue(name, obr, dict, typeName),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
regionType_(regionTypeNames_.read(dict.lookup("regionType"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
nCells_(0),
|
nCells_(0),
|
||||||
cellId_(),
|
cellId_(),
|
||||||
@ -255,13 +255,13 @@ Foam::functionObjects::fieldValues::cellSource::cellSource
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::fieldValues::cellSource::~cellSource()
|
Foam::functionObjects::fieldValues::volRegion::~volRegion()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldValues::cellSource::read
|
bool Foam::functionObjects::fieldValues::volRegion::read
|
||||||
(
|
(
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
@ -275,7 +275,7 @@ bool Foam::functionObjects::fieldValues::cellSource::read
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldValues::cellSource::write
|
bool Foam::functionObjects::fieldValues::volRegion::write
|
||||||
(
|
(
|
||||||
const bool postProcess
|
const bool postProcess
|
||||||
)
|
)
|
||||||
@ -22,13 +22,13 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::functionObjects::fieldValues::cellSource
|
Foam::functionObjects::fieldValues::volRegion
|
||||||
|
|
||||||
Group
|
Group
|
||||||
grpFieldFunctionObjects
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
Description
|
Description
|
||||||
This function object provides a 'cell source' variant of the fieldValues
|
This function object provides a 'cell region' variant of the fieldValues
|
||||||
function object. Given a list of user-specified fields and a selection
|
function object. Given a list of user-specified fields and a selection
|
||||||
of mesh cells, a number of operations can be performed, such as sums,
|
of mesh cells, a number of operations can be performed, such as sums,
|
||||||
averages and integrations.
|
averages and integrations.
|
||||||
@ -36,15 +36,15 @@ Description
|
|||||||
|
|
||||||
Example of function object specification:
|
Example of function object specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
cellSource1
|
volRegion1
|
||||||
{
|
{
|
||||||
type cellSource;
|
type volRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
...
|
...
|
||||||
log true;
|
log true;
|
||||||
writeFields true;
|
writeFields true;
|
||||||
source cellZone;
|
regionType cellZone;
|
||||||
sourceName c0;
|
name c0;
|
||||||
operation volAverage;
|
operation volAverage;
|
||||||
weightField alpha1;
|
weightField alpha1;
|
||||||
fields
|
fields
|
||||||
@ -58,21 +58,21 @@ Description
|
|||||||
\heading Function object usage
|
\heading Function object usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
type | Type name: cellSource | yes |
|
type | Type name: volRegion | yes |
|
||||||
log | Write data to standard output | no | no
|
log | Write data to standard output | no | no
|
||||||
writeFields | Write the raw output values | yes |
|
writeFields | Write the raw output values | yes |
|
||||||
writeVolume | Write the volume of the cellSource | no |
|
writeVolume | Write the volume of the volRegion | no |
|
||||||
source | cell source: see below | yes |
|
regionType | cell regionType: see below | yes |
|
||||||
sourceName | name of cell source if required | no |
|
name | name of cell regionType if required | no |
|
||||||
operation | operation to perform | yes |
|
operation | operation to perform | yes |
|
||||||
weightField | name of field to apply weighting | no |
|
weightField | name of field to apply weighting | no |
|
||||||
fields | list of fields to operate on | yes |
|
fields | list of fields to operate on | yes |
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
\linebreak
|
\linebreak
|
||||||
Where \c source is defined by
|
Where \c regionType is defined by
|
||||||
\plaintable
|
\plaintable
|
||||||
cellZone | requires a 'sourceName' entry to specify the cellZone
|
cellZone | requires a 'name' entry to specify the cellZone
|
||||||
all | all cells
|
all | all cells
|
||||||
\endplaintable
|
\endplaintable
|
||||||
|
|
||||||
@ -97,12 +97,12 @@ SeeAlso
|
|||||||
Foam::functionObject
|
Foam::functionObject
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
cellSource.C
|
volRegion.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef functionObjects_cellSource_H
|
#ifndef functionObjects_volRegion_H
|
||||||
#define functionObjects_cellSource_H
|
#define functionObjects_volRegion_H
|
||||||
|
|
||||||
#include "fieldValue.H"
|
#include "fieldValue.H"
|
||||||
#include "NamedEnum.H"
|
#include "NamedEnum.H"
|
||||||
@ -117,10 +117,10 @@ namespace fieldValues
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class cellSource Declaration
|
Class volRegion Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class cellSource
|
class volRegion
|
||||||
:
|
:
|
||||||
public fieldValue
|
public fieldValue
|
||||||
{
|
{
|
||||||
@ -129,15 +129,15 @@ public:
|
|||||||
|
|
||||||
// Public data types
|
// Public data types
|
||||||
|
|
||||||
//- Source type enumeration
|
//- region type enumeration
|
||||||
enum sourceType
|
enum regionTypes
|
||||||
{
|
{
|
||||||
stCellZone,
|
stCellZone,
|
||||||
stAll
|
stAll
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Source type names
|
//- region type names
|
||||||
static const NamedEnum<sourceType, 2> sourceTypeNames_;
|
static const NamedEnum<regionTypes, 2> regionTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
//- Operation type enumeration
|
//- Operation type enumeration
|
||||||
@ -170,7 +170,7 @@ private:
|
|||||||
//- Set cells to evaluate based on a patch
|
//- Set cells to evaluate based on a patch
|
||||||
void setPatchCells();
|
void setPatchCells();
|
||||||
|
|
||||||
//- Calculate and return volume of the cellSource: sum(V)
|
//- Calculate and return volume of the volRegion: sum(V)
|
||||||
scalar volume() const;
|
scalar volume() const;
|
||||||
|
|
||||||
|
|
||||||
@ -178,8 +178,8 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Source type
|
//- region type
|
||||||
sourceType source_;
|
regionTypes regionType_;
|
||||||
|
|
||||||
//- Operation to apply to values
|
//- Operation to apply to values
|
||||||
operationType operation_;
|
operationType operation_;
|
||||||
@ -193,10 +193,10 @@ protected:
|
|||||||
//- Weight field name - only used for opWeightedAverage mode
|
//- Weight field name - only used for opWeightedAverage mode
|
||||||
word weightFieldName_;
|
word weightFieldName_;
|
||||||
|
|
||||||
//- Volume of the cellSource
|
//- Volume of the volRegion
|
||||||
scalar volume_;
|
scalar volume_;
|
||||||
|
|
||||||
//- Optionally write the volume of the cellSource
|
//- Optionally write the volume of the volRegion
|
||||||
bool writeVolume_;
|
bool writeVolume_;
|
||||||
|
|
||||||
|
|
||||||
@ -233,13 +233,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Run-time type information
|
//- Run-time type information
|
||||||
TypeName("cellSource");
|
TypeName("volRegion");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from name, Time and dictionary
|
//- Construct from name, Time and dictionary
|
||||||
cellSource
|
volRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Time& runTime,
|
const Time& runTime,
|
||||||
@ -247,7 +247,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from name, objectRegistry and dictionary
|
//- Construct from name, objectRegistry and dictionary
|
||||||
cellSource
|
volRegion
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const objectRegistry& obr,
|
const objectRegistry& obr,
|
||||||
@ -256,13 +256,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~cellSource();
|
virtual ~volRegion();
|
||||||
|
|
||||||
|
|
||||||
// Public Member Functions
|
// Public Member Functions
|
||||||
|
|
||||||
//- Return the source type
|
//- Return the region type
|
||||||
inline const sourceType& source() const;
|
inline const regionTypes& regionType() const;
|
||||||
|
|
||||||
//- Return the local list of cell IDs
|
//- Return the local list of cell IDs
|
||||||
inline const labelList& cellId() const;
|
inline const labelList& cellId() const;
|
||||||
@ -291,12 +291,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "cellSourceI.H"
|
#include "volRegionI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "cellSourceTemplates.C"
|
#include "volRegionTemplates.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -23,19 +23,19 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "cellSource.H"
|
#include "volRegion.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline const Foam::functionObjects::fieldValues::cellSource::sourceType&
|
inline const Foam::functionObjects::fieldValues::volRegion::regionTypes&
|
||||||
Foam::functionObjects::fieldValues::cellSource::source() const
|
Foam::functionObjects::fieldValues::volRegion::regionType() const
|
||||||
{
|
{
|
||||||
return source_;
|
return regionType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::labelList&
|
inline const Foam::labelList&
|
||||||
Foam::functionObjects::fieldValues::cellSource::cellId() const
|
Foam::functionObjects::fieldValues::volRegion::cellId() const
|
||||||
{
|
{
|
||||||
return cellId_;
|
return cellId_;
|
||||||
}
|
}
|
||||||
@ -23,13 +23,13 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "cellSource.H"
|
#include "volRegion.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::functionObjects::fieldValues::cellSource::validField
|
bool Foam::functionObjects::fieldValues::volRegion::validField
|
||||||
(
|
(
|
||||||
const word& fieldName
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
@ -47,7 +47,7 @@ bool Foam::functionObjects::fieldValues::cellSource::validField
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::cellSource::setFieldValues
|
Foam::functionObjects::fieldValues::volRegion::setFieldValues
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const bool mustGet
|
const bool mustGet
|
||||||
@ -72,7 +72,7 @@ Foam::functionObjects::fieldValues::cellSource::setFieldValues
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Type Foam::functionObjects::fieldValues::cellSource::processValues
|
Type Foam::functionObjects::fieldValues::volRegion::processValues
|
||||||
(
|
(
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const scalarField& V,
|
const scalarField& V,
|
||||||
@ -155,7 +155,7 @@ Type Foam::functionObjects::fieldValues::cellSource::processValues
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool Foam::functionObjects::fieldValues::cellSource::writeValues
|
bool Foam::functionObjects::fieldValues::volRegion::writeValues
|
||||||
(
|
(
|
||||||
const word& fieldName
|
const word& fieldName
|
||||||
)
|
)
|
||||||
@ -191,8 +191,8 @@ bool Foam::functionObjects::fieldValues::cellSource::writeValues
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName + "_" + sourceTypeNames_[source_] + "-"
|
fieldName + "_" + regionTypeNames_[regionType_] + "-"
|
||||||
+ sourceName_,
|
+ name_,
|
||||||
obr_.time().timeName(),
|
obr_.time().timeName(),
|
||||||
obr_,
|
obr_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -206,7 +206,7 @@ bool Foam::functionObjects::fieldValues::cellSource::writeValues
|
|||||||
file()<< tab << result;
|
file()<< tab << result;
|
||||||
|
|
||||||
Log << " " << operationTypeNames_[operation_]
|
Log << " " << operationTypeNames_[operation_]
|
||||||
<< "(" << sourceName_ << ") of " << fieldName
|
<< "(" << name_ << ") of " << fieldName
|
||||||
<< " = " << result << endl;
|
<< " = " << result << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ bool Foam::functionObjects::fieldValues::cellSource::writeValues
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>>
|
Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::functionObjects::fieldValues::cellSource::filterField
|
Foam::functionObjects::fieldValues::volRegion::filterField
|
||||||
(
|
(
|
||||||
const Field<Type>& field
|
const Field<Type>& field
|
||||||
) const
|
) const
|
||||||
@ -32,7 +32,7 @@ functions
|
|||||||
|
|
||||||
faceObj2
|
faceObj2
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
enabled true;
|
enabled true;
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
@ -40,7 +40,7 @@ functions
|
|||||||
log true;
|
log true;
|
||||||
writeFields true;
|
writeFields true;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
name f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "boundaryToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(boundaryToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boundaryToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::boundaryToFace::usage_
|
||||||
|
(
|
||||||
|
boundaryToFace::typeName,
|
||||||
|
"\n Usage: boundaryToFace\n\n"
|
||||||
|
" Select all boundary faces\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boundaryToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
for
|
||||||
|
(
|
||||||
|
label facei = mesh().nInternalFaces();
|
||||||
|
facei < mesh().nFaces();
|
||||||
|
facei++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh, const dictionary&)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::boundaryToFace::boundaryToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boundaryToFace::~boundaryToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boundaryToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all boundary faces ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all boundary faces ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,117 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::boundaryToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select all external (boundary) faces.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
boundaryToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef boundaryToFace_H
|
||||||
|
#define boundaryToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class boundaryToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class boundaryToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("boundaryToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
boundaryToFace(const polyMesh&);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
boundaryToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
boundaryToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~boundaryToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
145
src/meshTools/sets/surfaceRegions/boxToFace/boxToFace.C
Normal file
145
src/meshTools/sets/surfaceRegions/boxToFace/boxToFace.C
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "boxToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(boxToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::boxToFace::usage_
|
||||||
|
(
|
||||||
|
boxToFace::typeName,
|
||||||
|
"\n Usage: boxToFace ((minx miny minz) (maxx maxy maxz))\n\n"
|
||||||
|
" Select all face with faceCentre within bounding box\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boxToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const pointField& ctrs = mesh_.faceCentres();
|
||||||
|
|
||||||
|
forAll(ctrs, facei)
|
||||||
|
{
|
||||||
|
forAll(bbs_, i)
|
||||||
|
{
|
||||||
|
if (bbs_[i].contains(ctrs[facei]))
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::boxToFace::boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const treeBoundBoxList& bbs
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_(bbs)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::boxToFace::boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_
|
||||||
|
(
|
||||||
|
dict.found("box")
|
||||||
|
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
|
||||||
|
: dict.lookup("boxes")
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::boxToFace::boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_(1, treeBoundBox(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boxToFace::~boxToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boxToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding faces with centre within boxes " << bbs_ << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing faces with centre within boxes " << bbs_ << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
126
src/meshTools/sets/surfaceRegions/boxToFace/boxToFace.H
Normal file
126
src/meshTools/sets/surfaceRegions/boxToFace/boxToFace.H
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::boxToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on face centres inside box.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
boxToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef boxToFace_H
|
||||||
|
#define boxToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "treeBoundBoxList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class boxToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class boxToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Bounding box.
|
||||||
|
treeBoundBoxList bbs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("boxToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const treeBoundBoxList& bbs
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
boxToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~boxToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
228
src/meshTools/sets/surfaceRegions/cellToFace/cellToFace.C
Normal file
228
src/meshTools/sets/surfaceRegions/cellToFace/cellToFace.C
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "syncTools.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellToFace, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cellToFace, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cellToFace, istream);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::cellToFace::cellAction,
|
||||||
|
2
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"all",
|
||||||
|
"both"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_
|
||||||
|
(
|
||||||
|
cellToFace::typeName,
|
||||||
|
"\n Usage: cellToFace <cellSet> all|both\n\n"
|
||||||
|
" Select -all : all faces of cells in the cellSet\n"
|
||||||
|
" -both: faces where both neighbours are in the cellSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::cellToFace::cellAction, 2>
|
||||||
|
Foam::cellToFace::cellActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cellToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Load the set
|
||||||
|
if (!exists(mesh_.time().path()/topoSet::localPath(mesh_, setName_)))
|
||||||
|
{
|
||||||
|
SeriousError<< "Cannot load set "
|
||||||
|
<< setName_ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cellSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
if (option_ == ALL)
|
||||||
|
{
|
||||||
|
// Add all faces from cell
|
||||||
|
forAllConstIter(cellSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label celli = iter.key();
|
||||||
|
const labelList& cFaces = mesh_.cells()[celli];
|
||||||
|
|
||||||
|
forAll(cFaces, cFacei)
|
||||||
|
{
|
||||||
|
addOrDelete(set, cFaces[cFacei], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (option_ == BOTH)
|
||||||
|
{
|
||||||
|
// Add all faces whose both neighbours are in set.
|
||||||
|
|
||||||
|
const label nInt = mesh_.nInternalFaces();
|
||||||
|
const labelList& own = mesh_.faceOwner();
|
||||||
|
const labelList& nei = mesh_.faceNeighbour();
|
||||||
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
|
|
||||||
|
// Check all internal faces
|
||||||
|
for (label facei = 0; facei < nInt; facei++)
|
||||||
|
{
|
||||||
|
if (loadedSet.found(own[facei]) && loadedSet.found(nei[facei]))
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get coupled cell status
|
||||||
|
boolList neiInSet(mesh_.nFaces()-nInt, false);
|
||||||
|
|
||||||
|
forAll(patches, patchi)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = patches[patchi];
|
||||||
|
|
||||||
|
if (pp.coupled())
|
||||||
|
{
|
||||||
|
label facei = pp.start();
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
neiInSet[facei-nInt] = loadedSet.found(own[facei]);
|
||||||
|
facei++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syncTools::swapBoundaryFaceList(mesh_, neiInSet);
|
||||||
|
|
||||||
|
|
||||||
|
// Check all boundary faces
|
||||||
|
forAll(patches, patchi)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = patches[patchi];
|
||||||
|
|
||||||
|
if (pp.coupled())
|
||||||
|
{
|
||||||
|
label facei = pp.start();
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
if (loadedSet.found(own[facei]) && neiInSet[facei-nInt])
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
}
|
||||||
|
facei++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from componenta
|
||||||
|
Foam::cellToFace::cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const cellAction option
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
option_(option)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::cellToFace::cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set")),
|
||||||
|
option_(cellActionNames_.read(dict.lookup("option")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::cellToFace::cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
option_(cellActionNames_.read(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellToFace::~cellToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cellToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding faces according to cellSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing faces according to cellSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
145
src/meshTools/sets/surfaceRegions/cellToFace/cellToFace.H
Normal file
145
src/meshTools/sets/surfaceRegions/cellToFace/cellToFace.H
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select a faceSet from cells.
|
||||||
|
|
||||||
|
Either all faces of cell or some other criterion.
|
||||||
|
See implementation.
|
||||||
|
Note: when picking up coupled faces uses cells on neighbouring processors.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellToFace_H
|
||||||
|
#define cellToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//- Enumeration defining the valid options
|
||||||
|
enum cellAction
|
||||||
|
{
|
||||||
|
ALL,
|
||||||
|
BOTH
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
static const NamedEnum<cellAction, 2> cellActionNames_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
cellAction option_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on face to cell option add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cellToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const cellAction option
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
cellToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
129
src/meshTools/sets/surfaceRegions/faceToFace/faceToFace.C
Normal file
129
src/meshTools/sets/surfaceRegions/faceToFace/faceToFace.C
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "faceToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "faceSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(faceToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::faceToFace::usage_
|
||||||
|
(
|
||||||
|
faceToFace::typeName,
|
||||||
|
"\n Usage: faceToFace <faceSet>\n\n"
|
||||||
|
" Select all faces in the faceSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::faceToFace::faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::faceToFace::faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::faceToFace::faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::faceToFace::~faceToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::faceToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all faces from faceSet " << setName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
// Load the set
|
||||||
|
faceSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
set.addSet(loadedSet);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all faces from faceSet " << setName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
// Load the set
|
||||||
|
faceSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
set.deleteSet(loadedSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
118
src/meshTools/sets/surfaceRegions/faceToFace/faceToFace.H
Normal file
118
src/meshTools/sets/surfaceRegions/faceToFace/faceToFace.H
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::faceToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on usage in another faceSet.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
faceToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef faceToFace_H
|
||||||
|
#define faceToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class faceToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class faceToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("faceToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
faceToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~faceToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/meshTools/sets/surfaceRegions/labelToFace/labelToFace.C
Normal file
131
src/meshTools/sets/surfaceRegions/labelToFace/labelToFace.C
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "labelToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(labelToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, labelToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, labelToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::labelToFace::usage_
|
||||||
|
(
|
||||||
|
labelToFace::typeName,
|
||||||
|
"\n Usage: labelToFace (i0 i1 .. in)\n\n"
|
||||||
|
" Select faces by label\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::labelToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
forAll(labels_, labelI)
|
||||||
|
{
|
||||||
|
addOrDelete(set, labels_[labelI], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::labelToFace::labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& labels
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(labels)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::labelToFace::labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(dict.lookup("value"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::labelToFace::labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::labelToFace::~labelToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::labelToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding faces mentioned in dictionary" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing faces mentioned dictionary" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
125
src/meshTools/sets/surfaceRegions/labelToFace/labelToFace.H
Normal file
125
src/meshTools/sets/surfaceRegions/labelToFace/labelToFace.H
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::labelToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces given explicitly provided face labels.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
labelToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef labelToFace_H
|
||||||
|
#define labelToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class labelToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class labelToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Cell labels read from dictionary
|
||||||
|
labelList labels_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("labelToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& labels
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
labelToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~labelToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
171
src/meshTools/sets/surfaceRegions/normalToFace/normalToFace.C
Normal file
171
src/meshTools/sets/surfaceRegions/normalToFace/normalToFace.C
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "normalToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "faceSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(normalToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, normalToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, normalToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::normalToFace::usage_
|
||||||
|
(
|
||||||
|
normalToFace::typeName,
|
||||||
|
"\n Usage: normalToFace (nx ny nz) <tol>\n\n"
|
||||||
|
" Select faces with normal aligned to unit vector (nx ny nz)\n"
|
||||||
|
" to within tol\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::normalToFace::setNormal()
|
||||||
|
{
|
||||||
|
normal_ /= mag(normal_) + VSMALL;
|
||||||
|
|
||||||
|
Info<< " normalToFace : Normalized vector to " << normal_ << endl;
|
||||||
|
|
||||||
|
if (tol_ < -1 || tol_ > 1)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "tolerance not within range -1..1 : " << tol_
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::normalToFace::normalToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& normal,
|
||||||
|
const scalar tol
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
normal_(normal),
|
||||||
|
tol_(tol)
|
||||||
|
{
|
||||||
|
setNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
normal_(dict.lookup("normal")),
|
||||||
|
tol_(readScalar(dict.lookup("cos")))
|
||||||
|
{
|
||||||
|
setNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::normalToFace::normalToFace(const polyMesh& mesh, Istream& is)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
normal_(checkIs(is)),
|
||||||
|
tol_(readScalar(checkIs(is)))
|
||||||
|
{
|
||||||
|
setNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::normalToFace::~normalToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::normalToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding faces according to normal being aligned with "
|
||||||
|
<< normal_ << " (to within " << tol_ << ") ..." << endl;
|
||||||
|
|
||||||
|
forAll(mesh_.faceAreas(), facei)
|
||||||
|
{
|
||||||
|
vector n = mesh_.faceAreas()[facei];
|
||||||
|
n /= mag(n) + VSMALL;
|
||||||
|
|
||||||
|
if (mag(1 - (n & normal_)) < tol_)
|
||||||
|
{
|
||||||
|
set.insert(facei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing faces according to normal being aligned with "
|
||||||
|
<< normal_ << " (to within " << tol_ << ") ..." << endl;
|
||||||
|
|
||||||
|
|
||||||
|
DynamicList<label> toBeRemoved(set.size()/10);
|
||||||
|
|
||||||
|
forAllConstIter(topoSet, set, iter)
|
||||||
|
{
|
||||||
|
const label facei = iter.key();
|
||||||
|
|
||||||
|
vector n = mesh_.faceAreas()[facei];
|
||||||
|
n /= mag(n) + VSMALL;
|
||||||
|
|
||||||
|
if (mag(1 - (n & normal_)) < tol_)
|
||||||
|
{
|
||||||
|
toBeRemoved.append(facei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(toBeRemoved, i)
|
||||||
|
{
|
||||||
|
set.erase(toBeRemoved[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
123
src/meshTools/sets/surfaceRegions/normalToFace/normalToFace.H
Normal file
123
src/meshTools/sets/surfaceRegions/normalToFace/normalToFace.H
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::normalToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on normal.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
normalToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef normalToFace_H
|
||||||
|
#define normalToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class normalToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class normalToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- (unit)vector to compare to
|
||||||
|
vector normal_;
|
||||||
|
|
||||||
|
//- Tolerance (i.e. cos of angle between normal_ and faceNormal)
|
||||||
|
const scalar tol_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Normalize normal and check tolerance
|
||||||
|
void setNormal();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("normalToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
normalToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& normal,
|
||||||
|
const scalar tol
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
normalToFace(const polyMesh& mesh, const dictionary& dict);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
normalToFace(const polyMesh& mesh, Istream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~normalToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
161
src/meshTools/sets/surfaceRegions/patchToFace/patchToFace.C
Normal file
161
src/meshTools/sets/surfaceRegions/patchToFace/patchToFace.C
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "patchToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(patchToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, patchToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, patchToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_
|
||||||
|
(
|
||||||
|
patchToFace::typeName,
|
||||||
|
"\n Usage: patchToFace patch\n\n"
|
||||||
|
" Select all faces in the patch. Note:accepts wildcards for patch.\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::patchToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
labelHashSet patchIDs = mesh_.boundaryMesh().patchSet
|
||||||
|
(
|
||||||
|
List<wordRe>(1, patchName_),
|
||||||
|
true, // warn if not found
|
||||||
|
true // use patch groups if available
|
||||||
|
);
|
||||||
|
|
||||||
|
forAllConstIter(labelHashSet, patchIDs, iter)
|
||||||
|
{
|
||||||
|
label patchi = iter.key();
|
||||||
|
|
||||||
|
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
||||||
|
|
||||||
|
Info<< " Found matching patch " << pp.name()
|
||||||
|
<< " with " << pp.size() << " faces." << endl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
label facei = pp.start();
|
||||||
|
facei < pp.start() + pp.size();
|
||||||
|
facei++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchIDs.empty())
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot find any patch named " << patchName_ << endl
|
||||||
|
<< "Valid names are " << mesh_.boundaryMesh().names() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::patchToFace::patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& patchName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
patchName_(patchName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::patchToFace::patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
patchName_(dict.lookup("name"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::patchToFace::patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
patchName_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::patchToFace::~patchToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::patchToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all faces of patch " << patchName_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all faces of patch " << patchName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
126
src/meshTools/sets/surfaceRegions/patchToFace/patchToFace.H
Normal file
126
src/meshTools/sets/surfaceRegions/patchToFace/patchToFace.H
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::patchToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on usage in patches.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
patchToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef patchToFace_H
|
||||||
|
#define patchToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "wordRe.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class patchToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class patchToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name/regular expression of patch
|
||||||
|
wordRe patchName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("patchToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& patchName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
patchToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~patchToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
224
src/meshTools/sets/surfaceRegions/pointToFace/pointToFace.C
Normal file
224
src/meshTools/sets/surfaceRegions/pointToFace/pointToFace.C
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "pointToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "pointSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(pointToFace, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, pointToFace, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, pointToFace, istream);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::pointToFace::pointAction,
|
||||||
|
3
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"any",
|
||||||
|
"all",
|
||||||
|
"edge"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::pointToFace::usage_
|
||||||
|
(
|
||||||
|
pointToFace::typeName,
|
||||||
|
"\n Usage: pointToFace <pointSet> any|all|edge\n\n"
|
||||||
|
" Select faces with\n"
|
||||||
|
" -any point in the pointSet\n"
|
||||||
|
" -all points in the pointSet\n\n"
|
||||||
|
" -two consecutive points (an edge) in the pointSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::pointToFace::pointAction, 3>
|
||||||
|
Foam::pointToFace::pointActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::pointToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Load the set
|
||||||
|
pointSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
if (option_ == ANY)
|
||||||
|
{
|
||||||
|
// Add faces with any point in loadedSet
|
||||||
|
forAllConstIter(pointSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label pointi = iter.key();
|
||||||
|
const labelList& pFaces = mesh_.pointFaces()[pointi];
|
||||||
|
|
||||||
|
forAll(pFaces, pFacei)
|
||||||
|
{
|
||||||
|
addOrDelete(set, pFaces[pFacei], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (option_ == ALL)
|
||||||
|
{
|
||||||
|
// Add all faces whose points are all in set.
|
||||||
|
|
||||||
|
// Count number of points using face.
|
||||||
|
Map<label> numPoints(loadedSet.size());
|
||||||
|
|
||||||
|
forAllConstIter(pointSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label pointi = iter.key();
|
||||||
|
const labelList& pFaces = mesh_.pointFaces()[pointi];
|
||||||
|
|
||||||
|
forAll(pFaces, pFacei)
|
||||||
|
{
|
||||||
|
const label facei = pFaces[pFacei];
|
||||||
|
|
||||||
|
Map<label>::iterator fndFace = numPoints.find(facei);
|
||||||
|
|
||||||
|
if (fndFace == numPoints.end())
|
||||||
|
{
|
||||||
|
numPoints.insert(facei, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fndFace()++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Include faces that are referenced as many times as there are points
|
||||||
|
// in face -> all points of face
|
||||||
|
forAllConstIter(Map<label>, numPoints, iter)
|
||||||
|
{
|
||||||
|
const label facei = iter.key();
|
||||||
|
|
||||||
|
if (iter() == mesh_.faces()[facei].size())
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (option_ == EDGE)
|
||||||
|
{
|
||||||
|
const faceList& faces = mesh_.faces();
|
||||||
|
forAll(faces, facei)
|
||||||
|
{
|
||||||
|
const face& f = faces[facei];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
|
||||||
|
{
|
||||||
|
addOrDelete(set, facei, add);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::pointToFace::pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointAction option
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
option_(option)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::pointToFace::pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set")),
|
||||||
|
option_(pointActionNames_.read(dict.lookup("option")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::pointToFace::pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
option_(pointActionNames_.read(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::pointToFace::~pointToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::pointToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding faces according to pointSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing faces according to pointSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
144
src/meshTools/sets/surfaceRegions/pointToFace/pointToFace.H
Normal file
144
src/meshTools/sets/surfaceRegions/pointToFace/pointToFace.H
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::pointToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on use of points.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
pointToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef pointToFace_H
|
||||||
|
#define pointToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class pointToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class pointToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Enumeration defining the valid options
|
||||||
|
enum pointAction
|
||||||
|
{
|
||||||
|
ANY,
|
||||||
|
ALL,
|
||||||
|
EDGE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
static const NamedEnum<pointAction, 3> pointActionNames_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
pointAction option_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on face to cell option add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("pointToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointAction option
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
pointToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~pointToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
254
src/meshTools/sets/surfaceRegions/regionToFace/regionToFace.C
Normal file
254
src/meshTools/sets/surfaceRegions/regionToFace/regionToFace.C
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "regionToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "faceSet.H"
|
||||||
|
#include "mappedPatchBase.H"
|
||||||
|
#include "indirectPrimitivePatch.H"
|
||||||
|
#include "PatchTools.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "PatchEdgeFaceWave.H"
|
||||||
|
#include "patchEdgeFaceRegion.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(regionToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, regionToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, regionToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::regionToFace::usage_
|
||||||
|
(
|
||||||
|
regionToFace::typeName,
|
||||||
|
"\n Usage: regionToFace <faceSet> (x y z)\n\n"
|
||||||
|
" Select all faces in the connected region of the faceSet"
|
||||||
|
" starting from the point.\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::regionToFace::markZone
|
||||||
|
(
|
||||||
|
const indirectPrimitivePatch& patch,
|
||||||
|
const label proci,
|
||||||
|
const label facei,
|
||||||
|
const label zoneI,
|
||||||
|
labelList& faceZone
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Data on all edges and faces
|
||||||
|
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges());
|
||||||
|
List<patchEdgeFaceRegion> allFaceInfo(patch.size());
|
||||||
|
|
||||||
|
DynamicList<label> changedEdges;
|
||||||
|
DynamicList<patchEdgeFaceRegion> changedInfo;
|
||||||
|
|
||||||
|
if (Pstream::myProcNo() == proci)
|
||||||
|
{
|
||||||
|
const labelList& fEdges = patch.faceEdges()[facei];
|
||||||
|
forAll(fEdges, i)
|
||||||
|
{
|
||||||
|
changedEdges.append(fEdges[i]);
|
||||||
|
changedInfo.append(zoneI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk
|
||||||
|
PatchEdgeFaceWave
|
||||||
|
<
|
||||||
|
indirectPrimitivePatch,
|
||||||
|
patchEdgeFaceRegion
|
||||||
|
> calc
|
||||||
|
(
|
||||||
|
mesh_,
|
||||||
|
patch,
|
||||||
|
changedEdges,
|
||||||
|
changedInfo,
|
||||||
|
allEdgeInfo,
|
||||||
|
allFaceInfo,
|
||||||
|
returnReduce(patch.nEdges(), sumOp<label>())
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(allFaceInfo, facei)
|
||||||
|
{
|
||||||
|
if (allFaceInfo[facei].region() == zoneI)
|
||||||
|
{
|
||||||
|
faceZone[facei] = zoneI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
Info<< " Loading subset " << setName_ << " to delimit search region."
|
||||||
|
<< endl;
|
||||||
|
faceSet subSet(mesh_, setName_);
|
||||||
|
|
||||||
|
indirectPrimitivePatch patch
|
||||||
|
(
|
||||||
|
IndirectList<face>(mesh_.faces(), subSet.toc()),
|
||||||
|
mesh_.points()
|
||||||
|
);
|
||||||
|
|
||||||
|
mappedPatchBase::nearInfo ni
|
||||||
|
(
|
||||||
|
pointIndexHit(false, Zero, -1),
|
||||||
|
Tuple2<scalar, label>
|
||||||
|
(
|
||||||
|
sqr(GREAT),
|
||||||
|
Pstream::myProcNo()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(patch, i)
|
||||||
|
{
|
||||||
|
const point& fc = patch.faceCentres()[i];
|
||||||
|
scalar d2 = magSqr(fc-nearPoint_);
|
||||||
|
|
||||||
|
if (!ni.first().hit() || d2 < ni.second().first())
|
||||||
|
{
|
||||||
|
ni.second().first() = d2;
|
||||||
|
ni.first().setHit();
|
||||||
|
ni.first().setPoint(fc);
|
||||||
|
ni.first().setIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Globally reduce
|
||||||
|
combineReduce(ni, mappedPatchBase::nearestEqOp());
|
||||||
|
|
||||||
|
Info<< " Found nearest face at " << ni.first().rawPoint()
|
||||||
|
<< " on processor " << ni.second().second()
|
||||||
|
<< " face " << ni.first().index()
|
||||||
|
<< " distance " << Foam::sqrt(ni.second().first()) << endl;
|
||||||
|
|
||||||
|
labelList faceRegion(patch.size(), -1);
|
||||||
|
markZone
|
||||||
|
(
|
||||||
|
patch,
|
||||||
|
ni.second().second(), // proci
|
||||||
|
ni.first().index(), // start face
|
||||||
|
0, // currentZone
|
||||||
|
faceRegion
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(faceRegion, facei)
|
||||||
|
{
|
||||||
|
if (faceRegion[facei] == 0)
|
||||||
|
{
|
||||||
|
addOrDelete(set, patch.addressing()[facei], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::regionToFace::regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const point& nearPoint
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
nearPoint_(nearPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::regionToFace::regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set")),
|
||||||
|
nearPoint_(dict.lookup("nearPoint"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::regionToFace::regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
nearPoint_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::regionToFace::~regionToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::regionToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all faces of connected region of set "
|
||||||
|
<< setName_
|
||||||
|
<< " starting from point "
|
||||||
|
<< nearPoint_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all cells of connected region of set "
|
||||||
|
<< setName_
|
||||||
|
<< " starting from point "
|
||||||
|
<< nearPoint_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
139
src/meshTools/sets/surfaceRegions/regionToFace/regionToFace.H
Normal file
139
src/meshTools/sets/surfaceRegions/regionToFace/regionToFace.H
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::regionToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces belonging to topological connected region
|
||||||
|
(that contains given point)
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
regionToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef regionToFace_H
|
||||||
|
#define regionToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "indirectPrimitivePatch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class regionToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class regionToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
//- Coordinate that is nearest/on connected region
|
||||||
|
point nearPoint_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Walk edge-face-edge
|
||||||
|
void markZone
|
||||||
|
(
|
||||||
|
const indirectPrimitivePatch& patch,
|
||||||
|
const label proci,
|
||||||
|
const label facei,
|
||||||
|
const label zoneI,
|
||||||
|
labelList& faceZone
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("regionToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const point& nearPoint
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
regionToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~regionToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
162
src/meshTools/sets/surfaceRegions/zoneToFace/zoneToFace.C
Normal file
162
src/meshTools/sets/surfaceRegions/zoneToFace/zoneToFace.C
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "zoneToFace.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(zoneToFace, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, zoneToFace, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_
|
||||||
|
(
|
||||||
|
zoneToFace::typeName,
|
||||||
|
"\n Usage: zoneToFace zone\n\n"
|
||||||
|
" Select all faces in the faceZone."
|
||||||
|
" Note:accepts wildcards for zone.\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::zoneToFace::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
bool hasMatched = false;
|
||||||
|
|
||||||
|
forAll(mesh_.faceZones(), i)
|
||||||
|
{
|
||||||
|
const faceZone& zone = mesh_.faceZones()[i];
|
||||||
|
|
||||||
|
if (zoneName_.match(zone.name()))
|
||||||
|
{
|
||||||
|
const labelList& faceLabels = mesh_.faceZones()[i];
|
||||||
|
|
||||||
|
Info<< " Found matching zone " << zone.name()
|
||||||
|
<< " with " << faceLabels.size() << " faces." << endl;
|
||||||
|
|
||||||
|
hasMatched = true;
|
||||||
|
|
||||||
|
forAll(faceLabels, i)
|
||||||
|
{
|
||||||
|
// Only do active faces
|
||||||
|
if (faceLabels[i] < mesh_.nFaces())
|
||||||
|
{
|
||||||
|
addOrDelete(set, faceLabels[i], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasMatched)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot find any faceZone named " << zoneName_ << endl
|
||||||
|
<< "Valid names are " << mesh_.faceZones().names() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::zoneToFace::zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(zoneName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::zoneToFace::zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(dict.lookup("name"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::zoneToFace::zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::zoneToFace::~zoneToFace()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::zoneToFace::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all faces of faceZone " << zoneName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all faces of faceZone " << zoneName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
126
src/meshTools/sets/surfaceRegions/zoneToFace/zoneToFace.H
Normal file
126
src/meshTools/sets/surfaceRegions/zoneToFace/zoneToFace.H
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::zoneToFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on faceZone.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
zoneToFace.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef zoneToFace_H
|
||||||
|
#define zoneToFace_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "wordRe.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class zoneToFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class zoneToFace
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name/regular expression of cellZone
|
||||||
|
wordRe zoneName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("zoneToFace");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
zoneToFace
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~zoneToFace();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return FACESETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
144
src/meshTools/sets/volRegions/boxToCell/boxToCell.C
Normal file
144
src/meshTools/sets/volRegions/boxToCell/boxToCell.C
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "boxToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(boxToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boxToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, boxToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::boxToCell::usage_
|
||||||
|
(
|
||||||
|
boxToCell::typeName,
|
||||||
|
"\n Usage: boxToCell (minx miny minz) (maxx maxy maxz)\n\n"
|
||||||
|
" Select all cells with cellCentre within bounding box\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boxToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
forAll(bbs_, i)
|
||||||
|
{
|
||||||
|
if (bbs_[i].contains(ctrs[celli]))
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::boxToCell::boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const treeBoundBoxList& bbs
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_(bbs)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::boxToCell::boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_
|
||||||
|
(
|
||||||
|
dict.found("box")
|
||||||
|
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
|
||||||
|
: dict.lookup("boxes")
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::boxToCell::boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
bbs_(1, treeBoundBox(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boxToCell::~boxToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::boxToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with center within boxes " << bbs_ << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with center within boxes " << bbs_ << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
127
src/meshTools/sets/volRegions/boxToCell/boxToCell.H
Normal file
127
src/meshTools/sets/volRegions/boxToCell/boxToCell.H
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::boxToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell centres inside box(es).
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
boxToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef boxToCell_H
|
||||||
|
#define boxToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "treeBoundBoxList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class boxToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class boxToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Bounding box.
|
||||||
|
treeBoundBoxList bbs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("boxToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const treeBoundBoxList& bbs
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
boxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~boxToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
129
src/meshTools/sets/volRegions/cellToCell/cellToCell.C
Normal file
129
src/meshTools/sets/volRegions/cellToCell/cellToCell.C
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(cellToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cellToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cellToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::cellToCell::usage_
|
||||||
|
(
|
||||||
|
cellToCell::typeName,
|
||||||
|
"\n Usage: cellToCell <cellSet>\n\n"
|
||||||
|
" Select all cells in the cellSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::cellToCell::cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::cellToCell::cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::cellToCell::cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellToCell::~cellToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cellToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW))
|
||||||
|
{
|
||||||
|
Info<< " Adding all elements of cellSet " << setName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
// Load the set
|
||||||
|
cellSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
set.addSet(loadedSet);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all elements of cellSet " << setName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
// Load the set
|
||||||
|
cellSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
set.deleteSet(loadedSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
118
src/meshTools/sets/volRegions/cellToCell/cellToCell.H
Normal file
118
src/meshTools/sets/volRegions/cellToCell/cellToCell.H
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select the cells from another cellSet.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellToCell_H
|
||||||
|
#define cellToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cellToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
cellToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,161 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cylinderAnnulusToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cylinderAnnulusToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cylinderAnnulusToCell, istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::cylinderAnnulusToCell::usage_
|
||||||
|
(
|
||||||
|
cylinderAnnulusToCell::typeName,
|
||||||
|
"\n Usage: cylinderAnnulusToCell (p1X p1Y p1Z) (p2X p2Y p2Z)"
|
||||||
|
" outerRadius innerRadius\n\n"
|
||||||
|
" Select all cells with cell centre within bounding cylinder annulus\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cylinderAnnulusToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const vector axis = p2_ - p1_;
|
||||||
|
const scalar orad2 = sqr(outerRadius_);
|
||||||
|
const scalar irad2 = sqr(innerRadius_);
|
||||||
|
const scalar magAxis2 = magSqr(axis);
|
||||||
|
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
vector d = ctrs[celli] - p1_;
|
||||||
|
scalar magD = d & axis;
|
||||||
|
|
||||||
|
if ((magD > 0) && (magD < magAxis2))
|
||||||
|
{
|
||||||
|
scalar d2 = (d & d) - sqr(magD)/magAxis2;
|
||||||
|
if ((d2 < orad2) && (d2 > irad2))
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& p1,
|
||||||
|
const vector& p2,
|
||||||
|
const scalar outerRadius,
|
||||||
|
const scalar innerRadius
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(p1),
|
||||||
|
p2_(p2),
|
||||||
|
outerRadius_(outerRadius),
|
||||||
|
innerRadius_(innerRadius)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(dict.lookup("p1")),
|
||||||
|
p2_(dict.lookup("p2")),
|
||||||
|
outerRadius_(readScalar(dict.lookup("outerRadius"))),
|
||||||
|
innerRadius_(readScalar(dict.lookup("innerRadius")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::cylinderAnnulusToCell::cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(checkIs(is)),
|
||||||
|
p2_(checkIs(is)),
|
||||||
|
outerRadius_(readScalar(checkIs(is))),
|
||||||
|
innerRadius_(readScalar(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cylinderAnnulusToCell::~cylinderAnnulusToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cylinderAnnulusToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with centre within cylinder annulus,"
|
||||||
|
<< " with p1 = "
|
||||||
|
<< p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
|
||||||
|
<< " and inner radius = " << innerRadius_
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with centre within cylinder, with p1 = "
|
||||||
|
<< p1_ << ", p2 = " << p2_ << " and outer radius = " << outerRadius_
|
||||||
|
<< " and inner radius " << innerRadius_
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,138 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cylinderAnnulusToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell centres inside a
|
||||||
|
cylinder annulus.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cylinderAnnulusToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cylinderAnnulusToCell_H
|
||||||
|
#define cylinderAnnulusToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cylinderAnnulusToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cylinderAnnulusToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- First point on cylinder axis
|
||||||
|
vector p1_;
|
||||||
|
|
||||||
|
//- Second point on cylinder axis
|
||||||
|
vector p2_;
|
||||||
|
|
||||||
|
//- Outer Radius
|
||||||
|
scalar outerRadius_;
|
||||||
|
|
||||||
|
//- Inner Radius
|
||||||
|
scalar innerRadius_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cylinderAnnulusToCell");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& p1,
|
||||||
|
const vector& p2,
|
||||||
|
const scalar outerRadius,
|
||||||
|
const scalar innerRadius
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
cylinderAnnulusToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~cylinderAnnulusToCell();
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
150
src/meshTools/sets/volRegions/cylinderToCell/cylinderToCell.C
Normal file
150
src/meshTools/sets/volRegions/cylinderToCell/cylinderToCell.C
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cylinderToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cylinderToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::cylinderToCell::usage_
|
||||||
|
(
|
||||||
|
cylinderToCell::typeName,
|
||||||
|
"\n Usage: cylinderToCell (p1X p1Y p1Z) (p2X p2Y p2Z) radius\n\n"
|
||||||
|
" Select all cells with cell centre within bounding cylinder\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cylinderToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const vector axis = p2_ - p1_;
|
||||||
|
const scalar rad2 = sqr(radius_);
|
||||||
|
const scalar magAxis2 = magSqr(axis);
|
||||||
|
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
vector d = ctrs[celli] - p1_;
|
||||||
|
scalar magD = d & axis;
|
||||||
|
|
||||||
|
if ((magD > 0) && (magD < magAxis2))
|
||||||
|
{
|
||||||
|
scalar d2 = (d & d) - sqr(magD)/magAxis2;
|
||||||
|
if (d2 < rad2)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cylinderToCell::cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& p1,
|
||||||
|
const vector& p2,
|
||||||
|
const scalar radius
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(p1),
|
||||||
|
p2_(p2),
|
||||||
|
radius_(radius)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::cylinderToCell::cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(dict.lookup("p1")),
|
||||||
|
p2_(dict.lookup("p2")),
|
||||||
|
radius_(readScalar(dict.lookup("radius")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::cylinderToCell::cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
p1_(checkIs(is)),
|
||||||
|
p2_(checkIs(is)),
|
||||||
|
radius_(readScalar(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cylinderToCell::~cylinderToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cylinderToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with centre within cylinder, with p1 = "
|
||||||
|
<< p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with centre within cylinder, with p1 = "
|
||||||
|
<< p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
134
src/meshTools/sets/volRegions/cylinderToCell/cylinderToCell.H
Normal file
134
src/meshTools/sets/volRegions/cylinderToCell/cylinderToCell.H
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cylinderToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell centres inside a cylinder.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cylinderToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cylinderToCell_H
|
||||||
|
#define cylinderToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cylinderToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cylinderToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- First point on cylinder axis
|
||||||
|
vector p1_;
|
||||||
|
|
||||||
|
//- Second point on cylinder axis
|
||||||
|
vector p2_;
|
||||||
|
|
||||||
|
//- Radius
|
||||||
|
scalar radius_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cylinderToCell");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& p1,
|
||||||
|
const vector& p2,
|
||||||
|
const scalar radius
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
cylinderToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cylinderToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
226
src/meshTools/sets/volRegions/faceToCell/faceToCell.C
Normal file
226
src/meshTools/sets/volRegions/faceToCell/faceToCell.C
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "faceToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "faceSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(faceToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceToCell, istream);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::faceToCell::faceAction,
|
||||||
|
4
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"neighbour",
|
||||||
|
"owner",
|
||||||
|
"any",
|
||||||
|
"all"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::faceToCell::usage_
|
||||||
|
(
|
||||||
|
faceToCell::typeName,
|
||||||
|
"\n Usage: faceToCell <faceSet> neighbour|owner|any|all\n\n"
|
||||||
|
" Select cells that are the owner|neighbour|any"
|
||||||
|
" of the faces in the faceSet or where all faces are in the faceSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::faceToCell::faceAction, 4>
|
||||||
|
Foam::faceToCell::faceActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::faceToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Load the set
|
||||||
|
faceSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
|
||||||
|
// Handle owner/neighbour/any selection
|
||||||
|
forAllConstIter(faceSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label facei = iter.key();
|
||||||
|
|
||||||
|
if ((option_ == OWNER) || (option_ == ANY))
|
||||||
|
{
|
||||||
|
const label celli = mesh_.faceOwner()[facei];
|
||||||
|
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh_.isInternalFace(facei))
|
||||||
|
{
|
||||||
|
if ((option_ == NEIGHBOUR) || (option_ == ANY))
|
||||||
|
{
|
||||||
|
const label celli = mesh_.faceNeighbour()[facei];
|
||||||
|
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle all selection.
|
||||||
|
if (option_ == ALL)
|
||||||
|
{
|
||||||
|
// Count number of selected faces per cell.
|
||||||
|
|
||||||
|
Map<label> facesPerCell(loadedSet.size());
|
||||||
|
|
||||||
|
forAllConstIter(faceSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label facei = iter.key();
|
||||||
|
const label own = mesh_.faceOwner()[facei];
|
||||||
|
|
||||||
|
Map<label>::iterator fndOwn = facesPerCell.find(own);
|
||||||
|
|
||||||
|
if (fndOwn == facesPerCell.end())
|
||||||
|
{
|
||||||
|
facesPerCell.insert(own, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fndOwn()++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh_.isInternalFace(facei))
|
||||||
|
{
|
||||||
|
label nei = mesh_.faceNeighbour()[facei];
|
||||||
|
|
||||||
|
Map<label>::iterator fndNei = facesPerCell.find(nei);
|
||||||
|
|
||||||
|
if (fndNei == facesPerCell.end())
|
||||||
|
{
|
||||||
|
facesPerCell.insert(nei, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fndNei()++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include cells that are referenced as many times as they have faces
|
||||||
|
// -> all faces in set.
|
||||||
|
forAllConstIter(Map<label>, facesPerCell, iter)
|
||||||
|
{
|
||||||
|
const label celli = iter.key();
|
||||||
|
|
||||||
|
if (iter() == mesh_.cells()[celli].size())
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::faceToCell::faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const faceAction option
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
option_(option)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::faceToCell::faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set")),
|
||||||
|
option_(faceActionNames_.read(dict.lookup("option")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::faceToCell::faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
option_(faceActionNames_.read(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::faceToCell::~faceToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::faceToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells according to faceSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells according to faceSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
144
src/meshTools/sets/volRegions/faceToCell/faceToCell.H
Normal file
144
src/meshTools/sets/volRegions/faceToCell/faceToCell.H
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::faceToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on usage in faces.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
faceToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef faceToCell_H
|
||||||
|
#define faceToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class faceToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class faceToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//- Enumeration defining the valid options
|
||||||
|
enum faceAction
|
||||||
|
{
|
||||||
|
NEIGHBOUR,
|
||||||
|
OWNER,
|
||||||
|
ANY,
|
||||||
|
ALL
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static const NamedEnum<faceAction, 4> faceActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
faceAction option_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on face to cell option add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("faceToCell");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const faceAction option
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
faceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~faceToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
183
src/meshTools/sets/volRegions/faceZoneToCell/faceZoneToCell.C
Normal file
183
src/meshTools/sets/volRegions/faceZoneToCell/faceZoneToCell.C
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "faceZoneToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(faceZoneToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::faceZoneToCell::faceAction,
|
||||||
|
2
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"master",
|
||||||
|
"slave"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_
|
||||||
|
(
|
||||||
|
faceZoneToCell::typeName,
|
||||||
|
"\n Usage: faceZoneToCell zone master|slave\n\n"
|
||||||
|
" Select master or slave side of the faceZone."
|
||||||
|
" Note:accepts wildcards for zone.\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>
|
||||||
|
Foam::faceZoneToCell::faceActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
bool hasMatched = false;
|
||||||
|
|
||||||
|
forAll(mesh_.faceZones(), i)
|
||||||
|
{
|
||||||
|
const faceZone& zone = mesh_.faceZones()[i];
|
||||||
|
|
||||||
|
if (zoneName_.match(zone.name()))
|
||||||
|
{
|
||||||
|
const labelList& cellLabels =
|
||||||
|
(
|
||||||
|
option_ == MASTER
|
||||||
|
? zone.masterCells()
|
||||||
|
: zone.slaveCells()
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< " Found matching zone " << zone.name()
|
||||||
|
<< " with " << cellLabels.size() << " cells on selected side."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
hasMatched = true;
|
||||||
|
|
||||||
|
forAll(cellLabels, i)
|
||||||
|
{
|
||||||
|
// Only do active cells
|
||||||
|
if (cellLabels[i] >= 0 && cellLabels[i] < mesh_.nCells())
|
||||||
|
{
|
||||||
|
addOrDelete(set, cellLabels[i], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasMatched)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot find any faceZone named " << zoneName_ << endl
|
||||||
|
<< "Valid names are " << mesh_.faceZones().names() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::faceZoneToCell::faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName,
|
||||||
|
const faceAction option
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(zoneName),
|
||||||
|
option_(option)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::faceZoneToCell::faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(dict.lookup("name")),
|
||||||
|
option_(faceActionNames_.read(dict.lookup("option")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::faceZoneToCell::faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(checkIs(is)),
|
||||||
|
option_(faceActionNames_.read(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::faceZoneToCell::~faceZoneToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::faceZoneToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all " << faceActionNames_[option_]
|
||||||
|
<< " cells of faceZone " << zoneName_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all " << faceActionNames_[option_]
|
||||||
|
<< " cells of faceZone " << zoneName_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
141
src/meshTools/sets/volRegions/faceZoneToCell/faceZoneToCell.H
Normal file
141
src/meshTools/sets/volRegions/faceZoneToCell/faceZoneToCell.H
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::faceZoneToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on side of faceZone.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
faceZoneToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef faceZoneToCell_H
|
||||||
|
#define faceZoneToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "wordRe.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class faceZoneToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class faceZoneToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//- Enumeration defining the valid options
|
||||||
|
enum faceAction
|
||||||
|
{
|
||||||
|
MASTER,
|
||||||
|
SLAVE
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
static const NamedEnum<faceAction, 2> faceActionNames_;
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name/regular expression of faceZone
|
||||||
|
wordRe zoneName_;
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
faceAction option_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("faceZoneToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName,
|
||||||
|
const faceAction option
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
faceZoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~faceZoneToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
97
src/meshTools/sets/volRegions/fieldToCell/fieldDictionary.H
Normal file
97
src/meshTools/sets/volRegions/fieldToCell/fieldDictionary.H
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fieldDictionary
|
||||||
|
|
||||||
|
Description
|
||||||
|
Read field as dictionary (without mesh).
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fieldDictionary_H
|
||||||
|
#define fieldDictionary_H
|
||||||
|
|
||||||
|
#include "regIOobject.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fieldDictionary Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fieldDictionary
|
||||||
|
:
|
||||||
|
public regIOobject,
|
||||||
|
public dictionary
|
||||||
|
{
|
||||||
|
const word type_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Redefine type name to be of the instantiated type
|
||||||
|
virtual const word& type() const
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from ioobject and overloaded typename.
|
||||||
|
fieldDictionary(const IOobject& io, const word& type)
|
||||||
|
:
|
||||||
|
regIOobject(io),
|
||||||
|
dictionary(readStream(type)),
|
||||||
|
type_(type)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
bool writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
static_cast<const dictionary&>(*this).write(os, false);
|
||||||
|
|
||||||
|
return os.good();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
230
src/meshTools/sets/volRegions/fieldToCell/fieldToCell.C
Normal file
230
src/meshTools/sets/volRegions/fieldToCell/fieldToCell.C
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fieldToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IFstream.H"
|
||||||
|
#include "fieldDictionary.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fieldToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, fieldToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, fieldToCell, istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::fieldToCell::usage_
|
||||||
|
(
|
||||||
|
fieldToCell::typeName,
|
||||||
|
"\n Usage: fieldToCell field min max\n\n"
|
||||||
|
" Select all cells with field value >= min and <= max\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fieldToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
const scalarField& field,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Info<< " Field min:" << min(field)
|
||||||
|
<< " max:" << max(field) << endl;
|
||||||
|
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all cells with value of field " << fieldName_
|
||||||
|
<< " within range " << min_ << ".." << max_ << endl;
|
||||||
|
|
||||||
|
forAll(field, celli)
|
||||||
|
{
|
||||||
|
if (field[celli] >= min_ && field[celli] <= max_)
|
||||||
|
{
|
||||||
|
set.insert(celli);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all cells with value of field " << fieldName_
|
||||||
|
<< " within range " << min_ << ".." << max_ << endl;
|
||||||
|
|
||||||
|
forAll(field, celli)
|
||||||
|
{
|
||||||
|
if (field[celli] >= min_ && field[celli] <= max_)
|
||||||
|
{
|
||||||
|
set.erase(celli);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::fieldToCell::fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& fieldName,
|
||||||
|
const scalar min,
|
||||||
|
const scalar max
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
fieldName_(fieldName),
|
||||||
|
min_(min),
|
||||||
|
max_(max)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::fieldToCell::fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
fieldName_(dict.lookup("field")),
|
||||||
|
min_(readScalar(dict.lookup("min"))),
|
||||||
|
max_(readScalar(dict.lookup("max")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::fieldToCell::fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
fieldName_(checkIs(is)),
|
||||||
|
min_(readScalar(checkIs(is))),
|
||||||
|
max_(readScalar(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fieldToCell::~fieldToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fieldToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
|
||||||
|
// // Construct temporary fvMesh from polyMesh
|
||||||
|
// fvMesh fMesh
|
||||||
|
// (
|
||||||
|
// mesh(), // IOobject
|
||||||
|
// mesh().points(),
|
||||||
|
// mesh().faces(),
|
||||||
|
// mesh().cells()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// const polyBoundaryMesh& patches = mesh().boundaryMesh();
|
||||||
|
//
|
||||||
|
// List<polyPatch*> newPatches(patches.size());
|
||||||
|
// forAll(patches, patchi)
|
||||||
|
// {
|
||||||
|
// const polyPatch& pp = patches[patchi];
|
||||||
|
//
|
||||||
|
// newPatches[patchi] =
|
||||||
|
// patches[patchi].clone
|
||||||
|
// (
|
||||||
|
// fMesh.boundaryMesh(),
|
||||||
|
// patchi,
|
||||||
|
// pp.size(),
|
||||||
|
// pp.start()
|
||||||
|
// ).ptr();
|
||||||
|
// }
|
||||||
|
// fMesh.addFvPatches(newPatches);
|
||||||
|
|
||||||
|
// Try to load field
|
||||||
|
IOobject fieldObject
|
||||||
|
(
|
||||||
|
fieldName_,
|
||||||
|
mesh().time().timeName(),
|
||||||
|
mesh(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!fieldObject.headerOk())
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot read field " << fieldName_
|
||||||
|
<< " from time " << mesh().time().timeName() << endl;
|
||||||
|
}
|
||||||
|
else if (fieldObject.headerClassName() == "volScalarField")
|
||||||
|
{
|
||||||
|
IFstream str(fieldObject.filePath());
|
||||||
|
|
||||||
|
// Read dictionary
|
||||||
|
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
|
||||||
|
|
||||||
|
scalarField internalVals("internalField", fieldDict, mesh().nCells());
|
||||||
|
|
||||||
|
applyToSet(action, internalVals, set);
|
||||||
|
}
|
||||||
|
else if (fieldObject.headerClassName() == "volVectorField")
|
||||||
|
{
|
||||||
|
IFstream str(fieldObject.filePath());
|
||||||
|
|
||||||
|
// Read dictionary
|
||||||
|
fieldDictionary fieldDict(fieldObject, fieldObject.headerClassName());
|
||||||
|
|
||||||
|
vectorField internalVals("internalField", fieldDict, mesh().nCells());
|
||||||
|
|
||||||
|
applyToSet(action, mag(internalVals), set);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot handle fields of type " << fieldObject.headerClassName()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
140
src/meshTools/sets/volRegions/fieldToCell/fieldToCell.H
Normal file
140
src/meshTools/sets/volRegions/fieldToCell/fieldToCell.H
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fieldToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on field values.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fieldToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fieldToCell_H
|
||||||
|
#define fieldToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "scalarField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fieldToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fieldToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Name of volScalarField
|
||||||
|
word fieldName_;
|
||||||
|
|
||||||
|
//- Min to subset field values with
|
||||||
|
scalar min_;
|
||||||
|
|
||||||
|
//- Max ,,
|
||||||
|
scalar max_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on field values add to or delete from cellSet.
|
||||||
|
void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
const scalarField& field,
|
||||||
|
topoSet& set
|
||||||
|
) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("fieldToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& fieldName,
|
||||||
|
const scalar min,
|
||||||
|
const scalar max
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
fieldToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~fieldToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/meshTools/sets/volRegions/labelToCell/labelToCell.C
Normal file
131
src/meshTools/sets/volRegions/labelToCell/labelToCell.C
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "labelToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(labelToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, labelToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, labelToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::labelToCell::usage_
|
||||||
|
(
|
||||||
|
labelToCell::typeName,
|
||||||
|
"\n Usage: labelToCell (i0 i1 .. in)\n\n"
|
||||||
|
" Select cells by cellLabel\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::labelToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
forAll(labels_, labelI)
|
||||||
|
{
|
||||||
|
addOrDelete(set, labels_[labelI], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::labelToCell::labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& labels
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(labels)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::labelToCell::labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(dict.lookup("value"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::labelToCell::labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
labels_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::labelToCell::~labelToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::labelToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells mentioned in dictionary" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells mentioned in dictionary" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
125
src/meshTools/sets/volRegions/labelToCell/labelToCell.H
Normal file
125
src/meshTools/sets/volRegions/labelToCell/labelToCell.H
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::labelToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on explicitly given labels.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
labelToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef labelToCell_H
|
||||||
|
#define labelToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class labelToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class labelToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Cell labels read from dictionary
|
||||||
|
labelList labels_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("labelToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& labels
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
labelToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~labelToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
174
src/meshTools/sets/volRegions/nbrToCell/nbrToCell.C
Normal file
174
src/meshTools/sets/volRegions/nbrToCell/nbrToCell.C
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "nbrToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(nbrToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, nbrToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, nbrToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::nbrToCell::usage_
|
||||||
|
(
|
||||||
|
nbrToCell::typeName,
|
||||||
|
"\n Usage: nbrToCell <nNeighbours>\n\n"
|
||||||
|
" Select all cells with <= nNeighbours neighbouring cells\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::nbrToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const cellList& cells = mesh().cells();
|
||||||
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
|
boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
|
||||||
|
|
||||||
|
forAll(patches, patchi)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = patches[patchi];
|
||||||
|
|
||||||
|
if (pp.coupled())
|
||||||
|
{
|
||||||
|
label facei = pp.start();
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
isCoupled[facei-mesh_.nInternalFaces()] = true;
|
||||||
|
facei++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(cells, celli)
|
||||||
|
{
|
||||||
|
const cell& cFaces = cells[celli];
|
||||||
|
|
||||||
|
label nNbrCells = 0;
|
||||||
|
|
||||||
|
forAll(cFaces, i)
|
||||||
|
{
|
||||||
|
label facei = cFaces[i];
|
||||||
|
|
||||||
|
if (mesh_.isInternalFace(facei))
|
||||||
|
{
|
||||||
|
nNbrCells++;
|
||||||
|
}
|
||||||
|
else if (isCoupled[facei-mesh_.nInternalFaces()])
|
||||||
|
{
|
||||||
|
nNbrCells++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nNbrCells <= minNbrs_)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::nbrToCell::nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const label minNbrs
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
minNbrs_(minNbrs)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::nbrToCell::nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
minNbrs_(readLabel(dict.lookup("neighbours")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::nbrToCell::nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
minNbrs_(readLabel(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::nbrToCell::~nbrToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::nbrToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with only " << minNbrs_ << " or less"
|
||||||
|
" neighbouring cells" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with only " << minNbrs_ << " or less"
|
||||||
|
" neighbouring cells" << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
126
src/meshTools/sets/volRegions/nbrToCell/nbrToCell.H
Normal file
126
src/meshTools/sets/volRegions/nbrToCell/nbrToCell.H
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::nbrToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on number of neighbouring cells
|
||||||
|
(i.e. number of internal or coupled faces)
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
nbrToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef nbrToCell_H
|
||||||
|
#define nbrToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class nbrToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class nbrToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Number of internal faces on cell
|
||||||
|
label minNbrs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("nbrToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const label minNbrs
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
nbrToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~nbrToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
130
src/meshTools/sets/volRegions/nearestToCell/nearestToCell.C
Normal file
130
src/meshTools/sets/volRegions/nearestToCell/nearestToCell.C
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "nearestToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(nearestToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, nearestToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, nearestToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::nearestToCell::usage_
|
||||||
|
(
|
||||||
|
nearestToCell::typeName,
|
||||||
|
"\n Usage: nearestToCell (pt0 .. ptn)\n\n"
|
||||||
|
" Select the nearest cell for each of the points pt0 ..ptn\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::nearestToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
forAll(points_, pointi)
|
||||||
|
{
|
||||||
|
addOrDelete(set, mesh_.findNearestCell(points_[pointi]), add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::nearestToCell::nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const pointField& points
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
points_(points)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::nearestToCell::nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
points_(dict.lookup("points"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::nearestToCell::nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
points_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::nearestToCell::~nearestToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::nearestToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells nearest to " << points_ << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells nearest to " << points_ << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
125
src/meshTools/sets/volRegions/nearestToCell/nearestToCell.H
Normal file
125
src/meshTools/sets/volRegions/nearestToCell/nearestToCell.H
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::nearestToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells nearest to points.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
nearestToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef nearestToCell_H
|
||||||
|
#define nearestToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class nearestToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class nearestToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Points to select nearest to
|
||||||
|
pointField points_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("nearestToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const pointField& points
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
nearestToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~nearestToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
183
src/meshTools/sets/volRegions/pointToCell/pointToCell.C
Normal file
183
src/meshTools/sets/volRegions/pointToCell/pointToCell.C
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "pointToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "pointSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(pointToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::pointToCell::pointAction,
|
||||||
|
2
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"any",
|
||||||
|
"edge"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
|
||||||
|
(
|
||||||
|
pointToCell::typeName,
|
||||||
|
"\n Usage: pointToCell <pointSet> any|edge\n\n"
|
||||||
|
" Select all cells with any point ('any') or any edge ('edge')"
|
||||||
|
" in the pointSet\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::pointToCell::pointAction, 2>
|
||||||
|
Foam::pointToCell::pointActionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::pointToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Load the set
|
||||||
|
pointSet loadedSet(mesh_, setName_);
|
||||||
|
|
||||||
|
|
||||||
|
// Handle any selection
|
||||||
|
if (option_ == ANY)
|
||||||
|
{
|
||||||
|
forAllConstIter(pointSet, loadedSet, iter)
|
||||||
|
{
|
||||||
|
const label pointi = iter.key();
|
||||||
|
const labelList& pCells = mesh_.pointCells()[pointi];
|
||||||
|
|
||||||
|
forAll(pCells, pCelli)
|
||||||
|
{
|
||||||
|
addOrDelete(set, pCells[pCelli], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (option_ == EDGE)
|
||||||
|
{
|
||||||
|
const faceList& faces = mesh_.faces();
|
||||||
|
forAll(faces, facei)
|
||||||
|
{
|
||||||
|
const face& f = faces[facei];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
|
||||||
|
{
|
||||||
|
addOrDelete(set, mesh_.faceOwner()[facei], add);
|
||||||
|
if (mesh_.isInternalFace(facei))
|
||||||
|
{
|
||||||
|
addOrDelete(set, mesh_.faceNeighbour()[facei], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::pointToCell::pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointAction option
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
option_(option)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::pointToCell::pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookup("set")),
|
||||||
|
option_(pointActionNames_.read(dict.lookup("option")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::pointToCell::pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
option_(pointActionNames_.read(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::pointToCell::~pointToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::pointToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells according to pointSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells according to pointSet " << setName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
141
src/meshTools/sets/volRegions/pointToCell/pointToCell.H
Normal file
141
src/meshTools/sets/volRegions/pointToCell/pointToCell.H
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::pointToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on usage of points.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
pointToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef pointToCell_H
|
||||||
|
#define pointToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class pointToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class pointToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//- Enumeration defining the valid options
|
||||||
|
enum pointAction
|
||||||
|
{
|
||||||
|
ANY, // Cells using any point in set
|
||||||
|
EDGE // Cells using an edge with both points in set
|
||||||
|
//ALL // Possible extension: cells whose all points are in set
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
static const NamedEnum<pointAction, 2> pointActionNames_;
|
||||||
|
|
||||||
|
//- Name of set to use
|
||||||
|
word setName_;
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
pointAction option_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on point-to-cell option add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("pointToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointAction option
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
pointToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~pointToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
468
src/meshTools/sets/volRegions/regionToCell/regionToCell.C
Normal file
468
src/meshTools/sets/volRegions/regionToCell/regionToCell.C
Normal file
@ -0,0 +1,468 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "regionToCell.H"
|
||||||
|
#include "regionSplit.H"
|
||||||
|
#include "emptyPolyPatch.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "syncTools.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(regionToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, regionToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, regionToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::regionToCell::usage_
|
||||||
|
(
|
||||||
|
regionToCell::typeName,
|
||||||
|
"\n Usage: regionToCell subCellSet (pt0 .. ptn)\n\n"
|
||||||
|
" Select all cells in the connected region containing"
|
||||||
|
" points (pt0..ptn).\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::regionToCell::markRegionFaces
|
||||||
|
(
|
||||||
|
const boolList& selectedCell,
|
||||||
|
boolList& regionFace
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Internal faces
|
||||||
|
const labelList& faceOwner = mesh_.faceOwner();
|
||||||
|
const labelList& faceNeighbour = mesh_.faceNeighbour();
|
||||||
|
forAll(faceNeighbour, facei)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
selectedCell[faceOwner[facei]]
|
||||||
|
!= selectedCell[faceNeighbour[facei]]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
regionFace[facei] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap neighbour selectedCell state
|
||||||
|
boolList nbrSelected;
|
||||||
|
syncTools::swapBoundaryCellList(mesh_, selectedCell, nbrSelected);
|
||||||
|
|
||||||
|
// Boundary faces
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
forAll(pbm, patchi)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = pbm[patchi];
|
||||||
|
const labelUList& faceCells = pp.faceCells();
|
||||||
|
forAll(faceCells, i)
|
||||||
|
{
|
||||||
|
label facei = pp.start()+i;
|
||||||
|
label bFacei = facei-mesh_.nInternalFaces();
|
||||||
|
if
|
||||||
|
(
|
||||||
|
selectedCell[faceCells[i]]
|
||||||
|
!= selectedCell[nbrSelected[bFacei]]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
regionFace[facei] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::boolList Foam::regionToCell::findRegions
|
||||||
|
(
|
||||||
|
const bool verbose,
|
||||||
|
const regionSplit& cellRegion
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
boolList keepRegion(cellRegion.nRegions(), false);
|
||||||
|
|
||||||
|
forAll(insidePoints_, i)
|
||||||
|
{
|
||||||
|
// Find the region containing the insidePoint
|
||||||
|
|
||||||
|
label celli = mesh_.findCell(insidePoints_[i]);
|
||||||
|
|
||||||
|
label keepRegionI = -1;
|
||||||
|
label keepProci = -1;
|
||||||
|
if (celli != -1)
|
||||||
|
{
|
||||||
|
keepRegionI = cellRegion[celli];
|
||||||
|
keepProci = Pstream::myProcNo();
|
||||||
|
}
|
||||||
|
reduce(keepRegionI, maxOp<label>());
|
||||||
|
keepRegion[keepRegionI] = true;
|
||||||
|
|
||||||
|
reduce(keepProci, maxOp<label>());
|
||||||
|
|
||||||
|
if (keepProci == -1)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Did not find " << insidePoints_[i]
|
||||||
|
<< " in mesh." << " Mesh bounds are " << mesh_.bounds()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< " Found location " << insidePoints_[i]
|
||||||
|
<< " in cell " << celli << " on processor " << keepProci
|
||||||
|
<< " in global region " << keepRegionI
|
||||||
|
<< " out of " << cellRegion.nRegions() << " regions." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keepRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::unselectOutsideRegions
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Determine faces on the edge of selectedCell
|
||||||
|
boolList blockedFace(mesh_.nFaces(), false);
|
||||||
|
markRegionFaces(selectedCell, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions
|
||||||
|
regionSplit cellRegion(mesh_, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions containing insidePoints_
|
||||||
|
boolList keepRegion(findRegions(true, cellRegion));
|
||||||
|
|
||||||
|
// Go back to bool per cell
|
||||||
|
forAll(cellRegion, celli)
|
||||||
|
{
|
||||||
|
if (!keepRegion[cellRegion[celli]])
|
||||||
|
{
|
||||||
|
selectedCell[celli] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::shrinkRegions
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Select points on unselected cells and boundary
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
boolList boundaryPoint(mesh_.nPoints(), false);
|
||||||
|
|
||||||
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
|
forAll(pbm, patchi)
|
||||||
|
{
|
||||||
|
const polyPatch& pp = pbm[patchi];
|
||||||
|
|
||||||
|
if (!pp.coupled() && !isA<emptyPolyPatch>(pp))
|
||||||
|
{
|
||||||
|
forAll(pp, i)
|
||||||
|
{
|
||||||
|
const face& f = pp[i];
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
boundaryPoint[f[fp]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(selectedCell, celli)
|
||||||
|
{
|
||||||
|
if (!selectedCell[celli])
|
||||||
|
{
|
||||||
|
const labelList& cPoints = mesh_.cellPoints(celli);
|
||||||
|
forAll(cPoints, i)
|
||||||
|
{
|
||||||
|
boundaryPoint[cPoints[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
|
||||||
|
|
||||||
|
|
||||||
|
// Select all cells using these points
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
label nChanged = 0;
|
||||||
|
forAll(boundaryPoint, pointi)
|
||||||
|
{
|
||||||
|
if (boundaryPoint[pointi])
|
||||||
|
{
|
||||||
|
const labelList& pCells = mesh_.pointCells(pointi);
|
||||||
|
forAll(pCells, i)
|
||||||
|
{
|
||||||
|
label celli = pCells[i];
|
||||||
|
if (selectedCell[celli])
|
||||||
|
{
|
||||||
|
selectedCell[celli] = false;
|
||||||
|
nChanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Info<< " Eroded " << returnReduce(nChanged, sumOp<label>())
|
||||||
|
<< " cells." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::erode
|
||||||
|
(
|
||||||
|
boolList& selectedCell
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
//Info<< "Entering shrinkRegions:" << count(selectedCell) << endl;
|
||||||
|
//generateField("selectedCell_before", selectedCell)().write();
|
||||||
|
|
||||||
|
// Now erode and see which regions get disconnected
|
||||||
|
boolList shrunkSelectedCell(selectedCell);
|
||||||
|
|
||||||
|
for (label iter = 0; iter < nErode_; iter++)
|
||||||
|
{
|
||||||
|
shrinkRegions(shrunkSelectedCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "After shrinking:" << count(shrunkSelectedCell) << endl;
|
||||||
|
//generateField("shrunkSelectedCell", shrunkSelectedCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Determine faces on the edge of shrunkSelectedCell
|
||||||
|
boolList blockedFace(mesh_.nFaces(), false);
|
||||||
|
markRegionFaces(shrunkSelectedCell, blockedFace);
|
||||||
|
|
||||||
|
// Find disconnected regions
|
||||||
|
regionSplit cellRegion(mesh_, blockedFace);
|
||||||
|
|
||||||
|
// Determine regions containing insidePoints
|
||||||
|
boolList keepRegion(findRegions(true, cellRegion));
|
||||||
|
|
||||||
|
|
||||||
|
// Extract cells in regions that are not to be kept.
|
||||||
|
boolList removeCell(mesh_.nCells(), false);
|
||||||
|
forAll(cellRegion, celli)
|
||||||
|
{
|
||||||
|
if (shrunkSelectedCell[celli] && !keepRegion[cellRegion[celli]])
|
||||||
|
{
|
||||||
|
removeCell[celli] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "removeCell before:" << count(removeCell) << endl;
|
||||||
|
//generateField("removeCell_before", removeCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Grow removeCell
|
||||||
|
for (label iter = 0; iter < nErode_; iter++)
|
||||||
|
{
|
||||||
|
// Grow selected cell in regions that are not for keeping
|
||||||
|
boolList boundaryPoint(mesh_.nPoints(), false);
|
||||||
|
forAll(removeCell, celli)
|
||||||
|
{
|
||||||
|
if (removeCell[celli])
|
||||||
|
{
|
||||||
|
const labelList& cPoints = mesh_.cellPoints(celli);
|
||||||
|
forAll(cPoints, i)
|
||||||
|
{
|
||||||
|
boundaryPoint[cPoints[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syncTools::syncPointList(mesh_, boundaryPoint, orEqOp<bool>(), false);
|
||||||
|
|
||||||
|
// Select all cells using these points
|
||||||
|
|
||||||
|
label nChanged = 0;
|
||||||
|
forAll(boundaryPoint, pointi)
|
||||||
|
{
|
||||||
|
if (boundaryPoint[pointi])
|
||||||
|
{
|
||||||
|
const labelList& pCells = mesh_.pointCells(pointi);
|
||||||
|
forAll(pCells, i)
|
||||||
|
{
|
||||||
|
label celli = pCells[i];
|
||||||
|
if (!removeCell[celli])
|
||||||
|
{
|
||||||
|
removeCell[celli] = true;
|
||||||
|
nChanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Info<< "removeCell after:" << count(removeCell) << endl;
|
||||||
|
//generateField("removeCell_after", removeCell)().write();
|
||||||
|
|
||||||
|
|
||||||
|
// Unmark removeCell
|
||||||
|
forAll(removeCell, celli)
|
||||||
|
{
|
||||||
|
if (removeCell[celli])
|
||||||
|
{
|
||||||
|
selectedCell[celli] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Note: wip. Select cells first
|
||||||
|
boolList selectedCell(mesh_.nCells(), true);
|
||||||
|
|
||||||
|
if (setName_.size() && setName_ != "none")
|
||||||
|
{
|
||||||
|
Info<< " Loading subset " << setName_ << " to delimit search region."
|
||||||
|
<< endl;
|
||||||
|
cellSet subSet(mesh_, setName_);
|
||||||
|
|
||||||
|
selectedCell = false;
|
||||||
|
forAllConstIter(cellSet, subSet, iter)
|
||||||
|
{
|
||||||
|
selectedCell[iter.key()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unselectOutsideRegions(selectedCell);
|
||||||
|
|
||||||
|
if (nErode_ > 0)
|
||||||
|
{
|
||||||
|
erode(selectedCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
forAll(selectedCell, celli)
|
||||||
|
{
|
||||||
|
if (selectedCell[celli])
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::regionToCell::regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointField& insidePoints,
|
||||||
|
const label nErode
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(setName),
|
||||||
|
insidePoints_(insidePoints),
|
||||||
|
nErode_(nErode)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::regionToCell::regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(dict.lookupOrDefault<word>("set", "none")),
|
||||||
|
insidePoints_
|
||||||
|
(
|
||||||
|
dict.found("insidePoints")
|
||||||
|
? dict.lookup("insidePoints")
|
||||||
|
: dict.lookup("insidePoint")
|
||||||
|
),
|
||||||
|
nErode_(dict.lookupOrDefault("nErode", 0))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::regionToCell::regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
setName_(checkIs(is)),
|
||||||
|
insidePoints_(checkIs(is)),
|
||||||
|
nErode_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::regionToCell::~regionToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::regionToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all cells of connected region containing points "
|
||||||
|
<< insidePoints_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all cells of connected region containing points "
|
||||||
|
<< insidePoints_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
168
src/meshTools/sets/volRegions/regionToCell/regionToCell.H
Normal file
168
src/meshTools/sets/volRegions/regionToCell/regionToCell.H
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::regionToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
TopoSetSource. Select cells belonging to topological connected region
|
||||||
|
(that contains given points)
|
||||||
|
|
||||||
|
In dictionary input:
|
||||||
|
|
||||||
|
// optional name of cellSet delimiting search
|
||||||
|
set c0;
|
||||||
|
|
||||||
|
//- Number of cell layers to erode mesh to detect holes in the mesh
|
||||||
|
// Set to 0 if not used.
|
||||||
|
nErode 3;
|
||||||
|
|
||||||
|
// points inside region to select
|
||||||
|
insidePoints ((1 2 3));
|
||||||
|
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
regionToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef regionToCell_H
|
||||||
|
#define regionToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "boolList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class regionSplit;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class regionToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class regionToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of cellSet to keep to
|
||||||
|
const word setName_;
|
||||||
|
|
||||||
|
//- Coordinate(s) that is inside connected region
|
||||||
|
const pointField insidePoints_;
|
||||||
|
|
||||||
|
//- Number of layers to erode
|
||||||
|
const label nErode_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Mark faces inbetween selected and unselected elements
|
||||||
|
void markRegionFaces
|
||||||
|
(
|
||||||
|
const boolList& selectedCell,
|
||||||
|
boolList& regionFace
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Determine for every disconnected region in the mesh whether
|
||||||
|
// it contains a locationInMesh
|
||||||
|
boolList findRegions(const bool verbose, const regionSplit&) const;
|
||||||
|
|
||||||
|
//- Unselect regions not containing a locationInMesh
|
||||||
|
void unselectOutsideRegions(boolList& selectedCell) const;
|
||||||
|
|
||||||
|
//- Unselect one layer of cells from selectedCell
|
||||||
|
void shrinkRegions(boolList& selectedCell) const;
|
||||||
|
|
||||||
|
//- Erode a given number of layers from selectedCell. Remove any
|
||||||
|
// region that gets disconnected that way.
|
||||||
|
void erode(boolList& selectedCell) const;
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("regionToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& setName,
|
||||||
|
const pointField& insidePoints,
|
||||||
|
const label nErode
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
regionToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~regionToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet(const topoSetSource::setAction action, topoSet&)
|
||||||
|
const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,193 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "rotatedBoxToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "cellModeller.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(rotatedBoxToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, rotatedBoxToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::rotatedBoxToCell::usage_
|
||||||
|
(
|
||||||
|
rotatedBoxToCell::typeName,
|
||||||
|
"\n Usage: rotatedBoxToCell (originx originy originz)"
|
||||||
|
" (ix iy iz) (jx jy jz) (kx ky kz)\n\n"
|
||||||
|
" Select all cells with cellCentre within parallelopiped\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
// Define a cell for the box
|
||||||
|
pointField boxPoints(8);
|
||||||
|
boxPoints[0] = origin_;
|
||||||
|
boxPoints[1] = origin_ + i_;
|
||||||
|
boxPoints[2] = origin_ + i_ + j_;
|
||||||
|
boxPoints[3] = origin_ + j_;
|
||||||
|
boxPoints[4] = origin_ + k_;
|
||||||
|
boxPoints[5] = origin_ + k_ + i_;
|
||||||
|
boxPoints[6] = origin_ + k_ + i_ + j_;
|
||||||
|
boxPoints[7] = origin_ + k_ + j_;
|
||||||
|
|
||||||
|
labelList boxVerts(8);
|
||||||
|
forAll(boxVerts, i)
|
||||||
|
{
|
||||||
|
boxVerts[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||||
|
|
||||||
|
// Get outwards pointing faces.
|
||||||
|
faceList boxFaces(cellShape(hex, boxVerts).faces());
|
||||||
|
|
||||||
|
// Precalculate normals
|
||||||
|
vectorField boxFaceNormals(boxFaces.size());
|
||||||
|
forAll(boxFaces, i)
|
||||||
|
{
|
||||||
|
boxFaceNormals[i] = boxFaces[i].normal(boxPoints);
|
||||||
|
|
||||||
|
//Pout<< "Face:" << i << " position:" << boxFaces[i].centre(boxPoints)
|
||||||
|
// << " normal:" << boxFaceNormals[i] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether cell centre is inside all faces of box.
|
||||||
|
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
bool inside = true;
|
||||||
|
|
||||||
|
forAll(boxFaces, i)
|
||||||
|
{
|
||||||
|
const face& f = boxFaces[i];
|
||||||
|
|
||||||
|
if (((ctrs[celli] - boxPoints[f[0]]) & boxFaceNormals[i]) > 0)
|
||||||
|
{
|
||||||
|
inside = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inside)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::rotatedBoxToCell::rotatedBoxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& origin,
|
||||||
|
const vector& i,
|
||||||
|
const vector& j,
|
||||||
|
const vector& k
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
origin_(origin),
|
||||||
|
i_(i),
|
||||||
|
j_(j),
|
||||||
|
k_(k)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::rotatedBoxToCell::rotatedBoxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
origin_(dict.lookup("origin")),
|
||||||
|
i_(dict.lookup("i")),
|
||||||
|
j_(dict.lookup("j")),
|
||||||
|
k_(dict.lookup("k"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::rotatedBoxToCell::rotatedBoxToCell(const polyMesh& mesh, Istream& is)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
origin_(is),
|
||||||
|
i_(is),
|
||||||
|
j_(is),
|
||||||
|
k_(is)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::rotatedBoxToCell::~rotatedBoxToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::rotatedBoxToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with center within rotated box " << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with center within rotated box " << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::rotatedBoxToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell centres inside
|
||||||
|
rotated/skewed box (parallelopiped?).
|
||||||
|
|
||||||
|
Box defined as origin and i,j,k vectors.
|
||||||
|
E.g. box rotated 45 degrees around z-axis with sizes sqrt(0.2^2+0.2^2)
|
||||||
|
(and extra large, 200 in z direction):
|
||||||
|
\verbatim
|
||||||
|
origin ( 0.4 0.4 -100);
|
||||||
|
i ( 0.2 0.2 0);
|
||||||
|
j (-0.2 0.2 0);
|
||||||
|
k ( 0.0 0.0 100);
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
rotatedBoxToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef rotatedBoxToCell_H
|
||||||
|
#define rotatedBoxToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "treeBoundBox.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class rotatedBoxToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class rotatedBoxToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Skewed box
|
||||||
|
const vector origin_;
|
||||||
|
const vector i_;
|
||||||
|
const vector j_;
|
||||||
|
const vector k_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("rotatedBoxToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
rotatedBoxToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& origin,
|
||||||
|
const vector& i,
|
||||||
|
const vector& j,
|
||||||
|
const vector& k
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
rotatedBoxToCell(const polyMesh& mesh, const dictionary& dict);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
rotatedBoxToCell(const polyMesh& mesh, Istream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~rotatedBoxToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
178
src/meshTools/sets/volRegions/shapeToCell/shapeToCell.C
Normal file
178
src/meshTools/sets/volRegions/shapeToCell/shapeToCell.C
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "shapeToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "unitConversion.H"
|
||||||
|
#include "hexMatcher.H"
|
||||||
|
#include "cellFeatures.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(shapeToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, shapeToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, shapeToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::shapeToCell::usage_
|
||||||
|
(
|
||||||
|
shapeToCell::typeName,
|
||||||
|
"\n Usage: shapeToCell tet|pyr|prism|hex|tetWedge|wedge|splitHex\n\n"
|
||||||
|
" Select all cells of given cellShape.\n"
|
||||||
|
" (splitHex hardcoded with internal angle < 10 degrees)\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Angle for polys to be considered splitHexes.
|
||||||
|
Foam::scalar Foam::shapeToCell::featureCos = Foam::cos(degToRad(10.0));
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::shapeToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
if (type_ == "splitHex")
|
||||||
|
{
|
||||||
|
for (label celli = 0; celli < mesh_.nCells(); celli++)
|
||||||
|
{
|
||||||
|
cellFeatures superCell(mesh_, featureCos, celli);
|
||||||
|
|
||||||
|
if (hexMatcher().isA(superCell.faces()))
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const cellModel& wantedModel = *(cellModeller::lookup(type_));
|
||||||
|
|
||||||
|
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||||
|
|
||||||
|
forAll(cellShapes, celli)
|
||||||
|
{
|
||||||
|
if (cellShapes[celli].model() == wantedModel)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::shapeToCell::shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& type
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
type_(type)
|
||||||
|
{
|
||||||
|
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal cell type " << type_ << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::shapeToCell::shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
type_(dict.lookup("type"))
|
||||||
|
{
|
||||||
|
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal cell type " << type_ << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::shapeToCell::shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
type_(checkIs(is))
|
||||||
|
{
|
||||||
|
if (!cellModeller::lookup(type_) && (type_ != "splitHex"))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal cell type " << type_ << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::shapeToCell::~shapeToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::shapeToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all cells of type " << type_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all cells of type " << type_ << " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
134
src/meshTools/sets/volRegions/shapeToCell/shapeToCell.H
Normal file
134
src/meshTools/sets/volRegions/shapeToCell/shapeToCell.H
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::shapeToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell shape.
|
||||||
|
|
||||||
|
Handles all ones from cellModeller and splitHex with 10 degrees
|
||||||
|
feature angle.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
shapeToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef shapeToCell_H
|
||||||
|
#define shapeToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class shapeToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class shapeToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of cell type
|
||||||
|
word type_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Depending on cell type add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("shapeToCell");
|
||||||
|
|
||||||
|
|
||||||
|
// Static data
|
||||||
|
|
||||||
|
//- Cos of feature angle for polyHedral to be splitHex
|
||||||
|
static scalar featureCos;
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& type
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
shapeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~shapeToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
138
src/meshTools/sets/volRegions/sphereToCell/sphereToCell.C
Normal file
138
src/meshTools/sets/volRegions/sphereToCell/sphereToCell.C
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sphereToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(sphereToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, sphereToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, sphereToCell, istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::sphereToCell::usage_
|
||||||
|
(
|
||||||
|
sphereToCell::typeName,
|
||||||
|
"\n Usage: sphereToCell (centreX centreY centreZ) radius\n\n"
|
||||||
|
" Select all cells with cellCentre within bounding sphere\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sphereToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
const scalar radSquared = radius_*radius_;
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
scalar offset = magSqr(centre_ - ctrs[celli]);
|
||||||
|
if (offset <= radSquared)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sphereToCell::sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& centre,
|
||||||
|
const scalar radius
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
centre_(centre),
|
||||||
|
radius_(radius)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sphereToCell::sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
centre_(dict.lookup("centre")),
|
||||||
|
radius_(readScalar(dict.lookup("radius")))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::sphereToCell::sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
centre_(checkIs(is)),
|
||||||
|
radius_(readScalar(checkIs(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sphereToCell::~sphereToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::sphereToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells with centre within sphere, with centre = "
|
||||||
|
<< centre_ << " and radius = " << radius_ << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells with centre within sphere, with centre = "
|
||||||
|
<< centre_ << " and radius = " << radius_ << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
130
src/meshTools/sets/volRegions/sphereToCell/sphereToCell.H
Normal file
130
src/meshTools/sets/volRegions/sphereToCell/sphereToCell.H
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::sphereToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on cell centres inside sphere.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sphereToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sphereToCell_H
|
||||||
|
#define sphereToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sphereToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sphereToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Centre
|
||||||
|
vector centre_;
|
||||||
|
|
||||||
|
//- Radius
|
||||||
|
scalar radius_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("sphereToCell");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vector& centre,
|
||||||
|
const scalar radius
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
sphereToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~sphereToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
506
src/meshTools/sets/volRegions/surfaceToCell/surfaceToCell.C
Normal file
506
src/meshTools/sets/volRegions/surfaceToCell/surfaceToCell.C
Normal file
@ -0,0 +1,506 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "surfaceToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "meshSearch.H"
|
||||||
|
#include "triSurface.H"
|
||||||
|
#include "triSurfaceSearch.H"
|
||||||
|
#include "cellClassification.H"
|
||||||
|
#include "cpuTime.H"
|
||||||
|
#include "demandDrivenData.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(surfaceToCell, 0);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, word);
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, surfaceToCell, istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::surfaceToCell::usage_
|
||||||
|
(
|
||||||
|
surfaceToCell::typeName,
|
||||||
|
"\n Usage: surfaceToCell"
|
||||||
|
"<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n"
|
||||||
|
" <surface> name of triSurface\n"
|
||||||
|
" <outsidePoints> list of points that define outside\n"
|
||||||
|
" <cut> boolean whether to include cells cut by surface\n"
|
||||||
|
" <inside> ,, ,, inside surface\n"
|
||||||
|
" <outside> ,, ,, outside surface\n"
|
||||||
|
" <near> scalar; include cells with centre <= near to surface\n"
|
||||||
|
" <curvature> scalar; include cells close to strong curvature"
|
||||||
|
" on surface\n"
|
||||||
|
" (curvature defined as difference in surface normal at nearest"
|
||||||
|
" point on surface for each vertex of cell)\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::label Foam::surfaceToCell::getNearest
|
||||||
|
(
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
const label pointi,
|
||||||
|
const point& pt,
|
||||||
|
const vector& span,
|
||||||
|
Map<label>& cache
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Map<label>::const_iterator iter = cache.find(pointi);
|
||||||
|
|
||||||
|
if (iter != cache.end())
|
||||||
|
{
|
||||||
|
// Found cached answer
|
||||||
|
return iter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pointIndexHit inter = querySurf.nearest(pt, span);
|
||||||
|
|
||||||
|
// Triangle label (can be -1)
|
||||||
|
label triI = inter.index();
|
||||||
|
|
||||||
|
// Store triangle on point
|
||||||
|
cache.insert(pointi, triI);
|
||||||
|
|
||||||
|
return triI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::surfaceToCell::differingPointNormals
|
||||||
|
(
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
|
||||||
|
const vector& span, // Current search span
|
||||||
|
const label celli,
|
||||||
|
const label cellTriI, // Nearest (to cell centre) surface triangle
|
||||||
|
|
||||||
|
Map<label>& pointToNearest // Cache for nearest triangle to point
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const triSurface& surf = querySurf.surface();
|
||||||
|
const vectorField& normals = surf.faceNormals();
|
||||||
|
|
||||||
|
const faceList& faces = mesh().faces();
|
||||||
|
const pointField& points = mesh().points();
|
||||||
|
|
||||||
|
const labelList& cFaces = mesh().cells()[celli];
|
||||||
|
|
||||||
|
forAll(cFaces, cFacei)
|
||||||
|
{
|
||||||
|
const face& f = faces[cFaces[cFacei]];
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
label pointi = f[fp];
|
||||||
|
|
||||||
|
label pointTriI =
|
||||||
|
getNearest
|
||||||
|
(
|
||||||
|
querySurf,
|
||||||
|
pointi,
|
||||||
|
points[pointi],
|
||||||
|
span,
|
||||||
|
pointToNearest
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pointTriI != -1 && pointTriI != cellTriI)
|
||||||
|
{
|
||||||
|
scalar cosAngle = normals[pointTriI] & normals[cellTriI];
|
||||||
|
|
||||||
|
if (cosAngle < 0.9)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
cpuTime timer;
|
||||||
|
|
||||||
|
|
||||||
|
if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
|
||||||
|
{
|
||||||
|
const meshSearch queryMesh(mesh_);
|
||||||
|
|
||||||
|
//- Calculate for each searchPoint inside/outside status.
|
||||||
|
boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
|
||||||
|
|
||||||
|
Info<< " Marked inside/outside using surface orientation in = "
|
||||||
|
<< timer.cpuTimeIncrement() << " s" << endl << endl;
|
||||||
|
|
||||||
|
forAll(isInside, celli)
|
||||||
|
{
|
||||||
|
if (isInside[celli] && includeInside_)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
else if (!isInside[celli] && includeOutside_)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (includeCut_ || includeInside_ || includeOutside_)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Cut cells with surface and classify cells
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// Construct search engine on mesh
|
||||||
|
|
||||||
|
const meshSearch queryMesh(mesh_);
|
||||||
|
|
||||||
|
|
||||||
|
// Check all 'outside' points
|
||||||
|
forAll(outsidePoints_, outsideI)
|
||||||
|
{
|
||||||
|
const point& outsidePoint = outsidePoints_[outsideI];
|
||||||
|
|
||||||
|
// Find cell point is in. Linear search.
|
||||||
|
label celli = queryMesh.findCell(outsidePoint, -1, false);
|
||||||
|
if (returnReduce(celli, maxOp<label>()) == -1)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "outsidePoint " << outsidePoint
|
||||||
|
<< " is not inside any cell"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cut faces with surface and classify cells
|
||||||
|
|
||||||
|
cellClassification cellType
|
||||||
|
(
|
||||||
|
mesh_,
|
||||||
|
queryMesh,
|
||||||
|
querySurf(),
|
||||||
|
outsidePoints_
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Info<< " Marked inside/outside using surface intersection in = "
|
||||||
|
<< timer.cpuTimeIncrement() << " s" << endl << endl;
|
||||||
|
|
||||||
|
//- Add/remove cells using set
|
||||||
|
forAll(cellType, celli)
|
||||||
|
{
|
||||||
|
label cType = cellType[celli];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(
|
||||||
|
includeCut_
|
||||||
|
&& (cType == cellClassification::CUT)
|
||||||
|
)
|
||||||
|
|| (
|
||||||
|
includeInside_
|
||||||
|
&& (cType == cellClassification::INSIDE)
|
||||||
|
)
|
||||||
|
|| (
|
||||||
|
includeOutside_
|
||||||
|
&& (cType == cellClassification::OUTSIDE)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (nearDist_ > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Determine distance to surface
|
||||||
|
//
|
||||||
|
|
||||||
|
const pointField& ctrs = mesh_.cellCentres();
|
||||||
|
|
||||||
|
// Box dimensions to search in octree.
|
||||||
|
const vector span(nearDist_, nearDist_, nearDist_);
|
||||||
|
|
||||||
|
|
||||||
|
if (curvature_ < -1)
|
||||||
|
{
|
||||||
|
Info<< " Selecting cells with cellCentre closer than "
|
||||||
|
<< nearDist_ << " to surface" << endl;
|
||||||
|
|
||||||
|
// No need to test curvature. Insert near cells into set.
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
const point& c = ctrs[celli];
|
||||||
|
|
||||||
|
pointIndexHit inter = querySurf().nearest(c, span);
|
||||||
|
|
||||||
|
if (inter.hit() && (mag(inter.hitPoint() - c) < nearDist_))
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " Determined nearest surface point in = "
|
||||||
|
<< timer.cpuTimeIncrement() << " s" << endl << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Test near cells for curvature
|
||||||
|
|
||||||
|
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
|
||||||
|
Map<label> pointToNearest(mesh_.nCells()/10);
|
||||||
|
|
||||||
|
forAll(ctrs, celli)
|
||||||
|
{
|
||||||
|
const point& c = ctrs[celli];
|
||||||
|
|
||||||
|
pointIndexHit inter = querySurf().nearest(c, span);
|
||||||
|
|
||||||
|
if (inter.hit() && (mag(inter.hitPoint() - c) < nearDist_))
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
differingPointNormals
|
||||||
|
(
|
||||||
|
querySurf(),
|
||||||
|
span,
|
||||||
|
celli,
|
||||||
|
inter.index(), // nearest surface triangle
|
||||||
|
pointToNearest
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " Determined nearest surface point in = "
|
||||||
|
<< timer.cpuTimeIncrement() << " s" << endl << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::surfaceToCell::checkSettings() const
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(nearDist_ < 0)
|
||||||
|
&& (curvature_ < -1)
|
||||||
|
&& (
|
||||||
|
(includeCut_ && includeInside_ && includeOutside_)
|
||||||
|
|| (!includeCut_ && !includeInside_ && !includeOutside_)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal include cell specification."
|
||||||
|
<< " Result would be either all or no cells." << endl
|
||||||
|
<< "Please set one of includeCut, includeInside, includeOutside"
|
||||||
|
<< " to true, set nearDistance to a value > 0"
|
||||||
|
<< " or set curvature to a value -1 .. 1."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useSurfaceOrientation_ && includeCut_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal include cell specification."
|
||||||
|
<< " You cannot specify both 'useSurfaceOrientation'"
|
||||||
|
<< " and 'includeCut'"
|
||||||
|
<< " since 'includeCut' specifies a topological split"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceToCell::surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const fileName& surfName,
|
||||||
|
const pointField& outsidePoints,
|
||||||
|
const bool includeCut,
|
||||||
|
const bool includeInside,
|
||||||
|
const bool includeOutside,
|
||||||
|
const bool useSurfaceOrientation,
|
||||||
|
const scalar nearDist,
|
||||||
|
const scalar curvature
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
surfName_(surfName),
|
||||||
|
outsidePoints_(outsidePoints),
|
||||||
|
includeCut_(includeCut),
|
||||||
|
includeInside_(includeInside),
|
||||||
|
includeOutside_(includeOutside),
|
||||||
|
useSurfaceOrientation_(useSurfaceOrientation),
|
||||||
|
nearDist_(nearDist),
|
||||||
|
curvature_(curvature),
|
||||||
|
surfPtr_(new triSurface(surfName_)),
|
||||||
|
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
|
||||||
|
IOwnPtrs_(true)
|
||||||
|
{
|
||||||
|
checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::surfaceToCell::surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const fileName& surfName,
|
||||||
|
const triSurface& surf,
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
const pointField& outsidePoints,
|
||||||
|
const bool includeCut,
|
||||||
|
const bool includeInside,
|
||||||
|
const bool includeOutside,
|
||||||
|
const bool useSurfaceOrientation,
|
||||||
|
const scalar nearDist,
|
||||||
|
const scalar curvature
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
surfName_(surfName),
|
||||||
|
outsidePoints_(outsidePoints),
|
||||||
|
includeCut_(includeCut),
|
||||||
|
includeInside_(includeInside),
|
||||||
|
includeOutside_(includeOutside),
|
||||||
|
useSurfaceOrientation_(useSurfaceOrientation),
|
||||||
|
nearDist_(nearDist),
|
||||||
|
curvature_(curvature),
|
||||||
|
surfPtr_(&surf),
|
||||||
|
querySurfPtr_(&querySurf),
|
||||||
|
IOwnPtrs_(false)
|
||||||
|
{
|
||||||
|
checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::surfaceToCell::surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
surfName_(fileName(dict.lookup("file")).expand()),
|
||||||
|
outsidePoints_(dict.lookup("outsidePoints")),
|
||||||
|
includeCut_(readBool(dict.lookup("includeCut"))),
|
||||||
|
includeInside_(readBool(dict.lookup("includeInside"))),
|
||||||
|
includeOutside_(readBool(dict.lookup("includeOutside"))),
|
||||||
|
useSurfaceOrientation_
|
||||||
|
(
|
||||||
|
dict.lookupOrDefault<bool>("useSurfaceOrientation", false)
|
||||||
|
),
|
||||||
|
nearDist_(readScalar(dict.lookup("nearDistance"))),
|
||||||
|
curvature_(readScalar(dict.lookup("curvature"))),
|
||||||
|
surfPtr_(new triSurface(surfName_)),
|
||||||
|
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
|
||||||
|
IOwnPtrs_(true)
|
||||||
|
{
|
||||||
|
checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::surfaceToCell::surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
surfName_(checkIs(is)),
|
||||||
|
outsidePoints_(checkIs(is)),
|
||||||
|
includeCut_(readBool(checkIs(is))),
|
||||||
|
includeInside_(readBool(checkIs(is))),
|
||||||
|
includeOutside_(readBool(checkIs(is))),
|
||||||
|
useSurfaceOrientation_(false),
|
||||||
|
nearDist_(readScalar(checkIs(is))),
|
||||||
|
curvature_(readScalar(checkIs(is))),
|
||||||
|
surfPtr_(new triSurface(surfName_)),
|
||||||
|
querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
|
||||||
|
IOwnPtrs_(true)
|
||||||
|
{
|
||||||
|
checkSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceToCell::~surfaceToCell()
|
||||||
|
{
|
||||||
|
if (IOwnPtrs_)
|
||||||
|
{
|
||||||
|
deleteDemandDrivenData(surfPtr_);
|
||||||
|
deleteDemandDrivenData(querySurfPtr_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::surfaceToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells in relation to surface " << surfName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells in relation to surface " << surfName_
|
||||||
|
<< " ..." << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
228
src/meshTools/sets/volRegions/surfaceToCell/surfaceToCell.H
Normal file
228
src/meshTools/sets/volRegions/surfaceToCell/surfaceToCell.H
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::surfaceToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on relation to surface.
|
||||||
|
|
||||||
|
Selects:
|
||||||
|
- all cells inside/outside/cut by surface
|
||||||
|
- all cells inside/outside surface ('useSurfaceOrientation', requires closed
|
||||||
|
surface)
|
||||||
|
- cells with centre nearer than XXX to surface
|
||||||
|
- cells with centre nearer than XXX to surface \b and with normal
|
||||||
|
at nearest point to centre and cell-corners differing by
|
||||||
|
more than YYY (i.e., point of high curvature)
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
surfaceToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef surfaceToCell_H
|
||||||
|
#define surfaceToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "Map.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
class triSurfaceSearch;
|
||||||
|
class triSurface;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class surfaceToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class surfaceToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name of surface file
|
||||||
|
const fileName surfName_;
|
||||||
|
|
||||||
|
//- Points which are outside
|
||||||
|
const pointField outsidePoints_;
|
||||||
|
|
||||||
|
//- Include cut cells
|
||||||
|
const bool includeCut_;
|
||||||
|
|
||||||
|
//- Include inside cells
|
||||||
|
const bool includeInside_;
|
||||||
|
|
||||||
|
//- Include outside cells
|
||||||
|
const bool includeOutside_;
|
||||||
|
|
||||||
|
//- Determine inside/outside purely using geometric test
|
||||||
|
// (does not allow includeCut)
|
||||||
|
const bool useSurfaceOrientation_;
|
||||||
|
|
||||||
|
//- If > 0 : include cells with distance from cellCentre to surface
|
||||||
|
// less than nearDist.
|
||||||
|
const scalar nearDist_;
|
||||||
|
|
||||||
|
//- If > -1 : include cells with normals at nearest surface points
|
||||||
|
// varying more than curvature_.
|
||||||
|
const scalar curvature_;
|
||||||
|
|
||||||
|
//- triSurface to search on. On pointer since can be external.
|
||||||
|
const triSurface* surfPtr_;
|
||||||
|
|
||||||
|
//- Search engine on surface.
|
||||||
|
const triSurfaceSearch* querySurfPtr_;
|
||||||
|
|
||||||
|
//- Whether I allocated above surface ptrs or whether they are
|
||||||
|
// external.
|
||||||
|
const bool IOwnPtrs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Find index of nearest triangle to point. Returns triangle or -1 if
|
||||||
|
// not found within search span.
|
||||||
|
// Cache result under pointi.
|
||||||
|
static label getNearest
|
||||||
|
(
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
const label pointi,
|
||||||
|
const point& pt,
|
||||||
|
const vector& searchSpan,
|
||||||
|
Map<label>& cache
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return true if surface normal of nearest points to vertices on
|
||||||
|
// cell differ from that on cell centre. Points cached in
|
||||||
|
// pointToNearest.
|
||||||
|
bool differingPointNormals
|
||||||
|
(
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
const vector& span,
|
||||||
|
const label celli,
|
||||||
|
const label cellTriI,
|
||||||
|
Map<label>& pointToNearest
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Depending on surface add to or delete from cellSet.
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
//- Check values at construction time.
|
||||||
|
void checkSettings() const;
|
||||||
|
|
||||||
|
const triSurfaceSearch& querySurf() const
|
||||||
|
{
|
||||||
|
return *querySurfPtr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("surfaceToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const fileName& surfName,
|
||||||
|
const pointField& outsidePoints,
|
||||||
|
const bool includeCut,
|
||||||
|
const bool includeInside,
|
||||||
|
const bool includeOutside,
|
||||||
|
const bool useSurfaceOrientation,
|
||||||
|
const scalar nearDist,
|
||||||
|
const scalar curvature
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (supplied surface, surfaceSearch)
|
||||||
|
surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const fileName& surfName,
|
||||||
|
const triSurface& surf,
|
||||||
|
const triSurfaceSearch& querySurf,
|
||||||
|
const pointField& outsidePoints,
|
||||||
|
const bool includeCut,
|
||||||
|
const bool includeInside,
|
||||||
|
const bool includeOutside,
|
||||||
|
const bool useSurfaceOrientation,
|
||||||
|
const scalar nearDist,
|
||||||
|
const scalar curvature
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
surfaceToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~surfaceToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,342 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "targetVolumeToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "globalMeshData.H"
|
||||||
|
#include "plane.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(targetVolumeToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::targetVolumeToCell::usage_
|
||||||
|
(
|
||||||
|
targetVolumeToCell::typeName,
|
||||||
|
"\n Usage: targetVolumeToCell (nx ny nz)\n\n"
|
||||||
|
" Adjust plane until obtained selected volume\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::targetVolumeToCell::volumeOfSet
|
||||||
|
(
|
||||||
|
const PackedBoolList& selected
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
scalar sumVol = 0.0;
|
||||||
|
forAll(selected, celli)
|
||||||
|
{
|
||||||
|
if (selected[celli])
|
||||||
|
{
|
||||||
|
sumVol += mesh_.cellVolumes()[celli];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnReduce(sumVol, sumOp<scalar>());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::targetVolumeToCell::selectCells
|
||||||
|
(
|
||||||
|
const scalar normalComp,
|
||||||
|
const PackedBoolList& maskSet,
|
||||||
|
PackedBoolList& selected
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
selected.setSize(mesh_.nCells());
|
||||||
|
selected = false;
|
||||||
|
|
||||||
|
label nSelected = 0;
|
||||||
|
|
||||||
|
forAll(mesh_.cellCentres(), celli)
|
||||||
|
{
|
||||||
|
const point& cc = mesh_.cellCentres()[celli];
|
||||||
|
|
||||||
|
if (maskSet[celli] && ((cc&n_) < normalComp))
|
||||||
|
{
|
||||||
|
selected[celli] = true;
|
||||||
|
nSelected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnReduce(nSelected, sumOp<label>());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
if (vol_ <= 0)
|
||||||
|
{
|
||||||
|
// Select no cells
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PackedBoolList maskSet(mesh_.nCells(), 1);
|
||||||
|
label nTotCells = mesh_.globalData().nTotalCells();
|
||||||
|
if (maskSetName_.size())
|
||||||
|
{
|
||||||
|
// Read cellSet
|
||||||
|
Info<< " Operating on subset defined by cellSet " << maskSetName_
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
maskSet = 0;
|
||||||
|
cellSet subset(mesh_, maskSetName_);
|
||||||
|
|
||||||
|
forAllConstIter(cellSet, subset, iter)
|
||||||
|
{
|
||||||
|
maskSet[iter.key()] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nTotCells = returnReduce(subset.size(), sumOp<label>());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get plane for min,max volume.
|
||||||
|
// Planes all have base (0 0 0) and fixed normal so work only on normal
|
||||||
|
// component.
|
||||||
|
|
||||||
|
scalar maxComp = -GREAT;
|
||||||
|
label maxCells = 0;
|
||||||
|
//scalar maxVol = 0;
|
||||||
|
scalar minComp = GREAT;
|
||||||
|
{
|
||||||
|
const boundBox& bb = mesh_.bounds();
|
||||||
|
pointField points(bb.points());
|
||||||
|
|
||||||
|
//label minPointi = -1;
|
||||||
|
label maxPointi = -1;
|
||||||
|
forAll(points, pointi)
|
||||||
|
{
|
||||||
|
scalar c = (points[pointi]&n_);
|
||||||
|
if (c > maxComp)
|
||||||
|
{
|
||||||
|
maxComp = c;
|
||||||
|
maxPointi = pointi;
|
||||||
|
}
|
||||||
|
else if (c < minComp)
|
||||||
|
{
|
||||||
|
minComp = c;
|
||||||
|
//minPointi = pointi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PackedBoolList maxSelected(mesh_.nCells());
|
||||||
|
maxCells = selectCells(maxComp, maskSet, maxSelected);
|
||||||
|
//maxVol = volumeOfSet(maxSelected);
|
||||||
|
|
||||||
|
// Check that maxPoint indeed selects all cells
|
||||||
|
if (maxCells != nTotCells)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Plane " << plane(points[maxPointi], n_)
|
||||||
|
<< " selects " << maxCells
|
||||||
|
<< " cells instead of all " << nTotCells
|
||||||
|
<< " cells. Results might be wrong." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Bisection
|
||||||
|
// ~~~~~~~~~
|
||||||
|
|
||||||
|
PackedBoolList selected(mesh_.nCells());
|
||||||
|
label nSelected = -1;
|
||||||
|
scalar selectedVol = 0.0;
|
||||||
|
//scalar selectedComp = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
scalar low = minComp;
|
||||||
|
scalar high = maxComp;
|
||||||
|
|
||||||
|
const scalar tolerance = SMALL*100*(maxComp-minComp);
|
||||||
|
|
||||||
|
while ((high-low) > tolerance)
|
||||||
|
{
|
||||||
|
scalar mid = 0.5*(low + high);
|
||||||
|
|
||||||
|
nSelected = selectCells(mid, maskSet, selected);
|
||||||
|
selectedVol = volumeOfSet(selected);
|
||||||
|
|
||||||
|
//Pout<< "High:" << high << " low:" << low << " mid:" << mid << nl
|
||||||
|
// << " nSelected:" << nSelected << nl
|
||||||
|
// << " vol :" << selectedVol << nl
|
||||||
|
// << endl;
|
||||||
|
|
||||||
|
if (selectedVol < vol_)
|
||||||
|
{
|
||||||
|
low = mid;
|
||||||
|
|
||||||
|
PackedBoolList highSelected(mesh_.nCells());
|
||||||
|
label nHigh = selectCells(high, maskSet, selected);
|
||||||
|
if (nSelected == nHigh)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
high = mid;
|
||||||
|
|
||||||
|
PackedBoolList lowSelected(mesh_.nCells());
|
||||||
|
label nLow = selectCells(low, maskSet, selected);
|
||||||
|
if (nSelected == nLow)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nSelected = selectCells(high, maskSet, selected);
|
||||||
|
selectedVol = volumeOfSet(selected);
|
||||||
|
|
||||||
|
if (selectedVol < vol_)
|
||||||
|
{
|
||||||
|
//selectedComp = high;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nSelected = selectCells(low, maskSet, selected);
|
||||||
|
selectedVol = volumeOfSet(selected);
|
||||||
|
|
||||||
|
if (selectedVol < vol_)
|
||||||
|
{
|
||||||
|
//selectedComp = low;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Did not converge onto plane. " << nl
|
||||||
|
<< "high plane:"
|
||||||
|
<< plane(high*n_, n_)
|
||||||
|
<< nl
|
||||||
|
<< "low plane :"
|
||||||
|
<< plane(low*n_, n_)
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< " Selected " << nSelected << " with actual volume " << selectedVol
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
forAll(selected, celli)
|
||||||
|
{
|
||||||
|
if (selected[celli])
|
||||||
|
{
|
||||||
|
addOrDelete(set, celli, add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::targetVolumeToCell::targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const scalar vol,
|
||||||
|
const vector& n
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
vol_(vol),
|
||||||
|
n_(n)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::targetVolumeToCell::targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
vol_(readScalar(dict.lookup("volume"))),
|
||||||
|
n_(dict.lookup("normal")),
|
||||||
|
maskSetName_(dict.lookupOrDefault<word>("set", ""))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::targetVolumeToCell::targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
vol_(readScalar(checkIs(is))),
|
||||||
|
n_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::targetVolumeToCell::~targetVolumeToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::targetVolumeToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding cells up to target volume " << vol_
|
||||||
|
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing cells up to target volume " << vol_
|
||||||
|
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::targetVolumeToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select cells based on the wanted volume of selected
|
||||||
|
cells. Adapts a plane until it has enough.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
targetVolumeToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef targetVolumeToCell_H
|
||||||
|
#define targetVolumeToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class targetVolumeToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class targetVolumeToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Wanted volume
|
||||||
|
const scalar vol_;
|
||||||
|
|
||||||
|
//- Normal of plane to sweep
|
||||||
|
const vector n_;
|
||||||
|
|
||||||
|
//- Optional name of cellSet to calculate volume in
|
||||||
|
const word maskSetName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
scalar volumeOfSet(const PackedBoolList&) const;
|
||||||
|
|
||||||
|
label selectCells
|
||||||
|
(
|
||||||
|
const scalar normalComp,
|
||||||
|
const PackedBoolList&,
|
||||||
|
PackedBoolList& selected
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("targetVolumeToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const scalar vol,
|
||||||
|
const vector&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
targetVolumeToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~targetVolumeToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
162
src/meshTools/sets/volRegions/zoneToCell/zoneToCell.C
Normal file
162
src/meshTools/sets/volRegions/zoneToCell/zoneToCell.C
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "zoneToCell.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(zoneToCell, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, zoneToCell, word);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable(topoSetSource, zoneToCell, istream);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_
|
||||||
|
(
|
||||||
|
zoneToCell::typeName,
|
||||||
|
"\n Usage: zoneToCell zone\n\n"
|
||||||
|
" Select all cells in the cellZone."
|
||||||
|
" Note:accepts wildcards for zone.\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::zoneToCell::combine(topoSet& set, const bool add) const
|
||||||
|
{
|
||||||
|
bool hasMatched = false;
|
||||||
|
|
||||||
|
forAll(mesh_.cellZones(), i)
|
||||||
|
{
|
||||||
|
const cellZone& zone = mesh_.cellZones()[i];
|
||||||
|
|
||||||
|
if (zoneName_.match(zone.name()))
|
||||||
|
{
|
||||||
|
const labelList& cellLabels = mesh_.cellZones()[i];
|
||||||
|
|
||||||
|
Info<< " Found matching zone " << zone.name()
|
||||||
|
<< " with " << cellLabels.size() << " cells." << endl;
|
||||||
|
|
||||||
|
hasMatched = true;
|
||||||
|
|
||||||
|
forAll(cellLabels, i)
|
||||||
|
{
|
||||||
|
// Only do active cells
|
||||||
|
if (cellLabels[i] < mesh_.nCells())
|
||||||
|
{
|
||||||
|
addOrDelete(set, cellLabels[i], add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasMatched)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Cannot find any cellZone named " << zoneName_ << endl
|
||||||
|
<< "Valid names are " << mesh_.cellZones().names() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Construct from components
|
||||||
|
Foam::zoneToCell::zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(zoneName)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from dictionary
|
||||||
|
Foam::zoneToCell::zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(dict.lookup("name"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from Istream
|
||||||
|
Foam::zoneToCell::zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream& is
|
||||||
|
)
|
||||||
|
:
|
||||||
|
topoSetSource(mesh),
|
||||||
|
zoneName_(checkIs(is))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::zoneToCell::~zoneToCell()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::zoneToCell::applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||||
|
{
|
||||||
|
Info<< " Adding all cells of cellZone " << zoneName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, true);
|
||||||
|
}
|
||||||
|
else if (action == topoSetSource::DELETE)
|
||||||
|
{
|
||||||
|
Info<< " Removing all cells of cellZone " << zoneName_ << " ..."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
combine(set, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
126
src/meshTools/sets/volRegions/zoneToCell/zoneToCell.H
Normal file
126
src/meshTools/sets/volRegions/zoneToCell/zoneToCell.H
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::zoneToCell
|
||||||
|
|
||||||
|
Description
|
||||||
|
A topoSetSource to select faces based on cellZone.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
zoneToCell.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef zoneToCell_H
|
||||||
|
#define zoneToCell_H
|
||||||
|
|
||||||
|
#include "topoSetSource.H"
|
||||||
|
#include "wordRe.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class zoneToCell Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class zoneToCell
|
||||||
|
:
|
||||||
|
public topoSetSource
|
||||||
|
{
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Add usage string
|
||||||
|
static addToUsageTable usage_;
|
||||||
|
|
||||||
|
//- Name/regular expression of cellZone
|
||||||
|
wordRe zoneName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void combine(topoSet& set, const bool add) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("zoneToCell");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& zoneName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
zoneToCell
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
Istream&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~zoneToCell();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual sourceType setType() const
|
||||||
|
{
|
||||||
|
return CELLSETSOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void applyToSet
|
||||||
|
(
|
||||||
|
const topoSetSource::setAction action,
|
||||||
|
topoSet&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -10,6 +10,5 @@ flowVelocity (100 0 0);
|
|||||||
pressure 0;
|
pressure 0;
|
||||||
turbulentKE 37;
|
turbulentKE 37;
|
||||||
turbulentOmega 32;
|
turbulentOmega 32;
|
||||||
#inputMode merge
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -10,6 +10,5 @@ flowVelocity (100 0 0);
|
|||||||
pressure 0;
|
pressure 0;
|
||||||
turbulentKE 37;
|
turbulentKE 37;
|
||||||
turbulentOmega 32;
|
turbulentOmega 32;
|
||||||
#inputMode merge
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -10,6 +10,5 @@ flowVelocity (20 0 0);
|
|||||||
pressure 0;
|
pressure 0;
|
||||||
turbulentKE 0.24;
|
turbulentKE 0.24;
|
||||||
turbulentOmega 1.78;
|
turbulentOmega 1.78;
|
||||||
#inputMode merge
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -10,6 +10,5 @@ flowVelocity (20 0 0);
|
|||||||
pressure 0;
|
pressure 0;
|
||||||
turbulentKE 0.24;
|
turbulentKE 0.24;
|
||||||
turbulentOmega 1.78;
|
turbulentOmega 1.78;
|
||||||
#inputMode merge
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -53,15 +53,15 @@ maxDeltaT 1e-03;
|
|||||||
|
|
||||||
functions
|
functions
|
||||||
{
|
{
|
||||||
faceSource1
|
surfaceRegion1
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
writeFields no;
|
writeFields no;
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName outlet;
|
name outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
weightField phi;
|
weightField phi;
|
||||||
|
|
||||||
|
|||||||
@ -48,15 +48,15 @@ runTimeModifiable yes;
|
|||||||
|
|
||||||
functions
|
functions
|
||||||
{
|
{
|
||||||
faceSource1
|
surfaceRegion1
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
writeFields no;
|
writeFields no;
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName outlet;
|
name outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
weightField phi;
|
weightField phi;
|
||||||
fields
|
fields
|
||||||
|
|||||||
@ -48,16 +48,16 @@ runTimeModifiable yes;
|
|||||||
|
|
||||||
functions
|
functions
|
||||||
{
|
{
|
||||||
faceSource1
|
surfaceRegion1
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
enabled yes;
|
enabled yes;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
log yes;
|
log yes;
|
||||||
writeFields no;
|
writeFields no;
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName outlet;
|
name outlet;
|
||||||
operation weightedAverage;
|
operation weightedAverage;
|
||||||
weightField phi;
|
weightField phi;
|
||||||
fields
|
fields
|
||||||
|
|||||||
@ -55,14 +55,14 @@ functions
|
|||||||
{
|
{
|
||||||
inletFlux
|
inletFlux
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
log true;
|
log true;
|
||||||
// Output field values as well
|
// Output field values as well
|
||||||
writeFields false;
|
writeFields false;
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName inlet;
|
name inlet;
|
||||||
operation sum;
|
operation sum;
|
||||||
|
|
||||||
fields
|
fields
|
||||||
@ -74,13 +74,13 @@ functions
|
|||||||
outletFlux
|
outletFlux
|
||||||
{
|
{
|
||||||
$inletFlux;
|
$inletFlux;
|
||||||
sourceName outlet;
|
name outlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
atmosphereFlux
|
atmosphereFlux
|
||||||
{
|
{
|
||||||
$inletFlux;
|
$inletFlux;
|
||||||
sourceName atmosphere;
|
name atmosphere;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ expansionRatio 1.0;
|
|||||||
linearDirectionCoeffs
|
linearDirectionCoeffs
|
||||||
{
|
{
|
||||||
axisPt (0 0 0);
|
axisPt (0 0 0);
|
||||||
direction (1 -0.2 -0.02);
|
direction (1 -0.2 -0.03);
|
||||||
thickness 40;
|
thickness 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,5 @@ inletFlowRate 75;
|
|||||||
pressure 0;
|
pressure 0;
|
||||||
turbulentKE 4.14e-03;
|
turbulentKE 4.14e-03;
|
||||||
turbulentEpsilon 4.39e-05;
|
turbulentEpsilon 4.39e-05;
|
||||||
#inputMode merge
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
awk '{print $1 " " $3}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceRegion.dat > poolHeight_vs_time
|
||||||
|
|||||||
@ -67,15 +67,15 @@ functions
|
|||||||
|
|
||||||
poolHeight
|
poolHeight
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
writeTotalArea no;
|
writeTotalArea no;
|
||||||
writeFields no;
|
writeFields no;
|
||||||
source faceZone;
|
regionType faceZone;
|
||||||
sourceName f0;
|
name f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
fields
|
fields
|
||||||
(
|
(
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
awk '{print $1 " " $3}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceRegion.dat > poolHeight_vs_time
|
||||||
|
|||||||
@ -67,15 +67,15 @@ functions
|
|||||||
|
|
||||||
poolHeight
|
poolHeight
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
writeTotalArea no;
|
writeTotalArea no;
|
||||||
writeFields no;
|
writeFields no;
|
||||||
source faceZone;
|
regionType faceZone;
|
||||||
sourceName f0;
|
name f0;
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
fields
|
fields
|
||||||
(
|
(
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
inletMassFlowRate
|
inletMassFlowRate
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
fields
|
fields
|
||||||
@ -21,8 +21,8 @@ inletMassFlowRate
|
|||||||
log true;
|
log true;
|
||||||
surfaceFormat null;
|
surfaceFormat null;
|
||||||
|
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName inlet;
|
name inlet;
|
||||||
|
|
||||||
operation sum;
|
operation sum;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ inletMassFlowRate
|
|||||||
|
|
||||||
outletMassFlowRate
|
outletMassFlowRate
|
||||||
{
|
{
|
||||||
type faceSource;
|
type surfaceRegion;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
fields
|
fields
|
||||||
@ -44,8 +44,8 @@ outletMassFlowRate
|
|||||||
log true;
|
log true;
|
||||||
surfaceFormat null;
|
surfaceFormat null;
|
||||||
|
|
||||||
source patch;
|
regionType patch;
|
||||||
sourceName outlet;
|
name outlet;
|
||||||
|
|
||||||
operation sum;
|
operation sum;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user