Skip to content

Commit 9239b3b

Browse files
author
Henry Weller
committed
polyTopoChange: Removed restrictive pointZone functionality
Now pointZones are handled directly by the applications and the new pointZone::topoChange function so that any point can now be in any number of zones, significantly increasing the flexibility and usefulness of pointZones. The same rationalisation and generalisation will be applied to cellZones and faceZones in the future.
1 parent 9e3d5fd commit 9239b3b

File tree

30 files changed

+218
-408
lines changed

30 files changed

+218
-408
lines changed

applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ int main(int argc, char *argv[])
12431243
// Add all points
12441244
forAll(points, pointi)
12451245
{
1246-
meshMod.addPoint(points[pointi], pointi, -1, true);
1246+
meshMod.addPoint(points[pointi], pointi, true);
12471247
}
12481248
points.setSize(0);
12491249

applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Description
4242
#include "polyTopoChange.H"
4343
#include "MeshedSurface.H"
4444
#include "edgeCollapser.H"
45-
#include "addPatchCellLayer.H"
4645
#include "patchToPoly2DMesh.H"
4746
#include "globalIndex.H"
4847
#include "IOdictionary.H"

applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ void Foam::extrude2DMesh::setRefinement
238238
(
239239
newPoint,
240240
pointi + offset,
241-
-1, // zoneID
242241
true // inCell
243242
);
244243
}

applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,8 @@ int main(int argc, char *argv[])
628628
mesh
629629
);
630630

631+
layerExtrude.updateZones(meshFromMesh());
632+
631633
layerExtrude.topoChange
632634
(
633635
map(),

applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Foam::mergePolyMesh::mergePolyMesh(polyMesh& mesh)
153153
pointZoneNames_.append(curPointZoneNames[zoneI]);
154154
}
155155

156+
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
157+
156158
// Face zones
157159
wordList curFaceZoneNames = mesh_.faceZones().names();
158160

@@ -201,26 +203,26 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
201203
forAll(pz, zoneI)
202204
{
203205
pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].name());
206+
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
204207
}
205208

206209
forAll(p, pointi)
207210
{
208-
// Grab zone ID. If a point is not in a zone, it will return -1
209-
zoneID = pz.whichZone(pointi);
210-
211-
if (zoneID >= 0)
212-
{
213-
// Translate zone ID into the new index
214-
zoneID = pointZoneIndices[zoneID];
215-
}
216-
217211
renumberPoints[pointi] = meshMod_.addPoint
218212
(
219213
p[pointi], // Point to add
220214
-1, // Master point (straight addition)
221-
zoneID, // Zone for point
222215
pointi < m.nPoints() // Is in cell?
223216
);
217+
218+
// Grab zone ID. If a point is not in a zone, it will return -1
219+
zoneID = pz.whichZone(pointi);
220+
221+
if (zoneID >= 0)
222+
{
223+
pointZonesAddedPoints_[pointZoneIndices[zoneID]]
224+
.insert(renumberPoints[pointi]);
225+
}
224226
}
225227

226228
// Add cells
@@ -509,6 +511,12 @@ void Foam::mergePolyMesh::merge()
509511

510512
// Clear topo change for the next operation
511513
meshMod_.clear();
514+
515+
// Add the new points to the pointZones in the merged mesh
516+
forAll(pointZonesAddedPoints_, zonei)
517+
{
518+
mesh_.pointZones()[zonei].insert(pointZonesAddedPoints_[zonei]);
519+
}
512520
}
513521

514522

applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class mergePolyMesh
6666
//- Point zone names
6767
DynamicList<word> pointZoneNames_;
6868

69+
//- Zones of the added points
70+
List<labelHashSet> pointZonesAddedPoints_;
71+
6972
//- Face zone names
7073
DynamicList<word> faceZoneNames_;
7174

applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ void Foam::meshDualiser::generateDualBoundaryEdges
127127
(
128128
e.centre(mesh_.points()),
129129
pointi, // masterPoint
130-
-1, // zoneID
131130
true // inCell
132131
);
133132
}
@@ -177,20 +176,6 @@ Foam::label Foam::meshDualiser::addInternalFace
177176
reverse(newFace);
178177
}
179178

