45namespace cellCellStencils
69 static bool hasWarned =
false;
78 const fvPatch& fvp = pbm[patchi];
93 faceBb.
min() -= smallVec;
94 faceBb.
max() += smallVec;
114 const fvPatch& fvp = pbm[patchi];
117 if (isA<oversetFvPatch>(fvp))
129 faceBb.
min() -= smallVec;
130 faceBb.
max() += smallVec;
137 <<
" : face at " << faceCentres[i]
138 <<
" is not inside search bounding box of"
139 <<
" voxel mesh " << bb <<
endl
140 <<
" Is your 'searchBox' specification correct?"
171 Pout<<
"Voxel mesh too coarse. Bounding box "
173 <<
" contains both non-overset and overset patches"
174 <<
". Refining voxel mesh to " << nDivs <<
endl;
213 const labelList& tgtCellMap = meshParts_[tgtI].cellMap();
220 if (srcPatchBb.
overlaps(tgtPatchBb))
225 forAll(tgtCellMap, tgtCelli)
227 label celli = tgtCellMap[tgtCelli];
228 boundBox cBb(allPoints, allCellPoints[celli],
false);
229 cBb.
min() -= smallVec_;
230 cBb.
max() += smallVec_;
240 static_cast<unsigned int>(patchCellType::PATCH)
244 allCellTypes[celli] = HOLE;
260 if (srcPatchBb.
overlaps(tgtPatchBb))
265 os << srcPatchBb << patchDivisions[srcI] << patchParts[srcI];
277 if (srcPatchBb.
overlaps(tgtPatchBb))
282 if (srcPatchBb != receivedBb)
286 <<
" srcPatchBb:" << srcPatchBb
287 <<
" receivedBb:" << receivedBb
294 forAll(tgtCellMap, tgtCelli)
296 label celli = tgtCellMap[tgtCelli];
297 boundBox cBb(allPoints, allCellPoints[celli],
false);
298 cBb.
min() -= smallVec_;
299 cBb.
max() += smallVec_;
309 static_cast<unsigned int>(patchCellType::PATCH)
313 allCellTypes[celli] = HOLE;
338 const fvMesh& srcMesh = meshParts_[srcI].subMesh();
339 const labelList& srcCellMap = meshParts_[srcI].cellMap();
341 const fvMesh& tgtMesh = meshParts_[tgtI].subMesh();
343 const labelList& tgtCellMap = meshParts_[tgtI].cellMap();
347 forAll(tgtCellMap, tgtCelli)
350 if (srcCelli != -1 && allCellTypes[srcCellMap[srcCelli]] != HOLE)
352 label celli = tgtCellMap[tgtCelli];
356 if (betterDonor(tgtI, allDonor[celli], srcI))
359 allStencil[celli][0] =
360 globalCells_.toGlobal(srcCellMap[srcCelli]);
361 allDonor[celli] = srcI;
382 tgtOverlapProcs.
append(procI);
386 srcOverlapProcs.
append(procI);
395 forAll(srcOverlapProcs, i)
397 label procI = srcOverlapProcs[i];
398 tgtSendCells[procI].reserve(tgtMesh.
nCells()/srcOverlapProcs.
size());
402 forAll(tgtCellMap, tgtCelli)
404 label celli = tgtCellMap[tgtCelli];
405 if (srcOverlapProcs.
size())
408 subBb.
min() -= smallVec_;
409 subBb.
max() += smallVec_;
411 forAll(srcOverlapProcs, i)
413 label procI = srcOverlapProcs[i];
416 tgtSendCells[procI].
append(tgtCelli);
425 forAll(srcOverlapProcs, i)
427 label procI = srcOverlapProcs[i];
431 os << UIndirectList<point>(tgtCc,
cellIDs);
437 forAll(tgtOverlapProcs, i)
439 label procI = tgtOverlapProcs[i];
448 if (srcCelli != -1 && allCellTypes[srcCellMap[srcCelli]] != HOLE)
450 donors[sampleI] = globalCells_.toGlobal(srcCellMap[srcCelli]);
460 forAll(srcOverlapProcs, i)
462 label procI = srcOverlapProcs[i];
476 label globalDonor = donors[donorI];
478 if (globalDonor != -1)
480 label celli = tgtCellMap[
cellIDs[donorI]];
483 if (betterDonor(tgtI, allDonor[celli], srcI))
486 allStencil[celli][0] = globalDonor;
487 allDonor[celli] = srcI;
505 globalCells_(mesh_.nCells())
533 (void)
meshParts_[zonei].subMesh().nGeometricD();
540 <<
" mesh regions" <<
endl;
572 scalar layerRelax(dict_.getOrDefault(
"layerRelax", 1.0));
574 label
nZones = meshParts_.size();
579 pointField subPoints(mesh_.points(), meshParts_[zonei].pointMap());
581 fvMesh& subMesh = meshParts_[zonei].subMesh();
592 << searchBoxDivisions.
size()
593 <<
" should equal the number of zones " <<
nZones
597 const boundBox& allBb(mesh_.bounds());
609 const fvMesh& subMesh = meshParts_[zonei].subMesh();
638 bbs[proci] = procBb[proci][zonei];
652 labelList allPatchTypes(mesh_.nCells(), OTHER);
656 if (dict_.readIfPresent(
"searchBox", globalPatchBb))
678 bool ok = markBoundaries
680 meshParts_[zonei].subMesh(),
684 patchDivisions[zonei],
687 meshParts_[zonei].cellMap(),
709 meshParts_[zonei].subMesh(),
711 patchDivisions[zonei],
723 forAll(meshSearches, zonei)
728 mesh_.time().timeName(),
734 voxelMeshes.
set(zonei, meshSearches[zonei].makeMesh(meshIO));
743 const labelList voxelTypes(patchParts[zonei].values());
744 const fvMesh& vm = voxelMeshes[zonei];
759 labelList allCellTypes(mesh_.nCells(), CALCULATED);
762 labelList allDonorID(mesh_.nCells(), -1);
770 for (label srci = 0; srci < meshParts_.size()-1; srci++)
772 for (label tgti = srci+1; tgti < meshParts_.size(); tgti++)
801 for (label srci = 0; srci < meshParts_.size()-1; srci++)
803 for (label tgti = srci+1; tgti < meshParts_.size(); tgti++)
839 createField(mesh_,
"allCellTypes", allCellTypes)
846 forAll(allPatchTypes, celli)
848 if (allCellTypes[celli] != HOLE)
850 switch (allPatchTypes[celli])
856 if (allStencil[celli].size())
858 allCellTypes[celli] = INTERPOLATED;
862 allCellTypes[celli] = HOLE;
874 createField(mesh_,
"allCellTypes_patch", allCellTypes)
885 label nCalculated = 0;
889 if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
891 if (allStencil[celli].size() == 0)
894 allCellTypes[celli] = HOLE;
895 allStencil[celli].
clear();
899 allCellTypes[celli] = INTERPOLATED;
907 Pout<<
"Detected " << nCalculated <<
" cells changing from hole"
908 <<
" to calculated. Changed to interpolated"
915 findHoles(globalCells_, mesh_,
zoneID, allStencil, allCellTypes);
922 createField(mesh_,
"allCellTypes_hole", allCellTypes)
929 walkFront(layerRelax, allStencil, allCellTypes, allWeight);
936 createField(mesh_,
"allCellTypes_front", allCellTypes)
944 cellTypes_.transfer(allCellTypes);
945 cellStencil_.setSize(mesh_.nCells());
946 cellInterpolationWeights_.setSize(mesh_.nCells());
950 if (cellTypes_[celli] == INTERPOLATED)
952 cellStencil_[celli].transfer(allStencil[celli]);
953 cellInterpolationWeights_[celli].setSize(1);
954 cellInterpolationWeights_[celli][0] = 1.0;
955 interpolationCells.
append(celli);
959 cellStencil_[celli].clear();
960 cellInterpolationWeights_[celli].clear();
963 interpolationCells_.transfer(interpolationCells);
966 cellInterpolationMap_.reset
975 cellInterpolationWeight_.
transfer(allWeight);
981 >(cellInterpolationWeight_.boundaryFieldRef(),
false);
987 mkDir(mesh_.time().timePath());
988 OBJstream str(mesh_.time().timePath()/
"injectionStencil.obj");
989 Pout<< typeName <<
" : dumping injectionStencil to "
992 cellInterpolationMap().distribute(cc);
994 forAll(cellStencil_, celli)
996 const labelList& slots = cellStencil_[celli];
999 const point& accCc = mesh_.cellCentres()[celli];
1002 const point& donorCc = cc[slots[i]];
1013 createStencil(globalCells);
1020 cellInterpolationWeight_.instance() = mesh_.time().timeName();
1021 cellInterpolationWeight_.
write();
1029 mesh_.time().timeName(),
1037 zeroGradientFvPatchScalarField::typeName
1042 volTypes[celli] = cellTypes_[celli];
1053 mkDir(mesh_.time().timePath());
1054 OBJstream str(mesh_.time().timePath()/
"stencil.obj");
1055 Pout<< typeName <<
" : dumping to " << str.
name() <<
endl;
1057 cellInterpolationMap().distribute(cc);
1059 forAll(cellStencil_, celli)
1061 const labelList& slots = cellStencil_[celli];
1064 const point& accCc = mesh_.cellCentres()[celli];
1067 const point& donorCc = cc[slots[i]];
1082 forAll(interpolationCells_, i)
1084 label celli = interpolationCells_[i];
1085 const labelList& slots = cellStencil_[celli];
1087 bool hasLocal =
false;
1088 bool hasRemote =
false;
1092 if (slots[sloti] >= mesh_.nCells())
1122 Info<<
"Overset analysis : nCells : "
1125 <<
indent <<
"calculated : " << nCells[CALCULATED] <<
nl
1126 <<
indent <<
"interpolated : " << nCells[INTERPOLATED]
1127 <<
" (interpolated from local:" << nLocal
1128 <<
" mixed local/remote:" << nMixed
1129 <<
" remote:" << nRemote <<
")" <<
nl
1130 <<
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.
void append(const T &val)
Copy append an element to the end of this list.
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.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName objectPath() const
The complete path + object name.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
void append(const T &val)
Append an element at the end of the list.
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.
virtual char fill() const =0
Get padding character.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
int overlaps
Flag to control which overlap calculations are performed.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
const Field< point_type > & points() const noexcept
Return reference to global points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
void finishedSends(const bool wait=true)
Mark sends as done.
void clear()
Clear individual buffers and reset states.
static void allGatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
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....
const T * set(const label i) const
void setSize(const label newLen)
Same as resize()
SubField is a Field obtained as a section of another Field, without its own allocation....
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
label size() const noexcept
The number of elements in the list.
A bounding box defined in terms of min/max extrema points.
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
bool contains(const point &pt) const
Contains point? (inside or on edge)
vector span() const
The bounding box span (from minimum to maximum)
Calculation of interpolation stencils.
const fvMesh & mesh_
Reference to the mesh.
const labelIOList & zoneID() const
Helper: get reference to registered zoneID. Loads volScalarField.
Inverse-distance-weighted interpolation stencil.
Inverse-distance-weighted interpolation stencil.
PtrList< fvMeshSubset > meshParts_
Subset according to zone.
static bool markBoundaries(const fvMesh &mesh, const vector &smallVec, const boundBox &bb, labelVector &nDivs, PackedList< 2 > &patchTypes, const labelList &cellMap, labelList &patchCellTypes)
Mark voxels of patchTypes with type of patch face.
labelList globalDonor_
Current (global) donor cell.
void markPatchesAsHoles(PstreamBuffers &pBufs, const List< treeBoundBoxList > &patchBb, const List< labelVector > &patchDivisions, const PtrList< PackedList< 2 > > &patchParts, const label srcI, const label tgtI, labelList &allCellTypes) const
Mark all cells overlapping (a voxel covered by) a src patch.
virtual ~trackingInverseDistance()
Destructor.
virtual bool update()
Update stencils. Return false if nothing changed.
void markDonors(PstreamBuffers &pBufs, const List< treeBoundBoxList > &meshBb, const PtrList< voxelMeshSearch > &meshSearches, const labelList &allCellTypes, const label srcI, const label tgtI, labelListList &allStencil, labelList &allDonor) const
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.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const polyPatch & patch() const
Return the polyPatch.
virtual const labelUList & faceCells() const
Return faceCells.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Class containing processor-to-processor mapping information.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
const word & name() const noexcept
The patch name.
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
virtual const pointField & points() const
Return raw points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
const vectorField::subField faceCentres() const
Return face centres.
const vectorField & cellCentres() const
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
int myProcNo() const noexcept
Return processor number.
virtual bool write(const bool valid=true) const
Write using setting from DB.
A class for managing temporary objects.
Standard boundBox with extra functionality for use in octree.
bool overlaps(const boundBox &bb) const
Overlaps other bounding box?
Fast, non-parallel searching in mesh without use of octree.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
labelList nCellsPerZone(nZones, Zero)
const labelIOList & zoneID
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
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
messageStream Info
Information stream (stdout output on master, null elsewhere)
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
List< treeBoundBox > treeBoundBoxList
List of bounding boxes.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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)
constexpr char nl
The newline '\n' character (0x0a)
wordList patchTypes(nPatches)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)