44 MeshObject_type(
mesh),
46 globalNumbering_(stencil_.globalNumbering()),
48 pBufs_(
UPstream::commsTypes::nonBlocking),
49 cyclicBoundaryCells_(
mesh.nCells(),
false)
55 bool hasCyclicPatches =
false;
64 hasCyclicPatches =
true;
74 forAll(cyclicBoundaryCells_, celli)
76 if (cyclicBoundaryCells_.
test(celli))
78 isCyclicCell[celli] =
true;
101 ptr =
new zoneDistribute(
mesh);
135 for (
const label celli : stencil.
needsComm())
139 for (
const label gblIdx : stencil_[celli])
141 const label proci = globalNumbering_.whichProcID(gblIdx);
145 needed[proci].insert(gblIdx);
156 for (
const int proci : pBufs_.allProcs())
158 const auto& indices = needed[proci];
163 UOPstream toProc(proci, pBufs_);
164 toProc << indices.sortedToc();
168 pBufs_.finishedSends(sendConnections_, sendProcs_, recvProcs_);
170 for (
const int proci : pBufs_.allProcs())
172 send_[proci].clear();
176 UIPstream fromProc(proci, pBufs_);
177 fromProc >> send_[proci];
186 const label globalIdx,
187 const vector globalIdxCellCentre
194 if (!cyclicBoundaryCells_.test(celli))
199 const polyBoundaryMesh&
bMesh = mesh_.boundaryMesh();
202 List<label> celliCyclicPatches;
205 if (isA<cyclicPolyPatch>(
bMesh[patchi]))
212 celliCyclicPatches.append(patchi);
219 if (globalNumbering_.isLocal(globalIdx))
223 List<label> localPointNeiCells(0);
224 const labelList& cellPoints = mesh_.cellPoints()[celli];
226 for (
const label cellPoint : cellPoints)
228 const labelList& pointKCells = mesh_.pointCells()[cellPoint];
230 for (
const label pointKCell : pointKCells)
232 if (!localPointNeiCells.found(pointKCell))
234 localPointNeiCells.
append(pointKCell);
242 const label localIdx = globalNumbering_.toLocal(globalIdx);
243 if (!localPointNeiCells.found(localIdx))
245 for (
const label patchi : celliCyclicPatches)
248 const cyclicPolyPatch& cpp =
249 static_cast<const cyclicPolyPatch&
>(
bMesh[patchi]);
255 if (
bMesh[neiPatch].faceCells().
found(localIdx))
271 List<label> cyclicID(3, -1);
272 List<vector> separationVectors(3,
vector(0,0,0));
275 forAll(celliCyclicPatches, cID)
277 cyclicID[cID] = celliCyclicPatches[cID];
279 const label& patchI = celliCyclicPatches[cID];
280 const cyclicPolyPatch& cpp =
281 static_cast<const cyclicPolyPatch&
>(
bMesh[patchI]);
283 if(cpp.transform() == coupledPolyPatch::transformType::ROTATIONAL)
286 <<
"Rotational cyclic patches are not supported in parallel.\n" 287 <<
"Try to decompose the domain so that the rotational cyclic patch " 288 <<
"is not split in between processors." 291 cpp.neighbPatch().transformPosition(separationVectors[cID], 0);
294 for(
int i = 0; i < 2; i++)
296 for(
int j = 0; j < 2; j++)
298 for(
int k = 0;
k < 2;
k++)
300 vector separation = i*separationVectors[0]
301 + j*separationVectors[1]
302 +
k*separationVectors[2];
304 scalar testDistance =
mag 306 (globalIdxCellCentre - separation)
316 List<label> applyCyclic({i,j,
k});
322 for(
int n = 0;
n < 3;
n++)
324 if(cyclicID[
n] != -1 && applyCyclic[
n] == 1)
326 const cyclicPolyPatch& cpp =
327 static_cast<const cyclicPolyPatch&
> 333 Info <<
"cpp.name() " << cpp.name() <<
endl;
350 const VolumeField<vector>& positions,
351 const Map<vector>& valuesFromOtherProc,
353 const List<label> cyclicPatchID
357 vector position(getValue(positions, valuesFromOtherProc, gblIdx));
363 const label patchi = cyclicPatchID[i];
365 const cyclicPolyPatch& cpp =
366 static_cast<const cyclicPolyPatch&
> 368 positions.mesh().boundaryMesh()[patchi]
371 if (cpp.transform() != coupledPolyPatch::transformType::ROTATIONAL)
373 cpp.neighbPatch().transformPosition(position, 0);
375 else if (globalNumbering_.isLocal(gblIdx))
377 const label localIdx = globalNumbering_.toLocal(gblIdx);
379 for (
const label facei : mesh_.cells()[localIdx])
381 if (mesh_.boundaryMesh().whichPatch(facei) == cyclicPatchID[i])
383 cpp.neighbPatch().transformPosition(position, facei);
391 <<
"Rotational cyclic patches are not supported in parallel.\n" 392 <<
"Try to decompose the domain so that the rotational cyclic" 393 <<
"patch is not split in between processors." vector getPosition(const VolumeField< vector > &positions, const Map< vector > &valuesFromOtherProc, const label gblIdx, const List< label > cyclicPatchID=List< label >()) const
void set(const bitSet &bitset)
Set specified bits from another bitset.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
void append(const T &val)
Append an element at the end of the list.
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.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static int myProcNo(label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
bool store()
Register object with its registry and transfer ownership to the registry.
scalar distance(const vector &p1, const vector &p2)
computes a cell point cell stencil in a narrow band. resizes in case of topological change ...
label k
Boltzmann constant.
const labelHashSet & needsComm() noexcept
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
#define forAll(list, i)
Loop across all elements in list.
static zoneDistribute & New(const fvMesh &)
Selector.
bool allowClearRecv() const noexcept
Is clearStorage of individual receive buffer by external hooks allowed? (default: true) ...
const labelUList & faceCells() const
Return face-cell addressing.
Base class for mesh zones.
const fvMesh & mesh() const noexcept
Reference to the mesh.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
zoneDistribute(const fvMesh &)
Construct from fvMesh.
static zoneCPCStencil & New(const fvMesh &)
const fvMesh & mesh_
Reference to the mesh.
bool test(label pos) const
Test for true value at specified position. A no-op and returns false for out-of-range positions (safe...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void updateStencil(const boolList &zone)
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
List< label > getCyclicPatches(const label celli, const label globalIdx, const vector globalIdxCellCentre) const
Finds and returns list of all cyclic patch labels to which celli's.
void setUpCommforZone(const boolList &zone, bool updateStencil=true)
Update stencil with boolList the size has to match mesh nCells.
void append(autoPtr< T > &ptr)
Move append an element to the end of the list.
static label nProcs(label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
virtual label neighbPatchID() const
Neighbour patchID.
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
void updateStencil(const boolList &zone)
Updates stencil with boolList the size has to match mesh nCells.
const volVectorField & C() const
Return cell centres as volVectorField.
Class for parallel communication in a narrow band. It either provides a Map with the neighbouring val...
List< label > labelList
A List of labels.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points) ...
List< bool > boolList
A List of bools.
Inter-processor communications stream.