180-
label zoneID = -1;
181-
bool zoneFlip = false;
182-
if (masterFacei != -1)
183-
{
184-
zoneID = mesh_.faceZones().whichZone(masterFacei);
185-
186-
if (zoneID != -1)
187-
{
188-
const faceZone& fZone = mesh_.faceZones()[zoneID];
189-
190-
zoneFlip = fZone.flipMap()[fZone.whichFace(masterFacei)];
191-
}
192-
}
193-
194179
label dualFacei;
195180

196181
if (dualCell0 < dualCell1)
@@ -203,8 +188,8 @@ Foam::label Foam::meshDualiser::addInternalFace
203188
masterFacei, // masterFaceID
204189
false, // flipFaceFlux
205190
-1, // patchID
206-
zoneID, // zoneID
207-
zoneFlip // zoneFlip
191+
-1, // zoneID
192+
false // zoneFlip
208193
);
209194

210195
// pointField dualPoints(meshMod.points());
@@ -228,8 +213,8 @@ Foam::label Foam::meshDualiser::addInternalFace
228213
masterFacei, // masterFaceID
229214
false, // flipFaceFlux
230215
-1, // patchID
231-
zoneID, // zoneID
232-
zoneFlip // zoneFlip
216+
-1, // zoneID
217+
false // zoneFlip
233218
);
234219

235220
// pointField dualPoints(meshMod.points());
@@ -261,20 +246,6 @@ Foam::label Foam::meshDualiser::addBoundaryFace
261246
{
262247
face newFace(verts);
263248

264-
label zoneID = -1;
265-
bool zoneFlip = false;
266-
if (masterFacei != -1)
267-
{
268-
zoneID = mesh_.faceZones().whichZone(masterFacei);
269-
270-
if (zoneID != -1)
271-
{
272-
const faceZone& fZone = mesh_.faceZones()[zoneID];
273-
274-
zoneFlip = fZone.flipMap()[fZone.whichFace(masterFacei)];
275-
}
276-
}
277-
278249
label dualFacei = meshMod.addFace
279250
(
280251
newFace,
@@ -283,8 +254,8 @@ Foam::label Foam::meshDualiser::addBoundaryFace
283254
masterFacei, // masterFaceID
284255
false, // flipFaceFlux
285256
patchi, // patchID
286-
zoneID, // zoneID
287-
zoneFlip // zoneFlip
257+
-1, // zoneID
258+
false // zoneFlip
288259
);
289260

290261
// pointField dualPoints(meshMod.points());
@@ -955,7 +926,6 @@ void Foam::meshDualiser::setRefinement
955926
(
956927
mesh_.points()[pointi],
957928
pointi, // masterPoint
958-
mesh_.pointZones().whichZone(pointi), // zoneID
959929
true // inCell
960930
);
961931

@@ -990,7 +960,6 @@ void Foam::meshDualiser::setRefinement
990960
(
991961
mesh_.points()[pointi],
992962
pointi, // masterPoint
993-
mesh_.pointZones().whichZone(pointi), // zoneID
994963
true // inCell
995964
);
996965

@@ -1005,7 +974,7 @@ void Foam::meshDualiser::setRefinement
1005974
pointToDualCells_[pointi][pCelli] = meshMod.addCell
1006975
(
1007976
-1, // masterCellID
1008-
mesh_.cellZones().whichZone(pCells[pCelli]) // zoneID
977+
-1
1009978
);
1010979
if (dualCcStr.valid())
1011980
{
@@ -1046,7 +1015,6 @@ void Foam::meshDualiser::setRefinement
10461015
(
10471016
cellCentres[celli],
10481017
mesh_.faces()[mesh_.cells()[celli][0]][0], // masterPoint
1049-
-1, // zoneID
10501018
true // inCell
10511019
);
10521020
}
@@ -1061,7 +1029,6 @@ void Foam::meshDualiser::setRefinement
10611029
(
10621030
mesh_.faceCentres()[facei],
10631031
mesh_.faces()[facei][0], // masterPoint
1064-
-1, // zoneID
10651032
true // inCell
10661033
);
10671034
}
@@ -1085,7 +1052,6 @@ void Foam::meshDualiser::setRefinement
10851052
(
10861053
mesh_.faceCentres()[facei],
10871054
f[fp], // masterPoint
1088-
-1, // zoneID
10891055
true // inCell
10901056
);
10911057

