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 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(),
901 distance.field() = smallGapDistance;
902 distance.correctBoundaryConditions();
904 Info<<
"Writing all small-gap cells to " 911 const label oldNRefine = nRefine;
912 forAll(smallGapDistance, celli)
914 if (smallGapDistance[celli] > SMALL)
929 Pout<<
"Stopped refining since reaching my cell" 930 <<
" limit of " << mesh_.nCells()+7*nRefine
944 Info<<
"Reached refinement limit." <<
endl;
947 return returnReduce(nRefine-oldNRefine, sumOp<label>());
953 const scalar planarAngle,
960 labelList neiLevel(mesh_.nBoundaryFaces());
962 calcNeighbourData(neiLevel, neiCc);
985 forAll(surfaces_.surfaces(), surfi)
987 const label geomi = surfaces_.surfaces()[surfi];
989 const label nRegions =
s.regions().size();
992 for (label regioni = 0; regioni < nRegions; regioni++)
994 const label globalRegioni = surfaces_.globalRegion(surfi, regioni);
998 surfaces_.blockLevel()[globalRegioni]
1004 surfToBlockLevel.
insert(surfi, minBlockLevel);
1009 markProximityRefinementWave
1037 Info<<
"Marked for blocking due to close opposite surfaces : " 1046 bitSet isOutsideFace;
1047 for (label iter = 0; iter < growIter; iter++)
1052 meshCutter_.cellLevel(),
1058 growSet(neiLevel, isOutsideFace, refineCell, nRefine);
1063 for (label iter = 0; iter < growIter; iter++)
1075 for (label celli = 0; celli < mesh_.nCells(); celli++)
1077 if (refineCell[celli] != -1 && oldRefineCell[celli] == -1)
1079 if (countFaceDirs(isOutsideFace, celli) >= 3)
1081 refineCell[celli] = -1;
1088 Info<<
"Marked for blocking after filtering : " 1094 const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
1096 const label defaultRegion(surfaces_.globalRegion(unnamedSurfaces[0], 0));
1111 forAll(refineCell, cellI)
1113 if (refineCell[cellI] != -1)
1115 cellsToRemove[nRefine++] = cellI;
1120 removeCells cellRemover(mesh_);
1121 labelList exposedFaces(cellRemover.getExposedFaces(cellsToRemove));
1123 labelList exposedPatches(exposedFaces.size());
1126 label facei = exposedFaces[i];
1127 exposedPatches[i] = globalToMasterPatch[nearestRegion[facei]];
1130 return doRemoveCells
1149 isBlockedFace.
setSize(mesh_.nFaces(),
false);
1152 selectSeparatedCoupledFaces(isBlockedFace);
1157 boolList isSelectedSurf(surfaces_.surfaces().size(),
false);
1160 forAll(surfaceIndex_, facei)
1162 const label surfi = surfaceIndex_[facei];
1163 if (surfi != -1 && isSelectedSurf[surfi])
1165 isBlockedFace[facei] =
true;
1836 selectIntersectedFaces(selectedSurfaces, isBlockedFace);
1839 const regionSplit cellRegion(mesh_, isBlockedFace);
1844 forAll(locationsInMesh, i)
1846 insideCells[i] = findCell
1849 mergeDistance_*vector::one,
1852 if (insideCells[i] != -1)
1854 insideRegions[i] = cellRegion[insideCells[i]];
1858 if (insideRegions[i] == -1)
1861 insideCells[i] = findCell
1864 mergeDistance_*vector::one,
1865 locationsInMesh[i]+mergeDistance_*vector::one
1867 if (insideCells[i] != -1)
1869 insideRegions[i] = cellRegion[insideCells[i]];
1873 if (insideRegions[i] == -1)
1876 <<
"Cannot find locationInMesh " << locationsInMesh[i]
1886 bool haveLeak =
false;
1887 forAll(locationsOutsideMesh, i)
1890 label regioni = findRegion
1894 mergeDistance_*vector::one,
1895 locationsOutsideMesh[i]
1901 if (insideRegions.find(regioni) != -1)
1905 <<
"Outside location " << locationsOutsideMesh[i]
1906 <<
" in region " << regioni
1907 <<
" is connected to one of the inside points " 1908 << locationsInMesh <<
endl;
1926 locationsOutsideMesh
1943 globalBlockingFaces,
1952 Pout<<
"meshRefinement::blockLeakFaces :" 1953 <<
" found closure faces:" << closureFaces.
size()
1954 <<
" map:" << bool(closureMapPtr) <<
endl;
1960 <<
"have leak but did not find any closure faces" 1978 ownPatch[
pp.start()+i] = patchi;
1979 neiPatch[
pp.start()+i] = patchi;
1987 labelList faceToZone(mesh_.nFaces(), -1);
1988 boolList faceToFlip(mesh_.nFaces(),
false);
1991 const labelList& addressing = fzs[zonei];
1992 const boolList& flipMap = fzs[zonei].flipMap();
1996 faceToZone[addressing[i]] = zonei;
1997 faceToFlip[addressing[i]] = flipMap[i];
2013 const label facei = closureFaces[i];
2014 const label sloti = closureToBlocked[i];
2019 ownPatch[facei] = packedOwnPatch[sloti];
2020 neiPatch[facei] = packedNeiPatch[sloti];
2021 faceToZone[facei] = packedZone[sloti];
2022 faceToFlip[facei] = packedFlip[sloti];
2034 forAll(faceToZone, facei)
2036 const label zonei = faceToZone[facei];
2039 zoneToFaces[zonei].append(facei);
2040 zoneToFlip[zonei].append(faceToFlip[facei]);
2044 forAll(zoneToFaces, zonei)
2068 bitSet isFrozenPoint(mesh_.nPoints());
2069 forAll(nEdgeFaces, edgei)
2071 if (nEdgeFaces[edgei] != 1)
2082 const label zonei = addPointZone(
"frozenPoints");
2083 const bitSet oldSet(mesh_.nPoints(), pointZones[zonei]);
2084 isFrozenPoint.
set(oldSet);
2096 pointZones[zonei] = isFrozenPoint.sortedToc();
2102 mapPtr = createBaffles(ownPatch, neiPatch);
2128 const_cast<Time&
>(mesh_.time())++;
2130 Pout<<
"Writing current mesh to time " 2142 Pout<<
"Dumped mesh in = " 2143 << 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< 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.
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.
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.
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.
::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.
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.
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.
#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). It 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 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.
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)
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. ...
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.
Do not request registration (bool: false)
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)