Loading...
Searching...
No Matches
primitiveMeshEdgeCells.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2023-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "primitiveMesh.H"
30#include "ListOps.H"
31
32// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33
35{
36 if (!ecPtr_)
37 {
38 if (debug)
39 {
40 Pout<< "primitiveMesh::edgeCells() : calculating edgeCells" << endl;
41
42 if (debug == -1)
43 {
44 // For checking calls:abort so we can quickly hunt down
45 // origin of call
47 << abort(FatalError);
48 }
49 }
50 // Invert cellEdges
51 ecPtr_ = std::make_unique<labelListList>(nEdges());
53 }
54
55 return *ecPtr_;
56}
57
58
60(
61 const label edgei,
62 DynamicList<label>& storage
63) const
64{
65 if (hasEdgeCells())
66 {
67 return edgeCells()[edgei];
68 }
69 else
70 {
71 const labelList& own = faceOwner();
72 const labelList& nei = faceNeighbour();
73
74 // Construct edgeFaces
75 DynamicList<label> eFacesStorage;
76 const labelList& eFaces = edgeFaces(edgei, eFacesStorage);
77
78 storage.clear();
79
80 // Do quadratic insertion.
81 for (const label facei : eFaces)
82 {
83 {
84 // Owner cell
85 if (!storage.contains(own[facei]))
86 {
87 storage.push_back(own[facei]);
88 }
89 }
90
91 if (isInternalFace(facei))
92 {
93 // Neighbour cell
94 if (!storage.contains(nei[facei]))
95 {
96 storage.push_back(nei[facei]);
97 }
98 }
99 }
100
101 return storage;
102 }
103}
104
105
106const Foam::labelList& Foam::primitiveMesh::edgeCells(const label edgei) const
107{
108 return edgeCells(edgei, labels_);
109}
110
111
112// ************************************************************************* //
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
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.
bool contains(const T &val) const
True if the value is contained in the list.
Definition UListI.H:302
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
const labelListList & cellEdges() const
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
bool hasEdgeCells() const noexcept
const labelListList & edgeFaces() const
const labelListList & edgeCells() const
label nEdges() const
Number of mesh edges.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for handling debugging switches.
Definition debug.C:45
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
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.