35 Foam::mirrorFvMesh::mirrorFvMesh(
const IOobject& io)
47 IOobject::MUST_READ_IF_MODIFIED,
55 Foam::mirrorFvMesh::mirrorFvMesh
58 const IOdictionary& mirrorDict
63 plane mirrorPlane(mirrorDict);
65 const scalar planeTolerance
67 mirrorDict.get<scalar>(
"planeTolerance")
76 Info<<
"Mirroring mesh at origin:" << mirrorPlane.origin()
77 <<
" normal:" << mirrorPlane.normal() <<
nl;
90 newPoints[nNewPoints] = pt;
97 mirrorPlane.normalIntersect
107 newPoints[nNewPoints] =
111 mirrorPointLookup[pointi] = nNewPoints;
118 newPoints[nNewPoints] =
121 mirrorPointLookup[pointi] = pointi;
126 Info<<
" New points: " << nNewPoints <<
endl;
127 newPoints.setSize(nNewPoints);
130 pointMapPtr_.reset(
new labelList(newPoints.size()));
135 pointMap[oldPointi] = oldPointi;
137 forAll(mirrorPointLookup, oldPointi)
139 pointMap[mirrorPointLookup[oldPointi]] = oldPointi;
143 Info<<
"Mirroring faces. Old faces: " << oldFaces.size();
163 const labelUList& oldOwnerStart = lduAddr().ownerStartAddr();
165 forAll(newCellFaces, celli)
167 labelList& curFaces = newCellFaces[celli];
169 const label
s = oldOwnerStart[celli];
170 const label
e = oldOwnerStart[celli + 1];
172 curFaces.setSize(
e -
s);
184 forAll(oldPatches, patchi)
186 const polyPatch& curPatch = oldPatches[patchi];
188 if (curPatch.coupled())
191 <<
"Found coupled patch " << curPatch.name() <<
endl
192 <<
" Mirroring faces on coupled patches destroys"
193 <<
" the ordering. This might be fixed by running a dummy"
194 <<
" createPatch afterwards." <<
endl;
197 boolList& curInsBouFace = insertedBouFace[patchi];
199 curInsBouFace.
setSize(curPatch.size());
200 curInsBouFace =
false;
203 const labelUList& curFaceCells = curPatch.faceCells();
204 const label curStart = curPatch.start();
211 const face& origFace = curPatch[facei];
213 face mirrorFace(origFace.size());
214 forAll(mirrorFace, pointi)
216 mirrorFace[pointi] = mirrorPointLookup[origFace[pointi]];
219 if (origFace == mirrorFace)
223 const label oldSize = newCellFaces[curFaceCells[facei]].size();
225 newCellFaces[curFaceCells[facei]].setSize(oldSize + 1);
226 newCellFaces[curFaceCells[facei]][oldSize] = curStart + facei;
228 curInsBouFace[facei] =
true;
238 labelList masterFaceLookup(oldFaces.size(), -1);
239 labelList mirrorFaceLookup(oldFaces.size(), -1);
241 faceList newFaces(2*oldFaces.size());
245 forAll(newCellFaces, celli)
247 const labelList& curCellFaces = newCellFaces[celli];
251 newFaces[nNewFaces] = oldFaces[curCellFaces[cfI]];
252 masterFaceLookup[curCellFaces[cfI]] = nNewFaces;
259 for (label facei = 0; facei < nOldInternalFaces; facei++)
261 const face& oldFace = oldFaces[facei];
262 face& nf = newFaces[nNewFaces];
263 nf.setSize(oldFace.size());
265 nf[0] = mirrorPointLookup[oldFace[0]];
267 for (label i = 1; i < oldFace.size(); i++)
269 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
272 mirrorFaceLookup[facei] = nNewFaces;
282 const label curPatchSize =
boundaryMesh()[patchi].size();
284 const boolList& curInserted = insertedBouFace[patchi];
286 newPatchStarts[patchi] = nNewFaces;
289 for (label facei = 0; facei < curPatchSize; facei++)
293 if (!curInserted[facei])
295 newFaces[nNewFaces] = oldFaces[curPatchStart + facei];
297 masterFaceLookup[curPatchStart + facei] = nNewFaces;
303 for (label facei = 0; facei < curPatchSize; facei++)
307 if (!curInserted[facei])
309 const face& oldFace = oldFaces[curPatchStart + facei];
310 face& nf = newFaces[nNewFaces];
313 nf[0] = mirrorPointLookup[oldFace[0]];
315 for (label i = 1; i < oldFace.size(); i++)
317 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
320 mirrorFaceLookup[curPatchStart + facei] = nNewFaces;
326 mirrorFaceLookup[curPatchStart + facei] =
327 masterFaceLookup[curPatchStart + facei];
332 if (nNewFaces > newPatchStarts[patchi])
334 newPatchSizes[patchi] =
335 nNewFaces - newPatchStarts[patchi];
340 newFaces.setSize(nNewFaces);
341 Info<<
" New faces: " << nNewFaces <<
endl;
343 Info<<
"Mirroring patches. Old patches: " <<
boundary().size()
346 Info<<
"Mirroring cells. Old cells: " << oldCells.size()
347 <<
" New cells: " << 2*oldCells.size() <<
endl;
349 cellList newCells(2*oldCells.size());
353 cellMapPtr_.reset(
new labelList(newCells.size()));
359 const cell& oc = oldCells[celli];
361 cell& nc = newCells[nNewCells];
362 nc.setSize(oc.size());
366 nc[i] = masterFaceLookup[oc[i]];
369 cellMap[nNewCells] = celli;
377 const cell& oc = oldCells[celli];
379 cell& nc = newCells[nNewCells];
380 nc.setSize(oc.size());
384 nc[i] = mirrorFaceLookup[oc[i]];
387 cellMap[nNewCells] = celli;
393 Info<<
"Mirroring cell shapes." <<
endl;
399 std::move(newPoints),
404 fvMesh& pMesh = mirrorMeshPtr_();
407 List<polyPatch*>
p(newPatchSizes.size());
413 pMesh.boundaryMesh(),
415 newPatchSizes[patchi],
416 newPatchStarts[patchi]