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);
59 pe[nextPointi].append(edgeI);
60 if (pointi < nextPointi)
62 es.append(edge(pointi, nextPointi));
66 es.append(edge(nextPointi, pointi));
72 void Foam::primitiveMesh::calcEdges(
const bool doFaceEdges)
const 76 Pout<<
"primitiveMesh::calcEdges(const bool) : " 77 <<
"calculating edges, pointEdges and optionally faceEdges" 83 if ((edgesPtr_ || pePtr_) || (doFaceEdges && fePtr_))
86 <<
"edges or pointEdges or faceEdges already calculated" 106 List<DynamicList<label>> pe(
nPoints());
122 faceEdges[facei].setSize(fcs[facei].size());
133 nInternal0Edges_ = 0;
135 label nInt1Edges = 0;
140 if (nInternalPoints_ == -1)
145 const face& f = fcs[facei];
149 label pointi = f[fp];
150 label nextPointi = f[f.fcIndex(fp)];
152 label edgeI = getEdge(pe, es, pointi, nextPointi);
156 (*fePtr_)[facei][fp] = edgeI;
162 nInternal0Edges_ = es.size();
168 for (
label facei = nInternalFaces_; facei < fcs.size(); facei++)
170 const face& f = fcs[facei];
174 label pointi = f[fp];
175 label nextPointi = f[f.fcIndex(fp)];
177 label oldNEdges = es.size();
178 label edgeI = getEdge(pe, es, pointi, nextPointi);
180 if (es.size() > oldNEdges)
186 (*fePtr_)[facei][fp] = edgeI;
192 for (
label facei = 0; facei < nInternalFaces_; facei++)
194 const face& f = fcs[facei];
198 label pointi = f[fp];
199 label nextPointi = f[f.fcIndex(fp)];
201 label oldNEdges = es.size();
202 label edgeI = getEdge(pe, es, pointi, nextPointi);
204 if (es.size() > oldNEdges)
206 if (pointi < nInternalPoints_)
208 if (nextPointi < nInternalPoints_)
219 if (nextPointi < nInternalPoints_)
231 (*fePtr_)[facei][fp] = edgeI;
242 if (nInternalPoints_ != -1)
244 nInternalEdges_ = es.size()-nExtEdges;
245 nInternal1Edges_ = nInternal0Edges_+nInt1Edges;
281 label internal0EdgeI = 0;
284 label internal1EdgeI = nInternal0Edges_;
287 label internal2EdgeI = nInternal1Edges_;
290 label externalEdgeI = nInternalEdges_;
300 const DynamicList<label>& pEdges = pe[pointi];
302 nbrPoints.setSize(pEdges.size());
306 const edge& e = es[pEdges[i]];
308 label nbrPointi = e.otherVertex(pointi);
310 if (nbrPointi < pointi)
316 nbrPoints[i] = nbrPointi;
322 if (nInternalPoints_ == -1)
327 if (nbrPoints[i] != -1)
329 label edgeI = pEdges[nbrPoints.indices()[i]];
331 oldToNew[edgeI] = internal0EdgeI++;
337 if (pointi < nInternalPoints_)
341 label nbrPointi = nbrPoints[i];
343 label edgeI = pEdges[nbrPoints.indices()[i]];
347 if (edgeI < nExtEdges)
350 oldToNew[edgeI] = externalEdgeI++;
352 else if (nbrPointi < nInternalPoints_)
355 oldToNew[edgeI] = internal0EdgeI++;
360 oldToNew[edgeI] = internal1EdgeI++;
369 label nbrPointi = nbrPoints[i];
371 label edgeI = pEdges[nbrPoints.indices()[i]];
375 if (edgeI < nExtEdges)
378 oldToNew[edgeI] = externalEdgeI++;
380 else if (nbrPointi < nInternalPoints_)
389 oldToNew[edgeI] = internal2EdgeI++;
404 const edge& e = es[edgeI];
407 <<
"Did not sort edge " << edgeI <<
" points:" << e
410 <<
"Current buckets:" <<
endl 411 <<
" internal0EdgeI:" << internal0EdgeI <<
endl 412 <<
" internal1EdgeI:" << internal1EdgeI <<
endl 413 <<
" internal2EdgeI:" << internal2EdgeI <<
endl 414 <<
" externalEdgeI:" << externalEdgeI <<
endl 424 edgesPtr_ =
new edgeList(es.size());
428 edges[oldToNew[edgeI]] = es[edgeI];
436 DynamicList<label>& pEdges = pe[pointi];
439 pointEdges[pointi].transfer(pEdges);
456 Foam::label Foam::primitiveMesh::findFirstCommonElementFromSortedLists
467 while (iter1 != list1.end() && iter2 != list2.end())
473 else if (*iter1 > *iter2)
486 <<
"No common elements in lists " << list1 <<
" and " << list2
524 Pout<<
"primitiveMesh::faceEdges() : " 525 <<
"calculating faceEdges" <<
endl;
538 const face& f = fcs[facei];
545 label pointi = f[fp];
553 label edgeI = pEdges[i];
555 if (es[edgeI].otherVertex(pointi) == nextPointi)
569 void Foam::primitiveMesh::clearOutEdges()
604 findFirstCommonElementFromSortedLists
645 labelSet_.
insert(fe[feI]);
658 storage.
append(iter.key());
List< labelList > labelListList
A List of labelList.
#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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const pointField & points() const =0
Return mesh points.
label size() const
Return number of elements in table.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
bool insert(const Key &key)
Insert a new entry.
const cellList & cells() const
Various functions to operate on Lists.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
bool hasCellEdges() const
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.
const labelListList & pointEdges() const
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
prefixOSstream Pout(cout,"Pout")
const labelListList & cellEdges() const
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
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.
label capacity() const
Size of the underlying storage.
virtual const faceList & faces() const =0
Return faces.
bool hasFaceEdges() const
label nextLabel(const label i) const
Next vertex on face.
void clear()
Clear the addressed list, i.e. set the size to zero.
const labelListList & faceEdges() const
void deleteDemandDrivenData(DataPtr &dataPtr)