VRWGraphListI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 namespace Foam
27 {
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
32 (
33  const label i,
34  const label j,
35  const label k
36 ) const
37 {
38  if( (i < 0) || (i >= rows_.size()) )
39  {
41  (
42  "void Foam::VRWGraphList<T,width>::"
43  "checkIndex(const label i, const label j, const label k) const"
44  ) << "Position index " << Foam::label(i)
45  << " is not in range " << Foam::label(0)
46  << " and " << rows_.size() << abort(FatalError);
47  }
48 
49  if( (j < 0) || (j >= rows_[i].size()) )
51  (
52  "void Foam::VRWGraphList<T,width>::"
53  "checkIndex(label const i, const label j, const label k) const"
54  ) << "Row index " << Foam::label(j)
55  << " is not in range " << Foam::label(0)
56  << " and " << rows_[i].size() << abort(FatalError);
57 
58  if( (k < 0) || (k >= data_.sizeOfRow(rows_[i].start()+j)) )
60  (
61  "void Foam::VRWGraphList<T,width>::"
62  "checkIndex(label const i, const label j, const label k) const"
63  ) << "Data index " << Foam::label(k)
64  << " is not in range " << Foam::label(0)
65  << " and " << data_.sizeOfRow(rows_[i].start()+j)
66  << abort(FatalError);
67 }
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
71 //- Construct null
73 :
74  data_(),
75  rows_()
76 {
77 }
78 
80 (
81  const VRWGraphList& ol
82 )
83 :
84  data_(ol.data_),
85  rows_(ol.rows_)
86 {
87 }
88 
90 {
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 {
98  return rows_.size();
99 }
100 
102 {
103  return rows_[posI].size();
104 }
105 
107 (
108  const label posI,
109  const label rowI
110 ) const
111 {
112  return data_.sizeOfRow(rows_[posI].start()+rowI);
113 }
114 
116 {
117  data_.setSize(0);
118  rows_.setSize(0);
119 }
120 
121 template<class GraphType>
123 (
124  const GraphType& l
125 )
126 {
127  rowElement re(data_.size(), l.size());
128 
129  for(label i=0;i<l.size();++i)
130  data_.appendList(l[i]);
131 
132  rows_.append(re);
133 }
134 
135 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
136 
137 inline Foam::label Foam::VRWGraphList::operator()
138 (
139  const label i,
140  const label j,
141  const label k
142 ) const
143 {
144  #ifdef FULLDEBUG
145  checkIndex(i, j, k);
146  #endif
147 
148  return data_(rows_[i].start() + j, k);
149 }
150 
151 
152 inline Foam::label& Foam::VRWGraphList::operator()
153 (
154  const label i, const label j, const label k
155 )
156 {
157  #ifdef FULLDEBUG
158  checkIndex(i, j, k);
159  #endif
160 
161  return data_(rows_[i].start() + j, k);
162 }
163 
164 inline const Foam::subGraph<const VRWGraph> Foam::VRWGraphList::operator[]
165 (
166  const label i
167 ) const
168 {
169  return Foam::subGraph<const VRWGraph>(data_, i, rows_[i].size());
170 }
171 
173 {
174  data_ = l.data_;
175  rows_ = l.rows_;
176 }
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // ************************************************************************* //
Foam::VRWGraphList::sizeOfRow
label sizeOfRow(const label posI, const label rowI) const
Return the number of element in the row at the given position.
Definition: VRWGraphListI.H:107
Foam::VRWGraphList::size
label size() const
Returns the number of graphs.
Definition: VRWGraphListI.H:96
Foam::VRWGraphList::operator=
void operator=(const VRWGraphList &)
Assignment operator.
Definition: VRWGraphListI.H:172
Foam::rowElement
Definition: VRWGraph.H:52
Foam::VRWGraphList::data_
VRWGraph data_
graph containing the data
Definition: VRWGraphList.H:56
Foam::VRWGraphList
Definition: VRWGraphList.H:51
Foam::VRWGraphList::appendGraph
void appendGraph(const GraphType &l)
Append a graph at the end of the graphList.
Definition: VRWGraphListI.H:123
Foam::VRWGraphList::VRWGraphList
VRWGraphList()
Construct null.
Definition: VRWGraphListI.H:72
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::subGraph
Definition: subGraph.H:47
Foam::constant::atomic::re
const dimensionedScalar re
Classical electron radius: default SI units: [m].
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::VRWGraphList::sizeOfGraph
label sizeOfGraph(const label posI) const
Returns the number of rows in the graph at that position.
Definition: VRWGraphListI.H:101
Foam::VRWGraphList::clear
void clear()
Clear the graph.
Definition: VRWGraphListI.H:115
Foam::VRWGraphList::~VRWGraphList
~VRWGraphList()
Definition: VRWGraphListI.H:89
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::VRWGraphList::checkIndex
void checkIndex(const label i, const label j, const label k) const
check index
Definition: VRWGraphListI.H:32
Foam::VRWGraphList::rows_
LongList< rowElement > rows_
number of rows
Definition: VRWGraphList.H:59