1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
30 #include "IOPosition.H"
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
34 template<class ParticleType>
35 void Foam::Cloud<ParticleType>::initCloud(const bool checkClass)
37 IOPosition<ParticleType> ioP(*this);
41 ioP.readData(*this, checkClass);
51 WarningIn("Cloud<ParticleType>::initCloud(const bool checkClass)")
52 << "Cannot read particle positions file " << nl
53 << " " << ioP.path() << nl
54 << " assuming the initial cloud contains 0 particles." << endl;
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 template<class ParticleType>
62 Foam::Cloud<ParticleType>::Cloud
64 const polyMesh& pMesh,
70 allFaces_(pMesh.faces()),
71 points_(pMesh.points()),
72 cellFaces_(pMesh.cells()),
73 allFaceCentres_(pMesh.faceCentres()),
74 owner_(pMesh.faceOwner()),
75 neighbour_(pMesh.faceNeighbour()),
78 initCloud(checkClass);
82 template<class ParticleType>
83 Foam::Cloud<ParticleType>::Cloud
85 const polyMesh& pMesh,
86 const word& cloudName,
90 cloud(pMesh, cloudName),
92 allFaces_(pMesh.faces()),
93 points_(pMesh.points()),
94 cellFaces_(pMesh.cells()),
95 allFaceCentres_(pMesh.faceCentres()),
96 owner_(pMesh.faceOwner()),
97 neighbour_(pMesh.faceNeighbour()),
100 initCloud(checkClass);
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 template<class ParticleType>
107 template<class DataType>
108 void Foam::Cloud<ParticleType>::checkFieldIOobject
110 const Cloud<ParticleType>& c,
111 const IOField<DataType>& data
114 if (data.size() != c.size())
118 "void Cloud<ParticleType>::checkFieldIOobject"
119 "(Cloud<ParticleType>, IOField<DataType>)"
120 ) << "Size of " << data.name()
121 << " field does not match the number of particles"
122 << abort(FatalError);
127 template<class ParticleType>
128 Foam::IOobject Foam::Cloud<ParticleType>::fieldIOobject
130 const word& fieldName
145 template<class ParticleType>
147 Foam::tmp<Foam::IOField<Type> > Foam::Cloud<ParticleType>::readField
149 const word& fieldName
152 return tmp<IOField<Type> >(new IOField<Type>(fieldIOobject(fieldName)));
156 template<class ParticleType>
157 void Foam::Cloud<ParticleType>::readFields()
161 template<class ParticleType>
162 void Foam::Cloud<ParticleType>::writeFields() const
166 template<class ParticleType>
167 bool Foam::Cloud<ParticleType>::writeObject
169 IOstream::streamFormat fmt,
170 IOstream::versionNumber ver,
171 IOstream::compressionType cmp
177 return cloud::writeObject(fmt, ver, cmp);
186 // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
188 template<class ParticleType>
189 Foam::Ostream& Foam::operator<<(Ostream& os, const Cloud<ParticleType>& pc)
193 // Check state of Ostream
194 os.check("Ostream& operator<<(Ostream&, const Cloud<ParticleType>&)");
200 // ************************************************************************* //