38void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
41 const pointField& cellCentres,
47 if (neiCc.size() != nBoundaryFaces)
50 <<
"nBoundaries:" << nBoundaryFaces
51 <<
" neiCc:" << neiCc.size()
59 const polyPatch& pp =
patches[patchi];
69 neiCc[bFacei] = cellCentres[faceCells[i]];
80void Foam::conformalVoronoiMesh::selectSeparatedCoupledFaces
90 const auto* cpp = isA<coupledPolyPatch>(pp);
92 if (cpp && (cpp->separated() || !cpp->parallel()))
94 SubList<bool>(selected, pp.size(), pp.start()) =
true;
100void Foam::conformalVoronoiMesh::findCellZoneInsideWalk
102 const polyMesh&
mesh,
110 selectSeparatedCoupledFaces(
mesh, blockedFace);
112 forAll(faceToSurface, facei)
114 if (faceToSurface[facei] == -1)
116 blockedFace[facei] =
false;
120 blockedFace[facei] =
true;
126 regionSplit cellRegion(
mesh, blockedFace);
133 const PtrList<surfaceZonesInfo>& surfZones =
134 geometryToConformTo().surfZones();
137 forAll(locationSurfaces, i)
139 label surfI = locationSurfaces[i];
141 const Foam::point& insidePoint = surfZones[surfI].zoneInsidePoint();
143 const word& surfName = geometryToConformTo().geometry().names()[surfI];
145 Info<<
" For surface " << surfName
146 <<
" finding inside point " << insidePoint
150 label keepRegionI = -1;
156 keepRegionI = cellRegion[celli];
158 reduce(keepRegionI, maxOp<label>());
160 Info<<
" For surface " << surfName
161 <<
" found point " << insidePoint <<
" in cell " << celli
162 <<
" in global region " << keepRegionI
163 <<
" out of " << cellRegion.nRegions() <<
" regions." <<
endl;
165 if (keepRegionI == -1)
168 <<
"Point " << insidePoint
169 <<
" is not inside the mesh." <<
nl
170 <<
"Bounding box of the mesh:" <<
mesh.
bounds()
177 if (cellRegion[celli] == keepRegionI)
179 if (cellToSurface[celli] == -2)
181 cellToSurface[celli] = surfI;
183 else if (cellToSurface[celli] != surfI)
188 <<
" is inside surface " << surfName
189 <<
" but already marked as being in zone "
190 << cellToSurface[celli] <<
endl
191 <<
"This can happen if your surfaces are not"
192 <<
" (sufficiently) closed."
206 labelList cellToSurface(cellCentres.size(), label(-1));
208 const PtrList<surfaceZonesInfo>& surfZones =
209 geometryToConformTo().surfZones();
217 geometryToConformTo().geometry(),
218 geometryToConformTo().surfaces()
222 forAll(closedNamedSurfaces, i)
224 label surfI = closedNamedSurfaces[i];
226 const searchableSurface&
surface =
227 allGeometry()[geometryToConformTo().surfaces()[surfI]];
230 surfZones[surfI].zoneInside();
240 <<
"Trying to use surface "
242 <<
" which has non-geometric inside selection method "
249 List<volumeType> volType;
250 surface.getVolumeType(cellCentres, volType);
252 bool selectInside =
true;
255 List<volumeType> volTypeInsidePoint;
258 pointField(1, surfZones[surfI].zoneInsidePoint()),
264 selectInside =
false;
269 selectInside =
false;
274 if (cellToSurface[pointi] == -1)
288 cellToSurface[pointi] = surfI;
295 return cellToSurface;
299void Foam::conformalVoronoiMesh::calcFaceZones
301 const polyMesh&
mesh,
321 const polyPatch& pp =
patches[patchi];
331 neiFaceOwner[bFacei] = cellToSurface[faceCells[i]];
341 const label ownerSurfacei = cellToSurface[faceOwner[facei]];
343 if (faceToSurface[facei] >= 0)
350 const label neiSurfacei = cellToSurface[faceNeighbour[facei]];
354 (ownerSurfacei >= 0 || neiSurfacei >= 0)
355 && ownerSurfacei != neiSurfacei
360 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
365 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
374 const label neiSurfacei =
379 (ownerSurfacei >= 0 || neiSurfacei >= 0)
380 && ownerSurfacei != neiSurfacei
385 ownerSurfacei ==
max(ownerSurfacei, neiSurfacei)
390 faceToSurface[facei] =
max(ownerSurfacei, neiSurfacei);
395 if (ownerSurfacei >= 0)
397 faceToSurface[facei] = ownerSurfacei;
404 const PtrList<surfaceZonesInfo>& surfZones =
405 geometryToConformTo().surfZones();
412 geometryToConformTo().geometry(),
413 geometryToConformTo().surfaces()
418 calcNeighbourCellCentres
428 if (faceToSurface[facei] >= 0)
435 const label own = faceOwner[facei];
437 List<pointIndexHit> surfHit;
442 const label nei = faceNeighbour[facei];
444 geometryToConformTo().findSurfaceAllIntersections
454 geometryToConformTo().findSurfaceAllIntersections
465 if (surfHit.size() == 1 && surfHit[0].hit())
467 if (unclosedSurfaces.found(hitSurface[0]))
470 geometryToConformTo().getNormal
473 List<pointIndexHit>(1, surfHit[0]),
479 if ((norm[0] & areaNorm) < 0)
481 flipMap[facei] =
true;
485 flipMap[facei] =
false;
488 faceToSurface[facei] = hitSurface[0];
539void Foam::conformalVoronoiMesh::addZones
545 Info<<
" Adding zones to mesh" <<
endl;
547 const PtrList<surfaceZonesInfo>& surfZones =
548 geometryToConformTo().surfZones();
550 labelList cellToSurface(calcCellZones(cellCentres));
569 findCellZoneInsideWalk
572 insidePointNamedSurfaces,
583 label surfI = namedSurfaces[i];
584 const wordList& fzNames = surfZones[surfI].faceZoneNames();
587 << geometryToConformTo().geometry().names()[surfI] <<
nl
588 <<
indent <<
" faceZone : "
589 << (fzNames.size() ? fzNames[0] :
"") <<
nl
590 <<
indent <<
" cellZone : "
591 << surfZones[surfI].cellZoneName()
596 labelList surfaceToFaceZone(surfZones.size(), -1);
607 forAll(surfaceToFaceZones, surfi)
609 if (surfaceToFaceZones[surfi].size())
611 surfaceToFaceZone[surfi] = surfaceToFaceZones[surfi][0];
627 polyTopoChange meshMod(
mesh);
629 forAll(cellToSurface, celli)
631 label surfacei = cellToSurface[celli];
635 label zoneI = surfaceToCellZone[surfacei];
655 forAll(faceToSurface, facei)
657 label surfacei = faceToSurface[facei];
668 label own = faceOwner[facei];
669 label nei = faceNeighbour[facei];
682 surfaceToFaceZone[surfacei],
689 label own = faceOwner[facei];
702 surfaceToFaceZone[surfacei],
710 autoPtr<mapPolyMesh> map = meshMod.changeMesh(
mesh,
false,
true);
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
virtual const faceList & faces() const
Return raw faces.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
const boundBox & bounds() const
Return mesh bounding box.
virtual const labelList & faceOwner() const
Return face owner.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual const pointField & points() const
Return raw points.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
label nInternalFaces() const noexcept
Number of internal faces.
const vectorField & cellCentres() const
label nFaces() const noexcept
Number of mesh faces.
static labelList getInsidePointNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of surfaces with a cellZone that have 'insidePoint'.
areaSelectionAlgo
Types of selection of area.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
static labelList getAllClosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are closed.
static labelList addCellZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
static labelList getUnclosedNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList, const searchableSurfaces &allGeometry, const labelList &surfaces)
Get indices of surfaces with a cellZone that are unclosed.
static labelListList addFaceZonesToMesh(const PtrList< surfaceZonesInfo > &surfList, const labelList &namedSurfaces, polyMesh &mesh)
static const Enum< areaSelectionAlgo > areaSelectionAlgoNames
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
List< word > wordList
A List of words.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
List< face > faceList
A List of faces.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.