2 // Read in a list of dictionaries for the merge patch pairs
3 if (meshDict.found("mergePatchPairs"))
5 List<Pair<word> > mergePatchPairs
7 meshDict.lookup("mergePatchPairs")
10 if (mergePatchPairs.size() > 0)
12 // Create and add point and face zones and mesh modifiers
13 List<pointZone*> pz(mergePatchPairs.size());
14 List<faceZone*> fz(3*mergePatchPairs.size());
15 List<cellZone*> cz(0);
17 forAll (mergePatchPairs, pairI)
21 mergePatchPairs[pairI].first()
22 + mergePatchPairs[pairI].second()
26 pz[pairI] = new pointZone
28 mergeName + "CutPointZone",
35 const word masterPatchName(mergePatchPairs[pairI].first());
36 const polyPatch& masterPatch =
39 mesh.boundaryMesh().findPatchID(masterPatchName)
42 labelList isf(masterPatch.size());
46 isf[i] = masterPatch.start() + i;
49 fz[3*pairI] = new faceZone
51 mergeName + "MasterZone",
53 boolList(masterPatch.size(), false),
59 const word slavePatchName(mergePatchPairs[pairI].second());
60 const polyPatch& slavePatch =
63 mesh.boundaryMesh().findPatchID(slavePatchName)
66 labelList osf(slavePatch.size());
70 osf[i] = slavePatch.start() + i;
73 fz[3*pairI + 1] = new faceZone
75 mergeName + "SlaveZone",
77 boolList(slavePatch.size(), false),
82 // Add empty zone for cut faces
83 fz[3*pairI + 2] = new faceZone
85 mergeName + "CutFaceZone",
91 } // end of all merge pairs
93 Info << "Adding point and face zones" << endl;
94 mesh.addZones(pz, fz, cz);
97 Info << "Creating topo change" << endl;
98 polyTopoChanger attacher(mesh);
99 attacher.setSize(mergePatchPairs.size());
101 forAll (mergePatchPairs, pairI)
105 mergePatchPairs[pairI].first()
106 + mergePatchPairs[pairI].second()
110 // Add the sliding interface mesh modifier
116 "couple" + name(pairI),
119 mergeName + "MasterZone",
120 mergeName + "SlaveZone",
121 mergeName + "CutPointZone",
122 mergeName + "CutFaceZone",
123 mergePatchPairs[pairI].first(),
124 mergePatchPairs[pairI].second(),
125 slidingInterface::INTEGRAL, // always integral
126 intersection::VISIBLE
131 attacher.changeMesh();
133 // Clean the mesh after attach
134 labelList patchSizes(mesh.boundaryMesh().size());
135 labelList patchStarts(mesh.boundaryMesh().size());
137 forAll (mesh.boundaryMesh(), patchI)
139 patchSizes[patchI] = mesh.boundaryMesh()[patchI].size();
140 patchStarts[patchI] = mesh.boundaryMesh()[patchI].start();
145 xferCopy<pointField>(mesh.points()),
146 xferCopy<faceList>(mesh.faces()),
147 xferCopy<labelList>(mesh.faceOwner()),
148 xferCopy<labelList>(mesh.faceNeighbour()),
153 mesh.setInstance(runTime.constant());
159 Info<< nl << "There are no merge patch pairs" << endl;
163 // Set any cellZones (note: cell labelling unaffected by above
166 label nZones = blocks.numZonedBlocks();
170 Info<< nl << "Adding cell zones" << endl;
172 // Map from zoneName to cellZone index
173 HashTable<label> zoneMap(nZones);
176 List<DynamicList<label> > zoneCells(nZones);
178 // Running cell counter
181 // Largest zone so far
184 forAll(blocks, blockI)
186 const block& b = blocks[blockI];
187 const labelListList& blockCells = b.cells();
188 const word& zoneName = b.blockDef().zoneName();
192 HashTable<label>::const_iterator iter = zoneMap.find(zoneName);
196 if (iter == zoneMap.end())
200 Info<< " " << zoneI << '\t' << zoneName << endl;
202 zoneMap.insert(zoneName, zoneI);
209 forAll(blockCells, i)
211 zoneCells[zoneI].append(cellI++);
216 cellI += b.cells().size();
221 List<cellZone*> cz(zoneMap.size());
223 Info<< nl << "Writing cell zones as cellSets" << endl;
225 forAllConstIter(HashTable<label>, zoneMap, iter)
227 label zoneI = iter();
229 cz[zoneI]= new cellZone
232 zoneCells[zoneI].shrink(),
237 // Write as cellSet for ease of processing
242 labelHashSet(zoneCells[zoneI].shrink())
247 mesh.pointZones().setSize(0);
248 mesh.faceZones().setSize(0);
249 mesh.cellZones().setSize(0);
250 mesh.addZones(List<pointZone*>(0), List<faceZone*>(0), cz);
253 // Set the precision of the points data to 10
254 IOstream::defaultPrecision(10);
256 Info << nl << "Writing polyMesh" << endl;
260 FatalErrorIn(args.executable())
261 << "Failed writing polyMesh."
265 Info<< nl << "End" << endl;
271 // ************************************************************************* //