Go to the documentation of this file.
52 const unsigned int val
80 if (protectedCell_.empty())
82 unrefineableCell.
clear();
86 const labelList& cellLevel = meshCutter_.cellLevel();
88 unrefineableCell = protectedCell_;
91 labelList neiLevel(nFaces()-nInternalFaces());
93 for (
label faceI = nInternalFaces(); faceI < nFaces(); faceI++)
95 neiLevel[faceI-nInternalFaces()] = cellLevel[faceOwner()[faceI]];
97 syncTools::swapBoundaryFaceList(*
this, neiLevel);
105 forAll(faceNeighbour(), faceI)
107 label own = faceOwner()[faceI];
108 bool ownProtected = unrefineableCell.
get(own);
109 label nei = faceNeighbour()[faceI];
110 bool neiProtected = unrefineableCell.
get(nei);
112 if (ownProtected && (cellLevel[nei] > cellLevel[own]))
114 seedFace[faceI] =
true;
116 else if (neiProtected && (cellLevel[own] > cellLevel[nei]))
118 seedFace[faceI] =
true;
121 for (
label faceI = nInternalFaces(); faceI < nFaces(); faceI++)
123 label own = faceOwner()[faceI];
124 bool ownProtected = unrefineableCell.
get(own);
128 && (neiLevel[faceI-nInternalFaces()] > cellLevel[own])
131 seedFace[faceI] =
true;
135 syncTools::syncFaceList(*
this, seedFace,
orEqOp<bool>());
139 bool hasExtended =
false;
141 for (
label faceI = 0; faceI < nInternalFaces(); faceI++)
145 label own = faceOwner()[faceI];
146 if (unrefineableCell.
get(own) == 0)
148 unrefineableCell.
set(own, 1);
152 label nei = faceNeighbour()[faceI];
153 if (unrefineableCell.
get(nei) == 0)
155 unrefineableCell.
set(nei, 1);
160 for (
label faceI = nInternalFaces(); faceI < nFaces(); faceI++)
164 label own = faceOwner()[faceI];
165 if (unrefineableCell.
get(own) == 0)
167 unrefineableCell.
set(own, 1);
201 refineDict.
lookup(
"correctFluxes")
207 correctFluxes_.insert(fluxVelocities[i][0], fluxVelocities[i][1]);
225 meshCutter_.setRefinement(cellsToRefine, meshMod);
231 Info<<
"Refined from "
233 <<
" to " << globalData().nTotalCells() <<
" cells." <<
endl;
238 for (
label faceI = 0; faceI < nInternalFaces(); faceI++)
240 label oldFaceI = map().faceMap()[faceI];
242 if (oldFaceI >= nInternalFaces())
245 <<
"New internal face:" << faceI
246 <<
" fc:" << faceCentres()[faceI]
247 <<
" originates from boundary oldFace:" << oldFaceI
280 const labelList& reverseFaceMap = map().reverseFaceMap();
293 label masterFaceI = reverseFaceMap[oldFaceI];
298 <<
"Problem: should not have removed faces"
302 else if (masterFaceI != faceI)
304 masterFaces.
insert(masterFaceI);
310 Pout<<
"Found " << masterFaces.
size() <<
" split faces " <<
endl;
315 lookupClass<surfaceScalarField>()
319 if (!correctFluxes_.found(iter.key()))
322 <<
"Cannot find surfaceScalarField " << iter.key()
323 <<
" in user-provided flux mapping table "
324 << correctFluxes_ <<
endl
325 <<
" The flux mapping table is used to recreate the"
326 <<
" flux on newly created faces." <<
endl
327 <<
" Either add the entry if it is a flux or use ("
328 << iter.key() <<
" none) to suppress this warning."
333 const word& UName = correctFluxes_[iter.key()];
342 Pout<<
"Setting surfaceScalarField " << iter.key()
343 <<
" to NaN" <<
endl;
354 Pout<<
"Mapping flux " << iter.key()
355 <<
" using interpolated flux " << UName
364 lookupObject<volVectorField>(UName)
370 for (
label faceI = 0; faceI < nInternalFaces(); faceI++)
377 phi[faceI] = phiU[faceI];
379 else if (reverseFaceMap[oldFaceI] != faceI)
382 phi[faceI] = phiU[faceI];
404 patchPhi[i] = patchPhiU[i];
406 else if (reverseFaceMap[oldFaceI] != faceI)
409 patchPhi[i] = patchPhiU[i];
419 label faceI = iter.key();
421 if (isInternalFace(faceI))
423 phi[faceI] = phiU[faceI];
435 patchPhi[i] = patchPhiU[i];
444 meshCutter_.updateMesh(map);
447 if (protectedCell_.size())
451 forAll(newProtectedCell, cellI)
453 label oldCellI = map().cellMap()[cellI];
454 newProtectedCell.
set(cellI, protectedCell_.get(oldCellI));
456 protectedCell_.transfer(newProtectedCell);
460 meshCutter_.checkRefinementLevels(-1,
labelList(0));
477 meshCutter_.setUnrefinement(splitPoints, meshMod);
491 label pointI = splitPoints[i];
493 const labelList& pEdges = pointEdges()[pointI];
497 label otherPointI = edges()[pEdges[j]].otherVertex(pointI);
503 faceToSplitPoint.insert(
pFaces[pFaceI], otherPointI);
514 Info<<
"Unrefined from "
516 <<
" to " << globalData().nTotalCells() <<
" cells."
539 const labelList& reversePointMap = map().reversePointMap();
540 const labelList& reverseFaceMap = map().reverseFaceMap();
544 lookupClass<surfaceScalarField>()
548 if (!correctFluxes_.found(iter.key()))
551 <<
"Cannot find surfaceScalarField " << iter.key()
552 <<
" in user-provided flux mapping table "
553 << correctFluxes_ <<
endl
554 <<
" The flux mapping table is used to recreate the"
555 <<
" flux on newly created faces." <<
endl
556 <<
" Either add the entry if it is a flux or use ("
557 << iter.key() <<
" none) to suppress this warning."
562 const word& UName = correctFluxes_[iter.key()];
571 Info<<
"Mapping flux " << iter.key()
572 <<
" using interpolated flux " << UName
584 lookupObject<volVectorField>(UName)
592 label oldFaceI = iter.key();
593 label oldPointI = iter();
595 if (reversePointMap[oldPointI] < 0)
598 label faceI = reverseFaceMap[oldFaceI];
602 if (isInternalFace(faceI))
604 phi[faceI] = phiU[faceI];
614 patchPhi[i] = patchPhiU[i];
624 meshCutter_.updateMesh(map);
627 if (protectedCell_.size())
631 forAll(newProtectedCell, cellI)
633 label oldCellI = map().cellMap()[cellI];
636 newProtectedCell.
set(cellI, protectedCell_.get(oldCellI));
639 protectedCell_.transfer(newProtectedCell);
643 meshCutter_.checkRefinementLevels(-1,
labelList(0));
655 forAll(pointCells(), pointI)
657 const labelList& pCells = pointCells()[pointI];
661 vFld[pCells[i]] =
max(vFld[pCells[i]], pFld[pointI]);
674 forAll(pointCells(), pointI)
676 const labelList& pCells = pointCells()[pointI];
680 pFld[pointI] =
max(pFld[pointI], vFld[pCells[i]]);
693 forAll(pointCells(), pointI)
695 const labelList& pCells = pointCells()[pointI];
700 sum += vFld[pCells[i]];
702 pFld[pointI] =
sum/pCells.
size();
712 const scalar minLevel,
713 const scalar maxLevel
720 scalar err =
min(
fld[i]-minLevel, maxLevel-
fld[i]);
733 const scalar lowerRefineLevel,
734 const scalar upperRefineLevel,
757 if (cellError[cellI] > 0)
759 candidateCell.
set(cellI, 1);
767 const label maxCells,
768 const label maxRefinement,
773 label nTotToRefine = (maxCells - globalData().nTotalCells()) / 7;
775 const labelList& cellLevel = meshCutter_.cellLevel();
780 calculateProtectedCells(unrefineableCell);
783 label nLocalCandidates = count(candidateCell, 1);
789 if (nCandidates < nTotToRefine)
791 forAll(candidateCell, cellI)
795 cellLevel[cellI] < maxRefinement
796 && candidateCell.
get(cellI)
798 unrefineableCell.
empty()
799 || !unrefineableCell.
get(cellI)
810 for (
label level = 0; level < maxRefinement; level++)
812 forAll(candidateCell, cellI)
816 cellLevel[cellI] == level
817 && candidateCell.
get(cellI)
819 unrefineableCell.
empty()
820 || !unrefineableCell.
get(cellI)
838 meshCutter_.consistentRefinement
846 <<
" cells for refinement out of " << globalData().nTotalCells()
849 return consistentSet;
855 const scalar unrefineLevel,
861 const labelList splitPoints(meshCutter_.getSplitPoints());
871 if (protectedCell_.size())
874 forAll(pointCells, pointI)
876 const labelList& pCells = pointCells[pointI];
880 label cellI = pCells[pCellI];
882 if (protectedCell_[cellI])
884 protectedPoint[pointI] =
true;
902 <<
" protected cells found "
904 <<
" protected points." <<
endl;
913 label pointI = splitPoints[i];
915 if (!protectedPoint[pointI] && pFld[pointI] < unrefineLevel)
918 const labelList& pCells = pointCells[pointI];
920 bool hasMarked =
false;
924 if (markedCell.
get(pCells[pCellI]))
933 newSplitPoints.
append(pointI);
944 meshCutter_.consistentUnrefinement
951 <<
" split points out of a possible "
955 return consistentSet;
965 boolList markedFace(nFaces(),
false);
969 if (markedCell.
get(cellI))
975 markedFace[cFaces[i]] =
true;
983 for (
label faceI = 0; faceI < nInternalFaces(); faceI++)
985 if (markedFace[faceI])
987 markedCell.
set(faceOwner()[faceI], 1);
988 markedCell.
set(faceNeighbour()[faceI], 1);
991 for (
label faceI = nInternalFaces(); faceI < nFaces(); faceI++)
993 if (markedFace[faceI])
995 markedCell.
set(faceOwner()[faceI], 1);
1007 const labelList& cellLevel = meshCutter_.cellLevel();
1008 const labelList& pointLevel = meshCutter_.pointLevel();
1012 forAll(pointLevel, pointI)
1014 const labelList& pCells = pointCells(pointI);
1018 label cellI = pCells[pCellI];
1020 if (pointLevel[pointI] <= cellLevel[cellI])
1023 if (nAnchorPoints[cellI] == 8)
1025 if (protectedCell.
set(cellI,
true))
1031 if (!protectedCell[cellI])
1033 nAnchorPoints[cellI]++;
1040 forAll(protectedCell, cellI)
1042 if (!protectedCell[cellI] && nAnchorPoints[cellI] != 8)
1044 protectedCell.
set(cellI,
true);
1058 nRefinementIterations_(0),
1059 protectedCell_(nCells(), 0)
1078 label nProtected = 0;
1086 label cellI = pCells[i];
1090 if (pointLevel[pointI] <= cellLevel[cellI])
1094 if (nAnchors[cellI] > 8)
1119 neiLevel[faceI] = cellLevel[
faceOwner()[faceI]];
1140 if (pointLevel[
f[fp]] <= faceLevel)
1146 protectedFace[faceI] =
true;
1157 if (protectedFace[faceI])
1167 if (protectedFace[faceI])
1179 if (cFaces.
size() < 6)
1213 cellSet protectedCells(*
this,
"protectedCells", nProtected);
1218 protectedCells.
insert(cellI);
1223 <<
" cells that are protected from refinement."
1224 <<
" Writing these to cellSet "
1225 << protectedCells.
name()
1228 protectedCells.
write();
1259 ).subDict(typeName +
"Coeffs")
1264 bool hasChanged =
false;
1266 if (refineInterval == 0)
1268 topoChanging(hasChanged);
1272 else if (refineInterval < 0)
1275 <<
"Illegal refineInterval " << refineInterval <<
nl
1276 <<
"The refineInterval setting in the dynamicMeshDict should"
1277 <<
" be >= 1." <<
nl
1294 <<
"Illegal maximum number of cells " << maxCells <<
nl
1295 <<
"The maxCells setting in the dynamicMeshDict should"
1302 if (maxRefinement <= 0)
1305 <<
"Illegal maximum refinement level " << maxRefinement <<
nl
1306 <<
"The maxCells setting in the dynamicMeshDict should"
1311 const word fieldName(refineDict.
lookup(
"field"));
1313 const volScalarField& vFld = lookupObject<volScalarField>(fieldName);
1315 const scalar lowerRefineLevel =
1317 const scalar upperRefineLevel =
1324 const label nBufferLayers =
1331 selectRefineCandidates
1339 if (globalData().nTotalCells() < maxCells)
1358 if (nCellsToRefine > 0)
1366 const labelList& cellMap = map().cellMap();
1367 const labelList& reverseCellMap = map().reverseCellMap();
1373 label oldCellI = cellMap[cellI];
1377 newRefineCell.
set(cellI, 1);
1379 else if (reverseCellMap[oldCellI] != cellI)
1381 newRefineCell.
set(cellI, 1);
1393 for (
label i = 0; i < nBufferLayers; i++)
1407 selectUnrefinePoints
1417 pointsToUnrefine.
size(),
1421 if (nSplitPoints > 0)
1424 unrefine(pointsToUnrefine);
1431 if ((nRefinementIterations_ % 10) == 0)
1437 nRefinementIterations_++;
1440 topoChanging(hasChanged);
1460 const_cast<hexRef8&
>(meshCutter_).setInstance(time().timeName());
1465 && meshCutter_.write()
1485 const labelList& cellLevel = meshCutter_.cellLevel();
1489 scalarCellLevel[cellI] = cellLevel[cellI];
1492 writeOk = writeOk && scalarCellLevel.write();
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
scalarField error(const scalarField &fld, const scalar minLevel, const scalar maxLevel) const
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual labelList selectRefineCells(const label maxCells, const label maxRefinement, const PackedBoolList &candidateCell) const
Subset candidate cells for refinement.
A class for handling words, derived from string.
static label count(const PackedBoolList &, const unsigned int)
Count set/unset elements in packedlist.
const labelIOList & cellLevel() const
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
List< label > labelList
A List of labels.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label whichPatch(const polyPatchList &, const label) const
Get index of patch for face.
#define forAll(list, i)
Loop across all elements in list.
virtual ~dynamicRefineFvMesh()
Destructor.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
virtual labelList selectUnrefinePoints(const scalar unrefineLevel, const PackedBoolList &markedCell, const scalarField &pFld) const
Select points that can be unrefined.
A topoSetSource to select points based on usage in cells.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
compressionType
Enumeration for the format of data in the stream.
void set(const PackedList< 1 > &)
Set specified bits.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const cellList & cells() const
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Direct mesh changes based on v1.3 polyTopoChange syntax.
Abstract base class for geometry and/or topology changing fvMesh.
hexRef8 meshCutter_
Mesh cutting engine.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual bool update()
Update the mesh for both mesh motion and topology change.
virtual bool write() const
Write using setting from DB.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void selectRefineCandidates(const scalar lowerRefineLevel, const scalar upperRefineLevel, const scalarField &vFld, PackedBoolList &candidateCell) const
Select candidate cells for refinement.
HashTable< word > correctFluxes_
Fluxes to map.
PackedBoolList protectedCell_
Protected cells (usually since not hexes)
Switch dumpLevel_
Dump cellLevel for postprocessing.
void readDict()
Read the projection parameters from dictionary.
Constant dispersed-phase particle diameter model.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
All refinement history. Used in unrefinement.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
virtual const labelList & faceOwner() const
Return face owner.
void calculateProtectedCells(PackedBoolList &unrefineableCell) const
Calculate cells that cannot be refined since would trigger.
InternalField & internalField()
Return internal field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const word & name() const
Return name.
scalarField maxCellField(const volScalarField &) const
Get point max of connected cell.
unsigned int count() const
Count number of bits set, O(log(n))
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
dynamicRefineFvMesh(const dynamicRefineFvMesh &)
Disallow default bitwise copy construct.
autoPtr< mapPolyMesh > refine(const labelList &)
Refine cells. Update mesh and fields.
bool empty() const
Return true if the list is empty (ie, size() is zero).
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
label nInternalFaces() const
Macros for easy insertion into run-time selection tables.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManip< error > abort(error &err)
void checkEightAnchorPoints(PackedBoolList &protectedCell, label &nProtected) const
Check all cells have 8 anchor points.
A collection of cell labels.
unsigned int get(const label) const
Get value at index I.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void extendMarkedCells(PackedBoolList &markedCell) const
Extend markedCell with cell-face-cell.
static void fillNan(UList< scalar > &)
Fill block of data with NaN.
An STL-conforming hash table.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Container with cells to refine. Refinement given as single direction.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatch & patch() const
Return patch.
Refinement of (split) hexes using polyTopoChange.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
prefixOSstream Pout(cout, "Pout")
const labelIOList & pointLevel() const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual bool writeObjects(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write the underlying polyMesh and other data.
label start() const
Return start label of this patch in the polyMesh face list.
const labelListList & pointCells() const
bool insert(const Key &key)
Insert a new entry.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
label readLabel(Istream &is)
const dimensionedScalar c
Speed of light in a vacuum.
const Time & time() const
Return the top-level database.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
autoPtr< mapPolyMesh > unrefine(const labelList &)
Unrefine cells. Gets passed in centre points of cells to combine.
scalarField cellToPoint(const scalarField &vFld) const
A face is a list of labels corresponding to mesh vertices.
void size(const label)
Override size to be inconsistent with allocated storage.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Generic GeometricField class.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
scalarField maxPointField(const scalarField &) const
Get per cell max of connected point.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void clear()
Clear the list, i.e. set addressable size to zero.
streamFormat
Enumeration for the format of data in the stream.