CloudIO.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "Cloud.H"
00028 #include "Particle.H"
00029 #include "Time.H"
00030 #include "IOPosition.H"
00031
00032
00033
00034 template<class ParticleType>
00035 void Foam::Cloud<ParticleType>::initCloud(const bool checkClass)
00036 {
00037 IOPosition<ParticleType> ioP(*this);
00038
00039 if (ioP.headerOk())
00040 {
00041 ioP.readData(*this, checkClass);
00042 ioP.close();
00043
00044 if (this->size())
00045 {
00046 readFields();
00047 }
00048 }
00049 else
00050 {
00051 WarningIn("Cloud<ParticleType>::initCloud(const bool checkClass)")
00052 << "Cannot read particle positions file " << nl
00053 << " " << ioP.path() << nl
00054 << " assuming the initial cloud contains 0 particles." << endl;
00055 }
00056 }
00057
00058
00059
00060
00061 template<class ParticleType>
00062 Foam::Cloud<ParticleType>::Cloud
00063 (
00064 const polyMesh& pMesh,
00065 const bool checkClass
00066 )
00067 :
00068 cloud(pMesh),
00069 polyMesh_(pMesh),
00070 particleCount_(0)
00071 {
00072 initCloud(checkClass);
00073 }
00074
00075
00076 template<class ParticleType>
00077 Foam::Cloud<ParticleType>::Cloud
00078 (
00079 const polyMesh& pMesh,
00080 const word& cloudName,
00081 const bool checkClass
00082 )
00083 :
00084 cloud(pMesh, cloudName),
00085 polyMesh_(pMesh),
00086 particleCount_(0)
00087 {
00088 initCloud(checkClass);
00089 }
00090
00091
00092
00093
00094 template<class ParticleType>
00095 Foam::IOobject Foam::Cloud<ParticleType>::fieldIOobject
00096 (
00097 const word& fieldName,
00098 const IOobject::readOption r
00099 ) const
00100 {
00101 return IOobject
00102 (
00103 fieldName,
00104 time().timeName(),
00105 *this,
00106 r,
00107 IOobject::NO_WRITE,
00108 false
00109 );
00110 }
00111
00112
00113 template<class ParticleType>
00114 template<class DataType>
00115 void Foam::Cloud<ParticleType>::checkFieldIOobject
00116 (
00117 const Cloud<ParticleType>& c,
00118 const IOField<DataType>& data
00119 ) const
00120 {
00121 if (data.size() != c.size())
00122 {
00123 FatalErrorIn
00124 (
00125 "void Cloud<ParticleType>::checkFieldIOobject"
00126 "(const Cloud<ParticleType>&, const IOField<DataType>&) const"
00127 ) << "Size of " << data.name()
00128 << " field " << data.size()
00129 << " does not match the number of particles " << c.size()
00130 << abort(FatalError);
00131 }
00132 }
00133
00134
00135 template<class ParticleType>
00136 void Foam::Cloud<ParticleType>::readFields()
00137 {}
00138
00139
00140 template<class ParticleType>
00141 void Foam::Cloud<ParticleType>::writeFields() const
00142 {}
00143
00144
00145 template<class ParticleType>
00146 bool Foam::Cloud<ParticleType>::writeObject
00147 (
00148 IOstream::streamFormat fmt,
00149 IOstream::versionNumber ver,
00150 IOstream::compressionType cmp
00151 ) const
00152 {
00153 if (this->size())
00154 {
00155 writeFields();
00156 return cloud::writeObject(fmt, ver, cmp);
00157 }
00158 else
00159 {
00160 return true;
00161 }
00162 }
00163
00164
00165
00166
00167 template<class ParticleType>
00168 Foam::Ostream& Foam::operator<<(Ostream& os, const Cloud<ParticleType>& pc)
00169 {
00170 pc.writeData(os);
00171
00172
00173 os.check("Ostream& operator<<(Ostream&, const Cloud<ParticleType>&)");
00174
00175 return os;
00176 }
00177
00178
00179
Copyright © 2000-2009 OpenCFD Ltd