cellPointLagrangianAddressor.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "remote.H"
28 #include "globalIndex.H"
29 #include "syncTools.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const polyMesh& mesh
44 )
45 :
47  <
48  polyMesh,
51  >(mesh),
52  pointCoupledPoint_(mesh.nPoints(), -1),
53  coupledPointPoint_(),
54  coupledPointCoupledPoint_()
55 {
56  // Enumerate all the coupled points, and create forward and reverse maps
57  // from the mesh point indices
58  {
59  DynamicList<label> coupledPointPoint;
61  {
62  const polyPatch& pp = mesh.boundaryMesh()[patchi];
63 
64  if (pp.coupled())
65  {
66  forAll(pp.meshPoints(), patchPointi)
67  {
68  const label pointi = pp.meshPoints()[patchPointi];
69 
70  if (pointCoupledPoint_[pointi] == -1)
71  {
72  pointCoupledPoint_[pointi] = coupledPointPoint.size();
73  coupledPointPoint.append(pointi);
74  }
75  }
76  }
77  }
78  coupledPointPoint_.transfer(coupledPointPoint);
79  }
80 
81  // For every coupled point, create a list of the points it is connected to
82  {
83  List<DynamicList<remote>> coupledPointCoupledPoint
84  (
85  coupledPointPoint_.size(),
87  );
88 
89  forAll(coupledPointPoint_, coupledPointi)
90  {
91  coupledPointCoupledPoint[coupledPointi].append
92  (
93  remote(coupledPointi)
94  );
95  }
96 
98  (
99  mesh,
100  coupledPointPoint_,
101  coupledPointCoupledPoint,
103  {
104  x.append(y);
105  },
107  );
108 
109  forAll(coupledPointCoupledPoint, coupledPointi)
110  {
111  label iNew = 0;
112  forAll(coupledPointCoupledPoint[coupledPointi], iOld)
113  {
114  if
115  (
116  coupledPointCoupledPoint[coupledPointi][iOld]
117  != remote(coupledPointi)
118  )
119  {
120  coupledPointCoupledPoint[coupledPointi][iNew] =
121  coupledPointCoupledPoint[coupledPointi][iOld];
122  iNew ++;
123  }
124  }
125  coupledPointCoupledPoint[coupledPointi].resize(iNew);
126  }
127 
128  CompactListList<remote> cpcp(coupledPointCoupledPoint);
129  coupledPointCoupledPoint_.transfer(cpcp);
130  }
131 }
132 
133 
134 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
135 
137 {}
138 
139 
140 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
141 
143 {
144  return true;
145 }
146 
147 
149 (
150  labelList& pointIndex,
151  DynamicList<label>& indexPoint
152 ) const
153 {
154  List<DynamicList<label>> remoteCoupledPoints(Pstream::nProcs());
155 
156  forAll(indexPoint, indexi)
157  {
158  const label pointi = indexPoint[indexi];
159  const label coupledPointi = pointCoupledPoint_[pointi];
160 
161  if (coupledPointi == -1) continue;
162 
163  const UList<remote> coupledPoints =
164  coupledPointCoupledPoint_[coupledPointi];
165 
166  forAll(coupledPoints, i)
167  {
168  remoteCoupledPoints[coupledPoints[i].proci].append
169  (
170  coupledPoints[i].elementi
171  );
172  }
173  }
174 
175  if (Pstream::parRun())
176  {
178 
179  forAll(remoteCoupledPoints, proci)
180  {
181  if (proci != Pstream::myProcNo())
182  {
183  UOPstream(proci, pBufs)() << remoteCoupledPoints[proci];
184  }
185  }
186 
187  pBufs.finishedSends();
188 
189  forAll(remoteCoupledPoints, proci)
190  {
191  if (proci != Pstream::myProcNo())
192  {
193  UIPstream(proci, pBufs)() >> remoteCoupledPoints[proci];
194  }
195  }
196  }
197 
198  forAll(remoteCoupledPoints, proci)
199  {
200  forAll(remoteCoupledPoints[proci], i)
201  {
202  const label coupledPointi = remoteCoupledPoints[proci][i];
203  const label pointi = coupledPointPoint_[coupledPointi];
204 
205  if (pointIndex[pointi] == -1)
206  {
207  pointIndex[pointi] = indexPoint.size();
208  indexPoint.append(pointi);
209  }
210  }
211  }
212 }
213 
214 
215 // ************************************************************************* //
scalar y
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:342
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
void resize(const label)
Alias for setSize(const label)
Definition: ListI.H:138
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
Input inter-processor communications stream operating on external buffer.
Definition: UIPstream.H:57
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
Output inter-processor communications stream operating on external buffer.
Definition: UOPstream.H:58
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:411
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
Helper class for the cell-point Lagrangian accumulation scheme. This is a mesh object in order to pro...
virtual bool movePoints()
Update for mesh motion.
cellPointLagrangianAddressor(const polyMesh &mesh)
Construct from mesh.
void sync(labelList &pointIndex, DynamicList< label > &indexPoint) const
Synchronise the identified set of points.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:401
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:290
Struct for keeping processor, element (cell, face, point) index.
Definition: remote.H:57
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
label patchi
label nPoints
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
defineTypeNameAndDebug(combustionModel, 0)