41 Foam::label Foam::mergePolyMesh::patchIndex(
const polyPatch&
p)
45 const word& pType = p.type();
46 const word& pName = p.name();
48 bool nameFound =
false;
50 forAll (patchNames_, patchI)
52 if (patchNames_[patchI] == pName)
54 if (patchTypes_[patchI] == pType)
74 const word&
caseName = p.boundaryMesh().mesh().time().caseName();
76 patchNames_.
append(pName +
"_" + caseName);
78 Info<<
"label patchIndex(const polyPatch& p) : "
79 <<
"Patch " << p.index() <<
" named "
80 << pName <<
" in mesh " << caseName
81 <<
" already exists, but patch types "
82 <<
" do not match.\nCreating a composite name as "
83 << patchNames_[patchNames_.
size() - 1] <<
endl;
90 return patchNames_.
size() - 1;
94 Foam::label Foam::mergePolyMesh::zoneIndex
96 DynamicList<word>& names,
102 if (names[zoneI] == curName)
109 names.append(curName);
111 return names.size() - 1;
117 Foam::mergePolyMesh::mergePolyMesh(
const IOobject& io)
121 patchTypes_(2*boundaryMesh().size()),
122 patchNames_(2*boundaryMesh().size()),
128 wordList curPatchTypes = boundaryMesh().types();
129 wordList curPatchNames = boundaryMesh().names();
131 forAll (curPatchTypes, patchI)
133 patchTypes_.append(curPatchTypes[patchI]);
134 patchNames_.append(curPatchNames[patchI]);
140 wordList curPointZoneNames = pointZones().names();
141 if (curPointZoneNames.size())
143 pointZoneNames_.setCapacity(2*curPointZoneNames.size());
146 forAll (curPointZoneNames, zoneI)
148 pointZoneNames_.append(curPointZoneNames[zoneI]);
152 wordList curFaceZoneNames = faceZones().names();
154 if (curFaceZoneNames.size())
156 faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
158 forAll (curFaceZoneNames, zoneI)
160 faceZoneNames_.append(curFaceZoneNames[zoneI]);
164 wordList curCellZoneNames = cellZones().names();
166 if (curCellZoneNames.size())
168 cellZoneNames_.setCapacity(2*curCellZoneNames.size());
170 forAll (curCellZoneNames, zoneI)
172 cellZoneNames_.append(curCellZoneNames[zoneI]);
198 pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].
name());
204 zoneID = pz.whichZone(pointI);
209 zoneID = pointZoneIndices[zoneID];
212 renumberPoints[pointI] =
235 cellZoneIndices[zoneI] = zoneIndex(cellZoneNames_, cz[zoneI].
name());
241 zoneID = cz.whichZone(cellI);
246 zoneID = cellZoneIndices[zoneID];
249 renumberCells[cellI] =
264 const polyBoundaryMesh& bm = m.boundaryMesh();
269 forAll (patchIndices, patchI)
271 patchIndices[patchI] = patchIndex(bm[patchI]);
276 meshMod_.setNumPatches(patchNames_.size());
285 faceZoneIndices[zoneI] = zoneIndex(faceZoneNames_, fz[zoneI].
name());
292 const labelList& nei = m.faceNeighbour();
294 label newOwn, newNei, newPatch, newZone;
299 const face& curFace = f[faceI];
301 face newFace(curFace.size());
305 newFace[pointI] = renumberPoints[curFace[pointI]];
311 if (
min(newFace) < 0)
313 FatalErrorIn(
"void mergePolyMesh::addMesh(const polyMesh&)")
314 <<
"Error in point mapping for face " << faceI
315 <<
". Old face: " << curFace <<
" New face: " << newFace
320 if (faceI < m.nInternalFaces() || faceI >= m.nFaces())
326 newPatch = patchIndices[bm.whichPatch(faceI)];
330 if (newOwn > -1) newOwn = renumberCells[newOwn];
339 newNei = renumberCells[newNei];
343 newZone = fz.whichZone(faceI);
348 newZoneFlip = fz[newZone].flipMap()[fz[newZone].whichFace(faceI)];
351 newZone = faceZoneIndices[newZone];
354 renumberFaces[faceI] =
378 Info<<
"patch names: " << patchNames_ <<
nl
379 <<
"patch types: " << patchTypes_ <<
nl
380 <<
"point zone names: " << pointZoneNames_ <<
nl
381 <<
"face zone names: " << faceZoneNames_ <<
nl
382 <<
"cell zone names: " << cellZoneNames_ <<
endl;
385 if (patchNames_.size() != boundaryMesh().size())
387 Info <<
"Copying old patches" <<
endl;
389 List<polyPatch*> newPatches(patchNames_.size());
391 const polyBoundaryMesh& oldPatches = boundaryMesh();
396 for (patchI = 0; patchI < oldPatches.size(); patchI++)
398 newPatches[patchI] = oldPatches[patchI].clone(oldPatches).ptr();
401 Info <<
"Adding new patches. " <<
endl;
403 label endOfLastPatch =
404 oldPatches[patchI - 1].start() + oldPatches[patchI - 1].size();
406 for (; patchI < patchNames_.size(); patchI++)
424 addPatches(newPatches);
430 pointZoneNames_.size() != pointZones().size()
431 || faceZoneNames_.size() != faceZones().size()
432 || cellZoneNames_.size() != cellZones().size()
439 meshMod_.changeMesh(*
this,
false);