primitiveMeshCellPoints.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) 2018 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 (!cpPtr_)
37 {
38 if (debug)
39 {
40 Pout<< "primitiveMesh::cellPoints() : "
41 << "calculating cellPoints" << endl;
42
43 if (debug == -1)
44 {
45 // For checking calls:abort so we can quickly hunt down
46 // origin of call
48 << abort(FatalError);
49 }
50 }
51
52 // Invert pointCells
53 cpPtr_ = new labelListList(nCells());
54 invertManyToMany(nCells(), pointCells(), *cpPtr_);
55 }
56
57 return *cpPtr_;
58}
59
60
62(
63 const label celli,
64 labelHashSet& set,
65 DynamicList<label>& storage
66) const
67{
68 if (hasCellPoints())
69 {
70 return cellPoints()[celli];
71 }
72
73 const faceList& fcs = faces();
74 const labelList& cFaces = cells()[celli];
75
76 set.clear();
77
78 for (const label facei : cFaces)
79 {
80 set.insert(fcs[facei]);
81 }
82
83 storage.clear();
84 if (set.size() > storage.capacity())
85 {
86 storage.setCapacity(set.size());
87 }
88
89 for (const label pointi : set)
90 {
91 storage.append(pointi);
92 }
93
94 return storage;
95}
96
97
98const Foam::labelList& Foam::primitiveMesh::cellPoints(const label celli) const
99{
100 return cellPoints(celli, labelSet_, labels_);
101}
102
103
104// ************************************************************************* //
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:72
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:391
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:503
label capacity() const noexcept
Size of the underlying storage.
Definition: DynamicListI.H:287
void setCapacity(const label len)
Alter the size of the underlying storage.
Definition: DynamicListI.H:303
const labelListList & pointCells() const
const labelListList & cellPoints() const
label nCells() const noexcept
Number of mesh cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const cellShapeList & cells
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.