graphRowI.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 template<class graphType>
30 inline void Foam::graphRow<graphType>::checkIndex(const label i) const
31 {
32  if( (i < 0) || (i >=data_.sizeOfRow(rowI_)) )
33  {
35  (
36  "void Foam::graphRow<graphType>::"
37  "checkIndex(const label i) const"
38  ) << "Row index " << rowI_
39  << " is not in range " << Foam::label(0)
40  << " and " << data_.sizeOfRow(rowI_) << abort(FatalError);
41  }
42 }
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 template<class graphType>
47 inline Foam::graphRow<graphType>::graphRow(graphType& g, const label i)
48 :
49  data_(g),
50  rowI_(i)
51 {
52 }
53 
54 template<class graphType>
56 (
57  const graphRow<graphType>& ol
58 )
59 :
60  data_(ol.data_),
61  rowI_(ol.rowI_)
62 {
63 }
64 
65 template<class graphType>
67 {
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
73 template<class graphType>
75 {
76  return data_.sizeOfRow(rowI_);
77 }
78 
79 template<class graphType>
81 {
82  data_.setRowSize(rowI_, s);
83 }
84 
85 template<class graphType>
87 {
88  data_.setRowSize(rowI_, 0);
89 }
90 
91 template<class graphType>
93 {
94  data_.append(rowI_, el);
95 }
96 
97 template<class graphType>
99 {
100  data_.appendIfNotIn(rowI_, el);
101 }
102 
103 template<class graphType>
105 {
106  return data_.contains(rowI_, e);
107 }
108 
109 template<class graphType>
111 (
112  const label e
113 ) const
114 {
115  return data_.containsAtPosition(rowI_, e);
116 }
117 
118 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
119 
120 template<class graphType>
122 {
123  return data_(rowI_, i);
124 }
125 
126 template<class graphType>
128 {
129  return data_(rowI_, i);
130 }
131 
132 template<class graphType>
134 (
135  const graphRow<graphType>& l
136 )
137 {
138  data_.setRowSize(rowI_, l.size());
139  for(label i=0;i<l.size();++i)
140  data_(rowI_, i) = l[i];
141 }
142 
143 template<class graphType>
144 template<class listType>
145 inline void Foam::graphRow<graphType>::operator=(const listType& l)
146 {
147  data_.setRowSize(rowI_, l.size());
148  for(label i=0;i<l.size();++i)
149  data_(rowI_, i) = l[i];
150 }
151 
152 template<class graphType>
153 inline Foam::Ostream& operator<<
154 (
155  Foam::Ostream& os,
157 )
158 {
159  os << r.size() << "(";
160  for(Foam::label i=0;i<r.size();++i)
161  os << r[i] << " ";
162  os << ")";
163 
164  return os;
165 }
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // ************************************************************************* //
Foam::graphRow::checkIndex
void checkIndex(const label i) const
check index
Definition: graphRowI.H:30
Foam::graphRow::appendIfNotIn
void appendIfNotIn(const label)
Append an element to the given row if it does not exist there.
Definition: graphRowI.H:98
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
Foam::graphRow::~graphRow
~graphRow()
Definition: graphRowI.H:66
Foam::graphRow::data_
graphType & data_
reference to the graph
Definition: graphRow.H:61
Foam::graphRow::append
void append(const label)
Append an element to the given row.
Definition: graphRowI.H:92
Foam::graphRow::rowI_
const label rowI_
row number
Definition: graphRow.H:64
Foam::graphRow::setSize
void setSize(const label size)
Reset the number of rows.
Definition: graphRowI.H:80
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::graphRow::size
label size() const
Returns the number of rows.
Definition: graphRowI.H:74
Foam::graphRow::clear
void clear()
Clear the graph.
Definition: graphRowI.H:86
Foam::FatalError
error FatalError
Foam::graphRow::operator[]
label operator[](const label) const
set and get operators
Definition: graphRowI.H:121
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::graphRow
Definition: graphRow.H:48
Foam::graphRow::graphRow
graphRow(graphType &, const label)
Construct from graph and row number.
Definition: graphRowI.H:47
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::graphRow::containsAtPosition
label containsAtPosition(const label e) const
Definition: graphRowI.H:111
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::graphRow::contains
bool contains(const label e) const
check if the element is in the given row (takes linear time)
Definition: graphRowI.H:104
Foam::graphRow::operator=
void operator=(const graphRow< graphType > &)
Assignment operator.
Definition: graphRowI.H:134