36 List<DynamicList<label>>& pe,
37 DynamicList<edge>& es,
40 const label nextPointi
46 label eI = pe[pointi][ppI];
48 const edge& e = es[eI];
50 if (e.start() == nextPointi || e.end() == nextPointi)
57 label edgeI = es.size();
58 pe[pointi].append(edgeI);
60 if (nextPointi != pointi)
64 pe[nextPointi].append(edgeI);
67 if (pointi < nextPointi)
69 es.append(edge(pointi, nextPointi));
73 es.append(edge(nextPointi, pointi));
79 void Foam::primitiveMesh::calcEdges(
const bool doFaceEdges)
const 83 Pout<<
"primitiveMesh::calcEdges(const bool) : " 84 <<
"calculating edges, pointEdges and optionally faceEdges" 90 if ((edgesPtr_ || pePtr_) || (doFaceEdges && fePtr_))
93 <<
"edges or pointEdges or faceEdges already calculated" 113 List<DynamicList<label>> pe(
nPoints());
129 faceEdges[facei].setSize(fcs[facei].size());
140 nInternal0Edges_ = 0;
142 label nInt1Edges = 0;
147 if (nInternalPoints_ == -1)
152 const face& f = fcs[facei];
156 label pointi = f[fp];
157 label nextPointi = f[f.fcIndex(fp)];
159 label edgeI = getEdge(pe, es, pointi, nextPointi);
163 (*fePtr_)[facei][fp] = edgeI;
169 nInternal0Edges_ = es.size();
175 for (
label facei = nInternalFaces_; facei < fcs.size(); facei++)
177 const face& f = fcs[facei];
181 label pointi = f[fp];
182 label nextPointi = f[f.fcIndex(fp)];
184 label oldNEdges = es.size();
185 label edgeI = getEdge(pe, es, pointi, nextPointi);
187 if (es.size() > oldNEdges)
193 (*fePtr_)[facei][fp] = edgeI;
199 for (
label facei = 0; facei < nInternalFaces_; facei++)
201 const face& f = fcs[facei];
205 label pointi = f[fp];
206 label nextPointi = f[f.fcIndex(fp)];
208 label oldNEdges = es.size();
209 label edgeI = getEdge(pe, es, pointi, nextPointi);
211 if (es.size() > oldNEdges)
213 if (pointi < nInternalPoints_)
215 if (nextPointi < nInternalPoints_)
226 if (nextPointi < nInternalPoints_)
238 (*fePtr_)[facei][fp] = edgeI;
249 if (nInternalPoints_ != -1)
251 nInternalEdges_ = es.size()-nExtEdges;
252 nInternal1Edges_ = nInternal0Edges_+nInt1Edges;
288 label internal0EdgeI = 0;
291 label internal1EdgeI = nInternal0Edges_;
294 label internal2EdgeI = nInternal1Edges_;
297 label externalEdgeI = nInternalEdges_;
307 const DynamicList<label>& pEdges = pe[pointi];
309 nbrPoints.setSize(pEdges.size());
313 const edge& e = es[pEdges[i]];
315 label nbrPointi = e.otherVertex(pointi);
317 if (nbrPointi < pointi)
323 nbrPoints[i] = nbrPointi;
329 if (nInternalPoints_ == -1)
334 if (nbrPoints[i] != -1)
336 label edgeI = pEdges[nbrPoints.indices()[i]];
338 oldToNew[edgeI] = internal0EdgeI++;
344 if (pointi < nInternalPoints_)
348 label nbrPointi = nbrPoints[i];
350 label edgeI = pEdges[nbrPoints.indices()[i]];
354 if (edgeI < nExtEdges)
357 oldToNew[edgeI] = externalEdgeI++;
359 else if (nbrPointi < nInternalPoints_)
362 oldToNew[edgeI] = internal0EdgeI++;
367 oldToNew[edgeI] = internal1EdgeI++;
376 label nbrPointi = nbrPoints[i];
378 label edgeI = pEdges[nbrPoints.indices()[i]];
382 if (edgeI < nExtEdges)
385 oldToNew[edgeI] = externalEdgeI++;
387 else if (nbrPointi < nInternalPoints_)
396 oldToNew[edgeI] = internal2EdgeI++;
411 const edge& e = es[edgeI];
414 <<
"Did not sort edge " << edgeI <<
" points:" << e
417 <<
"Current buckets:" <<
endl 418 <<
" internal0EdgeI:" << internal0EdgeI <<
endl 419 <<
" internal1EdgeI:" << internal1EdgeI <<
endl 420 <<
" internal2EdgeI:" << internal2EdgeI <<
endl 421 <<
" externalEdgeI:" << externalEdgeI <<
endl 431 edgesPtr_ =
new edgeList(es.size());
435 edges[oldToNew[edgeI]] = es[edgeI];
443 DynamicList<label>& pEdges = pe[pointi];
446 pointEdges[pointi].transfer(pEdges);
463 Foam::label Foam::primitiveMesh::findFirstCommonElementFromSortedLists
474 while (iter1 != list1.end() && iter2 != list2.end())
480 else if (*iter1 > *iter2)
493 <<
"No common elements in lists " << list1 <<
" and " << list2
531 Pout<<
"primitiveMesh::faceEdges() : " 532 <<
"calculating faceEdges" <<
endl;
545 const face& f = fcs[facei];
552 label pointi = f[fp];
560 label edgeI = pEdges[i];
562 if (es[edgeI].otherVertex(pointi) == nextPointi)
576 void Foam::primitiveMesh::clearOutEdges()
611 findFirstCommonElementFromSortedLists
652 labelSet_.
insert(fe[feI]);
665 storage.
append(iter.key());
List< labelList > labelListList
A List of labelList.
const labelListList & cellEdges() const
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
A face is a list of labels corresponding to mesh vertices.
const labelListList & faceEdges() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelListList & pointEdges() const
void size(const label)
Override size to be inconsistent with allocated storage.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nextLabel(const label i) const
Next vertex on face.
virtual const pointField & points() const =0
Return mesh points.
const cellList & cells() const
static const unsigned edgesPerPoint_
Estimated number of edges per point.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
Various functions to operate on Lists.
void clear()
Clear all entries from table.
void setCapacity(const label)
Alter the size of the underlying storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
bool hasCellEdges() const
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void setSize(const label)
Reset size of List.
Template functions to aid in the implementation of demand driven data.
const T * const_iterator
Random access iterator for traversing UList.
prefixOSstream Pout(cout, "Pout")
virtual const faceList & faces() const =0
Return faces.
label capacity() const
Size of the underlying storage.
void clear()
Clear the addressed list, i.e. set the size to zero.
void deleteDemandDrivenData(DataPtr &dataPtr)
bool hasFaceEdges() const