cellListPMGI.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 Description
25 
26 
27 \*---------------------------------------------------------------------------*/
28 
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 #include "SubList.H"
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // Constructors
39 
41 :
42  cellList(),
43  nElmts_(0)
44 {
45 }
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // Destructor
49 
51 {
52 }
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 inline label cellListPMG::size() const
57 {
58  return nElmts_;
59 }
60 
61 inline void cellListPMG::setSize(const label nElmts)
62 {
63  if( nElmts >= cellList::size() )
64  {
65  if( cellList::size() != 0 )
66  {
67  Info << "Resizing cells!" << endl;
68  cellList copy(label(1.5*nElmts));
69  for(label i=0;i<nElmts_;++i)
70  copy[i].transfer(this->operator[](i));
71 
72  cellList::transfer(copy);
73  }
74  else
75  {
76  cellList::setSize(label(1.5*nElmts));
77  }
78  }
79 
80  nElmts_ = nElmts;
81 }
82 
83 inline void cellListPMG::clear()
84 {
85  nElmts_ = 0;
86 }
87 
88 inline void cellListPMG::append(const cell& c)
89 {
90  const label i = nElmts_;
91  setSize(i+1);
92  this->operator[](i) = c;
93 }
94 
95 inline cell& cellListPMG::newElmt(const label cI)
96 {
97  setSize(cI+1);
98  return this->operator[](cI);
99 }
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 inline void cellListPMG::operator=(const cellList& cls)
104 {
105  setSize(cls.size());
106  forAll(cls, cI)
107  this->operator[](cI) = cls[cI];
108 }
109 
110 inline Ostream& operator<<(Ostream& os, const cellListPMG& cls)
111 {
112  SubList<cell> c(cls, cls.nElmts_, 0);
113 
114  os << c;
115  return os;
116 }
117 
119 {
120  cellList& cells = static_cast<cellList&>(cls);
121  is >> cells;
122  cls.nElmts_ = cells.size();
123 
124  return is;
125 }
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace Foam
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::cellListPMG::clear
void clear()
set the size to zero
Definition: cellListPMGI.H:83
Foam::cellListPMG::~cellListPMG
~cellListPMG()
Definition: cellListPMGI.H:50
SubList.H
Foam::cellListPMG::setSize
void setSize(const label nElmts)
set the number of used elements
Definition: cellListPMGI.H:61
Foam::cellListPMG::operator=
void operator=(const cellListPMG &)
Foam::cellListPMG::cellListPMG
cellListPMG()
null construct
Definition: cellListPMGI.H:40
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::List::transfer
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Foam::cellListPMG::newElmt
cell & newElmt(const label)
return an element with bound checking
Definition: cellListPMGI.H:95
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cellListPMG::transfer
void transfer(cellList &)
Foam::cellListPMG
Definition: cellListPMG.H:49
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::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::Info
messageStream Info
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::cellListPMG::nElmts_
label nElmts_
number of used elements
Definition: cellListPMG.H:54
Foam::List::size
label size() const
Return the number of elements in the UList.
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::cellListPMG::append
void append(const cell &)
add a cell at the end of the list
Definition: cellListPMGI.H:88
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Foam::cellListPMG::size
label size() const
return the number of used elements
Definition: cellListPMGI.H:56