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)
85 void 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());
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];
566 label pointi =
f[fp];
574 label edgeI = pEdges[i];
576 if (es[edgeI].otherVertex(pointi) == nextPointi)
590 void 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)]
638 return faceEdges(facei, labels_);
651 return cellEdges()[celli];
658 for (
const label facei : cFaces)
660 set.insert(faceEdges(facei));
664 if (storage.
capacity() <
set.size())
669 for (
const label edgei :
set)
680 return cellEdges(celli, labelSet_, labels_);
const labelListList & cellEdges() const
void size(const label n)
Older name for setAddressableSize.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
const labelListList & faceEdges() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const labelListList & pointEdges() const
static label findFirstCommonElementFromSortedLists(const labelUList &list1, const labelUList &list2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const pointField & points() const =0
Return mesh points.
void setCapacity(const label len)
Alter the size of the underlying storage.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
List< labelList > labelListList
List of labelList.
bool contains(const T &val) const
True if the value is contained in the list.
Various functions to operate on Lists.
label capacity() const noexcept
Size of the underlying storage.
#define forAll(list, i)
Loop across all elements in list.
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...
List< face > faceList
List of faces.
static label getEdge(List< DynamicList< label >> &pe, DynamicList< edge > &es, const label pointi, const label nextPointi)
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set 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 sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
int debug
Static debugging option.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void push_back(const T &val)
Copy append an element to the end of this list.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
virtual const faceList & faces() const =0
Return faces.
iterator end() noexcept
Return an iterator to end traversing the UList.
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.