mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
sorted zones
modified: ../applications/utilities/mesh/manipulation/setsToZones/setsToZones.C modified: dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
This commit is contained in:
@ -48,6 +48,7 @@ Description
|
|||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
|
#include "SortableList.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -107,6 +108,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
pointSet set(*iter());
|
pointSet set(*iter());
|
||||||
|
SortableList<label> pointLabels(set.toc());
|
||||||
|
|
||||||
label zoneID = mesh.pointZones().findZoneID(set.name());
|
label zoneID = mesh.pointZones().findZoneID(set.name());
|
||||||
if (zoneID == -1)
|
if (zoneID == -1)
|
||||||
@ -120,7 +122,7 @@ int main(int argc, char *argv[])
|
|||||||
new pointZone
|
new pointZone
|
||||||
(
|
(
|
||||||
set.name(), //name
|
set.name(), //name
|
||||||
set.toc(), //addressing
|
pointLabels, //addressing
|
||||||
sz, //index
|
sz, //index
|
||||||
mesh.pointZones() //pointZoneMesh
|
mesh.pointZones() //pointZoneMesh
|
||||||
)
|
)
|
||||||
@ -131,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "Overwriting contents of existing pointZone " << zoneID
|
Info<< "Overwriting contents of existing pointZone " << zoneID
|
||||||
<< " with that of set " << set.name() << "." << endl;
|
<< " with that of set " << set.name() << "." << endl;
|
||||||
mesh.pointZones()[zoneID] = set.toc();
|
mesh.pointZones()[zoneID] = pointLabels;
|
||||||
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
|
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,6 +152,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
cellSet set(*iter());
|
cellSet set(*iter());
|
||||||
|
SortableList<label> cellLabels(set.toc());
|
||||||
|
|
||||||
label zoneID = mesh.cellZones().findZoneID(set.name());
|
label zoneID = mesh.cellZones().findZoneID(set.name());
|
||||||
if (zoneID == -1)
|
if (zoneID == -1)
|
||||||
@ -163,7 +166,7 @@ int main(int argc, char *argv[])
|
|||||||
new cellZone
|
new cellZone
|
||||||
(
|
(
|
||||||
set.name(), //name
|
set.name(), //name
|
||||||
set.toc(), //addressing
|
cellLabels, //addressing
|
||||||
sz, //index
|
sz, //index
|
||||||
mesh.cellZones() //pointZoneMesh
|
mesh.cellZones() //pointZoneMesh
|
||||||
)
|
)
|
||||||
@ -174,7 +177,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "Overwriting contents of existing cellZone " << zoneID
|
Info<< "Overwriting contents of existing cellZone " << zoneID
|
||||||
<< " with that of set " << set.name() << "." << endl;
|
<< " with that of set " << set.name() << "." << endl;
|
||||||
mesh.cellZones()[zoneID] = set.toc();
|
mesh.cellZones()[zoneID] = cellLabels;
|
||||||
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
|
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,6 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// Not in memory. Load it.
|
// Not in memory. Load it.
|
||||||
faceSet set(*iter());
|
faceSet set(*iter());
|
||||||
|
SortableList<label> faceLabels(set.toc());
|
||||||
|
|
||||||
DynamicList<label> addressing(set.size());
|
DynamicList<label> addressing(set.size());
|
||||||
DynamicList<bool> flipMap(set.size());
|
DynamicList<bool> flipMap(set.size());
|
||||||
@ -214,9 +218,9 @@ int main(int argc, char *argv[])
|
|||||||
// Load corresponding cells
|
// Load corresponding cells
|
||||||
cellSet cells(mesh, setName);
|
cellSet cells(mesh, setName);
|
||||||
|
|
||||||
forAllConstIter(faceSet, set, iter)
|
forAll(faceLabels, i)
|
||||||
{
|
{
|
||||||
label faceI = iter.key();
|
label faceI = faceLabels[i];
|
||||||
|
|
||||||
bool flip = false;
|
bool flip = false;
|
||||||
|
|
||||||
@ -273,9 +277,10 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No flip map.
|
// No flip map.
|
||||||
forAllConstIter(faceSet, set, iter)
|
forAll(faceLabels, i)
|
||||||
{
|
{
|
||||||
addressing.append(iter.key());
|
label faceI = faceLabels[i];
|
||||||
|
addressing.append(faceI);
|
||||||
flipMap.append(false);
|
flipMap.append(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1464,6 +1464,11 @@ void Foam::polyTopoChange::resetZones
|
|||||||
|
|
||||||
addressing[zoneI][nPoints[zoneI]++] = iter.key();
|
addressing[zoneI][nPoints[zoneI]++] = iter.key();
|
||||||
}
|
}
|
||||||
|
// Sort the addressing
|
||||||
|
forAll(addressing, zoneI)
|
||||||
|
{
|
||||||
|
stableSort(addressing[zoneI]);
|
||||||
|
}
|
||||||
|
|
||||||
// So now we both have old zones and the new addressing.
|
// So now we both have old zones and the new addressing.
|
||||||
// Invert the addressing to get pointZoneMap.
|
// Invert the addressing to get pointZoneMap.
|
||||||
@ -1551,6 +1556,28 @@ void Foam::polyTopoChange::resetZones
|
|||||||
addressing[zoneI][index] = faceI;
|
addressing[zoneI][index] = faceI;
|
||||||
flipMode[zoneI][index] = faceZoneFlip_[faceI];
|
flipMode[zoneI][index] = faceZoneFlip_[faceI];
|
||||||
}
|
}
|
||||||
|
// Sort the addressing
|
||||||
|
forAll(addressing, zoneI)
|
||||||
|
{
|
||||||
|
labelList newToOld;
|
||||||
|
sortedOrder(addressing[zoneI], newToOld);
|
||||||
|
{
|
||||||
|
labelList newAddressing(addressing[zoneI].size());
|
||||||
|
forAll(newAddressing, i)
|
||||||
|
{
|
||||||
|
newAddressing[i] = addressing[zoneI][newToOld[i]];
|
||||||
|
}
|
||||||
|
addressing[zoneI].transfer(newAddressing);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
boolList newFlipMode(flipMode[zoneI].size());
|
||||||
|
forAll(newFlipMode, i)
|
||||||
|
{
|
||||||
|
newFlipMode[i] = flipMode[zoneI][newToOld[i]];
|
||||||
|
}
|
||||||
|
flipMode[zoneI].transfer(newFlipMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// So now we both have old zones and the new addressing.
|
// So now we both have old zones and the new addressing.
|
||||||
// Invert the addressing to get faceZoneFaceMap.
|
// Invert the addressing to get faceZoneFaceMap.
|
||||||
@ -1644,6 +1671,11 @@ void Foam::polyTopoChange::resetZones
|
|||||||
addressing[zoneI][nCells[zoneI]++] = cellI;
|
addressing[zoneI][nCells[zoneI]++] = cellI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Sort the addressing
|
||||||
|
forAll(addressing, zoneI)
|
||||||
|
{
|
||||||
|
stableSort(addressing[zoneI]);
|
||||||
|
}
|
||||||
|
|
||||||
// So now we both have old zones and the new addressing.
|
// So now we both have old zones and the new addressing.
|
||||||
// Invert the addressing to get cellZoneMap.
|
// Invert the addressing to get cellZoneMap.
|
||||||
|
|||||||
Reference in New Issue
Block a user