58 template<
class ListType>
62 typename ListType::const_reference t,
66 for (
label i = start; i < l.size(); i++)
104 forAll(localFaces, thisFacei)
106 result[thisFacei].resize(localFaces[thisFacei].size());
108 forAll(localFaces[thisFacei], i)
110 result[thisFacei][i] =
113 : map[localFaces[thisFacei][i]];
130 forAll(procFaces, tgtFacei)
132 result[tgtFacei].resize(procFaces[tgtFacei].size());
134 forAll(procFaces[tgtFacei], i)
136 result[tgtFacei][i] =
138 ? procFaces[tgtFacei][i].facei
139 : map[procFaces[tgtFacei][i]];
157 treeBoundBox box = srcBox(srcFace, srcPoints, srcPointNormals);
162 box =
combine(box, srcBox(srcFace, srcPoints0, srcPointNormals0));
178 forAll(srcPatch, srcFacei)
184 srcBox(srcPatch, srcPointNormals, srcPointNormals0, srcFacei)
221 forAll(tgtPatch, tgtFacei)
223 box =
combine(box, tgtBox(tgtPatch, tgtFacei));
238 const label srcFacei,
243 auto intersected = []
247 const label otherFacei
250 forAll(faceLocalFaces[facei], i)
252 if (faceLocalFaces[facei][i] == otherFacei)
261 intersected(srcLocalTgtFaces_, srcFacei, tgtFacei)
262 || intersected(tgtLocalSrcFaces_, tgtFacei, srcFacei)
304 label nFaceComplete = 0;
308 const label otherFacei = queue[queuei].second();
313 otherFaceVisited[otherFacei] =
true;
314 label otherPerimeterReached =
false;
315 while (otherCurrentFaces.
size())
318 forAll(otherCurrentFaces, otheri)
320 const label otherFacej = otherCurrentFaces[otheri];
330 isSrc ? facei : otherFacej,
331 isSrc ? otherFacej : facei
351 forAll(otherPatch[otherFacej], otherFacePointj)
353 const label otherPointj =
354 otherLocalFaces[otherFacej][otherFacePointj];
355 forAll(otherPointFaces[otherPointj], otherPointFacej)
357 const label otherFacek =
358 otherPointFaces[otherPointj][otherPointFacej];
359 if (!otherFaceVisited[otherFacek])
361 otherFaceVisited[otherFacek] =
true;
362 otherVisitedFaces.
append(otherFacek);
363 otherNextFaces.
append(otherFacek);
369 forAll(otherPatch[otherFacej], otherFaceEdgej)
371 const label otherEdgej =
372 otherPatch.
faceEdges()[otherFacej][otherFaceEdgej];
379 otherPerimeterReached =
true;
387 otherFaceComplete[otherFacej] == 0
388 && !otherFaceQueued[otherFacej]
391 otherFaceQueued[otherFacej] =
true;
392 otherQueuedFaces.
append(otherFacej);
398 otherCurrentFaces.
transfer(otherNextFaces);
402 forAll(otherVisitedFaces, otherVisitedFacei)
404 otherFaceVisited[otherVisitedFaces[otherVisitedFacei]] =
false;
408 nFaceComplete -= faceComplete[facei] == 2;
409 faceComplete[facei] =
410 max(faceComplete[facei], otherPerimeterReached ? 1 : 2);
411 nFaceComplete += faceComplete[facei] == 2;
415 forAll(otherQueuedFaces, otherQueuedFacei)
417 otherFaceQueued[otherQueuedFaces[otherQueuedFacei]] =
false;
420 return nFaceComplete;
432 if (srcPatch.empty() || tgtPatch.empty())
return;
438 const fileName srcFileName = typeName +
"_srcPatch.vtk";
451 const fileName tgtFileName = typeName +
"_tgtPatch.vtk";
467 auto writeQueue = [&]
469 const label restarti,
470 const label iterationi,
478 typeName +
"_restarti=" +
name(restarti) +
"_iterationi=";
480 word(isSrc ?
"src" :
"tgt") +
"Queue";
484 if (iterationi == 0 || iterationi % 2 == !isSrc)
487 queueFileNamePart0 +
name(iterationi) +
'_' 488 + queueFileNamePart1 +
".vtk";
505 queueFileNamePart0 +
name(iterationi - 1) +
'_' 506 + queueFileNamePart1 +
".vtk",
507 queueFileNamePart0 +
name(iterationi) +
'_' 508 + queueFileNamePart1 +
".vtk" 515 auto writeQueues = [&]
517 const label restarti,
518 const label iterationi,
526 <<
": processing " << srcQueue.size() <<
'/' 527 << srcPatch.size() <<
" source and " 528 << tgtQueue.size() <<
'/' << tgtPatch.size()
529 <<
" target faces " <<
endl;
534 writeQueue(restarti, iterationi,
true, srcQueue);
535 writeQueue(restarti, iterationi,
false, tgtQueue);
565 label nSrcFaceComplete = 0, nTgtFaceComplete = 0;
566 labelList srcFaceComplete(srcPatch.size(), 0);
567 labelList tgtFaceComplete(tgtPatch.size(), 0);
568 boolList srcFaceQueued(srcPatch.size(),
false);
569 boolList tgtFaceQueued(tgtPatch.size(),
false);
570 boolList srcFaceVisited(srcPatch.size(),
false);
571 boolList tgtFaceVisited(tgtPatch.size(),
false);
574 while (srcFacei < srcPatch.size() && srcFacei != -1)
577 srcFaceComplete[srcFacei] = 2;
584 srcBox(srcPatch, srcPointNormals, srcPointNormals0, srcFacei)
587 if (!seedTgtFaces.
empty())
592 <<
" from at source face at " 599 forAll(seedTgtFaces, seedTgtFacei)
601 const label tgtFacei = seedTgtFaces[seedTgtFacei];
608 writeQueues(restarti, 0, srcQueue, tgtQueue);
612 label iterationi = 0;
635 writeQueues(restarti, 2*iterationi + 1, srcQueue, tgtQueue);
638 if (!tgtQueue.
size())
break;
660 writeQueues(restarti, 2*iterationi + 2, srcQueue, tgtQueue);
663 if (!srcQueue.
size())
break;
670 Info<<
indent <<
"Completed " << nSrcFaceComplete <<
'/' 671 << srcPatch.size() <<
" source faces " <<
decrIndent 697 srcLocalTgtFaces_.resize(srcPatch.size());
698 forAll(srcLocalTgtFaces_, i)
700 srcLocalTgtFaces_[i].clear();
703 tgtLocalSrcFaces_.resize(tgtPatch.size());
704 forAll(tgtLocalSrcFaces_, i)
706 tgtLocalSrcFaces_[i].clear();
733 if (localTgtProcFacesPtr_.empty())
743 distributePatch(tgtMap, tgtPatch, localTgtProcFacesPtr_())
756 srcMap = patchDistributionMap(srcPatchSendFaces());
758 if (localSrcProcFacesPtr_.empty())
768 distributePatch(srcMap, srcPatch, localSrcProcFacesPtr_())
782 forAll(localSrcProcFacesPtr_(), localSrcFacei)
786 localSrcProcFacesPtr_()[localSrcFacei],
794 localFacesToProcFaces(tgtLocalSrcFaces_);
796 rDistributeListList(tgtPatch.size(), tgtMap, tgtSrcProcFaces);
799 procFacesToLocalFaces(tgtSrcProcFaces, srcProcFaceToLocal);
814 forAll(srcLocalTgtFaces_, srcFacei)
816 nCouples += srcLocalTgtFaces_[srcFacei].size();
818 forAll(tgtLocalSrcFaces_, tgtFacei)
820 nCouples += tgtLocalSrcFaces_[tgtFacei].size();
835 localSrcProcFacesPtr_(nullptr),
836 localTgtProcFacesPtr_(nullptr),
852 const word& patchToPatchType,
856 boolConstructorTable::iterator cstrIter =
857 boolConstructorTablePtr_->find(patchToPatchType);
859 if (cstrIter == boolConstructorTablePtr_->end())
862 <<
"Unknown " << typeName <<
" type " 864 <<
"Valid " << typeName <<
" types are : " <<
endl 865 << boolConstructorTablePtr_->sortedToc()
890 if (srcTotalSize == 0 || tgtTotalSize == 0)
916 tTgtPoints0Ptr.
ref(),
937 Info<<
indent << typeName <<
": Calculating couplings between " 938 << srcTotalSize <<
" source faces and " << tgtTotalSize
948 initialise(srcPatch, srcPointNormals, srcPointNormals0, tTgtPatch);
952 srcBox(srcPatch, srcPointNormals, srcPointNormals0);
954 if (srcPatchBox.
overlaps(tgtPatchBox))
985 SubList<face>(localTTgtPatchPtr(), localTTgtPatchPtr().size()),
986 localTTgtPatchPtr().
points(),
987 localTTgtPatchPtr().points0()
991 SubList<face>(localTTgtPatchPtr(), localTTgtPatchPtr().size()),
992 localTTgtPatchPtr().
points()
996 initialise(srcPatch, srcPointNormals, srcPointNormals, localTTgtPatch);
999 if (localTTgtPatch.size())
1020 const label nCouples =
1032 Info<<
indent << nCouples <<
" couplings calculated in " 1056 NullObjectRef<vectorField>(),
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
labelList first(const UList< labelPair > &p)
List< labelList > labelListList
A List of labelList.
virtual treeBoundBox srcBox(const face &srcFace, const pointField &srcPoints, const vectorField &srcPointNormals) const =0
Get the bound box for a source face.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
virtual void rDistributeTgt(const primitiveOldTimePatch &tgtPatch, const distributionMap &tgtMap)
Send data that resulted from an intersection between the source.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
A class for handling file names.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
patchToPatch(const bool reverse)
Construct from components.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Field< PointType > & faceCentres() const
Return face centres for patch.
Structure to conveniently store processor and face indices.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
bool reverse() const
Flag to indicate that the two patches are co-directional and.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Ostream & endl(Ostream &os)
Add newline and flush stream.
void intersectPatches(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch)
Intersect the patches.
T & ref()
Return non-const reference or generate a fatal error.
static List< DynamicList< label > > procFacesToLocalFaces(const List< List< procFace >> &procFaces, const HashTable< label, procFace, Hash< procFace >> &map)
Map proc faces to local faces.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
T & first()
Return the first element of the list.
bool has0() const
Return whether or not old-time geometry is available.
label findNotIndex(const ListType &l, typename ListType::const_reference t, const label start=0)
virtual tmpNrc< PrimitiveOldTimePatch< faceList, pointField > > distributeSrc(const primitiveOldTimePatch &srcPatch, distributionMap &srcMap)
Distribute the source patch so that everything the target.
static List< List< procFace > > localFacesToProcFaces(const List< DynamicList< label >> &localFaces, const List< procFace > &map=NullObjectRef< List< procFace >>())
Map local faces to proc faces.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
label intersectPatchQueue(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const bool isSrc, const DynamicList< labelPair > &queue, labelList &faceComplete, DynamicList< labelPair > &otherQueue, const labelList &otherFaceComplete, boolList &otherFaceQueued, boolList &otherFaceVisited)
Intersect a queue of source-target face pairs. Update completion.
A list of faces which address into the list of points.
A List obtained as a section of another List.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
vectorField pointField
pointField is a vectorField.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
static autoPtr< patchToPatch > New(const word &patchToPatchType, const bool reverse)
Select from name.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
PrimitiveOldTimePatch< SubList< face >, const pointField & > primitiveOldTimePatch
Addressing for a faceList slice.
A class for handling words, derived from string.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
void append(const T &)
Append an element at the end of the list.
Encapsulation of data needed to search on PrimitivePatches.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual tmpNrc< PrimitiveOldTimePatch< faceList, pointField > > distributeTgt(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, distributionMap &tgtMap)
Distribute the target patch so that enough is locally available.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const labelListList & edgeFaces() const
Return edge-face addressing.
Pair< label > labelPair
Label pair.
static const label labelMax
List< label > labelList
A List of labels.
virtual ~patchToPatch()
Destructor.
An STL-conforming hash table.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
const labelListList & pointFaces() const
Return point-face addressing.
bool findOrIntersectFaces(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const label srcFacei, const label tgtFacei)
Intersect two faces.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
void update(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const transformer &tgtToSrc=NullObjectRef< transformer >())
Update addressing and weights for the given patches.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
labelList second(const UList< labelPair > &p)
A class for managing temporary objects without reference counting.
virtual label finalise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const transformer &tgtToSrc)
Finalising.
const point & max() const
Maximum point defining the bounding box.
Class containing processor-to-processor mapping information.
void calcSingleProcess(const primitiveOldTimePatch &srcPatch, const primitiveOldTimePatch &tgtPatch)
Determine whether or not the intersection of the given patches.
Non-pointer based hierarchical recursive searching.
const Field< PointType > & localPoints0() const
Return pointField of old-time points in patch.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
static const treeBoundBox invertedBox
As per boundBox::invertedBox, but with great instead of vGreat.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Standard boundBox + extra functionality for use in octree.
const labelListList & faceEdges() const
Return face-edge addressing.
treeBoundBox tgtBox(const primitiveOldTimePatch &tgtPatch, const label tgtFacei) const
Get the bound box for a target face.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
Starts timing CPU usage and return elapsed time from start.
const point & min() const
Minimum point defining the bounding box.
virtual void initialise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch)
Initialisation.
label size() const
Return the number of elements in the UList.
void clear()
Clear the addressed list, i.e. set the size to zero.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void transfer(List< T > &)
Transfer contents of the argument List into this.
Class to generate coupling geometry between two primitive patches.
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
bool isSingleProcess() const
Is this intersection on a single process?