37 void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
44 const label nBoundaryFaces =
mesh.nBoundaryFaces();
46 if (neiCc.size() != nBoundaryFaces)
49 <<
"nBoundaries:" << nBoundaryFaces
50 <<
" neiCc:" << neiCc.size()
54 const polyBoundaryMesh&
patches =
mesh.boundaryMesh();
58 const polyPatch& pp =
patches[patchi];
62 label bFacei = pp.start() -
mesh.nInternalFaces();
68 neiCc[bFacei] = cellCentres[faceCells[i]];
79 void Foam::conformalVoronoiMesh::selectSeparatedCoupledFaces
90 if (isA<coupledPolyPatch>(
patches[patchi]))
92 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
97 if (cpp.separated() || !cpp.parallel())
101 selected[cpp.start()+i] =
true;
109 void Foam::conformalVoronoiMesh::findCellZoneInsideWalk
111 const polyMesh&
mesh,
119 selectSeparatedCoupledFaces(
mesh, blockedFace);
121 forAll(faceToSurface, facei)
123 if (faceToSurface[facei] == -1)
125 blockedFace[facei] =
false;
129 blockedFace[facei] =
true;
135 regionSplit cellRegion(
mesh, blockedFace);
142 const PtrList<surfaceZonesInfo>& surfZones =
143 geometryToConformTo().surfZones();
146 forAll(locationSurfaces, i)
148 label surfI = locationSurfaces[i];
150 const Foam::point& insidePoint = surfZones[surfI].zoneInsidePoint();
152 const word& surfName = geometryToConformTo().geometry().names()[surfI];
154 Info<<
" For surface " << surfName
155 <<
" finding inside point " << insidePoint
159 label keepRegionI = -1;
165 keepRegionI = cellRegion[celli];
167 reduce(keepRegionI, maxOp<label>());
169 Info<<
" For surface " << surfName
170 <<
" found point " << insidePoint <<
" in cell " << celli
171 <<
" in global region " << keepRegionI
172 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
174 if (keepRegionI == -1)
177 <<
"Point " << insidePoint
178 <<
" is not inside the mesh." <<
nl
179 <<
"Bounding box of the mesh:" <<
mesh.
bounds()
186 if (cellRegion[celli] == keepRegionI)
188 if (cellToSurface[celli] == -2)
190 cellToSurface[celli] = surfI;
192 else if (cellToSurface[celli] != surfI)
197 <<
" is inside surface " << surfName
198 <<
" but already marked as being in zone "
199 << cellToSurface[celli] <<
endl
200 <<
"This can happen if your surfaces are not"
201 <<
" (sufficiently) closed."
215 labelList cellToSurface(cellCentres.size(), label(-1));
217 const PtrList<surfaceZonesInfo>& surfZones =
218 geometryToConformTo().surfZones();
226 geometryToConformTo().geometry(),
227 geometryToConformTo().surfaces()
231 forAll(closedNamedSurfaces, i)
233 label surfI = closedNamedSurfaces[i];
235 const searchableSurface& surface =
236 allGeometry()[geometryToConformTo().surfaces()[surfI]];
239 surfZones[surfI].zoneInside();
249 <<
"Trying to use surface "
251 <<
" which has non-geometric inside selection method "
256 if (surface.hasVolumeType())
258 List<volumeType> volType;
259 surface.getVolumeType(cellCentres, volType);
261 bool selectInside =
true;
264 List<volumeType> volTypeInsidePoint;
265 surface.getVolumeType
267 pointField(1, surfZones[surfI].zoneInsidePoint()),
273 selectInside =
false;
278 selectInside =
false;
283 if (cellToSurface[pointi] == -1)
297 cellToSurface[pointi] = surfI;
304 return cellToSurface;
308 void Foam::conformalVoronoiMesh::calcFaceZones
310 const polyMesh&
mesh,
330 const polyPatch& pp =
patches[patchi];
340 neiFaceOwner[bFacei] = cellToSurface[faceCells[i]];
350 const label ownerSurfacei = cellToSurface[faceOwner[facei]];
352 if (faceToSurface[facei] >= 0)
359 const label neiSurfacei = cellToSurface[faceNeighbour[facei]];
363 (ownerSurfacei >= 0 || neiSurfacei >= 0)
364 && ownerSurfacei != neiSurfacei
369 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
374 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
383 const label neiSurfacei =
388 (ownerSurfacei >= 0 || neiSurfacei >= 0)
389 && ownerSurfacei != neiSurfacei
394 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
399 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
404 if (ownerSurfacei >= 0)
406 faceToSurface[facei] = ownerSurfacei;
413 const PtrList<surfaceZonesInfo>& surfZones =
414 geometryToConformTo().surfZones();
421 geometryToConformTo().geometry(),
422 geometryToConformTo().surfaces()
427 calcNeighbourCellCentres
437 if (faceToSurface[facei] >= 0)
444 const label own = faceOwner[facei];
446 List<pointIndexHit> surfHit;
451 const label nei = faceNeighbour[facei];
453 geometryToConformTo().findSurfaceAllIntersections
463 geometryToConformTo().findSurfaceAllIntersections
474 if (surfHit.size() == 1 && surfHit[0].hit())
476 if (unclosedSurfaces.found(hitSurface[0]))
479 geometryToConformTo().getNormal
482 List<pointIndexHit>(1, surfHit[0]),
488 if ((norm[0] & areaNorm) < 0)
490 flipMap[facei] =
true;
494 flipMap[facei] =
false;
497 faceToSurface[facei] = hitSurface[0];
548 void Foam::conformalVoronoiMesh::addZones
554 Info<<
" Adding zones to mesh" <<
endl;
556 const PtrList<surfaceZonesInfo>& surfZones =
557 geometryToConformTo().surfZones();
559 labelList cellToSurface(calcCellZones(cellCentres));
578 findCellZoneInsideWalk
581 insidePointNamedSurfaces,
592 label surfI = namedSurfaces[i];
593 const wordList& fzNames = surfZones[surfI].faceZoneNames();
596 << geometryToConformTo().geometry().names()[surfI] <<
nl
597 <<
indent <<
" faceZone : "
598 << (fzNames.size() ? fzNames[0] :
"") <<
nl
599 <<
indent <<
" cellZone : "
600 << surfZones[surfI].cellZoneName()
605 labelList surfaceToFaceZone(surfZones.size(), -1);
616 forAll(surfaceToFaceZones, surfi)
618 if (surfaceToFaceZones[surfi].size())
620 surfaceToFaceZone[surfi] = surfaceToFaceZones[surfi][0];
636 polyTopoChange meshMod(
mesh);
638 forAll(cellToSurface, celli)
640 label surfacei = cellToSurface[celli];
644 label zoneI = surfaceToCellZone[surfacei];
664 forAll(faceToSurface, facei)
666 label surfacei = faceToSurface[facei];
677 label own = faceOwner[facei];
678 label nei = faceNeighbour[facei];
691 surfaceToFaceZone[surfacei],
698 label own = faceOwner[facei];
711 surfaceToFaceZone[surfacei],
719 autoPtr<mapPolyMesh> map = meshMod.changeMesh(
mesh,
false,
true);