VRWGraph.C
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 #include "VRWGraph.H"
27 #include "token.H"
28 #include "labelList.H"
29 
30 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
31 
32 Foam::Ostream& Foam::operator<<
33 (
34  Foam::Ostream& os,
35  const Foam::VRWGraph& DL
36 )
37 {
38  os << DL.size() << nl << token::BEGIN_LIST << nl;
39 
40  for(label i=0;i<DL.size();++i)
41  {
42  os << DL.sizeOfRow(i) << token::BEGIN_LIST;
43  for(label j=0;j<DL.sizeOfRow(i);++j)
44  {
45  if( j ) os << token::SPACE;
46 
47  os << DL(i, j);
48  }
49 
50  os << token::END_LIST << nl;
51  }
52 
53  os << token::END_LIST;
54 
55  // Check state of IOstream
56  os.check
57  (
58  "Foam::Ostream& Foam::operator<<(Foam::Ostream&, const Foam::VRWGraph&)"
59  );
60 
61  return os;
62 }
63 
64 /*
65 template<class T, Foam::label width>
66 Foam::Istream& Foam::operator>>
67 (
68  Foam::Istream& is,
69  Foam::VRWGraph<T, width>& DL
70 )
71 {
72  label size;
73  T e;
74  is >> size;
75  DL.setSize(size);
76  for(IndexType i=0;i<size;++i)
77  {
78  is >> e;
79  DL[i] = e;
80  }
81 
82  return is;
83 }
84 */
85 
87 {
88  labelLongList newPosForNode(data_.size());
89  label pos(0), nElements;
90  nElements = data_.size();
91  for(label elI=0;elI<nElements;++elI)
92  if( data_[elI] != FREEENTRY )
93  {
94  newPosForNode[elI] = pos++;
95  }
96  else
97  {
98  newPosForNode[elI] = -1;
99  }
100 
101  //- create new data
102  for(label elI=0;elI<nElements;++elI)
103  if( (newPosForNode[elI] != -1) && (newPosForNode[elI] < elI) )
104  data_[newPosForNode[elI]] = data_[elI];
105 
106  data_.setSize(pos);
107 
108  //- renumber rows
109  nElements = rows_.size();
110  for(label rowI=0;rowI<nElements;++rowI)
111  if( rows_[rowI].start() != INVALIDROW )
112  rows_[rowI].start() = newPosForNode[rows_[rowI].start()];
113 }
114 
115 // ************************************************************************* //
token.H
VRWGraph.H
Foam::LongList::size
label size() const
Size of the active part of the list.
Definition: LongListI.H:203
Foam::VRWGraph::INVALIDROW
@ INVALIDROW
Definition: VRWGraph.H:118
Foam::LongList::setSize
void setSize(const label)
Reset size of List.
Definition: LongListI.H:223
Foam::LongList< label >
Foam::VRWGraph::FREEENTRY
@ FREEENTRY
Definition: VRWGraph.H:119
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
labelList.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::VRWGraph::data_
labelLongList data_
list containing data
Definition: VRWGraph.H:105
Foam::VRWGraph::optimizeMemoryUsage
void optimizeMemoryUsage()
optimize memory usage
Definition: VRWGraph.C:86
Foam::VRWGraph::rows_
LongList< rowElement > rows_
number of rows
Definition: VRWGraph.H:108
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190