@@ -1107,7 +1073,6 @@ void Foam::meshDualiser::setRefinement
11071073
(
11081074
e.centre(mesh_.points()),
11091075
e[0], // masterPoint
1110-
-1, // zoneID
11111076
true // inCell
11121077
);
11131078
}
@@ -1142,7 +1107,6 @@ void Foam::meshDualiser::setRefinement
11421107
(
11431108
e.centre(mesh_.points()),
11441109
e[0], // masterPoint
1145-
mesh_.pointZones().whichZone(e[0]), // zoneID
11461110
true // inCell
11471111
);
11481112

@@ -1157,7 +1121,6 @@ void Foam::meshDualiser::setRefinement
11571121
(
11581122
e.centre(mesh_.points()),
11591123
e[1], // masterPoint
1160-
mesh_.pointZones().whichZone(e[1]), // zoneID
11611124
true // inCell
11621125
);
11631126

applications/utilities/mesh/manipulation/polyDualMesh/polyDualMesh.C

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ int main(int argc, char *argv[])
422422
}
423423

424424

425+
mesh.cellZones().clear();
426+
mesh.pointZones().clear();
427+
428+
if (doNotPreserveFaceZones)
429+
{
430+
mesh.faceZones().clear();
431+
}
432+
425433
// Face(centre)s that need inclusion in the dual mesh
426434
labelList featureFaces;
427435
// Edge(centre)s ,,
@@ -446,6 +454,8 @@ int main(int argc, char *argv[])
446454
multiCellFeaturePoints
447455
);
448456

457+
mesh.faceZones().clear();
458+
449459
// If we want to split all polyMesh faces into one dualface per cell
450460
// we are passing through we also need a point
451461
// at the polyMesh facecentre and edgemid of the faces we want to

src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ License
2424
\*---------------------------------------------------------------------------*/
2525

2626
#include "cellZone.H"
27-
#include "addToRunTimeSelectionTable.H"
2827
#include "meshCellZones.H"
2928
#include "polyMesh.H"
30-
#include "primitiveMesh.H"
31-
#include "IOstream.H"
32-
#include "demandDrivenData.H"
29+
#include "polyTopoChangeMap.H"
30+
#include "addToRunTimeSelectionTable.H"
3331

3432
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
3533

@@ -130,6 +128,33 @@ bool Foam::cellZone::checkDefinition(const bool report) const
130128
}
131129

132130

131+
void Foam::cellZone::topoChange(const polyTopoChangeMap& map)
132+
{
133+
clearAddressing();
134+
135+
/*
136+
labelList newAddressing(size());
137+
label nCells = 0;
138+
139+
const labelList& cellMap = map.reverseCellMap();
140+
141+
forAll(*this, i)
142+
{
143+
const label celli = operator[](i);
144+
145+
if (cellMap[celli] >= 0)
146+
{
147+
newAddressing[nCells] = cellMap[celli];
148+
nCells++;
149+
}
150+
}
151+
152+
newAddressing.setSize(nCells);
153+
transfer(newAddressing);
154+
*/
155+
}
156+
157+
133158
void Foam::cellZone::writeDict(Ostream& os) const
134159
{
135160
os << nl << name() << nl << token::BEGIN_BLOCK << nl

src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ public:
200200
return false;
201201
}
202202

203+
//- Update zone using the given map
204+
virtual void topoChange(const polyTopoChangeMap& map);
205+
203206
//- Write dictionary
204207
virtual void writeDict(Ostream&) const;
205208

0 commit comments

Comments
 (0)