32 Foam::mirrorFvMesh::mirrorFvMesh(
const IOobject& io)
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
86 if (
mag(alpha) > planeTolerance)
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();
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())
158 WarningIn(
"mirrorFvMesh::mirrorFvMesh(const IOobject&)")
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;
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];
217 forAll (curCellFaces, cfI)
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;
250 label nNewPatches = 0;
252 forAll (boundaryMesh(), patchI)
254 const label curPatchSize = boundaryMesh()[patchI].size();
255 const label curPatchStart = boundaryMesh()[patchI].start();
256 const boolList& curInserted = insertedBouFace[patchI];
258 newPatchStarts[nNewPatches] = nNewFaces;
261 for (label faceI = 0; faceI < curPatchSize; faceI++)
265 if (!curInserted[faceI])
267 newFaces[nNewFaces] = oldFaces[curPatchStart + faceI];
269 masterFaceLookup[curPatchStart + faceI] = nNewFaces;
275 for (label faceI = 0; faceI < curPatchSize; faceI++)
279 if (!curInserted[faceI])
281 const face& oldFace = oldFaces[curPatchStart + faceI];
282 face& nf = newFaces[nNewFaces];
285 nf[0] = mirrorPointLookup[oldFace[0]];
287 for (label i = 1; i < oldFace.size(); i++)
289 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
292 mirrorFaceLookup[curPatchStart + faceI] = nNewFaces;
298 mirrorFaceLookup[curPatchStart + faceI] =
299 masterFaceLookup[curPatchStart + faceI];
304 if (nNewFaces > newPatchStarts[nNewPatches])
306 newPatchTypes[nNewPatches] = boundaryMesh()[patchI].type();
307 newPatchNames[nNewPatches] = boundaryMesh()[patchI].name();
308 newPatchSizes[nNewPatches] =
309 nNewFaces - newPatchStarts[nNewPatches];
316 newFaces.setSize(nNewFaces);
317 Info <<
" New faces: " << nNewFaces <<
endl;
319 newPatchTypes.setSize(nNewPatches);
320 newPatchNames.setSize(nNewPatches);
321 newPatchSizes.setSize(nNewPatches);
322 newPatchStarts.setSize(nNewPatches);
324 Info <<
"Mirroring patches. Old patches: " <<
boundary().size()
325 <<
" New patches: " << nNewPatches <<
endl;
327 Info<<
"Mirroring cells. Old cells: " << oldCells.size()
328 <<
" New cells: " << 2*oldCells.size() <<
endl;
330 cellList newCells(2*oldCells.size());
336 const cell& oc = oldCells[cellI];
338 cell& nc = newCells[nNewCells];
339 nc.setSize(oc.size());
343 nc[i] = masterFaceLookup[oc[i]];
352 const cell& oc = oldCells[cellI];
354 cell& nc = newCells[nNewCells];
355 nc.setSize(oc.size());
359 nc[i] = mirrorFaceLookup[oc[i]];
366 Info <<
"Mirroring cell shapes." <<
endl;
369 mirrorMeshPtr_ =
new fvMesh
377 fvMesh& pMesh = *mirrorMeshPtr_;
380 List<polyPatch*>
p(newPatchTypes.size());
384 p[patchI] = polyPatch::New
386 newPatchTypes[patchI],
387 newPatchNames[patchI],
388 newPatchSizes[patchI],
389 newPatchStarts[patchI],