42 IOobject::MUST_READ_IF_MODIFIED,
48 plane mirrorPlane(mirrorMeshDict_);
52 readScalar(mirrorMeshDict_.lookup(
"planeTolerance"))
58 const label nOldInternalFaces = nInternalFaces();
62 Info<<
"Mirroring points. Old points: " << oldPoints.size();
67 labelList mirrorPointLookup(oldPoints.size(), -1);
72 newPoints[nNewPoints] = oldPoints[pointI];
79 mirrorPlane.normalIntersect
89 newPoints[nNewPoints] =
90 oldPoints[pointI] + 2.0*
alpha*mirrorPlane.normal();
93 mirrorPointLookup[pointI] = nNewPoints;
100 newPoints[nNewPoints] =
101 oldPoints[pointI] +
alpha*mirrorPlane.normal();
103 mirrorPointLookup[pointI] = pointI;
108 Info<<
" New points: " << nNewPoints <<
endl;
109 newPoints.setSize(nNewPoints);
111 Info<<
"Mirroring faces. Old faces: " << oldFaces.size();
131 const labelUList& oldOwnerStart = lduAddr().ownerStartAddr();
133 forAll(newCellFaces, cellI)
135 labelList& curFaces = newCellFaces[cellI];
137 const label s = oldOwnerStart[cellI];
138 const label e = oldOwnerStart[cellI + 1];
140 curFaces.setSize(
e -
s);
152 forAll(oldPatches, patchI)
154 const polyPatch& curPatch = oldPatches[patchI];
156 if (curPatch.coupled())
159 <<
"Found coupled patch " << curPatch.name() <<
endl
160 <<
" Mirroring faces on coupled patches destroys"
161 <<
" the ordering. This might be fixed by running a dummy"
162 <<
" createPatch afterwards." <<
endl;
165 boolList& curInsBouFace = insertedBouFace[patchI];
167 curInsBouFace.
setSize(curPatch.size());
168 curInsBouFace =
false;
171 const labelUList& curFaceCells = curPatch.faceCells();
172 const label curStart = curPatch.start();
179 const face& origFace = curPatch[faceI];
181 face mirrorFace(origFace.size());
182 forAll(mirrorFace, pointI)
184 mirrorFace[pointI] = mirrorPointLookup[origFace[pointI]];
187 if (origFace == mirrorFace)
191 const label oldSize = newCellFaces[curFaceCells[faceI]].size();
193 newCellFaces[curFaceCells[faceI]].setSize(oldSize + 1);
194 newCellFaces[curFaceCells[faceI]][oldSize] = curStart + faceI;
196 curInsBouFace[faceI] =
true;
206 labelList masterFaceLookup(oldFaces.size(), -1);
207 labelList mirrorFaceLookup(oldFaces.size(), -1);
209 faceList newFaces(2*oldFaces.size());
213 forAll(newCellFaces, cellI)
215 const labelList& curCellFaces = newCellFaces[cellI];
219 newFaces[nNewFaces] = oldFaces[curCellFaces[cfI]];
220 masterFaceLookup[curCellFaces[cfI]] = nNewFaces;
227 for (
label faceI = 0; faceI < nOldInternalFaces; faceI++)
229 const face& oldFace = oldFaces[faceI];
230 face& nf = newFaces[nNewFaces];
231 nf.setSize(oldFace.size());
233 nf[0] = mirrorPointLookup[oldFace[0]];
235 for (
label i = 1; i < oldFace.size(); i++)
237 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
240 mirrorFaceLookup[faceI] = nNewFaces;
248 label nNewPatches = 0;
250 forAll(boundaryMesh(), patchI)
252 const label curPatchSize = boundaryMesh()[patchI].size();
253 const label curPatchStart = boundaryMesh()[patchI].start();
254 const boolList& curInserted = insertedBouFace[patchI];
256 newPatchStarts[nNewPatches] = nNewFaces;
259 for (
label faceI = 0; faceI < curPatchSize; faceI++)
263 if (!curInserted[faceI])
265 newFaces[nNewFaces] = oldFaces[curPatchStart + faceI];
267 masterFaceLookup[curPatchStart + faceI] = nNewFaces;
273 for (
label faceI = 0; faceI < curPatchSize; faceI++)
277 if (!curInserted[faceI])
279 const face& oldFace = oldFaces[curPatchStart + faceI];
280 face& nf = newFaces[nNewFaces];
283 nf[0] = mirrorPointLookup[oldFace[0]];
285 for (
label i = 1; i < oldFace.size(); i++)
287 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
290 mirrorFaceLookup[curPatchStart + faceI] = nNewFaces;
296 mirrorFaceLookup[curPatchStart + faceI] =
297 masterFaceLookup[curPatchStart + faceI];
302 if (nNewFaces > newPatchStarts[nNewPatches])
304 newToOldPatch[nNewPatches] = patchI;
306 newPatchSizes[nNewPatches] =
307 nNewFaces - newPatchStarts[nNewPatches];
314 newFaces.setSize(nNewFaces);
315 Info<<
" New faces: " << nNewFaces <<
endl;
317 newToOldPatch.setSize(nNewPatches);
318 newPatchSizes.setSize(nNewPatches);
319 newPatchStarts.setSize(nNewPatches);
321 Info<<
"Mirroring patches. Old patches: " <<
boundary().size()
322 <<
" New patches: " << nNewPatches <<
endl;
324 Info<<
"Mirroring cells. Old cells: " << oldCells.size()
325 <<
" New cells: " << 2*oldCells.size() <<
endl;
327 cellList newCells(2*oldCells.size());
333 const cell& oc = oldCells[cellI];
335 cell& nc = newCells[nNewCells];
336 nc.setSize(oc.size());
340 nc[i] = masterFaceLookup[oc[i]];
349 const cell& oc = oldCells[cellI];
351 cell& nc = newCells[nNewCells];
352 nc.setSize(oc.size());
356 nc[i] = mirrorFaceLookup[oc[i]];
363 Info<<
"Mirroring cell shapes." <<
endl;
366 mirrorMeshPtr_ =
new fvMesh
374 fvMesh& pMesh = *mirrorMeshPtr_;
381 p[patchI] = boundaryMesh()[newToOldPatch[patchI]].clone
383 pMesh.boundaryMesh(),
385 newPatchSizes[patchI],
386 newPatchStarts[patchI]