46 const label nextPointi
50 for (
const label edgei : pe[pointi])
59 const label edgei = es.
size();
60 pe[pointi].push_back(edgei);
62 if (nextPointi != pointi)
66 pe[nextPointi].push_back(edgei);
69 if (pointi < nextPointi)
85void Foam::primitiveMesh::calcEdges(
const bool doFaceEdges)
const
89 Pout<<
"primitiveMesh::calcEdges(const bool) : "
90 <<
"calculating edges, pointEdges and optionally faceEdges"
96 if ((edgesPtr_ || pePtr_) || (doFaceEdges && fePtr_))
99 <<
"edges or pointEdges or faceEdges already calculated"
119 List<DynamicList<label>> pe(
nPoints());
131 fePtr_ = std::make_unique<labelListList>(fcs.size());
135 faceEdges[facei].setSize(fcs[facei].size());
146 nInternal0Edges_ = 0;
148 label nInt1Edges = 0;
153 if (nInternalPoints_ == -1)
158 const face&
f = fcs[facei];
162 label pointi =
f[fp];
163 label nextPointi =
f[
f.fcIndex(fp)];
165 label edgeI =
getEdge(pe, es, pointi, nextPointi);
169 (*fePtr_)[facei][fp] = edgeI;
175 nInternal0Edges_ = es.size();
181 for (label facei = nInternalFaces_; facei < fcs.size(); facei++)
183 const face&
f = fcs[facei];
187 label pointi =
f[fp];
188 label nextPointi =
f[
f.fcIndex(fp)];
190 label oldNEdges = es.size();
191 label edgeI =
getEdge(pe, es, pointi, nextPointi);
193 if (es.size() > oldNEdges)
199 (*fePtr_)[facei][fp] = edgeI;
205 for (label facei = 0; facei < nInternalFaces_; facei++)
207 const face&
f = fcs[facei];
211 label pointi =
f[fp];
212 label nextPointi =
f[
f.fcIndex(fp)];
214 label oldNEdges = es.size();
215 label edgeI =
getEdge(pe, es, pointi, nextPointi);
217 if (es.size() > oldNEdges)
219 if (pointi < nInternalPoints_)
221 if (nextPointi < nInternalPoints_)
232 if (nextPointi < nInternalPoints_)
244 (*fePtr_)[facei][fp] = edgeI;
255 if (nInternalPoints_ != -1)
257 nInternalEdges_ = es.size()-nExtEdges;
258 nInternal1Edges_ = nInternal0Edges_+nInt1Edges;
294 label internal0EdgeI = 0;
297 label internal1EdgeI = nInternal0Edges_;
300 label internal2EdgeI = nInternal1Edges_;
303 label externalEdgeI = nInternalEdges_;
313 const DynamicList<label>& pEdges = pe[pointi];
315 nbrPoints.setSize(pEdges.size());
319 const edge&
e = es[pEdges[i]];
321 label nbrPointi =
e.otherVertex(pointi);
323 if (nbrPointi < pointi)
329 nbrPoints[i] = nbrPointi;
335 if (nInternalPoints_ == -1)
340 if (nbrPoints[i] != -1)
342 label edgeI = pEdges[nbrPoints.indices()[i]];
344 oldToNew[edgeI] = internal0EdgeI++;
350 if (pointi < nInternalPoints_)
354 label nbrPointi = nbrPoints[i];
356 label edgeI = pEdges[nbrPoints.indices()[i]];
360 if (edgeI < nExtEdges)
363 oldToNew[edgeI] = externalEdgeI++;
365 else if (nbrPointi < nInternalPoints_)
368 oldToNew[edgeI] = internal0EdgeI++;
373 oldToNew[edgeI] = internal1EdgeI++;
382 label nbrPointi = nbrPoints[i];
384 label edgeI = pEdges[nbrPoints.indices()[i]];
388 if (edgeI < nExtEdges)
391 oldToNew[edgeI] = externalEdgeI++;
393 else if (nbrPointi < nInternalPoints_)
402 oldToNew[edgeI] = internal2EdgeI++;
413 label edgeI = oldToNew.find(-1);
417 const edge&
e = es[edgeI];
420 <<
"Did not sort edge " << edgeI <<
" points:" <<
e
423 <<
"Current buckets:" <<
endl
424 <<
" internal0EdgeI:" << internal0EdgeI <<
endl
425 <<
" internal1EdgeI:" << internal1EdgeI <<
endl
426 <<
" internal2EdgeI:" << internal2EdgeI <<
endl
427 <<
" externalEdgeI:" << externalEdgeI <<
endl
437 edgesPtr_ = std::make_unique<edgeList>(es.size());
438 auto&
edges = *edgesPtr_;
441 edges[oldToNew[edgeI]] = es[edgeI];
445 pePtr_ = std::make_unique<labelListList>(
nPoints());
449 DynamicList<label>& pEdges = pe[pointi];
483 auto iter1 = list1.
begin();
484 auto iter2 = list2.
begin();
486 while (iter1 != list1.
end() && iter2 != list2.
end())
492 else if (*iter1 > *iter2)
505 <<
"No common elements in lists " << list1 <<
" and " << list2
545 Pout<<
"primitiveMesh::faceEdges() : "
546 <<
"calculating faceEdges" <<
endl;
554 fePtr_ = std::make_unique<labelListList>(fcs.size());
555 auto& faceEdges = *fePtr_;
559 const face&
f = fcs[facei];
562 fEdges.setSize(
f.
size());
566 label pointi =
f[fp];
574 label edgeI = pEdges[i];
576 if (es[edgeI].otherVertex(pointi) == nextPointi)
590void Foam::primitiveMesh::clearOutEdges()
592 edgesPtr_.reset(
nullptr);
593 pePtr_.reset(
nullptr);
594 fePtr_.reset(
nullptr);
608 return faceEdges()[facei];
612 const face&
f = faces()[facei];
627 pointEs[
f.nextLabel(fp)]
651 return cellEdges()[celli];
658 for (
const label facei : cFaces)
660 set.insert(faceEdges(facei));
669 for (
const label edgei : set)
680 return cellEdges(celli, labelSet_, labels_);
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
void push_back(const T &val)
Copy append an element to the end of this list.
label capacity() const noexcept
Size of the underlying storage.
void setCapacity(const label len)
Alter the size of the underlying storage.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool contains(const T &val) const
True if the value is contained in the list.
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
A face is a list of labels corresponding to mesh vertices.
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
bool hasCellEdges() const noexcept
virtual const faceList & faces() const =0
Return faces.
label nPoints() const noexcept
Number of mesh points.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
const labelListList & faceEdges() const
bool hasFaceEdges() const noexcept
virtual const pointField & points() const =0
Return mesh points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
static label getEdge(List< DynamicList< label > > &pe, DynamicList< edge > &es, const label pointi, const label nextPointi)
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
static label findFirstCommonElementFromSortedLists(const labelUList &list1, const labelUList &list2)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.