faceListPMGI.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  regIOobject(io),
43  faceList(readStream(typeName)),
44  nElmts_(faceList::size())
45 {
46 }
47 
48 inline faceListPMG::faceListPMG(const IOobject& io, const label s)
49 :
50  regIOobject(io),
51  faceList(s),
52  nElmts_(s)
53 {
54 }
55 
56 inline faceListPMG::faceListPMG(const IOobject& io, const faceList& fcs)
57 :
58  regIOobject(io),
59  faceList(fcs),
60  nElmts_(fcs.size())
61 {
62 }
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 // Destructor
66 
68 {
69 }
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 inline label faceListPMG::size() const
74 {
75  return nElmts_;
76 }
77 
78 inline void faceListPMG::setSize(const label nElmts)
79 {
80  if( nElmts >= faceList::size() )
81  {
82  if( faceList::size() != 0 )
83  {
84  Info << "Resizing faces!" << endl;
85  faceList copy(label(1.5*nElmts));
86  for(label i=0;i<nElmts_;++i)
87  copy[i].transfer(this->operator[](i));
88 
89  faceList::transfer(copy);
90  }
91  else
92  {
93  faceList::setSize(label(1.5*nElmts));
94  }
95  }
96 
97  nElmts_ = nElmts;
98 }
99 
100 inline void faceListPMG::clear()
101 {
102  nElmts_ = 0;
103 }
104 
105 inline void faceListPMG::append(const face& f)
106 {
107  const label i = nElmts_;
108  setSize(i+1);
109  this->operator[](i) = f;
110 }
111 
112 inline face& faceListPMG::newElmt(const label fI)
113 {
114  setSize(fI+1);
115  return this->operator[](fI);
116 }
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 inline bool faceListPMG::writeData(Ostream& os) const
121 {
122  return (os << *this).good();
123 }
124 
125 inline void faceListPMG::operator=(const faceList& fcs)
126 {
127  setSize(fcs.size());
128  forAll(fcs, fI)
129  this->operator[](fI) = fcs[fI];
130 }
131 
132 inline Ostream& operator<<(Ostream& os, const faceListPMG& fcs)
133 {
134  SubList<face> f(fcs, fcs.nElmts_, 0);
135 
136  os << f;
137  return os;
138 }
139 
141 {
142  faceList& faces = static_cast<faceList&>(fcs);
143  is >> faces;
144  fcs.nElmts_ = faces.size();
145 
146  return is;
147 }
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
SubList.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::faceListPMG::writeData
bool writeData(Ostream &) const
read/write the list onto disk
Definition: faceListPMGI.H:120
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::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::faceListPMG::newElmt
face & newElmt(const label)
return an element with bound checking
Definition: faceListPMGI.H:112
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::faceListPMG::setSize
void setSize(const label nElmts)
set the number of used elements
Definition: faceListPMGI.H:78
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::faceListPMG::append
void append(const face &)
add a face at the end of the list
Definition: faceListPMGI.H:105
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
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::faceListPMG::clear
void clear()
set the size to zero
Definition: faceListPMGI.H:100
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::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
f
labelList f(nPoints)
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
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::faceListPMG::operator=
void operator=(const faceListPMG &)
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::faceListPMG::~faceListPMG
~faceListPMG()
Definition: faceListPMGI.H:67
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
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::faceListPMG::faceListPMG
faceListPMG(const faceListPMG &)
Foam::faceListPMG
Definition: faceListPMG.H:50
Foam::faceListPMG::nElmts_
label nElmts_
number of used elements
Definition: faceListPMG.H:56
Foam::faceListPMG::transfer
void transfer(faceList &)