33 template<
typename Type>
34 Type Foam::zoneDistribute::getLocalValue
36 const VolumeField<Type>&
phi,
45 return faceValue(
phi,localIdx);
49 template<
typename Type>
50 Type Foam::zoneDistribute::faceValue
52 const VolumeField<Type>&
phi,
56 const label faceI = localIdx + mesh_.nInternalFaces() - mesh_.nCells();
58 const polyBoundaryMesh&
pbm = mesh_.boundaryMesh();
63 if (patchI < 0 || patchI >=
pbm.
size())
66 <<
"Cannot find patch for face " << faceI
70 const polyPatch&
pp =
pbm[patchI];
72 const label patchFaceI =
pp.whichFace(faceI);
74 return phi.boundaryField()[patchI][patchFaceI];
78 template<
typename Type>
86 if (globalNumbering_.isLocal(gblIdx))
88 const label localIdx = globalNumbering_.toLocal(gblIdx);
89 return getLocalValue(
phi,localIdx);
94 return valuesFromOtherProc[gblIdx];
99 template<
typename Type>
103 const VolumeField<Type>&
phi 106 if (zone.size() !=
phi.size())
109 <<
"size of zone: " << zone.size()
110 <<
"size of phi:" <<
phi.size()
111 <<
"do not match. Did the mesh change?" 117 Map<Type> neiValues = getDatafromOtherProc(zone,
phi);
119 Map<Field<Type>> stencilWithValues;
121 DynamicField<Type> tmpField(128);
129 for (
const label gblIdx : stencil_[celli])
131 tmpField.append(getValue(
phi,neiValues,gblIdx));
134 stencilWithValues.emplace(celli, tmpField);
138 return stencilWithValues;
142 template<
typename Type>
153 <<
"size of phi:" <<
phi.size()
154 <<
"do not match. Did the mesh change?" 164 if (sendConnections_.empty())
167 <<
"The send/recv connections not initialized - " 168 <<
"likely that setUpCommforZone() was not called" 178 for (
const int proci : pBufs_.allProcs())
180 const auto& indices = send_[proci];
185 Map<Type> sendValues(2*indices.size());
187 for (
const label sendIdx : indices)
192 getLocalValue(
phi, globalNumbering_.toLocal(sendIdx))
196 UOPstream toProc(proci, pBufs_);
197 toProc << sendValues;
201 pBufs_.finishedSends(sendConnections_, sendProcs_, recvProcs_);
203 for (
const int proci : pBufs_.allProcs())
207 UIPstream fromProc(proci, pBufs_);
208 Map<Type> tmpValues(fromProc);
210 neiValues += tmpValues;
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
Map< Type > getDatafromOtherProc(const boolList &zone, const VolumeField< Type > &phi)
Returns stencil and provides a Map with globalNumbering.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Map< Field< Type > > getFields(const boolList &zone, const VolumeField< Type > &phi)
Returns stencil and provides a Map with globalNumbering.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
Generic GeometricField class.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
#define forAll(list, i)
Loop across all elements in list.
Base class for mesh zones.
label size() const noexcept
The number of entries in the list.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
const fvMesh & mesh_
Reference to the mesh.
errorManip< error > abort(error &err)
#define WarningInFunction
Report a warning using Foam::Warning.
label nCells() const noexcept
Number of mesh cells.
List< bool > boolList
A List of bools.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A HashTable to objects of type <T> with a label key.
Type getValue(const VolumeField< Type > &phi, const Map< Type > &valuesFromOtherProc, const label gblIdx) const
Gives patchNumber and patchFaceNumber for a given Geometric volume field.