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];
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,
300 if (countFaceDirs(isOutsideFace, celli) == 3)
458Foam::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];
477 if (isA<triSurfaceMesh>(
s) && !isA<distributedTriSurfaceMesh>(
s))
484 if (edFaces[i].size() == 1)
486 isOpenEdge[i] =
true;
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].hitPoint());
655 originDistSqr.append(
magSqr(fc-hit1[i].hitPoint()));
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]];
670 originLocation.
append(hit2[i].hitPoint());
671 originDistSqr.append(
magSqr(fc-hit2[i].hitPoint()));
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 : "
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)
1093 Info<<
"Marked for blocking after filtering : "
1101 const label defaultRegion(surfaces_.globalRegion(unnamedSurfaces[0], 0));
1120 cellsToRemove[nRefine++] = cellI;
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
1867 if (insideCells[i] != -1)
1869 insideRegions[i] = cellRegion[insideCells[i]];
1873 if (insideRegions[i] == -1)
1876 insideCells[i] = findCell
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
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];
2019 closureMapPtr->distribute(packedOwnPatch);
2021 closureMapPtr->distribute(packedNeiPatch);
2023 closureMapPtr->distribute(packedZone);
2025 closureMapPtr->distribute(packedFlip);
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)
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;
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
void setSize(const label n, unsigned int val=0u)
Alias for resize()
A list of faces which address into the list of points.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const labelListList & edgeFaces() const
Return edge-face addressing.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
void clearAddressing()
Clear addressing.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
bool valid() const noexcept
Identical to good(), or bool operator.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A cell is defined as a list of faces with extra functionality.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
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.
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.
writeType
Enumeration for what to write. Used as a bit-pattern.
label countFaceDirs(const bitSet &isOutsideFace, const label celli) const
Count number of faces on cell that are in set.
autoPtr< mapPolyMesh > removeGapCells(const scalar planarAngle, const labelList &minSurfaceLevel, const labelList &globalToMasterPatch, const label growIter)
Detect gapRefinement cells and remove them.
void markOutsideFaces(const labelList &cellLevel, const labelList &neiLevel, const labelList &refineCell, bitSet &isOutsideFace) const
Mark faces on interface between set and rest.
debugType
Enumeration for what to debug. Used as a bit-pattern.
void selectIntersectedFaces(const labelList &surfaces, boolList &isBlockedFace) const
Faces currently on boundary or intersected by surface.
void growSet(const labelList &neiLevel, const bitSet &isOutsideFace, labelList &refineCell, label &nRefine) const
Add one layer of cells to set.
static writeType writeLevel()
Get/set write level.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label nNonProcessor() const
The number of patches before the first processor patch.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
label nInternalFaces() const noexcept
Number of internal faces.
label nFaces() const noexcept
Number of mesh faces.
Container with cells to refine. Refinement given as single direction.
static List< pointField > zonePoints(const pointField &locationsInMesh, const wordList &zonesInMesh, const pointField &locationsOutsideMesh)
Helper: per zone (entry in zonesInMesh) the locations with.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Given list of cells to remove, insert all the topology changes.
labelList getExposedFaces(const bitSet &removedCell) const
Get labels of faces exposed after cells removal.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
static label addFaceZone(const word &name, const labelList &addressing, const boolList &flipMap, polyMesh &mesh)
IOoject and searching on triSurface.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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))
#define WarningInFunction
Report a warning using Foam::Warning.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
scalar distance(const vector &p1, const vector &p2)
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UIndirectList< label > labelUIndList
UIndirectList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.