46namespace cellCellStencils
61 const scalar layerRelax,
77 if (isA<oversetFvPatch>(fvm[patchI]))
82 isFront.
set(fvm[patchI].start()+i);
95 label ownType = allCellTypes[own[faceI]];
96 label neiType = allCellTypes[nei[faceI]];
100 || (ownType !=
HOLE && neiType ==
HOLE)
119 label ownType = allCellTypes[own[faceI]];
124 (ownType ==
HOLE && neiType !=
HOLE)
125 || (ownType !=
HOLE && neiType ==
HOLE)
138 scalar fraction = 1.0;
144 Info<<
"Front : fraction:" << fraction
151 if (isFront.
test(faceI))
154 if (allCellTypes[own] !=
HOLE)
156 if (allWeight[own] < fraction)
158 allWeight[own] = fraction;
173 if (allCellTypes[nei] !=
HOLE)
175 if (allWeight[nei] < fraction)
177 allWeight[nei] = fraction;
198 fraction -= layerRelax;
228 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
234 (ownType == HOLE && neiType != HOLE)
235 || (ownType != HOLE && neiType == HOLE)
238 isBlockedFace[faceI] =
true;
245 for (label faceI =
mesh.nInternalFaces(); faceI <
mesh.nFaces(); faceI++)
248 label neiType = nbrCellTypes[faceI-
mesh.nInternalFaces()];
252 (ownType == HOLE && neiType != HOLE)
253 || (ownType != HOLE && neiType == HOLE)
256 isBlockedFace[faceI] =
true;
262 Info<< typeName <<
" : detected " << cellRegion.
nRegions()
263 <<
" mesh regions after overset" <<
nl <<
endl;
281 for (label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
283 if (isBlockedFace[faceI])
285 label ownRegion = cellRegion[own[faceI]];
289 if (regionType[ownRegion] == 0)
295 regionType[ownRegion] = 1;
299 label neiRegion = cellRegion[nei[faceI]];
303 if (regionType[neiRegion] == 0)
309 regionType[neiRegion] = 1;
316 label faceI =
mesh.nInternalFaces();
317 faceI <
mesh.nFaces();
321 if (isBlockedFace[faceI])
323 label ownRegion = cellRegion[own[faceI]];
325 if (regionType[ownRegion] == 0)
331 regionType[ownRegion] = 1;
341 const fvPatch& fvp = pbm[patchI];
343 if (isA<oversetFvPatch>(fvp))
353 label regionI = cellRegion[fc[i]];
355 if (
cellTypes[fc[i]] != HOLE && regionType[regionI] != 2)
360 regionType[regionI] = 2;
390 const fvPatch& fvp = pbm[patchI];
392 if (isA<oversetFvPatch>(fvp))
398 label regionI = cellRegion[cellI];
400 if (regionType[regionI] != 2)
402 const labelList& slots = compactStencil[cellI];
405 label otherType = cellRegionType[slots[i]];
412 regionType[regionI] = 2;
434 label
type = regionType[cellRegion[cellI]];
454 const fvPatch& fvp = pbm[patchI];
457 if (isA<oversetFvPatch>(fvp))
463 patchCellTypes[cellMap[cellI]] = OVERSET;
473 if (patchCellTypes[cellMap[cellI]] != OVERSET)
475 patchCellTypes[cellMap[cellI]] =
PATCH;
492 const labelList& slots = addressing[cellI];
500 result[cellI] = OVERSET;
506 result[cellI] =
PATCH;
508 else if (result[cellI] == -1)
511 result[cellI] = OTHER;
526 if (result.
size() != addressing.
size())
540 mapPtr().distribute(work);
542 interpolatePatchTypes(addressing, work, result);
546 interpolatePatchTypes(addressing,
patchTypes, result);
553 const label subZoneID,
557 const label donorZoneID,
561 const labelList& interpolatedOtherPatchTypes,
569 forAll(subCellMap, subCellI)
571 label cellI = subCellMap[subCellI];
573 bool validDonors =
true;
574 switch (interpolatedOtherPatchTypes[subCellI])
591 allCellTypes[cellI] = HOLE;
638 label currentDiff =
mag(subZoneID-allDonorID[cellI]);
639 label thisDiff =
mag(subZoneID-donorZoneID);
643 allDonorID[cellI] == -1
644 || (thisDiff < currentDiff)
645 || (thisDiff == currentDiff && donorZoneID > allDonorID[cellI])
648 allWeights[cellI] = weights[subCellI];
651 allDonorID[cellI] = donorZoneID;
669 overlapTolerance_(defaultOverlapTolerance_),
671 interpolationCells_(0),
672 cellInterpolationMap_(),
674 cellInterpolationWeights_(0),
675 cellInterpolationWeight_
679 "cellInterpolationWeight",
680 mesh_.facesInstance(),
688 zeroGradientFvPatchScalarField::typeName
698 const word w(
"snGradCorr(cellDisplacement)");
699 const word d(
"((viscosity*faceDiffusivity)*magSf)");
724 forAll(volCellTypes, celli)
748 scalar layerRelax(dict_.getOrDefault(
"layerRelax", 1.0));
761 <<
" mesh regions" <<
nl <<
endl;
769 Info<<
indent<<
"zone:" << zonei <<
" nCells:"
784 labelList allCellTypes(mesh_.nCells(), CALCULATED);
785 labelList allPatchTypes(mesh_.nCells(), OTHER);
789 labelList allDonorID(mesh_.nCells(), -1);
802 Info<<
"Marking patch-cells on zone " << partI <<
endl;
803 markPatchCells(partMesh, partCellMap, allPatchTypes);
807 labelList nCells(count(3, allPatchTypes));
809 <<
"After patch analysis : nCells : "
812 <<
indent <<
"other : " << nCells[OTHER] <<
nl
814 <<
indent <<
"overset: " << nCells[OVERSET] <<
nl
820 for (label srcI = 0; srcI <
meshParts.size()-1; srcI++)
825 for (label tgtI = srcI+1; tgtI <
meshParts.size(); tgtI++)
845 interpolatePatchTypes
850 interpolatedTgtPatchTypes
857 forAll(tgtCellMap, tgtCellI)
859 label cellI = tgtCellMap[tgtCellI];
860 tgtGlobalCells[tgtCellI] = globalCells.
toGlobal(cellI);
864 mapper.
tgtMap()->distribute(tgtGlobalCells);
877 interpolatedTgtPatchTypes,
890 interpolatePatchTypes
895 interpolatedSrcPatchTypes
900 forAll(srcCellMap, srcCellI)
902 label cellI = srcCellMap[srcCellI];
903 srcGlobalCells[srcCellI] = globalCells.
toGlobal(cellI);
907 mapper.
srcMap()->distribute(srcGlobalCells);
921 interpolatedSrcPatchTypes,
938 createField(mesh_,
"allCellTypes", allCellTypes)
945 forAll(allPatchTypes, cellI)
947 if (allCellTypes[cellI] != HOLE)
949 switch (allPatchTypes[cellI])
954 scalar v = mesh_.V()[cellI];
955 scalar overlapVol =
sum(allWeights[cellI]);
956 if (overlapVol > overlapTolerance_*v)
958 allCellTypes[cellI] = INTERPOLATED;
964 allCellTypes[cellI] = HOLE;
965 allWeights[cellI].
clear();
966 allStencil[cellI].
clear();
997 createField(mesh_,
"allCellTypes_patch", allCellTypes)
1009 label nCalculated = 0;
1011 forAll(cellTypes_, celli)
1013 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
1015 if (allStencil[celli].size() == 0)
1018 allCellTypes[celli] = HOLE;
1019 allWeights[celli].
clear();
1020 allStencil[celli].
clear();
1024 allCellTypes[celli] = INTERPOLATED;
1032 Pout<<
"Detected " << nCalculated <<
" cells changing from hole"
1033 <<
" to calculated. Changed these to interpolated"
1040 findHoles(globalCells, mesh_,
zoneID, allStencil, allCellTypes);
1046 createField(mesh_,
"allCellTypes_hole", allCellTypes)
1055 walkFront(layerRelax, allCellTypes, allWeight);
1061 createField(mesh_,
"allCellTypes_front", allCellTypes)
1068 forAll(allCellTypes, cellI)
1070 if (allCellTypes[cellI] == INTERPOLATED)
1072 if (allWeight[cellI] < SMALL || allStencil[cellI].size() == 0)
1076 allWeights[cellI].
clear();
1077 allStencil[cellI].
clear();
1078 allWeight[cellI] = 0.0;
1082 scalar
s =
sum(allWeights[cellI]);
1083 forAll(allWeights[cellI], i)
1085 allWeights[cellI][i] /=
s;
1091 allWeights[cellI].
clear();
1092 allStencil[cellI].
clear();
1105 mesh_.time().timeName(),
1113 zeroGradientFvPatchScalarField::typeName
1135 mesh_.time().timeName(),
1143 zeroGradientFvPatchScalarField::typeName
1148 volTypes[cellI] = allCellTypes[cellI];
1195 cellTypes_.transfer(allCellTypes);
1196 cellStencil_.transfer(allStencil);
1197 cellInterpolationWeights_.transfer(allWeights);
1198 cellInterpolationWeight_.transfer(allWeight);
1204 >(cellInterpolationWeight_.boundaryFieldRef(),
false);
1207 forAll(cellStencil_, cellI)
1209 if (cellStencil_[cellI].size())
1211 interpolationCells.append(cellI);
1214 interpolationCells_.transfer(interpolationCells);
1218 cellInterpolationMap_.reset
1227 cellInterpolationWeight_.instance() = mesh_.time().timeName();
1228 cellInterpolationWeight_.write();
1231 mkDir(mesh_.time().timePath());
1232 OBJstream str(mesh_.time().timePath()/
"stencil2.obj");
1233 Info<< typeName <<
" : dumping to " << str.
name() <<
endl;
1235 cellInterpolationMap().distribute(cc);
1237 forAll(interpolationCells_, compactI)
1239 label cellI = interpolationCells_[compactI];
1240 const labelList& slots = cellStencil_[cellI];
1242 Pout<<
"cellI:" << cellI <<
" at:"
1243 << mesh_.cellCentres()[cellI]
1244 <<
" calculated from slots:" << slots
1246 <<
" weights:" << cellInterpolationWeights_[cellI]
1251 const point& donorCc = cc[slots[i]];
1252 const point& accCc = mesh_.cellCentres()[cellI];
1262 Info<<
"Overset analysis : nCells : "
1265 <<
indent <<
"calculated : " << nCells[CALCULATED] <<
nl
1266 <<
indent <<
"interpolated : " << nCells[INTERPOLATED] <<
nl
1267 <<
indent <<
"hole : " << nCells[HOLE] <<
nl
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Minimal example by using system/controlDict.functions:
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set size to zero.
OFstream that keeps track of vertices.
virtual Ostream & write(const char c)
Write character.
virtual const fileName & name() const
Read/write access to the name of the stream.
Bookkeeping for patch definitions.
static void listCombineAllGather(const List< commsStruct > &comms, List< T > &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static word timeName(const scalar t, const int precision=precision_)
A List with indirect addressing. Like IndirectList but does not store addressing.
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)
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
Calculation of interpolation stencils.
const fvMesh & mesh_
Reference to the mesh.
const labelIOList & zoneID() const
Helper: get reference to registered zoneID. Loads volScalarField.
wordHashSet nonInterpolatedFields_
Set of fields that should not be interpolated.
Volume-weighted interpolation stencil.
labelList cellTypes_
Per cell the cell type.
virtual void stencilWeights(const point &sample, const pointList &donorCcs, scalarList &weights) const
Calculate inverse distance weights for a single acceptor. Revert.
static scalar defaultOverlapTolerance_
Default overlap tolerance. Fraction of volume.
void walkFront(const scalar layerRelax, labelList &allCellTypes, scalarField &allWeight) const
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
void interpolatePatchTypes(const labelListList &addressing, const labelList &patchTypes, labelList &result) const
interpolate (= combine) patch types
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.
virtual ~cellVolumeWeight()
Destructor.
virtual bool update()
Update stencils. Return false if nothing changed.
void markPatchCells(const fvMesh &mesh, const labelList &cellMap, labelList &patchCellTypes) const
according to additionalDocumentation/MEJ_oversetMesh.txt
virtual const word & constraintType() const
Return the constraint type this pointPatch implements.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const Time & time() const
Return the top-level database.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual const labelUList & faceCells() const
Return faceCells.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label toGlobal(const label i) const
From local to global index.
Class containing processor-to-processor mapping information.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
Class to calculate the cell-addressing between two overlapping meshes.
const labelListList & srcToTgtCellAddr() const
Return const access to the source to target cell addressing.
const autoPtr< mapDistribute > & srcMap() const
Source map pointer - valid if no singleMeshProc.
const scalarListList & srcToTgtCellWght() const
Return const access to the source to target cell weights.
const scalarListList & tgtToSrcCellWght() const
Return const access to the target to source cell weights.
const labelListList & tgtToSrcCellAddr() const
Return const access to the target to source cell addressing.
const autoPtr< mapDistribute > & tgtMap() const
Target map pointer - valid if no singleMeshProc.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nInternalFaces() const noexcept
Number of internal faces.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
const cellList & cells() const
virtual bool write(const bool valid=true) const
Write using setting from DB.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
label nRegions() const
Return total number of regions.
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
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))
labelList nCellsPerZone(nZones, Zero)
PtrList< fvMeshSubset > meshParts(nZones)
const labelIOList & zoneID
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
List< word > wordList
A List of words.
const dimensionSet dimless
Dimensionless.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
line< point, const point & > linePointRef
A line using referred points.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
static constexpr const zero Zero
Global zero (0)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Type gMax(const FieldField< Field, Type > &f)
UIndirectList< label > labelUIndList
UIndirectList of labels.
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
const labelList & cellTypes
#define forAll(list, i)
Loop across all elements in list.