47 namespace cellCellStencils
78 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
85 || (ownType !=
HOLE && neiType ==
HOLE)
95 for (label faceI =
mesh.nInternalFaces(); faceI <
mesh.nFaces(); faceI++)
98 label neiType = nbrCellTypes[faceI-
mesh.nInternalFaces()];
102 (ownType ==
HOLE && neiType !=
HOLE)
103 || (ownType !=
HOLE && neiType ==
HOLE)
112 Info<< typeName <<
" : detected " << cellRegion.
nRegions()
113 <<
" mesh regions after overset" <<
nl <<
endl;
131 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
135 label ownRegion = cellRegion[own[faceI]];
139 if (regionType[ownRegion] == 0)
145 regionType[ownRegion] = 1;
149 label neiRegion = cellRegion[nei[faceI]];
153 if (regionType[neiRegion] == 0)
159 regionType[neiRegion] = 1;
166 label faceI =
mesh.nInternalFaces();
167 faceI <
mesh.nFaces();
173 label ownRegion = cellRegion[own[faceI]];
175 if (regionType[ownRegion] == 0)
181 regionType[ownRegion] = 1;
193 if (isA<oversetFvPatch>(fvp))
200 for (
const label celli : fvp.
faceCells())
202 label regionI = cellRegion[celli];
209 regionType[regionI] = 2;
241 if (isA<oversetFvPatch>(fvp))
247 label regionI = cellRegion[cellI];
249 if (regionType[regionI] != 2)
251 const labelList& slots = compactStencil[cellI];
254 label otherType = cellRegionType[slots[i]];
261 regionType[regionI] = 2;
282 label
type = regionType[cellRegion[cellI]];
298 const fvBoundaryMesh&
pbm =
mesh.boundary();
302 const fvPatch& fvp =
pbm[patchI];
305 if (isA<oversetFvPatch>(fvp))
311 patchCellTypes[cellMap[cellI]] = OVERSET;
321 if (patchCellTypes[cellMap[cellI]] != OVERSET)
323 patchCellTypes[cellMap[cellI]] =
PATCH;
340 const labelList& slots = addressing[cellI];
348 result[cellI] = OVERSET;
354 result[cellI] =
PATCH;
357 else if (result[cellI] == -1)
360 result[cellI] = OTHER;
369 const autoPtr<mapDistribute>& mapPtr,
375 if (result.size() != addressing.size())
389 mapPtr().distribute(work);
391 interpolatePatchTypes(addressing, work, result);
395 interpolatePatchTypes(addressing,
patchTypes, result);
402 const label subZoneID,
406 const label donorZoneID,
410 const labelList& interpolatedOtherPatchTypes,
418 forAll(subCellMap, subCellI)
420 label cellI = subCellMap[subCellI];
422 bool validDonors =
true;
423 switch (interpolatedOtherPatchTypes[subCellI])
440 allCellTypes[cellI] = HOLE;
486 label currentDiff =
mag(subZoneID-allDonorID[cellI]);
487 label thisDiff =
mag(subZoneID-donorZoneID);
491 allDonorID[cellI] == -1
492 || (thisDiff < currentDiff)
493 || (thisDiff == currentDiff && donorZoneID > allDonorID[cellI])
496 allWeights[cellI] = weights[subCellI];
499 allDonorID[cellI] = donorZoneID;
508 Foam::cellCellStencils::cellVolumeWeight::cellVolumeWeight
517 overlapTolerance_(defaultOverlapTolerance_),
519 interpolationCells_(0),
520 cellInterpolationMap_(),
522 cellInterpolationWeights_(0),
523 cellInterpolationWeight_
527 "cellInterpolationWeight",
528 mesh_.facesInstance(),
538 allowInterpolatedDonors_
540 dict.getOrDefault(
"allowInterpolatedDonors", true)
571 forAll(volCellTypes, celli)
595 scalar layerRelax(dict_.getOrDefault(
"layerRelax", 1.0));
598 label nZones =
gMax(zoneID)+1;
602 nCellsPerZone[zoneID[cellI]]++;
606 Info<< typeName <<
" : detected " << nZones
607 <<
" mesh regions" <<
nl <<
endl;
615 Info<<
indent<<
"zone:" << zonei <<
" nCells:" 616 << nCellsPerZone[zonei] <<
nl;
629 labelList allCellTypes(mesh_.nCells(), CALCULATED);
630 labelList allPatchTypes(mesh_.nCells(), OTHER);
634 labelList allDonorID(mesh_.nCells(), -1);
640 const fvMesh& partMesh = meshParts[partI].subMesh();
641 const labelList& partCellMap = meshParts[partI].cellMap();
647 Info<<
"Marking patch-cells on zone " << partI <<
endl;
648 markPatchCells(partMesh, partCellMap, allPatchTypes);
651 if ((
debug & 2) && mesh_.time().writeTime())
663 <<
"After patch analysis : nCells : " 666 <<
indent <<
"other : " << nCells[OTHER] <<
nl 668 <<
indent <<
"overset: " << nCells[OVERSET] <<
nl 673 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
675 const fvMesh& srcMesh = meshParts[srcI].subMesh();
676 const labelList& srcCellMap = meshParts[srcI].cellMap();
678 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
680 const fvMesh& tgtMesh = meshParts[tgtI].subMesh();
681 const labelList& tgtCellMap = meshParts[tgtI].cellMap();
697 interpolatePatchTypes
702 interpolatedTgtPatchTypes
709 forAll(tgtCellMap, tgtCellI)
711 label cellI = tgtCellMap[tgtCellI];
712 tgtGlobalCells[tgtCellI] = globalCells.
toGlobal(cellI);
716 mapper.
tgtMap()->distribute(tgtGlobalCells);
731 interpolatedTgtPatchTypes,
744 interpolatePatchTypes
749 interpolatedSrcPatchTypes
754 forAll(srcCellMap, srcCellI)
756 label cellI = srcCellMap[srcCellI];
757 srcGlobalCells[srcCellI] = globalCells.
toGlobal(cellI);
761 mapper.
srcMap()->distribute(srcGlobalCells);
775 interpolatedSrcPatchTypes,
788 if ((
debug & 2) && mesh_.time().writeTime())
806 forAll(allPatchTypes, cellI)
808 if (allCellTypes[cellI] != HOLE)
810 switch (allPatchTypes[cellI])
815 scalar v = mesh_.V()[cellI];
816 scalar overlapVol =
sum(allWeights[cellI]);
817 if (overlapVol > overlapTolerance_*v)
819 allCellTypes[cellI] = INTERPOLATED;
823 allCellTypes[cellI] = HOLE;
824 allWeights[cellI].
clear();
825 allStencil[cellI].
clear();
834 if ((
debug & 2) && mesh_.time().writeTime())
838 createField(mesh_,
"allCellTypes_patch", allCellTypes)
845 stencilSize[celli] = allStencil[celli].
size();
849 createField(mesh_,
"allStencil_patch", stencilSize)
851 tfldStencil().write();
856 findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
858 if ((
debug & 2) && mesh_.time().writeTime())
862 createField(mesh_,
"allCellTypes_hole", allCellTypes)
869 stencilSize[celli] = allStencil[celli].
size();
875 tfldStencil().write();
884 mapDistribute map(globalCells, compactStencil, compactStencilMap);
899 dict_.getOrDefault(
"holeLayers", 1),
900 dict_.getOrDefault(
"useLayer", -1)
904 if ((
debug & 2) && mesh_.time().writeTime())
908 createField(mesh_,
"allCellTypes_front", allCellTypes)
915 stencilSize[celli] = allStencil[celli].
size();
919 createField(mesh_,
"allStencil_front", stencilSize)
921 tfldStencil().write();
929 label nCalculated = 0;
933 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
935 if (allStencil[celli].size() == 0)
938 allCellTypes[celli] = HOLE;
939 allWeights[celli].
clear();
940 allStencil[celli].
clear();
944 allCellTypes[celli] = INTERPOLATED;
952 Pout<<
"Detected " << nCalculated <<
" cells changing from hole" 953 <<
" to calculated. Changed these to interpolated" 959 labelList compactCellTypes(allCellTypes);
962 label nHoleDonors = 0;
963 forAll(allCellTypes, cellI)
965 if (allCellTypes[cellI] == INTERPOLATED)
967 const labelList& slots = compactStencil[cellI];
972 compactCellTypes[slots[0]] == HOLE
975 !allowInterpolatedDonors_
976 && compactCellTypes[slots[0]] == INTERPOLATED
980 allWeights[cellI][subCellI] = 0;
987 allWeights[cellI].
clear();
988 allStencil[cellI].
clear();
995 forAll(allCellTypes, cellI)
997 if (allCellTypes[cellI] == INTERPOLATED)
999 const scalar
s =
sum(allWeights[cellI]);
1003 allCellTypes[cellI] = POROUS;
1004 allWeights[cellI].
clear();
1005 allStencil[cellI].
clear();
1009 forAll(allWeights[cellI], i)
1011 allWeights[cellI][i] /=
s;
1018 if ((
debug & 2) && mesh_.time().writeTime())
1022 createField(mesh_,
"allCellTypes_final", allCellTypes)
1028 cellTypes_.transfer(allCellTypes);
1029 cellStencil_.transfer(allStencil);
1030 cellInterpolationWeights_.transfer(allWeights);
1031 cellInterpolationWeight_.transfer(allWeight);
1038 >(cellInterpolationWeight_.boundaryFieldRef());
1041 forAll(cellStencil_, cellI)
1043 if (cellStencil_[cellI].size())
1045 interpolationCells.append(cellI);
1048 interpolationCells_.transfer(interpolationCells);
1052 cellInterpolationMap_.reset
1058 if ((
debug & 2) && mesh_.time().writeTime())
1061 cellInterpolationWeight_.instance() = mesh_.time().timeName();
1062 cellInterpolationWeight_.write();
1065 mkDir(mesh_.time().timePath());
1066 OBJstream str(mesh_.time().timePath()/
"stencil2.obj");
1067 Info<< typeName <<
" : dumping to " << str.name() <<
endl;
1069 cellInterpolationMap().distribute(cc);
1071 forAll(interpolationCells_, compactI)
1073 label cellI = interpolationCells_[compactI];
1074 const labelList& slots = cellStencil_[cellI];
1076 Pout<<
"cellI:" << cellI <<
" at:" 1077 << mesh_.cellCentres()[cellI]
1078 <<
" calculated from slots:" << slots
1080 <<
" weights:" << cellInterpolationWeights_[cellI]
1085 if (cellInterpolationWeights_[cellI][slots[i]] > 0)
1087 const point& donorCc = cc[slots[i]];
1088 const point& accCc = mesh_.cellCentres()[cellI];
1089 str.writeLine(accCc, 0.1*accCc+0.9*donorCc);
1095 Info << this->info();
1103 const point& sample,
1114 scalar d =
mag(sample-donorCcs[i]);
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
scalar overlapTolerance_
Tolerance for volume overlap. Fraction of volume.
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
const word zeroGradientType
A zeroGradient patch field type.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual void stencilWeights(const point &sample, const pointList &donorCcs, scalarList &weights) const
Calculate inverse distance weights for a single acceptor. Revert.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void combineCellTypes(const label subZoneID, const fvMesh &subMesh, const labelList &subCellMap, const label donorZoneID, const labelListList &toOtherCells, const List< scalarList > &weights, const labelList &otherCells, const labelList &interpolatedOtherPatchTypes, labelListList &allStencil, scalarListList &allWeights, labelList &allCellTypes, labelList &allDonorID) const
const bitSet isBlockedFace(intersectedFaces())
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.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
UIndirectList< label > labelUIndList
UIndirectList of labels.
virtual bool update()
Update stencils. Return false if nothing changed.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static tmp< volScalarField > createField(const fvMesh &mesh, const scalar val)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
void findHoles(const globalIndex &globalCells, const fvMesh &mesh, const labelList &zoneID, const labelListList &stencil, labelList &cellTypes) const
Find cells next to cells of type PATCH.
defineTypeNameAndDebug(cellVolumeWeight, 0)
Template invariant parts for fvPatchField.
Class to calculate the cell-addressing between two overlapping meshes.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
List< labelList > labelListList
List of labelList.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
void reduce(T &value, [[maybe_unused]] BinaryOp bop, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce)
#define forAll(list, i)
Loop across all elements in list.
const dictionary dict_
Dictionary of motion control parameters.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const labelListList & srcToTgtCellAddr() const
Return const access to the source to target cell addressing.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void suppressMotionFields()
Helper: populate nonInterpolatedFields_ with motion solver.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Calculation of interpolation stencils.
const autoPtr< mapDistribute > & srcMap() const noexcept
Source map pointer - valid if no singleMeshProc.
void clear()
Clear the list, i.e. set size to zero.
virtual const labelUList & faceCells() const
Return faceCells.
static void correctBoundaryConditions(typename GeoField::Boundary &bfld)
Correct boundary conditions of certain type (TypeOnly = true) or explicitly not of the type (TypeOnly...
label size() const noexcept
The number of entries in the list.
const labelUList & cellTypes
Reading is optional [identical to LAZY_READ].
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.
A HashTable similar to std::unordered_map.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
const fvMesh & mesh_
Reference to the mesh.
addToRunTimeSelectionTable(cellCellStencil, cellVolumeWeight, mesh)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
void interpolatePatchTypes(const labelListList &addressing, const labelList &patchTypes, labelList &result) const
interpolate (= combine) patch types
labelList cellTypes_
Per cell the cell type.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
List< word > wordList
List of word.
const labelListList & tgtToSrcCellAddr() const
Return const access to the target to source cell addressing.
const labelIOList & zoneID() const
Helper: get reference to registered zoneID. Loads volScalarField.
Volume-weighted interpolation stencil.
Class containing processor-to-processor mapping information.
label toGlobal(const label proci, const label i) const
From local to global on proci.
static scalar defaultOverlapTolerance_
Default overlap tolerance. Fraction of volume.
label nCells() const noexcept
Number of mesh cells.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
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.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
virtual const labelUList & cellTypes() const
Return the cell type list.
label nRegions() const
Return total number of regions.
const autoPtr< mapDistribute > & tgtMap() const noexcept
Target map pointer - valid if no singleMeshProc.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const scalarListList & srcToTgtCellWght() const
Return const access to the source to target cell weights.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
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))
void markPatchCells(const fvMesh &mesh, const labelList &cellMap, labelList &patchCellTypes) const
according to additionalDocumentation/MEJ_oversetMesh.txt
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Defines the attributes of an object for which implicit objectRegistry management is supported...
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
virtual ~cellVolumeWeight()
Destructor.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
const scalarListList & tgtToSrcCellWght() const
Return const access to the target to source cell weights.
static constexpr const zero Zero
Global zero (0)