190 isOutsideFace =
Zero;
198 (cellLevel[own] == cellLevel[nei])
205 isOutsideFace.
set(facei);
214 for (label bFacei = 0; bFacei < nBnd; ++bFacei)
221 (cellLevel[own] == neiLevel[bFacei])
224 != (neiRefineCell[bFacei] != -1)
228 isOutsideFace.
set(facei);
237 const bitSet& isOutsideFace,
241 const cell& cFaces = mesh_.cells()[celli];
244 Vector<bool> haveDirs(vector::uniform(
false));
248 const label facei = cFaces[cFacei];
250 if (isOutsideFace[facei])
252 const vector&
n = faceAreas[facei];
255 if (magSqrN > ROOTVSMALL)
266 haveDirs[dir] =
true;
289 const bitSet& isOutsideFace,
298 if (refineCell[celli] == -1)
300 if (countFaceDirs(isOutsideFace, celli) == 3)
303 refineCell[celli] = 0;
458 void Foam::meshRefinement::markProximityCandidateFaces
461 const List<scalarList>& regionToBlockSize,
471 for (
const label surfi : blockedSurfaces)
473 const label geomi = surfaces_.surfaces()[surfi];
474 const searchableSurface&
s = surfaces_.geometry()[geomi];
475 if (isA<triSurfaceMesh>(
s) && !isA<distributedTriSurfaceMesh>(
s))
477 const triSurfaceMesh& surf = refCast<const triSurfaceMesh>(
s);
479 boolList isOpenEdge(edFaces.size(),
false);
482 if (edFaces[i].size() == 1)
484 isOpenEdge[i] =
true;
489 const label nZones = surf.markZones(isOpenEdge, faceZone);
492 faceZones[surfi].
transfer(faceZone);
502 const label nIters = mesh_.globalData().nTotalCells();
536 List<pointIndexHit> hit1;
541 List<pointIndexHit> hit2;
545 surfaces_.findNearestIntersection
591 List<wallPoints> faceDist(
n);
595 DynamicList<point> originLocation(2);
596 DynamicList<scalar> originDistSqr(2);
597 DynamicList<FixedList<label, 3>> originSurface(2);
613 const label facei = testFaces[i];
615 const point& fc = mesh_.faceCentres()[facei];
616 const labelList& fz1 = faceZones[surface1[i]];
618 originLocation.
clear();
619 originDistSqr.clear();
621 originSurface.clear();
623 originLocation.append(hit1[i].
point());
624 originDistSqr.append(hit1[i].
point().distSqr(fc));
632 (fz1.size() ? fz1[hit1[i].index()] : region1[i])
636 if (hit2[i].hit() && hit1[i] != hit2[i])
638 const labelList& fz2 = faceZones[surface2[i]];
640 originDistSqr.append(hit2[i].
point().distSqr(fc));
648 (fz2.size() ? fz2[hit2[i].index()] : region2[i])
655 faceDist[
n] = wallPoints
662 changedFaces[
n] = facei;
688 FaceCellWave<wallPoints, wallPoints::trackData>
wallDistCalc 703 bitSet isProximityFace(mesh_.nFaces(),
false);
706 isProximityFace.set(testFaces);
712 isProximityFace.set(mesh_.cells()[celli]);
720 orEqOp<unsigned int>(),
724 testFaces = isProximityFace.toc();
728 Foam::label Foam::meshRefinement::markFakeGapRefinement
730 const scalar planarCos,
732 const label nAllowRefine,
742 List<scalarList> regionToBlockSize(surfaces_.surfaces().size());
743 scalar maxBlockSize(-1);
744 for (
const label surfi : blockedSurfaces)
746 const label geomi = surfaces_.surfaces()[surfi];
747 const searchableSurface&
s = surfaces_.geometry()[geomi];
748 const label nRegions =
s.regions().size();
750 regionToBlockSize[surfi].setSize(nRegions, -1);
751 for (label regioni = 0; regioni < nRegions; regioni++)
753 const label globalRegioni = surfaces_.globalRegion(surfi, regioni);
754 const label bLevel = surfaces_.blockLevel()[globalRegioni];
759 regionToBlockSize[surfi][regioni] =
760 meshCutter_.level0EdgeLength()/
pow(2.0, bLevel);
763 maxBlockSize =
max(maxBlockSize, regionToBlockSize[surfi][regioni]);
780 labelList testFaces(getRefineCandidateFaces(refineCell));
783 markProximityCandidateFaces
793 bitSet isTestCell(mesh_.nCells());
794 for (
const label facei : testFaces)
796 const label own = mesh_.faceOwner()[facei];
797 if (refineCell[own] == -1)
801 if (mesh_.isInternalFace(facei))
803 const label nei = mesh_.faceNeighbour()[facei];
804 if (refineCell[nei] == -1)
810 cellMap = isTestCell.sortedToc();
822 List<pointIndexHit> nearInfo;
827 surfaces_.findNearestRegion
840 DynamicList<label> map(nearInfo.size());
841 DynamicField<point> rayStart(nearInfo.size());
842 DynamicField<point> rayEnd(nearInfo.size());
843 DynamicField<scalar> gapSize(nearInfo.size());
845 DynamicField<point> rayStart2(nearInfo.size());
846 DynamicField<point> rayEnd2(nearInfo.size());
847 DynamicField<scalar> gapSize2(nearInfo.size());
849 label nTestCells = 0;
853 if (nearInfo[i].hit())
855 const label globalRegioni = surfaces_.globalRegion
862 const label bLevel = surfaces_.blockLevel()[globalRegioni];
863 const FixedList<label, 3> gapInfo
872 const label celli = cellMap[i];
873 const label cLevel = meshCutter_.cellLevel()[celli];
876 const label nRays = generateRays
879 nearInfo[i].hitPoint(),
884 mesh_.cellCentres()[celli],
898 for (label j = 0; j < nRays; j++)
907 <<
" cells for testing out of " 908 << mesh_.globalData().nTotalCells() <<
endl;
919 nearNormal = UIndirectList<vector>(nearNormal, map)();
928 List<pointIndexHit> hit1;
930 surfaces_.findNearestIntersection
942 List<pointIndexHit> hit2;
944 surfaces_.findNearestIntersection
958 if (surf1[i] != -1 && surf2[i] != -1)
964 const label celli = cellMap[i];
965 if (celli != -1 && refineCell[celli] == -1)
967 const scalar d2 =
magSqr(hit1[i].hitPoint()-hit2[i].hitPoint());
969 const scalar maxGapSize
973 regionToBlockSize[surf1[i]][region1[i]],
974 regionToBlockSize[surf2[i]][region2[i]]
980 (
mag(normal1[i]&normal2[i]) > planarCos)
997 Pout<<
"Stopped refining since reaching my cell" 998 <<
" limit of " << mesh_.nCells()+7*nRefine
1014 Info<<
"Reached refinement limit." <<
endl;
1023 const scalar planarAngle,
1026 const label growIter
1030 labelList neiLevel(mesh_.nBoundaryFaces());
1032 calcNeighbourData(neiLevel, neiCc);
1055 forAll(surfaces_.surfaces(), surfi)
1057 const label geomi = surfaces_.surfaces()[surfi];
1059 const label nRegions =
s.regions().size();
1062 for (label regioni = 0; regioni < nRegions; regioni++)
1064 const label globalRegioni = surfaces_.globalRegion(surfi, regioni);
1068 surfaces_.blockLevel()[globalRegioni]
1074 surfToBlockLevel.
insert(surfi, minBlockLevel);
1092 markFakeGapRefinement
1106 Info<<
"Marked for blocking due to close opposite surfaces : " 1115 bitSet isOutsideFace;
1116 for (label iter = 0; iter < growIter; iter++)
1121 meshCutter_.cellLevel(),
1127 growSet(neiLevel, isOutsideFace, refineCell, nRefine);
1132 for (label iter = 0; iter < growIter; iter++)
1144 for (label celli = 0; celli < mesh_.nCells(); celli++)
1146 if (refineCell[celli] != -1 && oldRefineCell[celli] == -1)
1148 if (countFaceDirs(isOutsideFace, celli) >= 3)
1150 refineCell[celli] = -1;
1157 Info<<
"Marked for blocking after filtering : " 1163 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
1165 const label defaultRegion(surfaces_.globalRegion(unnamedSurfaces[0], 0));
1180 forAll(refineCell, cellI)
1182 if (refineCell[cellI] != -1)
1184 cellsToRemove[nRefine++] = cellI;
1189 removeCells cellRemover(mesh_);
1190 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1192 labelList exposedPatches(exposedFaces.size());
1195 label facei = exposedFaces[i];
1196 exposedPatches[i] = globalToMasterPatch[nearestRegion[facei]];
1199 return doRemoveCells
1226 boolList isSelectedSurf(surfaces_.surfaces().size(),
false);
1229 forAll(surfaceIndex_, facei)
1231 const label surfi = surfaceIndex_[facei];
1232 if (surfi != -1 && isSelectedSurf[surfi])
1913 forAll(locationsInMesh, i)
1915 insideCells[i] = findCell
1918 mergeDistance_*vector::one,
1921 if (insideCells[i] != -1)
1923 insideRegions[i] = cellRegion[insideCells[i]];
1927 if (insideRegions[i] == -1)
1930 insideCells[i] = findCell
1933 mergeDistance_*vector::one,
1934 locationsInMesh[i]+mergeDistance_*vector::one
1936 if (insideCells[i] != -1)
1938 insideRegions[i] = cellRegion[insideCells[i]];
1942 if (insideRegions[i] == -1)
1945 <<
"Cannot find locationInMesh " << locationsInMesh[i]
1955 bool haveLeak =
false;
1956 forAll(locationsOutsideMesh, i)
1959 label regioni = findRegion
1963 mergeDistance_*vector::one,
1964 locationsOutsideMesh[i]
1970 if (insideRegions.find(regioni) != -1)
1974 <<
"Outside location " << locationsOutsideMesh[i]
1975 <<
" in region " << regioni
1976 <<
" is connected to one of the inside points " 1977 << locationsInMesh <<
endl;
1995 locationsOutsideMesh
2012 globalBlockingFaces,
2021 Pout<<
"meshRefinement::blockLeakFaces :" 2022 <<
" found closure faces:" << closureFaces.
size()
2023 <<
" map:" << bool(closureMapPtr) <<
endl;
2029 <<
"have leak but did not find any closure faces" 2047 ownPatch[
pp.start()+i] = patchi;
2048 neiPatch[
pp.start()+i] = patchi;
2056 labelList faceToZone(mesh_.nFaces(), -1);
2057 boolList faceToFlip(mesh_.nFaces(),
false);
2060 const labelList& addressing = fzs[zonei];
2061 const boolList& flipMap = fzs[zonei].flipMap();
2065 faceToZone[addressing[i]] = zonei;
2066 faceToFlip[addressing[i]] = flipMap[i];
2082 const label facei = closureFaces[i];
2083 const label sloti = closureToBlocked[i];
2088 ownPatch[facei] = packedOwnPatch[sloti];
2089 neiPatch[facei] = packedNeiPatch[sloti];
2090 faceToZone[facei] = packedZone[sloti];
2091 faceToFlip[facei] = packedFlip[sloti];
2103 forAll(faceToZone, facei)
2105 const label zonei = faceToZone[facei];
2108 zoneToFaces[zonei].append(facei);
2109 zoneToFlip[zonei].append(faceToFlip[facei]);
2113 forAll(zoneToFaces, zonei)
2137 bitSet isFrozenPoint(mesh_.nPoints());
2138 forAll(nEdgeFaces, edgei)
2140 if (nEdgeFaces[edgei] != 1)
2151 const label zonei = addPointZone(
"frozenPoints");
2152 const bitSet oldSet(mesh_.nPoints(), pointZones[zonei]);
2153 isFrozenPoint.
set(oldSet);
2165 pointZones[zonei] = isFrozenPoint.sortedToc();
2171 mapPtr = createBaffles(ownPatch, neiPatch);
2197 const_cast<Time&
>(mesh_.time())++;
2199 Pout<<
"Writing current mesh to time " 2211 Pout<<
"Dumped mesh in = " 2212 << mesh_.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
void markOutsideFaces(const labelList &cellLevel, const labelList &neiLevel, const labelList &refineCell, bitSet &isOutsideFace) const
Mark faces on interface between set and rest.
void size(const label n)
Older name for setAddressableSize.
void clearAddressing()
Clear addressing.
void set(const bitSet &bitset)
Set specified bits from another bitset.
List< wallPoints > allCellInfo(mesh_.nCells())
List< cell > cellList
List of cell.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const bitSet isBlockedFace(intersectedFaces())
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
autoPtr< mapPolyMesh > removeGapCells(const scalar planarAngle, const labelList &minSurfaceLevel, const labelList &globalToMasterPatch, const label growIter)
Detect gapRefinement cells and remove them.
void setSize(const label n, unsigned int val=0u)
Alias for resize()
UIndirectList< label > labelUIndList
UIndirectList of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static writeType writeLevel()
Get/set write level.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
label countFaceDirs(const bitSet &isOutsideFace, const label celli) const
Count number of faces on cell that are in set.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
label nFaces() const noexcept
Number of mesh faces.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
dimensionedScalar cos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
void clear()
Clear the list, i.e. set size to zero.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label size() const noexcept
The number of entries in the list.
autoPtr< mapPolyMesh > blockLeakFaces(const labelList &globalToMasterPatch, const labelList &globalToSlavePatch, const pointField &locationsInMesh, const wordList &zonesInMesh, const pointField &locationsOutsideMesh, const labelList &selectedSurfaces)
Baffle faces to break any leak from inside to outside.
virtual const labelList & faceOwner() const
Return face owner.
void growSet(const labelList &neiLevel, const bitSet &isOutsideFace, labelList &refineCell, label &nRefine) const
Add one layer of cells to set.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalFaces() const noexcept
Number of internal faces.
Container with cells to refine. Refinement given as single direction.
FaceCellWave< wallPoints, wallPoints::trackData > wallDistCalc(mesh_, changedFaces, faceDist, allFaceInfo, allCellInfo, 0, td)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
A location that is partly inside and outside.
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
const polyBoundaryMesh & patches
void selectIntersectedFaces(const labelList &surfaces, boolList &isBlockedFace) const
Faces currently on boundary or intersected by surface.
static List< pointField > zonePoints(const pointField &locationsInMesh, const wordList &zonesInMesh, const pointField &locationsOutsideMesh)
Helper: per zone (entry in zonesInMesh) the locations with.
messageStream Info
Information stream (stdout output on master, null elsewhere)
writeType
Enumeration for what to write. Used as a bit-pattern.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static autoPtr< mapDistribute > calcClosure(const polyMesh &mesh, const List< pointField > &zonePoints, const labelList &blockedFaces, const globalIndex &globalBlockedFaces, const bool erode, labelList &closureFaces, labelList &closureToBlocked)
Optional direct use to generate the set of faces and the method to.
debugType
Enumeration for what to debug. Used as a bit-pattern.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
label nNonProcessor() const
The number of patches before the first processor patch.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
List< bool > boolList
A List of bools.
List< wallPoints > allFaceInfo(mesh_.nFaces())
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)