37 Foam::label Foam::primitiveMesh::getEdge
39 List<DynamicList<label>>& pe,
40 DynamicList<edge>& es,
43 const label nextPointi
49 label eI = pe[pointi][ppI];
51 const edge&
e = es[eI];
53 if (
e.start() == nextPointi ||
e.end() == nextPointi)
60 label edgeI = es.size();
61 pe[pointi].append(edgeI);
63 if (nextPointi != pointi)
67 pe[nextPointi].append(edgeI);
70 if (pointi < nextPointi)
72 es.append(edge(pointi, nextPointi));
76 es.append(edge(nextPointi, pointi));
82 void Foam::primitiveMesh::calcEdges(
const bool doFaceEdges)
const 86 Pout<<
"primitiveMesh::calcEdges(const bool) : " 87 <<
"calculating edges, pointEdges and optionally faceEdges" 93 if ((edgesPtr_ || pePtr_) || (doFaceEdges && fePtr_))
96 <<
"edges or pointEdges or faceEdges already calculated" 116 List<DynamicList<label>> pe(
nPoints());
132 faceEdges[facei].setSize(fcs[facei].size());
143 nInternal0Edges_ = 0;
145 label nInt1Edges = 0;
150 if (nInternalPoints_ == -1)
155 const face&
f = fcs[facei];
159 label pointi =
f[fp];
162 label edgeI = getEdge(pe, es, pointi, nextPointi);
166 (*fePtr_)[facei][fp] = edgeI;
172 nInternal0Edges_ = es.size();
178 for (label facei = nInternalFaces_; facei < fcs.size(); facei++)
180 const face&
f = fcs[facei];
184 label pointi =
f[fp];
187 label oldNEdges = es.
size();
188 label edgeI = getEdge(pe, es, pointi, nextPointi);
190 if (es.size() > oldNEdges)
196 (*fePtr_)[facei][fp] = edgeI;
202 for (label facei = 0; facei < nInternalFaces_; facei++)
204 const face&
f = fcs[facei];
208 label pointi =
f[fp];
211 label oldNEdges = es.
size();
212 label edgeI = getEdge(pe, es, pointi, nextPointi);
214 if (es.size() > oldNEdges)
216 if (pointi < nInternalPoints_)
218 if (nextPointi < nInternalPoints_)
229 if (nextPointi < nInternalPoints_)
241 (*fePtr_)[facei][fp] = edgeI;
252 if (nInternalPoints_ != -1)
254 nInternalEdges_ = es.size()-nExtEdges;
255 nInternal1Edges_ = nInternal0Edges_+nInt1Edges;
291 label internal0EdgeI = 0;
294 label internal1EdgeI = nInternal0Edges_;
297 label internal2EdgeI = nInternal1Edges_;
300 label externalEdgeI = nInternalEdges_;
310 const DynamicList<label>& pEdges = pe[pointi];
312 nbrPoints.setSize(pEdges.size());
316 const edge&
e = es[pEdges[i]];
318 label nbrPointi =
e.otherVertex(pointi);
320 if (nbrPointi < pointi)
326 nbrPoints[i] = nbrPointi;
332 if (nInternalPoints_ == -1)
337 if (nbrPoints[i] != -1)
339 label edgeI = pEdges[nbrPoints.indices()[i]];
341 oldToNew[edgeI] = internal0EdgeI++;
347 if (pointi < nInternalPoints_)
351 label nbrPointi = nbrPoints[i];
353 label edgeI = pEdges[nbrPoints.indices()[i]];
357 if (edgeI < nExtEdges)
360 oldToNew[edgeI] = externalEdgeI++;
362 else if (nbrPointi < nInternalPoints_)
365 oldToNew[edgeI] = internal0EdgeI++;
370 oldToNew[edgeI] = internal1EdgeI++;
379 label nbrPointi = nbrPoints[i];
381 label edgeI = pEdges[nbrPoints.indices()[i]];
385 if (edgeI < nExtEdges)
388 oldToNew[edgeI] = externalEdgeI++;
390 else if (nbrPointi < nInternalPoints_)
399 oldToNew[edgeI] = internal2EdgeI++;
410 label edgeI = oldToNew.find(-1);
414 const edge&
e = es[edgeI];
417 <<
"Did not sort edge " << edgeI <<
" points:" <<
e 420 <<
"Current buckets:" <<
endl 421 <<
" internal0EdgeI:" << internal0EdgeI <<
endl 422 <<
" internal1EdgeI:" << internal1EdgeI <<
endl 423 <<
" internal2EdgeI:" << internal2EdgeI <<
endl 424 <<
" externalEdgeI:" << externalEdgeI <<
endl 434 edgesPtr_ =
new edgeList(es.size());
438 edges[oldToNew[edgeI]] = es[edgeI];
446 DynamicList<label>& pEdges = pe[pointi];
449 pointEdges[pointi].transfer(pEdges);
466 Foam::label Foam::primitiveMesh::findFirstCommonElementFromSortedLists
477 while (iter1 != list1.end() && iter2 != list2.end())
483 else if (*iter1 > *iter2)
496 <<
"No common elements in lists " << list1 <<
" and " << list2
534 Pout<<
"primitiveMesh::faceEdges() : " 535 <<
"calculating faceEdges" <<
endl;
548 const face&
f = fcs[facei];
555 label pointi =
f[fp];
563 label edgeI = pEdges[i];
565 if (es[edgeI].otherVertex(pointi) == nextPointi)
579 void Foam::primitiveMesh::clearOutEdges()
597 return faceEdges()[facei];
601 const face&
f = faces()[facei];
613 findFirstCommonElementFromSortedLists
616 pointEs[
f.nextLabel(fp)]
627 return faceEdges(facei, labels_);
640 return cellEdges()[celli];
647 for (
const label facei : cFaces)
649 set.insert(faceEdges(facei));
653 if (
set.size() > storage.
capacity())
658 for (
const label edgei :
set)
669 return cellEdges(celli, labelSet_, labels_);
List< labelList > labelListList
A List of labelList.
const labelListList & cellEdges() const
void size(const label n)
Older name for setAddressableSize.
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.
const labelListList & pointEdges() const
List< face > faceList
A List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void setCapacity(const label len)
Alter the size of the underlying storage.
static const unsigned edgesPerPoint_
Estimated number of edges per point.
Various functions to operate on Lists.
#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...
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
List< edge > edgeList
A List of edges.
void clear()
Clear the list, i.e. set size to zero.
void sort(UList< T > &list)
Sort the list.
void append(const T &val)
Copy append an element to the end of this list.
errorManip< error > abort(error &err)
int debug
Static debugging option.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Template functions to aid in the implementation of demand driven data.
label capacity() const noexcept
Size of the underlying storage.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
const label * const_iterator
Random access iterator for traversing a UList.
List< label > labelList
A List of labels.
void deleteDemandDrivenData(DataPtr &dataPtr)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.