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))
203 label regionI = cellRegion[fc[i]];
210 regionType[regionI] = 2;
242 if (isA<oversetFvPatch>(fvp))
248 label regionI = cellRegion[cellI];
250 if (regionType[regionI] != 2)
252 const labelList& slots = compactStencil[cellI];
255 label otherType = cellRegionType[slots[i]];
262 regionType[regionI] = 2;
283 label
type = regionType[cellRegion[cellI]];
299 const fvBoundaryMesh&
pbm =
mesh.boundary();
303 const fvPatch& fvp =
pbm[patchI];
306 if (isA<oversetFvPatch>(fvp))
312 patchCellTypes[cellMap[cellI]] = OVERSET;
322 if (patchCellTypes[cellMap[cellI]] != OVERSET)
324 patchCellTypes[cellMap[cellI]] =
PATCH;
341 const labelList& slots = addressing[cellI];
349 result[cellI] = OVERSET;
355 result[cellI] =
PATCH;
358 else if (result[cellI] == -1)
361 result[cellI] = OTHER;
370 const autoPtr<mapDistribute>& mapPtr,
376 if (result.size() != addressing.size())
390 mapPtr().distribute(work);
392 interpolatePatchTypes(addressing, work, result);
396 interpolatePatchTypes(addressing,
patchTypes, result);
403 const label subZoneID,
407 const label donorZoneID,
411 const labelList& interpolatedOtherPatchTypes,
419 forAll(subCellMap, subCellI)
421 label cellI = subCellMap[subCellI];
423 bool validDonors =
true;
424 switch (interpolatedOtherPatchTypes[subCellI])
441 allCellTypes[cellI] = HOLE;
487 label currentDiff =
mag(subZoneID-allDonorID[cellI]);
488 label thisDiff =
mag(subZoneID-donorZoneID);
492 allDonorID[cellI] == -1
493 || (thisDiff < currentDiff)
494 || (thisDiff == currentDiff && donorZoneID > allDonorID[cellI])
497 allWeights[cellI] = weights[subCellI];
500 allDonorID[cellI] = donorZoneID;
509 Foam::cellCellStencils::cellVolumeWeight::cellVolumeWeight
518 overlapTolerance_(defaultOverlapTolerance_),
520 interpolationCells_(0),
521 cellInterpolationMap_(),
523 cellInterpolationWeights_(0),
524 cellInterpolationWeight_
528 "cellInterpolationWeight",
529 mesh_.facesInstance(),
539 allowInterpolatedDonors_
541 dict.getOrDefault(
"allowInterpolatedDonors", true)
572 forAll(volCellTypes, celli)
596 scalar layerRelax(dict_.getOrDefault(
"layerRelax", 1.0));
599 label nZones =
gMax(zoneID)+1;
603 nCellsPerZone[zoneID[cellI]]++;
607 Info<< typeName <<
" : detected " << nZones
608 <<
" mesh regions" <<
nl <<
endl;
616 Info<<
indent<<
"zone:" << zonei <<
" nCells:" 617 << nCellsPerZone[zonei] <<
nl;
630 labelList allCellTypes(mesh_.nCells(), CALCULATED);
631 labelList allPatchTypes(mesh_.nCells(), OTHER);
635 labelList allDonorID(mesh_.nCells(), -1);
641 const fvMesh& partMesh = meshParts[partI].subMesh();
642 const labelList& partCellMap = meshParts[partI].cellMap();
648 Info<<
"Marking patch-cells on zone " << partI <<
endl;
649 markPatchCells(partMesh, partCellMap, allPatchTypes);
652 if ((
debug & 2) && mesh_.time().writeTime())
664 <<
"After patch analysis : nCells : " 667 <<
indent <<
"other : " << nCells[OTHER] <<
nl 669 <<
indent <<
"overset: " << nCells[OVERSET] <<
nl 674 for (label srcI = 0; srcI < meshParts.
size()-1; srcI++)
676 const fvMesh& srcMesh = meshParts[srcI].subMesh();
677 const labelList& srcCellMap = meshParts[srcI].cellMap();
679 for (label tgtI = srcI+1; tgtI < meshParts.
size(); tgtI++)
681 const fvMesh& tgtMesh = meshParts[tgtI].subMesh();
682 const labelList& tgtCellMap = meshParts[tgtI].cellMap();
698 interpolatePatchTypes
703 interpolatedTgtPatchTypes
710 forAll(tgtCellMap, tgtCellI)
712 label cellI = tgtCellMap[tgtCellI];
713 tgtGlobalCells[tgtCellI] = globalCells.
toGlobal(cellI);
717 mapper.
tgtMap()->distribute(tgtGlobalCells);
732 interpolatedTgtPatchTypes,
745 interpolatePatchTypes
750 interpolatedSrcPatchTypes
755 forAll(srcCellMap, srcCellI)
757 label cellI = srcCellMap[srcCellI];
758 srcGlobalCells[srcCellI] = globalCells.
toGlobal(cellI);
762 mapper.
srcMap()->distribute(srcGlobalCells);
776 interpolatedSrcPatchTypes,
789 if ((
debug & 2) && mesh_.time().writeTime())
807 forAll(allPatchTypes, cellI)
809 if (allCellTypes[cellI] != HOLE)
811 switch (allPatchTypes[cellI])
816 scalar v = mesh_.V()[cellI];
817 scalar overlapVol =
sum(allWeights[cellI]);
818 if (overlapVol > overlapTolerance_*v)
820 allCellTypes[cellI] = INTERPOLATED;
824 allCellTypes[cellI] = HOLE;
825 allWeights[cellI].
clear();
826 allStencil[cellI].
clear();
835 if ((
debug & 2) && mesh_.time().writeTime())
839 createField(mesh_,
"allCellTypes_patch", allCellTypes)
846 stencilSize[celli] = allStencil[celli].
size();
850 createField(mesh_,
"allStencil_patch", stencilSize)
852 tfldStencil().write();
857 findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
859 if ((
debug & 2) && mesh_.time().writeTime())
863 createField(mesh_,
"allCellTypes_hole", allCellTypes)
870 stencilSize[celli] = allStencil[celli].
size();
876 tfldStencil().write();
885 mapDistribute map(globalCells, compactStencil, compactStencilMap);
900 dict_.getOrDefault(
"holeLayers", 1),
901 dict_.getOrDefault(
"useLayer", -1)
905 if ((
debug & 2) && mesh_.time().writeTime())
909 createField(mesh_,
"allCellTypes_front", allCellTypes)
916 stencilSize[celli] = allStencil[celli].
size();
920 createField(mesh_,
"allStencil_front", stencilSize)
922 tfldStencil().write();
930 label nCalculated = 0;
934 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
936 if (allStencil[celli].size() == 0)
939 allCellTypes[celli] = HOLE;
940 allWeights[celli].
clear();
941 allStencil[celli].
clear();
945 allCellTypes[celli] = INTERPOLATED;
953 Pout<<
"Detected " << nCalculated <<
" cells changing from hole" 954 <<
" to calculated. Changed these to interpolated" 960 labelList compactCellTypes(allCellTypes);
963 label nHoleDonors = 0;
964 forAll(allCellTypes, cellI)
966 if (allCellTypes[cellI] == INTERPOLATED)
968 const labelList& slots = compactStencil[cellI];
973 compactCellTypes[slots[0]] == HOLE
976 !allowInterpolatedDonors_
977 && compactCellTypes[slots[0]] == INTERPOLATED
981 allWeights[cellI][subCellI] = 0;
988 allWeights[cellI].
clear();
989 allStencil[cellI].
clear();
996 forAll(allCellTypes, cellI)
998 if (allCellTypes[cellI] == INTERPOLATED)
1000 const scalar
s =
sum(allWeights[cellI]);
1004 allCellTypes[cellI] = POROUS;
1005 allWeights[cellI].
clear();
1006 allStencil[cellI].
clear();
1010 forAll(allWeights[cellI], i)
1012 allWeights[cellI][i] /=
s;
1019 if ((
debug & 2) && mesh_.time().writeTime())
1023 createField(mesh_,
"allCellTypes_final", allCellTypes)
1029 cellTypes_.transfer(allCellTypes);
1030 cellStencil_.transfer(allStencil);
1031 cellInterpolationWeights_.transfer(allWeights);
1032 cellInterpolationWeight_.transfer(allWeight);
1038 >(cellInterpolationWeight_.boundaryFieldRef(),
false);
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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
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.
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.
Macros for easy insertion into run-time selection tables.
#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.
label size() const noexcept
The number of entries in the list.
Reading is optional [identical to LAZY_READ].
A HashTable similar to std::unordered_map.
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.
const labelList & cellTypes
static void correctBoundaryConditions(typename GeoField::Boundary &bfld, const bool typeOnly)
Correct boundary conditions of certain type (typeOnly = true) or explicitly not of the type (typeOnly...
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...
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))
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
virtual ~cellVolumeWeight()
Destructor.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements. After completion all processors have the same data.
const scalarListList & tgtToSrcCellWght() const
Return const access to the target to source cell weights.
static constexpr const zero Zero
Global zero (0)