38template<
class T,
class CombineOp>
47 auto iter = pointValues.find(index);
55 pointValues.insert(index, val);
60template<
class T,
class CombineOp>
63 EdgeMap<T>& edgeValues,
69 auto iter = edgeValues.find(index);
77 edgeValues.insert(index, val);
82template<
class T,
class CombineOp,
class TransformOp>
88 const TransformOp& top
97 Map<T> sharedPointValues(0);
107 sharedPointValues.
resize(sharedPtAddr.
size());
112 const auto fnd = pointValues.
cfind(sharedPtLabels[i]);
136 const auto* ppp = isA<processorPolyPatch>(pp);
138 if (ppp && pp.nPoints())
140 const auto& procPatch = *ppp;
141 const label nbrProci = procPatch.neighbProcNo();
145 const labelList& meshPts = procPatch.meshPoints();
146 const labelList& nbrPts = procPatch.neighbPoints();
154 const auto iter = pointValues.
cfind(meshPts[i]);
158 patchInfo.
insert(nbrPts[i], *iter);
162 neighbProcs.
append(nbrProci);
174 const auto* ppp = isA<processorPolyPatch>(pp);
176 if (ppp && pp.nPoints())
178 const auto& procPatch = *ppp;
179 const label nbrProci = procPatch.neighbProcNo();
182 Map<T> nbrPatchInfo(fromNbr);
185 top(procPatch, nbrPatchInfo);
187 const labelList& meshPts = procPatch.meshPoints();
196 meshPts[nbrIter.key()],
209 if (cpp && cpp->
owner())
226 const edge&
e = coupledPoints[i];
228 const auto point0Fnd = pointValues.
cfind(meshPtsA[
e[0]]);
230 if (point0Fnd.found())
232 half0Values.
insert(i, *point0Fnd);
235 const auto point1Fnd = pointValues.
cfind(meshPtsB[
e[1]]);
237 if (point1Fnd.found())
239 half1Values.
insert(i, *point1Fnd);
244 top(cycPatch, half1Values);
245 top(nbrPatch, half0Values);
249 const edge&
e = coupledPoints[i];
251 const auto half0Fnd = half0Values.
cfind(i);
253 if (half0Fnd.found())
264 const auto half1Fnd = half1Values.
cfind(i);
266 if (half1Fnd.found())
298 Map<T> nbrValues(fromProc);
321 toMaster << sharedPointValues;
335 sharedToMeshPoint.
insert(sharedPtAddr[i], sharedPtLabels[i]);
341 const auto sharedFnd = sharedPointValues.
cfind(iter.key());
343 if (sharedFnd.found())
345 pointValues.
set(*iter, *sharedFnd);
352template<
class T,
class CombineOp,
class TransformOp>
357 const CombineOp& cop,
358 const TransformOp& top
379 const auto* ppp = isA<processorPolyPatch>(pp);
381 if (ppp && pp.nEdges())
383 const auto& procPatch = *ppp;
384 const label nbrProci = procPatch.neighbProcNo();
388 const edgeList& edges = procPatch.edges();
389 const labelList& meshPts = procPatch.meshPoints();
390 const labelList& nbrPts = procPatch.neighbPoints();
394 for (
const edge&
e : edges)
396 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
398 const auto iter = edgeValues.
cfind(meshEdge);
402 const edge nbrEdge(nbrPts[
e[0]], nbrPts[
e[1]]);
403 patchInfo.
insert(nbrEdge, *iter);
407 neighbProcs.
append(nbrProci);
420 const auto* ppp = isA<processorPolyPatch>(pp);
422 if (ppp && pp.nEdges())
424 const auto& procPatch = *ppp;
428 UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
429 fromNbr >> nbrPatchInfo;
433 top(procPatch, nbrPatchInfo);
437 const labelList& meshPts = procPatch.meshPoints();
441 const edge&
e = nbrIter.key();
442 const edge meshEdge(meshPts[
e[0]], meshPts[
e[1]]);
464 if (cpp && cpp->
owner())
483 forAll(coupledEdges, edgei)
485 const edge& twoEdges = coupledEdges[edgei];
488 const edge& e0 = edgesA[twoEdges[0]];
489 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
491 const auto iter = edgeValues.
cfind(meshEdge0);
495 half0Values.
insert(edgei, *iter);
499 const edge& e1 = edgesB[twoEdges[1]];
500 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
502 const auto iter = edgeValues.
cfind(meshEdge1);
506 half1Values.
insert(edgei, *iter);
512 top(cycPatch, half1Values);
513 top(nbrPatch, half0Values);
518 forAll(coupledEdges, edgei)
520 const edge& twoEdges = coupledEdges[edgei];
522 const auto half1Fnd = half1Values.
cfind(edgei);
524 if (half1Fnd.found())
526 const edge& e0 = edgesA[twoEdges[0]];
527 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
538 const auto half0Fnd = half0Values.
cfind(edgei);
540 if (half0Fnd.found())
542 const edge& e1 = edgesB[twoEdges[1]];
543 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
570 meshToShared.
insert(sharedPtLabels[i], sharedPtAddr[i]);
589 const label v0 =
f[fp];
592 const auto v0Fnd = meshToShared.
cfind(v0);
596 const auto v1Fnd = meshToShared.
cfind(v1);
600 const edge meshEdge(v0, v1);
603 const edge sharedEdge(*v0Fnd, *v1Fnd);
606 potentialSharedEdge.
insert(sharedEdge, meshEdge);
608 const auto edgeFnd = edgeValues.
cfind(meshEdge);
665 toMaster << sharedEdgeValues;
680 const edge& sharedEdge = iter.key();
681 const edge& meshEdge = iter.val();
684 const auto sharedFnd = sharedEdgeValues.
cfind(sharedEdge);
686 if (sharedFnd.found())
700template<
class T,
class CombineOp,
class TransformOp>
705 const CombineOp& cop,
707 const TransformOp& top
713 <<
"Number of values " << pointValues.
size()
714 <<
" is not equal to the number of points in the mesh "
722template<
class T,
class CombineOp,
class TransformOp>
728 const CombineOp& cop,
730 const TransformOp& top
733 if (pointValues.
size() != meshPoints.
size())
736 <<
"Number of values " << pointValues.
size()
737 <<
" is not equal to the number of meshPoints "
748 const auto iter = mpm.
cfind(meshPoints[i]);
752 cppFld[*iter] = pointValues[i];
769 const auto iter = mpm.
cfind(meshPoints[i]);
773 pointValues[i] = cppFld[*iter];
779template<
class T,
class CombineOp,
class TransformOp,
class FlipOp>
784 const CombineOp& cop,
786 const TransformOp& top,
793 <<
"Number of values " << edgeValues.
size()
794 <<
" is not equal to the number of edges in the mesh "
811 const edge& cppE = cppEdges[i];
812 const label meshEdgei = meshEdges[i];
813 const edge& meshE = edges[meshEdgei];
827 const bool sameOrientation = ((dir == 1) == orientation[i]);
831 cppFld[i] = edgeValues[meshEdgei];
835 cppFld[i] = fop(edgeValues[meshEdgei]);
854 const edge& cppE = cppEdges[i];
855 const label meshEdgei = meshEdges[i];
856 const edge& meshE = edges[meshEdgei];
862 const bool sameOrientation = ((dir == 1) == orientation[i]);
866 edgeValues[meshEdges[i]] = cppFld[i];
870 edgeValues[meshEdges[i]] = fop(cppFld[i]);
876template<
class T,
class CombineOp,
class TransformOp,
class FlipOp>
882 const CombineOp& cop,
884 const TransformOp& top,
888 if (edgeValues.
size() != meshEdges.
size())
891 <<
"Number of values " << edgeValues.
size()
892 <<
" is not equal to the number of meshEdges "
907 const label meshEdgei = meshEdges[i];
908 const auto iter = mpm.
cfind(meshEdgei);
911 const label cppEdgei = iter();
912 const edge& cppE = cppEdges[cppEdgei];
913 const edge& meshE = edges[meshEdgei];
927 const bool sameOrientation = ((dir == 1) == orientation[i]);
931 cppFld[cppEdgei] = edgeValues[i];
935 cppFld[cppEdgei] = fop(edgeValues[i]);
953 label meshEdgei = meshEdges[i];
955 if (iter != mpm.
end())
957 label cppEdgei = iter();
958 const edge& cppE = cppEdges[cppEdgei];
959 const edge& meshE = edges[meshEdgei];
962 const bool sameOrientation = ((dir == 1) == orientation[i]);
966 edgeValues[i] = cppFld[cppEdgei];
970 edgeValues[i] = fop(cppFld[cppEdgei]);
977template<
class T,
class CombineOp,
class TransformOp>
982 const CombineOp& cop,
983 const TransformOp& top,
993 <<
"Number of values " << faceValues.
size()
994 <<
" is not equal to the number of boundary faces in the mesh "
1019 const auto* ppp = isA<processorPolyPatch>(pp);
1021 if (ppp && pp.size())
1023 const auto& procPatch = *ppp;
1029 pp.start()-boundaryOffset
1035 procPatch.neighbProcNo(),
1045 const auto* ppp = isA<processorPolyPatch>(pp);
1047 if (ppp && pp.size())
1049 const auto& procPatch = *ppp;
1055 pp.start()-boundaryOffset
1061 procPatch.neighbProcNo(),
1074 const auto* ppp = isA<processorPolyPatch>(pp);
1076 if (ppp && pp.size())
1078 const auto& procPatch = *ppp;
1084 pp.start()-boundaryOffset
1086 const List<T>& fakeList = recvFld;
1087 top(procPatch,
const_cast<List<T>&
>(fakeList));
1093 pp.start()-boundaryOffset
1098 cop(patchValues[i], recvFld[i]);
1111 const auto* ppp = isA<processorPolyPatch>(pp);
1113 if (ppp && pp.size())
1115 const auto& procPatch = *ppp;
1116 const label nbrProci = procPatch.neighbProcNo();
1122 pp.start()-boundaryOffset
1125 neighbProcs.
append(nbrProci);
1138 const auto* ppp = isA<processorPolyPatch>(pp);
1140 if (ppp && pp.size())
1142 const auto& procPatch = *ppp;
1146 UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
1149 top(procPatch, recvFld);
1155 pp.start()-boundaryOffset
1160 cop(patchValues[i], recvFld[i]);
1172 if (cpp && cpp->
owner())
1178 const label patchSize = cycPatch.size();
1184 cycPatch.
start()-boundaryOffset
1191 nbrPatch.
start()-boundaryOffset
1195 List<T> ownVals(ownPatchValues);
1196 top(nbrPatch, ownVals);
1198 List<T> nbrVals(nbrPatchValues);
1199 top(cycPatch, nbrVals);
1201 forAll(ownPatchValues, i)
1203 cop(ownPatchValues[i], nbrVals[i]);
1206 forAll(nbrPatchValues, i)
1208 cop(nbrPatchValues[i], ownVals[i]);
1217template<
unsigned W
idth,
class CombineOp>
1221 const bool isBoundaryOnly,
1223 const CombineOp& cop,
1234 <<
"Number of values " << faceValues.
size()
1235 <<
" is not equal to the number of "
1236 << (isBoundaryOnly ?
"boundary" :
"mesh") <<
" faces "
1253 const auto* ppp = isA<processorPolyPatch>(pp);
1255 if (ppp && pp.size())
1257 const auto& procPatch = *ppp;
1258 const label patchi = pp.index();
1259 const label patchSize = pp.size();
1267 procPatch.neighbProcNo(),
1280 const auto* ppp = isA<processorPolyPatch>(pp);
1282 if (ppp && pp.size())
1284 const auto& procPatch = *ppp;
1285 const label patchi = pp.index();
1289 pp.start()-boundaryOffset,
1302 procPatch.neighbProcNo(),
1315 const auto* ppp = isA<processorPolyPatch>(pp);
1317 if (ppp && pp.size())
1319 const label patchi = pp.index();
1320 const label patchSize = pp.size();
1325 label bFacei = pp.start()-boundaryOffset;
1326 for (label i = 0; i < patchSize; ++i)
1328 unsigned int recvVal = recvInfo[i];
1329 unsigned int faceVal = faceValues[bFacei];
1331 cop(faceVal, recvVal);
1332 faceValues.
set(bFacei, faceVal);
1346 if (cpp && cpp->
owner())
1352 const label patchSize = cycPatch.size();
1354 label face0 = cycPatch.
start()-boundaryOffset;
1355 label face1 = nbrPatch.
start()-boundaryOffset;
1356 for (label i = 0; i < patchSize; ++i)
1358 unsigned int val0 = faceValues[face0];
1359 unsigned int val1 = faceValues[face1];
1361 unsigned int t = val0;
1363 faceValues[face0] = t;
1366 faceValues[face1] = val1;
1387 <<
"Number of cell values " << cellData.
size()
1388 <<
" is not equal to the number of cells in the mesh "
1398 label bFacei = pp.offset();
1400 for (
const label celli : pp.faceCells())
1402 neighbourCellData[bFacei] = cellData[celli];
1410template<
unsigned W
idth,
class CombineOp>
1415 const CombineOp& cop,
1419 syncFaceList(
mesh,
false, faceValues, cop, parRun);
1423template<
unsigned W
idth,
class CombineOp>
1428 const CombineOp& cop,
1432 syncFaceList(
mesh,
true, faceValues, cop, parRun);
1436template<
unsigned W
idth>
1447template<
unsigned W
idth>
1458template<
unsigned W
idth,
class CombineOp>
1463 const CombineOp& cop,
1464 const unsigned int nullValue
1470 <<
"Number of values " << pointValues.
size()
1471 <<
" is not equal to the number of points in the mesh "
1481 cppFld[i] = pointValues[meshPoints[i]];
1496 pointValues[meshPoints[i]] = cppFld[i];
1501template<
unsigned W
idth,
class CombineOp>
1506 const CombineOp& cop,
1507 const unsigned int nullValue
1513 <<
"Number of values " << edgeValues.
size()
1514 <<
" is not equal to the number of edges in the mesh "
1524 cppFld[i] = edgeValues[meshEdges[i]];
1539 edgeValues[meshEdges[i]] = cppFld[i];
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
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.
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
bool set(const Key &key, const T &obj)
Copy assign a new entry, overwriting existing entries.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
void resize(const label sz)
Resize the hash table for efficiency.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
iterator end() noexcept
iterator to signal the end (for any HashTable)
Input inter-processor communications stream.
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
typename parent_type::const_iterator const_iterator
Output inter-processor communications stream.
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
char * data_bytes() noexcept
A pointer to the raw storage, reinterpreted as byte data.
label size() const noexcept
Number of entries.
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
const char * cdata_bytes() const noexcept
A const pointer to the raw storage, reinterpreted as byte data.
std::streamsize size_bytes() const noexcept
A list of faces which address into the list of points.
label nEdges() const
Number of edges in patch.
label nPoints() const
Number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedNeighbourSends(const labelUList &neighProcs, const bool wait=true)
UPstream::rangeType subProcs() const noexcept
Range of sub-processes indices associated with PstreamBuffers.
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
virtual bool read()
Re-read model coefficients if they have changed.
A List obtained as a section of another List.
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
@ nonBlocking
"nonBlocking"
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static label nRequests()
Get number of outstanding requests.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static commsTypes defaultCommsType
Default commsType.
static bool & parRun() noexcept
Test if this a parallel run.
label size() const noexcept
The number of elements in the list.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
virtual bool owner() const
Does this side own the patch ?
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
const cyclicPolyPatch & neighbPatch() const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static int compare(const edge &a, const edge &b)
Compare edges.
linePointRef line(const UList< point > &pts) const
Return edge line.
A face is a list of labels corresponding to mesh vertices.
virtual bool write()
Write the output fields.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
const bitSet & globalEdgeOrientation() const
Is my edge same orientation as master edge.
const labelListList & globalEdgeTransformedSlaves() const
const Map< label > & coupledPatchMeshEdgeMap() const
Return map from mesh edges to coupledPatch edges.
label nGlobalPoints() const
Return number of globally shared points.
const mapDistribute & globalPointSlavesMap() const
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const mapDistribute & globalEdgeSlavesMap() const
static void syncData(List< Type > &elems, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
void syncPointData(List< Type > &pointData, const CombineOp &cop, const TransformOp &top) const
Helper to synchronise coupled patch point data.
const labelListList & globalPointSlaves() const
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
const labelListList & globalPointTransformedSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
const labelListList & globalEdgeSlaves() const
A range or interval of labels defined by a start and a size.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const globalMeshData & globalData() const
Return parallel info.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
label nEdges() const
Number of mesh edges.
splitCell * master() const
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
A template class to specify that a data type can be considered as being contiguous in memory.