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)
260 dir < pTraits<vector>::nComponents;
266 haveDirs[dir] =
true;
289 const bitSet& isOutsideFace,
298 if (refineCell[celli] == -1)
300 if (countFaceDirs(isOutsideFace, celli) == 3)
303 refineCell[celli] = 0;
458 Foam::label Foam::meshRefinement::markProximityRefinementWave
460 const scalar planarCos,
462 const label nAllowRefine,
473 for (
const label surfi : blockedSurfaces)
475 const label geomi = surfaces_.surfaces()[surfi];
476 const searchableSurface&
s = surfaces_.geometry()[geomi];
477 if (isA<triSurfaceMesh>(
s) && !isA<distributedTriSurfaceMesh>(
s))
479 const triSurfaceMesh& surf = refCast<const triSurfaceMesh>(
s);
481 boolList isOpenEdge(edFaces.size(),
false);
484 if (edFaces[i].size() == 1)
486 isOpenEdge[i] =
true;
491 const label nZones = surf.markZones(isOpenEdge, faceZone);
494 faceZones[surfi].
transfer(faceZone);
503 List<scalarList> regionToBlockSize(surfaces_.surfaces().size());
504 for (
const label surfi : blockedSurfaces)
506 const label geomi = surfaces_.surfaces()[surfi];
507 const searchableSurface&
s = surfaces_.geometry()[geomi];
508 const label nRegions =
s.regions().size();
509 regionToBlockSize[surfi].setSize(nRegions);
510 for (label regioni = 0; regioni < nRegions; regioni++)
512 const label globalRegioni = surfaces_.globalRegion(surfi, regioni);
513 const label bLevel = surfaces_.blockLevel()[globalRegioni];
514 regionToBlockSize[surfi][regioni] =
515 meshCutter_.level0EdgeLength()/
pow(2.0, bLevel);
533 const label nIters = mesh_.globalData().nTotalCells();
538 const labelList testFaces(getRefineCandidateFaces(refineCell));
567 List<pointIndexHit> hit1;
572 List<pointIndexHit> hit2;
576 surfaces_.findNearestIntersection
622 List<wallPoints> faceDist(
n);
626 DynamicList<point> originLocation(2);
627 DynamicList<scalar> originDistSqr(2);
628 DynamicList<FixedList<label, 3>> originSurface(2);
644 const label facei = testFaces[i];
646 const point& fc = mesh_.faceCentres()[facei];
647 const labelList& fz1 = faceZones[surface1[i]];
649 originLocation.
clear();
650 originDistSqr.clear();
652 originSurface.clear();
654 originLocation.append(hit1[i].
point());
655 originDistSqr.append(hit1[i].
point().distSqr(fc));
663 (fz1.size() ? fz1[hit1[i].index()] : region1[i])
667 if (hit2[i].hit() && hit1[i] != hit2[i])
669 const labelList& fz2 = faceZones[surface2[i]];
671 originDistSqr.append(hit2[i].
point().distSqr(fc));
679 (fz2.size() ? fz2[hit2[i].index()] : region2[i])
686 faceDist[
n] = wallPoints
693 changedFaces[
n] = facei;
710 List<wallPoints> allFaceInfo(mesh_.nFaces());
711 List<wallPoints> allCellInfo(mesh_.nCells());
716 const bitSet isBlockedFace(intersectedFaces());
718 wallPoints::trackData td(isBlockedFace, regionToBlockSize);
719 FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc
729 wallDistCalc.iterate(nIters);
740 mesh_.time().timeName(),
755 forAll(allCellInfo, celli)
757 if (allCellInfo[celli].valid(wallDistCalc.data()))
759 const point& cc = mesh_.cellCentres()[celli];
761 const List<point>& origin = allCellInfo[celli].origin();
764 for (label i = 0; i < origin.size(); i++)
766 for (label j = i + 1; j < origin.size(); j++)
768 if (((cc-origin[i]) & (cc-origin[j])) < 0)
770 const scalar d(
mag(origin[i]-origin[j]));
784 distance.correctBoundaryConditions();
786 Info<<
"Writing measured gap distance to " 806 forAll(allCellInfo, celli)
808 if (allCellInfo[celli].valid(wallDistCalc.data()))
810 const point& cc = mesh_.cellCentres()[celli];
812 const List<point>& origin = allCellInfo[celli].origin();
813 const List<FixedList<label, 3>>&
surface =
814 allCellInfo[celli].surface();
817 for (label i = 0; i < origin.size(); i++)
819 for (label j = i + 1; j < origin.size(); j++)
837 if (((cc-origin[i]) & (cc-origin[j])) < 0)
839 const label surfi =
surface[i][0];
840 const label regioni =
surface[i][1];
842 const label surfj =
surface[j][0];
843 const label regionj =
surface[j][1];
845 const scalar maxSize =
max 847 regionToBlockSize[surfi][regioni],
848 regionToBlockSize[surfj][regionj]
853 magSqr(origin[i]-origin[j])
866 smallGapDistance[celli] =
867 max(smallGapDistance[celli], maxDist);
879 Info<<
"Marked for blocking due to intersecting multiple surfaces : " 881 Info<<
"Marked for blocking due to close opposite surfaces : " 892 mesh_.time().timeName(),
902 dimensionSet(0, 1, 0, 0, 0),
906 distance.field() = smallGapDistance;
907 distance.correctBoundaryConditions();
909 Info<<
"Writing all small-gap cells to " 916 const label oldNRefine = nRefine;
917 forAll(smallGapDistance, celli)
919 if (smallGapDistance[celli] > SMALL)
934 Pout<<
"Stopped refining since reaching my cell" 935 <<
" limit of " << mesh_.nCells()+7*nRefine
949 Info<<
"Reached refinement limit." <<
endl;
952 return returnReduce(nRefine-oldNRefine, sumOp<label>());
958 const scalar planarAngle,
965 labelList neiLevel(mesh_.nBoundaryFaces());
967 calcNeighbourData(neiLevel, neiCc);
990 forAll(surfaces_.surfaces(), surfi)
992 const label geomi = surfaces_.surfaces()[surfi];
994 const label nRegions =
s.regions().size();
997 for (label regioni = 0; regioni < nRegions; regioni++)
999 const label globalRegioni = surfaces_.globalRegion(surfi, regioni);
1003 surfaces_.blockLevel()[globalRegioni]
1009 surfToBlockLevel.
insert(surfi, minBlockLevel);
1014 markProximityRefinementWave
1042 Info<<
"Marked for blocking due to close opposite surfaces : " 1051 bitSet isOutsideFace;
1052 for (label iter = 0; iter < growIter; iter++)
1057 meshCutter_.cellLevel(),
1063 growSet(neiLevel, isOutsideFace, refineCell, nRefine);
1068 for (label iter = 0; iter < growIter; iter++)
1080 for (label celli = 0; celli < mesh_.nCells(); celli++)
1082 if (refineCell[celli] != -1 && oldRefineCell[celli] == -1)
1084 if (countFaceDirs(isOutsideFace, celli) >= 3)
1086 refineCell[celli] = -1;
1093 Info<<
"Marked for blocking after filtering : " 1099 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
1101 const label defaultRegion(surfaces_.globalRegion(unnamedSurfaces[0], 0));
1116 forAll(refineCell, cellI)
1118 if (refineCell[cellI] != -1)
1120 cellsToRemove[nRefine++] = cellI;
1125 removeCells cellRemover(mesh_);
1126 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1128 labelList exposedPatches(exposedFaces.size());
1131 label facei = exposedFaces[i];
1132 exposedPatches[i] = globalToMasterPatch[nearestRegion[facei]];
1135 return doRemoveCells
1154 isBlockedFace.
setSize(mesh_.nFaces(),
false);
1157 selectSeparatedCoupledFaces(isBlockedFace);
1162 boolList isSelectedSurf(surfaces_.surfaces().size(),
false);
1165 forAll(surfaceIndex_, facei)
1167 const label surfi = surfaceIndex_[facei];
1168 if (surfi != -1 && isSelectedSurf[surfi])
1170 isBlockedFace[facei] =
true;
1851 selectIntersectedFaces(selectedSurfaces, isBlockedFace);
1854 const regionSplit cellRegion(mesh_, isBlockedFace);
1859 forAll(locationsInMesh, i)
1861 insideCells[i] = findCell
1864 mergeDistance_*vector::one,
1867 if (insideCells[i] != -1)
1869 insideRegions[i] = cellRegion[insideCells[i]];
1873 if (insideRegions[i] == -1)
1876 insideCells[i] = findCell
1879 mergeDistance_*vector::one,
1880 locationsInMesh[i]+mergeDistance_*vector::one
1882 if (insideCells[i] != -1)
1884 insideRegions[i] = cellRegion[insideCells[i]];
1888 if (insideRegions[i] == -1)
1891 <<
"Cannot find locationInMesh " << locationsInMesh[i]
1901 bool haveLeak =
false;
1902 forAll(locationsOutsideMesh, i)
1905 label regioni = findRegion
1909 mergeDistance_*vector::one,
1910 locationsOutsideMesh[i]
1916 if (insideRegions.find(regioni) != -1)
1920 <<
"Outside location " << locationsOutsideMesh[i]
1921 <<
" in region " << regioni
1922 <<
" is connected to one of the inside points " 1923 << locationsInMesh <<
endl;
1941 locationsOutsideMesh
1958 globalBlockingFaces,
1967 Pout<<
"meshRefinement::blockLeakFaces :" 1968 <<
" found closure faces:" << closureFaces.
size()
1969 <<
" map:" << closureMapPtr.valid() <<
endl;
1972 if (!closureMapPtr.valid())
1975 <<
"have leak but did not find any closure faces" 1993 ownPatch[pp.
start()+i] = patchi;
1994 neiPatch[pp.
start()+i] = patchi;
2002 labelList faceToZone(mesh_.nFaces(), -1);
2003 boolList faceToFlip(mesh_.nFaces(),
false);
2006 const labelList& addressing = fzs[zonei];
2007 const boolList& flipMap = fzs[zonei].flipMap();
2011 faceToZone[addressing[i]] = zonei;
2012 faceToFlip[addressing[i]] = flipMap[i];
2028 const label facei = closureFaces[i];
2029 const label sloti = closureToBlocked[i];
2034 ownPatch[facei] = packedOwnPatch[sloti];
2035 neiPatch[facei] = packedNeiPatch[sloti];
2036 faceToZone[facei] = packedZone[sloti];
2037 faceToFlip[facei] = packedFlip[sloti];
2049 forAll(faceToZone, facei)
2051 const label zonei = faceToZone[facei];
2054 zoneToFaces[zonei].append(facei);
2055 zoneToFlip[zonei].append(faceToFlip[facei]);
2059 forAll(zoneToFaces, zonei)
2080 const labelList nEdgeFaces(countEdgeFaces(pp));
2083 bitSet isFrozenPoint(mesh_.nPoints());
2084 forAll(nEdgeFaces, edgei)
2086 if (nEdgeFaces[edgei] != 1)
2088 const edge&
e = pp.edges()[edgei];
2089 isFrozenPoint.set(pp.meshPoints()[
e[0]]);
2090 isFrozenPoint.set(pp.meshPoints()[
e[1]]);
2097 const label zonei = addPointZone(
"frozenPoints");
2098 const bitSet oldSet(mesh_.nPoints(), pointZones[zonei]);
2099 isFrozenPoint.
set(oldSet);
2111 pointZones[zonei] = isFrozenPoint.sortedToc();
2117 mapPtr = createBaffles(ownPatch, neiPatch);
2143 const_cast<Time&
>(mesh_.time())++;
2145 Pout<<
"Writing current mesh to time " 2157 Pout<<
"Dumped mesh in = " 2158 << mesh_.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
List< labelList > labelListList
A List of labelList.
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.
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.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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()
Ostream & endl(Ostream &os)
Add newline and flush stream.
static writeType writeLevel()
Get/set write level.
scalar distance(const vector &p1, const vector &p2)
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.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Ignore writing from objectRegistry::writeObject()
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
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) is 1 for serial run.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
dimensionedScalar cos(const dimensionedScalar &ds)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
An edge is a list of two point labels. The functionality it provides supports the discretisation 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 elements 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.
label nInternalFaces() const noexcept
Number of internal faces.
Container with cells to refine. Refinement given as single direction.
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...
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
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)
UIndirectList< label > labelUIndList
UIndirectList of labels.
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.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
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. ...
label start() const
Return start label of this patch in the polyMesh face list.
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.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< cell > cellList
A List of cells.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)
static constexpr const zero Zero
Global zero (0)