mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
topoSet: cellZoneSet, pointZoneSet extensions
cellZones and pointZones can now be created in one action without the
need to first create a cellSet or pointSet and converting that to the
corresponding zone, e.g.
actions
(
// Example: create cellZone from a box region
{
name c0;
type cellZoneSet;
action new;
source boxToCell;
sourceInfo
{
box (0.04 0 0)(0.06 100 100);
}
}
);
This commit is contained in:
@ -33,9 +33,6 @@ Description
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "topoSetSource.H"
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "timeSelector.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
@ -342,8 +342,12 @@ FoamFile
|
||||
//
|
||||
// cellZoneSet
|
||||
// ~~~~~~~~~~~
|
||||
// (mirrors operations on a cellSet into a cellZone)
|
||||
// Manipulates a cellZone (as well as a cellSet)
|
||||
// Takes any cellSet source. The difference with a cellSet is
|
||||
// - reads the cells from the cellZone, not the cellSet
|
||||
// - write to the cellZone as well as the cellSet
|
||||
//
|
||||
// For backwards compatibility:
|
||||
// // Select based on cellSet
|
||||
// source setToCellZone;
|
||||
// sourceInfo
|
||||
@ -355,6 +359,9 @@ FoamFile
|
||||
//
|
||||
// faceZoneSet
|
||||
// ~~~~~~~~~~~
|
||||
// Manipulates a faceZone (as well as a faceSet). It can only be used
|
||||
// with two special sources:
|
||||
//
|
||||
// // Select based on faceSet without orientation
|
||||
// source setToFaceZone;
|
||||
// sourceInfo
|
||||
@ -391,17 +398,19 @@ FoamFile
|
||||
//
|
||||
// pointZoneSet
|
||||
// ~~~~~~~~~~~~
|
||||
// (mirrors operations on a pointSet into a pointZone)
|
||||
// Manipulates a pointZone (as well as a pointSet)
|
||||
// Takes any pointSet source. The difference with a pointSet is
|
||||
// - reads the cells from the pointZone, not the pointSet
|
||||
// - write to the pointZone as well as the pointSet
|
||||
//
|
||||
// For backwards compatibility:
|
||||
// // Select based on pointSet
|
||||
// source setToPointZone;
|
||||
// sourceInfo
|
||||
// {
|
||||
// set p0; // name of pointSet
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
actions
|
||||
(
|
||||
@ -413,7 +422,7 @@ actions
|
||||
name c0;
|
||||
type cellSet;
|
||||
action new;
|
||||
source labelToCell;
|
||||
source labelToCell;
|
||||
sourceInfo
|
||||
{
|
||||
value (12 13 56);
|
||||
@ -462,6 +471,19 @@ actions
|
||||
option all;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Example: create cellZone from geometric region
|
||||
{
|
||||
name c0;
|
||||
type cellZoneSet;
|
||||
action new;
|
||||
source boxToCell;
|
||||
sourceInfo
|
||||
{
|
||||
box (0.04 0 0)(0.06 100 100);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -229,7 +229,13 @@ void cellZoneSet::deleteSet(const topoSet& set)
|
||||
|
||||
|
||||
void cellZoneSet::sync(const polyMesh& mesh)
|
||||
{}
|
||||
{
|
||||
cellSet::sync(mesh);
|
||||
|
||||
// Take over contents of cellSet into addressing.
|
||||
addressing_ = sortedToc();
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
label cellZoneSet::maxSize(const polyMesh& mesh) const
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::cellZoneSet
|
||||
|
||||
Description
|
||||
Like cellSet but updates cellZone when writing.
|
||||
Like cellSet but -reads data from cellZone -updates cellZone when writing.
|
||||
|
||||
SourceFiles
|
||||
cellZone.C
|
||||
@ -126,7 +126,7 @@ public:
|
||||
//- Delete elements present in set.
|
||||
virtual void deleteSet(const topoSet& set);
|
||||
|
||||
//- Sync cellZoneSet across coupled patches.
|
||||
//- Sync cellSet across coupled patches; update cellZone from cellSet
|
||||
virtual void sync(const polyMesh& mesh);
|
||||
|
||||
//- Write maxLen items with label and coordinates.
|
||||
@ -150,10 +150,6 @@ public:
|
||||
|
||||
//- Return max index+1.
|
||||
virtual label maxSize(const polyMesh& mesh) const;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -26,6 +26,9 @@ License
|
||||
#include "faceZoneSet.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "setToFaceZone.H"
|
||||
#include "setsToFaceZone.H"
|
||||
#include "syncTools.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -322,7 +325,132 @@ void faceZoneSet::deleteSet(const topoSet& set)
|
||||
|
||||
|
||||
void faceZoneSet::sync(const polyMesh& mesh)
|
||||
{}
|
||||
{
|
||||
// Make sure that the faceZone is consistent with the faceSet
|
||||
{
|
||||
const labelHashSet zoneSet(addressing_);
|
||||
|
||||
// Get elements that are in zone but not faceSet
|
||||
labelHashSet badSet(zoneSet);
|
||||
badSet -= *this;
|
||||
|
||||
// Add elements that are in faceSet but not in zone
|
||||
labelHashSet fSet(*this);
|
||||
fSet -= zoneSet;
|
||||
|
||||
badSet += fSet;
|
||||
|
||||
label nBad = returnReduce(badSet.size(), sumOp<label>());
|
||||
|
||||
if (nBad)
|
||||
{
|
||||
WarningInFunction << "Detected " << nBad
|
||||
<< " faces that are in the faceZone but not"
|
||||
<< " in the faceSet or vice versa."
|
||||
<< " The faceZoneSet should only be manipulated"
|
||||
<< " using " << setsToFaceZone::typeName
|
||||
<< " or " << setToFaceZone::typeName << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make sure that on coupled faces orientation is opposite. Pushes
|
||||
// master orientation to slave in case of conflict.
|
||||
|
||||
|
||||
// 0 : not in faceZone
|
||||
// 1 : in faceZone and unflipped
|
||||
//-1 : in faceZone and flipped
|
||||
const label UNFLIPPED = 1;
|
||||
const label FLIPPED = -1;
|
||||
labelList myZoneFace(mesh.nFaces()-mesh.nInternalFaces(), 0);
|
||||
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
label bFacei = addressing_[i]-mesh.nInternalFaces();
|
||||
|
||||
if (bFacei >= 0)
|
||||
{
|
||||
if (flipMap_[i])
|
||||
{
|
||||
myZoneFace[bFacei] = FLIPPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
myZoneFace[bFacei] = UNFLIPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
labelList neiZoneFace(myZoneFace);
|
||||
syncTools::swapBoundaryFaceList(mesh, neiZoneFace);
|
||||
|
||||
|
||||
const PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh));
|
||||
|
||||
|
||||
// Rebuild faceZone addressing and flipMap
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
DynamicList<label> newAddressing(addressing_.size());
|
||||
DynamicList<bool> newFlipMap(flipMap_.size());
|
||||
|
||||
forAll(addressing_, i)
|
||||
{
|
||||
label facei = addressing_[i];
|
||||
if (facei < mesh.nInternalFaces())
|
||||
{
|
||||
newAddressing.append(facei);
|
||||
newFlipMap.append(flipMap_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
|
||||
{
|
||||
label myStat = myZoneFace[facei-mesh.nInternalFaces()];
|
||||
label neiStat = neiZoneFace[facei-mesh.nInternalFaces()];
|
||||
|
||||
if (myStat == 0)
|
||||
{
|
||||
if (neiStat == UNFLIPPED)
|
||||
{
|
||||
// Neighbour is unflipped so I am flipped
|
||||
newAddressing.append(facei);
|
||||
newFlipMap.append(true);
|
||||
}
|
||||
else if (neiStat == FLIPPED)
|
||||
{
|
||||
newAddressing.append(facei);
|
||||
newFlipMap.append(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myStat == neiStat)
|
||||
{
|
||||
// Conflict. masterFace wins
|
||||
newAddressing.append(facei);
|
||||
if (isMasterFace[facei])
|
||||
{
|
||||
newFlipMap.append(myStat == FLIPPED);
|
||||
}
|
||||
else
|
||||
{
|
||||
newFlipMap.append(neiStat == UNFLIPPED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newAddressing.append(facei);
|
||||
newFlipMap.append(myStat == FLIPPED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addressing_.transfer(newAddressing);
|
||||
flipMap_.transfer(newFlipMap);
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
label faceZoneSet::maxSize(const polyMesh& mesh) const
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::faceZoneSet
|
||||
|
||||
Description
|
||||
Like faceSet but updates faceZone when writing.
|
||||
Like faceSet but -reads data from faceZone -updates faceZone when writing.
|
||||
|
||||
SourceFiles
|
||||
faceZone.C
|
||||
@ -167,10 +167,6 @@ public:
|
||||
|
||||
//- Return max index+1.
|
||||
virtual label maxSize(const polyMesh& mesh) const;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -230,7 +230,13 @@ void pointZoneSet::deleteSet(const topoSet& set)
|
||||
|
||||
|
||||
void pointZoneSet::sync(const polyMesh& mesh)
|
||||
{}
|
||||
{
|
||||
pointSet::sync(mesh);
|
||||
|
||||
// Take over contents of pointSet into addressing.
|
||||
addressing_ = sortedToc();
|
||||
updateSet();
|
||||
}
|
||||
|
||||
|
||||
label pointZoneSet::maxSize(const polyMesh& mesh) const
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,8 @@ Class
|
||||
Foam::pointZoneSet
|
||||
|
||||
Description
|
||||
Like pointSet but updates pointZone when writing.
|
||||
Like pointSet but -reads data from pointZone -updates pointZone when
|
||||
writing.
|
||||
|
||||
SourceFiles
|
||||
pointZone.C
|
||||
@ -153,10 +154,6 @@ public:
|
||||
|
||||
//- Return max index+1.
|
||||
virtual label maxSize(const polyMesh& mesh) const;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user