35 void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
42 label nBoundaryFaces = mesh.nFaces() - mesh.nInternalFaces();
44 if (neiCc.size() != nBoundaryFaces)
47 <<
"nBoundaries:" << nBoundaryFaces
48 <<
" neiCc:" << neiCc.size()
52 const polyBoundaryMesh& patches = mesh.boundaryMesh();
56 const polyPatch& pp = patches[
patchi];
60 label bFacei = pp.start() - mesh.nInternalFaces();
66 neiCc[bFacei] = cellCentres[faceCells[i]];
77 void Foam::conformalVoronoiMesh::selectSeparatedCoupledFaces
83 const polyBoundaryMesh& patches = mesh.boundaryMesh();
88 if (isA<coupledPolyPatch>(patches[patchi]))
90 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
95 if (cpp.separated() || !cpp.parallel())
99 selected[cpp.start()+i] =
true;
107 void Foam::conformalVoronoiMesh::findCellZoneInsideWalk
109 const polyMesh& mesh,
116 boolList blockedFace(mesh.nFaces());
117 selectSeparatedCoupledFaces(mesh, blockedFace);
119 forAll(faceToSurface, facei)
121 if (faceToSurface[facei] == -1)
123 blockedFace[facei] =
false;
127 blockedFace[facei] =
true;
133 regionSplit cellRegion(mesh, blockedFace);
138 (void)mesh.tetBasePtIs();
140 const PtrList<surfaceZonesInfo>& surfZones =
144 forAll(locationSurfaces, i)
146 label surfI = locationSurfaces[i];
148 const Foam::point& insidePoint = surfZones[surfI].zoneInsidePoint();
152 Info<<
" For surface " << surfName
153 <<
" finding inside point " << insidePoint
157 label keepRegionI = -1;
159 label celli = mesh.findCell(insidePoint);
163 keepRegionI = cellRegion[celli];
165 reduce(keepRegionI, maxOp<label>());
167 Info<<
" For surface " << surfName
168 <<
" found point " << insidePoint <<
" in cell " << celli
169 <<
" in global region " << keepRegionI
170 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
172 if (keepRegionI == -1)
175 <<
"Point " << insidePoint
176 <<
" is not inside the mesh." <<
nl 177 <<
"Bounding box of the mesh:" << mesh.bounds()
184 if (cellRegion[celli] == keepRegionI)
186 if (cellToSurface[celli] == -2)
188 cellToSurface[celli] = surfI;
190 else if (cellToSurface[celli] != surfI)
194 <<
" at " << mesh.cellCentres()[celli]
195 <<
" is inside surface " << surfName
196 <<
" but already marked as being in zone " 197 << cellToSurface[celli] << endl
198 <<
"This can happen if your surfaces are not" 199 <<
" (sufficiently) closed." 215 const PtrList<surfaceZonesInfo>& surfZones =
229 forAll(closedNamedSurfaces, i)
231 label surfI = closedNamedSurfaces[i];
233 const searchableSurface& surface =
237 surfZones[surfI].zoneInside();
247 <<
"Trying to use surface " 249 <<
" which has non-geometric inside selection method " 254 if (surface.hasVolumeType())
256 List<volumeType> volType;
257 surface.getVolumeType(cellCentres, volType);
259 bool selectInside =
true;
262 List<volumeType> volTypeInsidePoint;
263 surface.getVolumeType
265 pointField(1, surfZones[surfI].zoneInsidePoint()),
271 selectInside =
false;
276 selectInside =
false;
281 if (cellToSurface[pointi] == -1)
295 cellToSurface[pointi] = surfI;
302 return cellToSurface;
306 void Foam::conformalVoronoiMesh::calcFaceZones
308 const polyMesh& mesh,
315 faceToSurface.setSize(mesh.nFaces(), -1);
316 flipMap.setSize(mesh.nFaces(),
false);
318 const faceList& faces = mesh.faces();
319 const labelList& faceOwner = mesh.faceOwner();
320 const labelList& faceNeighbour = mesh.faceNeighbour();
322 labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(),
label(-1));
324 const polyBoundaryMesh& patches = mesh.boundaryMesh();
328 const polyPatch& pp = patches[
patchi];
332 label bFacei = pp.start() - mesh.nInternalFaces();
338 neiFaceOwner[bFacei] = cellToSurface[faceCells[i]];
348 const label ownerSurfacei = cellToSurface[faceOwner[facei]];
350 if (faceToSurface[facei] >= 0)
355 if (mesh.isInternalFace(facei))
357 const label neiSurfacei = cellToSurface[faceNeighbour[facei]];
361 (ownerSurfacei >= 0 || neiSurfacei >= 0)
362 && ownerSurfacei != neiSurfacei
367 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
372 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
377 label patchID = mesh.boundaryMesh().whichPatch(facei);
379 if (mesh.boundaryMesh()[patchID].coupled())
381 const label neiSurfacei =
382 neiFaceOwner[facei - mesh.nInternalFaces()];
386 (ownerSurfacei >= 0 || neiSurfacei >= 0)
387 && ownerSurfacei != neiSurfacei
392 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
397 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
402 if (ownerSurfacei >= 0)
404 faceToSurface[facei] = ownerSurfacei;
411 const PtrList<surfaceZonesInfo>& surfZones =
424 pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
425 calcNeighbourCellCentres
435 if (faceToSurface[facei] >= 0)
440 label patchID = mesh.boundaryMesh().whichPatch(facei);
442 const label own = faceOwner[facei];
444 List<pointIndexHit> surfHit;
447 if (mesh.isInternalFace(facei))
449 const label nei = faceNeighbour[facei];
459 else if (patchID != -1 && mesh.boundaryMesh()[patchID].coupled())
464 neiCc[facei - mesh.nInternalFaces()],
472 if (surfHit.size() == 1 && surfHit[0].hit())
474 if (
findIndex(unclosedSurfaces, hitSurface[0]) != -1)
480 List<pointIndexHit>(1, surfHit[0]),
484 vector fN = faces[facei].normal(mesh.points());
485 fN /=
mag(fN) + SMALL;
487 if ((norm[0] & fN) < 0)
489 flipMap[facei] =
true;
493 flipMap[facei] =
false;
496 faceToSurface[facei] = hitSurface[0];
547 void Foam::conformalVoronoiMesh::addZones
553 Info<<
" Adding zones to mesh" <<
endl;
555 const PtrList<surfaceZonesInfo>& surfZones =
558 labelList cellToSurface(calcCellZones(cellCentres));
577 findCellZoneInsideWalk
580 insidePointNamedSurfaces,
589 label surfI = namedSurfaces[i];
593 <<
indent <<
" faceZone : " 594 << surfZones[surfI].faceZoneName() <<
nl 595 <<
indent <<
" cellZone : " 596 << surfZones[surfI].cellZoneName()
618 polyTopoChange meshMod(mesh);
620 forAll(cellToSurface, celli)
622 label surfacei = cellToSurface[celli];
626 label zoneI = surfaceToCellZone[surfacei];
643 const labelList& faceOwner = mesh.faceOwner();
644 const labelList& faceNeighbour = mesh.faceNeighbour();
646 forAll(faceToSurface, facei)
648 label surfacei = faceToSurface[facei];
655 label patchID = mesh.boundaryMesh().whichPatch(facei);
657 if (mesh.isInternalFace(facei))
659 label own = faceOwner[facei];
660 label nei = faceNeighbour[facei];
673 surfaceToFaceZone[surfacei],
678 else if (patchID != -1 && mesh.boundaryMesh()[patchID].coupled())
680 label own = faceOwner[facei];
693 surfaceToFaceZone[surfacei],
701 autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh,
false,
true);
#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.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static labelList addCellZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
Vector< scalar > vector
A scalar version of the templated Vector.
static labelList getUnclosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are unclosed.
UList< label > labelUList
static labelList getAllClosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are closed.
List< bool > boolList
Bool container classes.
vectorField pointField
pointField is a vectorField.
List< label > labelList
A List of labels.
static labelList getInsidePointNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of surfaces with a cellZone that have 'insidePoint'.
errorManip< error > abort(error &err)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const wordList & names() const
#define WarningInFunction
Report a warning using Foam::Warning.
static labelList addFaceZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
static const NamedEnum< areaSelectionAlgo, 4 > areaSelectionAlgoNames
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
areaSelectionAlgo
Types of selection of area.