pointFieldPMGI.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  pointField(readStream(typeName)),
44  nElmts_(pointField::size())
45 {
46  close();
47 }
48 
49 inline pointFieldPMG::pointFieldPMG(const IOobject& io, const label s)
50 :
51  regIOobject(io),
52  pointField(s),
53  nElmts_(s)
54 {}
55 
56 inline pointFieldPMG::pointFieldPMG(const IOobject& io, const pointField& pts)
57 :
58  regIOobject(io),
59  pointField(pts),
60  nElmts_(pts.size())
61 {}
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 // Destructor
65 
67 {}
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 inline label pointFieldPMG::size() const
72 {
73  return nElmts_;
74 }
75 
76 inline void pointFieldPMG::setSize(const label nElmts)
77 {
78  if( nElmts >= pointField::size() )
79  {
80  Info << "Resizing points!" << endl;
81  pointField::setSize(label(1.5*nElmts)+1);
82  }
83 
84  nElmts_ = nElmts;
85 }
86 
87 inline void pointFieldPMG::reserve(const label capacity)
88 {
89  if( capacity > size() )
90  this->setSize(capacity);
91 }
92 
93 inline void pointFieldPMG::clear()
94 {
95  nElmts_ = 0;
96 }
97 
98 inline void pointFieldPMG::append(const point& p)
99 {
100  const label i = nElmts_;
101  setSize(i+1);
102  this->operator[](i) = p;
103 }
104 
106 {
107  setSize(pI+1);
108  return this->operator[](pI);
109 }
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 inline bool pointFieldPMG::writeData(Ostream& os) const
114 {
115  return (os << *this).good();
116 }
117 
118 inline void pointFieldPMG::operator=(const pointField& pts)
119 {
120  setSize(pts.size());
121  forAll(pts, pI)
122  this->operator[](pI) = pts[pI];
123 }
124 
125 inline Ostream& operator<<(Ostream& os, const pointFieldPMG& pts)
126 {
127  SubList<point> p(pts, pts.nElmts_, 0);
128 
129  os << p;
130  return os;
131 }
132 
134 {
135  pointField& points = static_cast<pointField&>(pts);
136  is >> points;
137  pts.nElmts_ = points.size();
138 
139  return is;
140 }
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
setSize
points setSize(newPointi)
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
SubList.H
p
p
Definition: pEqn.H:62
Foam::pointFieldPMG::writeData
bool writeData(Ostream &) const
read/write the list onto disk
Definition: pointFieldPMGI.H:113
Foam::pointFieldPMG::newElmt
point & newElmt(const label)
return an element with bound checking
Definition: pointFieldPMGI.H:105
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::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::pointFieldPMG::clear
void clear()
set the size to zero
Definition: pointFieldPMGI.H:93
Foam::pointFieldPMG::reserve
void reserve(const label capacity)
Definition: pointFieldPMGI.H:87
Foam::pointFieldPMG::pointFieldPMG
pointFieldPMG(const pointFieldPMG &)
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::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
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::pointFieldPMG::size
label size() const
return the number of used elements
Definition: pointFieldPMGI.H:71
Foam::pointFieldPMG::setSize
void setSize(const label nElmts)
set the number of used elements
Definition: pointFieldPMGI.H:76
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::pointFieldPMG::append
void append(const point &)
add a point at the end of the list
Definition: pointFieldPMGI.H:98
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::pointFieldPMG::operator=
void operator=(const pointFieldPMG &)
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
Foam::pointFieldPMG::nElmts_
label nElmts_
number of used elements
Definition: pointFieldPMG.H:56
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:148
Foam::Vector< scalar >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::pointFieldPMG::~pointFieldPMG
~pointFieldPMG()
Definition: pointFieldPMGI.H:66
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::pointFieldPMG
Definition: pointFieldPMG.H:50