33 template<
class ParticleType>
39 template<
class ParticleType>
42 typeIOobject<timeIOdictionary> dictObj
46 "uniform"/cloud::prefix/
name(),
48 IOobject::MUST_READ_IF_MODIFIED,
53 if (dictObj.headerOk())
55 const timeIOdictionary uniformPropsDict(dictObj);
57 const word procName(
"processor" +
Foam::name(Pstream::myProcNo()));
58 if (uniformPropsDict.found(procName))
60 uniformPropsDict.subDict(procName).lookup(
"particleCount")
61 >> ParticleType::particleCount_;
66 ParticleType::particleCount_ = 0;
71 template<
class ParticleType>
74 timeIOdictionary uniformPropsDict
80 "uniform"/cloud::prefix/
name(),
89 np[Pstream::myProcNo()] = ParticleType::particleCount_;
91 Pstream::listCombineGather(np, maxEqOp<label>());
92 Pstream::listCombineScatter(np);
97 uniformPropsDict.add(procName, dictionary());
98 uniformPropsDict.subDict(procName).add(
"particleCount", np[i]);
101 uniformPropsDict.writeObject
104 IOstream::currentVersion,
105 time().writeCompression(),
111 template<
class ParticleType>
114 readCloudUniformProperties();
116 IOPosition<Cloud<ParticleType>> ioP(*
this);
118 bool valid = ioP.headerOk();
119 Istream& is = ioP.readStream(checkClass ? typeName :
"",
valid);
122 ioP.readData(is, *
this);
128 Pout<<
"Cannot read particle positions file:" <<
nl
129 <<
" " << ioP.objectPath() <<
nl
130 <<
"Assuming the initial cloud contains 0 particles." <<
endl;
136 pMesh_.tetBasePtIs();
142 template<
class ParticleType>
147 const bool checkClass
152 patchNbrProc_(patchNbrProc(pMesh)),
153 patchNbrProcPatch_(patchNbrProcPatch(pMesh)),
154 patchNonConformalCyclicPatches_(patchNonConformalCyclicPatches(pMesh)),
155 globalPositionsPtr_()
157 pMesh_.tetBasePtIs();
158 pMesh_.oldCellCentres();
160 initCloud(checkClass);
166 template<
class ParticleType>
169 const word& fieldName,
185 template<
class ParticleType>
186 template<
class DataType>
193 if (data.
size() !=
c.size())
196 <<
"Size of " << data.
name()
197 <<
" field " << data.
size()
198 <<
" does not match the number of particles " <<
c.size()
204 template<
class ParticleType>
205 template<
class DataType>
212 if (data.size() !=
c.size())
215 <<
"Size of " << data.name()
216 <<
" field " << data.size()
217 <<
" does not match the number of particles " <<
c.size()
223 template<
class ParticleType>
226 ParticleType::writeFields(*
this);
230 template<
class ParticleType>
239 writeCloudUniformProperties();
242 return cloud::writeObject(fmt, ver, cmp, this->size());
248 template<
class ParticleType>
254 os.
check(
"Ostream& operator<<(Ostream&, const Cloud<ParticleType>&)");
#define forAll(list, i)
Loop across all elements in list.
Base cloud calls templated on particle type.
static word cloudPropertiesName
Name of cloud properties dictionary.
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write=true) const
Write using given format, version and compression.
IOobject fieldIOobject(const word &fieldName, const IOobject::readOption r) const
Helper to construct IOobject for field and current time.
Cloud(const polyMesh &mesh, const word &cloudName, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType >> &data) const
Check lagrangian data fieldfield.
A Field of objects of type <Type> with automated input and output using a compact storage....
Pre-declare SubField and related Field type.
A primitive field of type <Type> with automated input and output.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
readOption
Enumeration defining the read options.
const word & name() const
Return name.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A cloud is a collection of lagrangian particles.
virtual bool writeData(Ostream &) const
writeData function required by regIOobject but not used
Mesh consisting of general polyhedral cells.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool valid(const PtrList< ModelType > &l)
const dimensionedScalar c
Speed of light in a vacuum.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
prefixOSstream Pout(cout, "Pout")
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
const word cloudName(propsDict.lookup("cloudName"))