49 { cellType::CALCULATED,
"calculated" },
50 { cellType::INTERPOLATED,
"interpolated" },
51 { cellType::HOLE,
"hole" },
53 { cellType::POROUS,
"porous" },
59Foam::cellCellStencil::cellCellStencil(
const fvMesh&
mesh)
75 const word stencilType(
dict.get<word>(
"method"));
77 auto* ctorPtr = meshConstructorTable(stencilType);
86 *meshConstructorTablePtr_
104 if (
name.ends_with(
"_0"))
116 nonInterpolatedFields_.insert(
"cellInterpolationWeight");
117 nonInterpolatedFields_.insert(
"cellTypes");
118 nonInterpolatedFields_.insert(
"maxMagWeight");
122 nonInterpolatedFields_.insert(
"cellDisplacement");
123 nonInterpolatedFields_.insert(
"grad(cellDisplacement)");
124 const word w(
"snGradCorr(cellDisplacement)");
125 const word d(
"((viscosity*faceDiffusivity)*magSf)");
126 nonInterpolatedFields_.insert(
"surfaceIntegrate(("+d+
"*"+w+
"))");
131 nonInterpolatedFields_.insert(
"cellMotionU");
132 nonInterpolatedFields_.insert(
"grad(cellMotionU)");
133 const word w(
"snGradCorr(cellMotionU)");
134 const word d(
"((viscosity*faceDiffusivity)*magSf)");
151 mesh.facesInstance(),
163 auto& zoneID = *zoneIDPtr;
170 mesh.time().findInstance(
mesh.dbDir(),
"zoneID"),
180 zoneID[celli] = label(volZoneID[celli]);
220 if (slots[i] >= mesh_.nCells())
278 cellCellCentres.setSize(cellCells.size());
282 label celli = selectedCells[i];
286 pointList& stencilPoints = cellCellCentres[celli];
287 stencil.setSize(cFaces.size()+1);
288 stencilPoints.setSize(stencil.size());
292 if (isValidCell[celli])
294 stencil[compacti] = globalCellIDs[celli];
295 stencilPoints[compacti++] = cellCentres[celli];
301 label facei = cFaces[i];
303 label own = faceOwner[facei];
306 bool isValid =
false;
309 nbrCelli = nbrGlobalCellIDs[bFacei];
310 nbrCc = nbrCellCentres[bFacei];
311 isValid = nbrIsValidCell[bFacei];
317 nbrCelli = gi.toGlobal(own);
318 nbrCc = cellCentres[own];
319 isValid = isValidCell[own];
323 label nei = faceNeighbour[facei];
324 nbrCelli = gi.toGlobal(nei);
325 nbrCc = cellCentres[nei];
326 isValid = isValidCell[nei];
333 if (!current.found(nbrCelli))
335 stencil[compacti] = nbrCelli;
336 stencilPoints[compacti++] = nbrCc;
340 stencil.setSize(compacti);
341 stencilPoints.setSize(compacti);
348 const scalar wantedFraction,
353 const cell& cFaces = mesh_.cells()[celli];
356 const label nbrFacei = cFaces[i];
357 if (fraction[nbrFacei] < wantedFraction)
359 fraction[nbrFacei] = wantedFraction;
360 isFront.set(nbrFacei);
372 const labelList& own = mesh_.faceOwner();
373 const labelList& nei = mesh_.faceNeighbour();
375 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
377 const label ownType = allCellTypes[own[facei]];
378 const label neiType = allCellTypes[nei[facei]];
381 (ownType == HOLE && neiType != HOLE)
382 || (ownType != HOLE && neiType == HOLE)
394 label facei = mesh_.nInternalFaces();
395 facei < mesh_.nFaces();
399 const label ownType = allCellTypes[own[facei]];
400 const label neiType = nbrCellTypes[facei-mesh_.nInternalFaces()];
404 (ownType == HOLE && neiType != HOLE)
405 || (ownType != HOLE && neiType == HOLE)
429 const label celli = fc[i];
430 if (allCellTypes[celli] == INTERPOLATED)
435 isFront.set(
fvm[patchi].start()+i);
446 const scalar layerRelax,
453 const label holeLayers,
457 if (useLayer > holeLayers)
460 <<
" is larger than : " << holeLayers
467 <<
" can not be zero."
472 bitSet isFront(mesh_.nFaces());
489 for (label currLayer = 1; currLayer < holeLayers+1; ++currLayer)
494 setUpFront(allCellTypes, isFront);
496 labelList allCellTypesWork(allCellTypes);
498 bitSet isFrontWork(isFront);
499 label nCurrLayer = currLayer;
503 bitSet newIsFront(mesh_.nFaces());
504 forAll(isFrontWork, facei)
506 if (isFrontWork.test(facei))
508 const label own = mesh_.faceOwner()[facei];
510 if (allCellTypesWork[own] != HOLE)
512 allCellTypesWork[own] = HOLE;
513 newIsFront.set(mesh_.cells()[own]);
516 if (mesh_.isInternalFace(facei))
518 const label nei = mesh_.faceNeighbour()[facei];
519 if (allCellTypesWork[nei] != HOLE)
521 allCellTypesWork[nei] = HOLE;
522 newIsFront.set(mesh_.cells()[nei]);
529 isFrontWork.transfer(newIsFront);
535 if ((
debug & 2) && mesh_.time().writeTime())
542 "allCellTypesWork_Holes" +
name(currLayer),
551 setUpFrontOnOversetPatch(allCellTypes, isFront);
557 setUpFrontOnOversetPatch(allCellTypesWork, isFront);
558 setUpFront(allCellTypesWork, isFront);
569 if (isFront.test(facei))
571 fraction[facei] = 1.0;
576 bitSet nHoles(allCellTypes.size());
581 bitSet newIsFront(mesh_.nFaces());
586 if (isFront.test(facei))
588 const label own = mesh_.faceOwner()[facei];
590 if (allCellTypesWork[own] != HOLE)
592 if (allWeightWork[own] < fraction[facei])
596 if (allStencil[own].size())
598 nLayer[own] = currLayer;
600 allWeightWork[own] = fraction[facei];
601 allCellTypesWork[own] = INTERPOLATED;
603 const label donorId = compactStencil[own][0];
605 volRatio[own] =
V[own]/compactCellVol[donorId];
610 fraction[facei]-layerRelax,
619 allWeightWork[own] = 0.0;
620 allCellTypesWork[own] = HOLE;
632 if (mesh_.isInternalFace(facei))
634 label nei = mesh_.faceNeighbour()[facei];
635 if (allCellTypesWork[nei] != HOLE)
637 if (allWeightWork[nei] < fraction[facei])
639 if (allStencil[nei].size())
641 nLayer[nei] = currLayer;
643 allWeightWork[nei] = fraction[facei];
644 allCellTypesWork[nei] = INTERPOLATED;
646 const label donorId =
647 compactStencil[nei][0];
650 V[nei]/compactCellVol[donorId];
655 fraction[facei]-layerRelax,
662 allWeightWork[nei] = 0.0;
663 allCellTypesWork[nei] = HOLE;
682 isFront.transfer(newIsFront);
683 fraction.transfer(newFraction);
686 if ((
debug & 2) && mesh_.time().writeTime())
693 "allCellTypesWork_Layers" +
name(currLayer),
700 dAlllWeight.append(allWeightWork);
701 dataSet.append(allCellTypesWork);
715 const scalar aveVol =
mag(
gSum(volRatio));
717 daverageVolRatio.append(aveVol/nCount);
721 label nTotalHoles(nHoles.count());
723 dHoles.append(nTotalHoles);
730 & (nTotalHoles > 2.0*dHoles[currLayer - 1])
738 if ((
debug & 2) && mesh_.time().writeTime())
750 averageVolRatio.transfer(daverageVolRatio);
751 label minVolId =
findMin(averageVolRatio);
755 Info<<
nl <<
" Number of layers : " << averageVolRatio.size() <<
nl
756 <<
" Average volumetric ratio : " << averageVolRatio <<
nl
757 <<
" Number of holes cells : " << dHoles <<
nl
758 <<
" Using layer : " << useLayer <<
nl <<
endl;
763 minVolId = useLayer - 1;
766 allCellTypes.transfer(dataSet[minVolId]);
767 allWeight.transfer(dAlllWeight[minVolId]);
777 const InfoProxy<cellCellStencil>& iproxy
780 const auto&
e = *iproxy;
783 const labelUList& interpolationCells =
e.interpolationCells();
788 label nInvalidInterpolated = 0;
792 forAll(interpolationCells, i)
794 label celli = interpolationCells[i];
795 const labelList& slots = cellStencil[celli];
799 nInvalidInterpolated++;
802 bool hasLocal =
false;
803 bool hasRemote =
false;
838 os <<
"Overset analysis : nCells : "
844 <<
" (interpolated from local:" << nLocal
845 <<
" mixed local/remote:" << nMixed
846 <<
" remote:" << nRemote
847 <<
" special:" << nInvalidInterpolated <<
")" <<
nl
Macros for easy insertion into run-time selection tables.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
@ NO_REGISTER
Do not request registration (bool: false).
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A helper class for outputting values to Ostream.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void listCombineGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listGather with an in-place cop.
A non-owning sub-view of a List (allocated or unallocated storage).
bool found(const T &val, label pos=0) const
Same as contains().
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
void set(const bitSet &bitset)
Set specified bits from another bitset.
void transfer(bitSet &bitset)
Transfer the contents of the argument list into this list and annul the argument list.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
bool any() const
True if any bits in this bitset are set.
Calculation of interpolation stencils.
static word baseName(const word &name)
Helper: strip off trailing _0.
void setUpFrontOnOversetPatch(const labelList &allCellTypes, bitSet &isFront) const
Set up front on overset patches.
const fvMesh & mesh_
Reference to the mesh.
void walkFront(const globalIndex &globalCells, const scalar layerRelax, const labelListList &allStencil, labelList &allCellTypes, scalarField &allWeight, const scalarList &compactCellVol, const labelListList &compactStencil, const labelList &zoneID, const label holeLayers, const label useLayer) const
Surround holes with layer(s) of interpolated cells.
void setUpFront(const labelList &allCellTypes, bitSet &isFront) const
Set up front using allCellTypes.
bool localStencil(const labelUList &) const
Helper: is stencil fully local.
static labelList count(const label size, const labelUList &lst)
Count occurrences (in parallel).
void seedCell(const label cellI, const scalar wantedFraction, bitSet &isFront, scalarField &fraction) const
Seed faces of cell with wantedFraction (if higher than current).
const labelIOList & zoneID() const
Helper: get reference to registered zoneID. Loads volScalarField.
virtual bool update()=0
Update stencils. Return false if nothing changed.
static autoPtr< cellCellStencil > New(const fvMesh &, const dictionary &dict, const bool update=true)
New function which constructs and returns pointer to a.
static const labelIOList & zoneID(const fvMesh &)
Helper: get reference to registered zoneID. Loads volScalarField.
void suppressMotionFields()
Helper: populate nonInterpolatedFields_ with motion solver.
virtual const wordHashSet & nonInterpolatedFields() const
Return the names of any (stencil or mesh specific) fields that.
virtual ~cellCellStencil()
Destructor.
static const Enum< cellType > cellTypeNames_
Mode type names.
static tmp< volScalarField > createField(const fvMesh &mesh, const word &name, const UList< Type > &)
Helper: create volScalarField for postprocessing.
wordHashSet nonInterpolatedFields_
Set of fields that should not be interpolated.
static void globalCellCells(const globalIndex &gi, const polyMesh &mesh, const boolList &isValidDonor, const labelList &selectedCells, labelListList &cellCells, pointListList &cellCellCentres)
Helper: create cell-cell addressing in global numbering.
A cell is defined as a list of faces with extra functionality.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A fvBoundaryMesh is a fvPatch list with a reference to the associated fvMesh, with additional search ...
Mesh data needed to do the Finite Volume discretisation.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
labelRange range(label proci) const noexcept
Return start/size range of proci data.
label toGlobal(const label proci, const label i) const
From local to global on proci.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
label nInternalFaces() const noexcept
Number of internal faces.
const vectorField & cellCentres() const
label nCells() const noexcept
Number of mesh cells.
const cellList & cells() const
bool store()
Register object with its registry and transfer ownership to the registry.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInFunction
Report an information message using Foam::Info.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
const expr V(m.psi().mesh().V())
Namespace for handling debugging switches.
Namespace of functions to calculate implicit derivatives returning a matrix.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Type gSum(const FieldField< Field, Type > &f)
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
IOList< label > labelIOList
IO for a List of label.
label findMin(const ListType &input, label start=0)
Linear search for the index of the min element, similar to std::min_element but for lists and returns...
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
List< cell > cellList
List of cell.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
List< point > pointList
List of point.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
Field< label > labelField
Specialisation of Field<T> for label.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vector point
Point is a vector.
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< pointList > pointListList
List of pointList.
static tmp< volScalarField > createField(const fvMesh &mesh, const scalar val)
constexpr char nl
The newline '\n' character (0x0a).
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
const labelUList & cellTypes
#define forAll(list, i)
Loop across all elements in list.