32 Foam::mirrorFvMesh::mirrorFvMesh(
const IOobject& io)
42 IOobject::MUST_READ_IF_MODIFIED,
48 plane mirrorPlane(mirrorMeshDict_);
52 readScalar(mirrorMeshDict_.lookup(
"planeTolerance"))
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();
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);
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;
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;
250 label nNewPatches = 0;
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 newToOldPatch[nNewPatches] =
patchi;
308 newPatchSizes[nNewPatches] =
309 nNewFaces - newPatchStarts[nNewPatches];
316 newFaces.setSize(nNewFaces);
317 Info<<
" New faces: " << nNewFaces <<
endl;
319 newToOldPatch.setSize(nNewPatches);
320 newPatchSizes.setSize(nNewPatches);
321 newPatchStarts.setSize(nNewPatches);
323 Info<<
"Mirroring patches. Old patches: " <<
boundary().size()
324 <<
" New patches: " << nNewPatches <<
endl;
326 Info<<
"Mirroring cells. Old cells: " << oldCells.size()
327 <<
" New cells: " << 2*oldCells.size() <<
endl;
329 cellList newCells(2*oldCells.size());
335 const cell& oc = oldCells[celli];
337 cell& nc = newCells[nNewCells];
338 nc.setSize(oc.size());
342 nc[i] = masterFaceLookup[oc[i]];
351 const cell& oc = oldCells[celli];
353 cell& nc = newCells[nNewCells];
354 nc.setSize(oc.size());
358 nc[i] = mirrorFaceLookup[oc[i]];
365 Info<<
"Mirroring cell shapes." <<
endl;
368 mirrorMeshPtr_ =
new fvMesh
376 fvMesh& pMesh = *mirrorMeshPtr_;
379 List<polyPatch*>
p(newPatchSizes.size());
385 pMesh.boundaryMesh(),
PtrList< polyPatch > polyPatchList
container classes for polyPatch
List< labelList > labelListList
A List of labelList.
#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
Ostream & endl(Ostream &os)
Add newline and flush stream.
label size() const
Return number of elements in table.
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
Foam::autoPtr< IOobject > clone() const
Clone.
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 succesful.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual const faceList & faces() const
Return raw faces.
label nInternalFaces() const
List< cell > cellList
list of cells
~mirrorFvMesh()
Destructor.
int system(const std::string &command)
Execute the specified command.
label size() const
Return the number of elements in the UPtrList.