32 Foam::mirrorFvMesh::mirrorFvMesh(
const IOobject& io,
const word& dictName)
47 plane mirrorPlane(mirrorMeshDict_);
51 readScalar(mirrorMeshDict_.lookup(
"planeTolerance"))
61 Info<<
"Mirroring points. Old points: " << oldPoints.size();
66 labelList mirrorPointLookup(oldPoints.size(), -1);
71 newPoints[nNewPoints] = oldPoints[pointi];
78 mirrorPlane.normalIntersect
85 if (
mag(alpha) > planeTolerance)
88 newPoints[nNewPoints] =
89 oldPoints[pointi] + 2.0*alpha*mirrorPlane.normal();
92 mirrorPointLookup[pointi] = nNewPoints;
99 newPoints[nNewPoints] =
100 oldPoints[pointi] + alpha*mirrorPlane.normal();
102 mirrorPointLookup[pointi] = pointi;
107 Info<<
" New points: " << nNewPoints <<
endl;
108 newPoints.setSize(nNewPoints);
111 pointMapPtr_.reset(
new labelList(newPoints.size()));
114 forAll(oldPoints, oldPointi)
116 pointMap[oldPointi] = oldPointi;
118 forAll(mirrorPointLookup, oldPointi)
120 pointMap[mirrorPointLookup[oldPointi]] = oldPointi;
125 Info<<
"Mirroring faces. Old faces: " << oldFaces.size();
145 const labelUList& oldOwnerStart = lduAddr().ownerStartAddr();
147 forAll(newCellFaces, celli)
149 labelList& curFaces = newCellFaces[celli];
151 const label s = oldOwnerStart[celli];
152 const label e = oldOwnerStart[celli + 1];
154 curFaces.setSize(e - s);
168 const polyPatch& curPatch = oldPatches[
patchi];
170 if (curPatch.coupled())
173 <<
"Found coupled patch " << curPatch.name() << endl
174 <<
" Mirroring faces on coupled patches destroys" 175 <<
" the ordering. This might be fixed by running a dummy" 176 <<
" createPatch afterwards." <<
endl;
181 curInsBouFace.
setSize(curPatch.size());
182 curInsBouFace =
false;
185 const labelUList& curFaceCells = curPatch.faceCells();
186 const label curStart = curPatch.start();
193 const face& origFace = curPatch[facei];
195 face mirrorFace(origFace.size());
196 forAll(mirrorFace, pointi)
198 mirrorFace[pointi] = mirrorPointLookup[origFace[pointi]];
201 if (origFace == mirrorFace)
205 const label oldSize = newCellFaces[curFaceCells[facei]].size();
207 newCellFaces[curFaceCells[facei]].setSize(oldSize + 1);
208 newCellFaces[curFaceCells[facei]][oldSize] = curStart + facei;
210 curInsBouFace[facei] =
true;
220 labelList masterFaceLookup(oldFaces.size(), -1);
221 labelList mirrorFaceLookup(oldFaces.size(), -1);
223 faceList newFaces(2*oldFaces.size());
227 forAll(newCellFaces, celli)
229 const labelList& curCellFaces = newCellFaces[celli];
233 newFaces[nNewFaces] = oldFaces[curCellFaces[cfI]];
234 masterFaceLookup[curCellFaces[cfI]] = nNewFaces;
241 for (
label facei = 0; facei < nOldInternalFaces; facei++)
243 const face& oldFace = oldFaces[facei];
244 face& nf = newFaces[nNewFaces];
245 nf.setSize(oldFace.size());
247 nf[0] = mirrorPointLookup[oldFace[0]];
249 for (
label i = 1; i < oldFace.size(); i++)
251 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
254 mirrorFaceLookup[facei] = nNewFaces;
264 label nNewPatches = 0;
272 newPatchStarts[nNewPatches] = nNewFaces;
275 for (
label facei = 0; facei < curPatchSize; facei++)
279 if (!curInserted[facei])
281 newFaces[nNewFaces] = oldFaces[curPatchStart + facei];
283 masterFaceLookup[curPatchStart + facei] = nNewFaces;
289 for (
label facei = 0; facei < curPatchSize; facei++)
293 if (!curInserted[facei])
295 const face& oldFace = oldFaces[curPatchStart + facei];
296 face& nf = newFaces[nNewFaces];
299 nf[0] = mirrorPointLookup[oldFace[0]];
301 for (
label i = 1; i < oldFace.size(); i++)
303 nf[i] = mirrorPointLookup[oldFace[oldFace.size() - i]];
306 mirrorFaceLookup[curPatchStart + facei] = nNewFaces;
312 mirrorFaceLookup[curPatchStart + facei] =
313 masterFaceLookup[curPatchStart + facei];
318 if (nNewFaces > newPatchStarts[nNewPatches])
320 newToOldPatch[nNewPatches] =
patchi;
322 newPatchSizes[nNewPatches] =
323 nNewFaces - newPatchStarts[nNewPatches];
330 newFaces.setSize(nNewFaces);
331 Info<<
" New faces: " << nNewFaces <<
endl;
333 newToOldPatch.setSize(nNewPatches);
334 newPatchSizes.setSize(nNewPatches);
335 newPatchStarts.setSize(nNewPatches);
337 Info<<
"Mirroring patches. Old patches: " <<
boundary().size()
338 <<
" New patches: " << nNewPatches <<
endl;
340 Info<<
"Mirroring cells. Old cells: " << oldCells.size()
341 <<
" New cells: " << 2*oldCells.size() <<
endl;
343 cellList newCells(2*oldCells.size());
347 cellMapPtr_.reset(
new labelList(newCells.size()));
353 const cell& oc = oldCells[celli];
355 cell& nc = newCells[nNewCells];
356 nc.setSize(oc.size());
360 nc[i] = masterFaceLookup[oc[i]];
363 cellMap[nNewCells] = celli;
371 const cell& oc = oldCells[celli];
373 cell& nc = newCells[nNewCells];
374 nc.setSize(oc.size());
378 nc[i] = mirrorFaceLookup[oc[i]];
381 cellMap[nNewCells] = celli;
387 Info<<
"Mirroring cell shapes." <<
endl;
401 fvMesh& pMesh = mirrorMeshPtr_();
404 List<polyPatch*>
p(newPatchSizes.size());
410 pMesh.boundaryMesh(),
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
PtrList< polyPatch > polyPatchList
container classes for polyPatch
List< labelList > labelListList
A List of labelList.
autoPtr< IOobject > clone() const
Clone.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< List< bool > > boolListList
label nInternalFaces() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
label size() const
Return number of elements in table.
UList< label > labelUList
virtual const pointField & points() const
Return raw points.
List< bool > boolList
Bool container classes.
vectorField pointField
pointField is a vectorField.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
List< label > labelList
A List of labels.
faceListList boundary(nPatches)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
virtual const faceList & faces() const
Return raw faces.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
dimensioned< scalar > mag(const dimensioned< Type > &)
List< cell > cellList
list of cells
~mirrorFvMesh()
Destructor.
int system(const std::string &command)
Execute the specified command.