37 template<
class ParticleType>
43 template<
class ParticleType>
50 "uniform"/cloud::prefix/
name(),
57 if (dictObj.typeHeaderOk<IOdictionary>(
true))
59 const IOdictionary uniformPropsDict(dictObj);
64 cloud::geometryTypeNames.getOrDefault
68 cloud::geometryType::POSITIONS
71 const word procName(
"processor" +
Foam::name(Pstream::myProcNo()));
73 const dictionary* dictptr = uniformPropsDict.findDict(procName);
77 dictptr->readEntry(
"particleCount", ParticleType::particleCount_);
82 ParticleType::particleCount_ = 0;
87 template<
class ParticleType>
90 IOdictionary uniformPropsDict
96 "uniform"/cloud::prefix/
name(),
100 IOobject::NO_REGISTER
105 np[Pstream::myProcNo()] = ParticleType::particleCount_;
108 Pstream::listCombineReduce(np, maxEqOp<label>());
113 cloud::geometryTypeNames[geometryType_]
118 const word procName(
"processor" +
Foam::name(i));
119 uniformPropsDict.subDictOrAdd(procName).add(
"particleCount", np[i]);
122 uniformPropsDict.writeObject
124 IOstreamOption(IOstreamOption::ASCII, time().writeCompression()),
130 template<
class ParticleType>
133 readCloudUniformProperties();
135 IOPosition<Cloud<ParticleType>> ioP(*
this, geometryType_);
137 const bool haveFile = ioP.headerOk();
138 Istream& is = ioP.readStream(checkClass ? typeName : word::null, haveFile);
141 ioP.readData(is, *
this);
145 if (!haveFile &&
debug)
147 Pout<<
"Not reading particle positions file: " 148 << ioP.objectRelPath() <<
nl 149 <<
"Assuming the initial cloud contains 0 particles." <<
endl;
153 geometryType_ = cloud::geometryType::COORDINATES;
158 (void)polyMesh_.tetBasePtIs();
164 template<
class ParticleType>
169 const bool checkClass
174 initCloud(checkClass);
180 template<
class ParticleType>
183 const word& fieldName,
193 IOobjectOption::NO_WRITE,
194 IOobjectOption::NO_REGISTER
199 template<
class ParticleType>
200 template<
class DataType>
207 if (data.
size() !=
c.size())
210 <<
"Size of " << data.
name()
211 <<
" field " << data.
size()
212 <<
" does not match the number of particles " <<
c.size()
218 template<
class ParticleType>
219 template<
class DataType>
222 const Cloud<ParticleType>&
c,
223 const CompactIOField<Field<DataType>, DataType>& data
226 if (data.
size() !=
c.size())
229 <<
"Size of " << data.
name()
230 <<
" field " << data.
size()
231 <<
" does not match the number of particles " <<
c.size()
237 template<
class ParticleType>
242 const IOobject& ioNew
245 if (
io.isHeaderClass<IOField<Type>>())
247 IOField<Type>
fld(
io);
248 auto* fldNewPtr =
new IOField<Type>(ioNew, std::move(
fld));
249 return fldNewPtr->store();
256 template<
class ParticleType>
268 IOobject::NO_REGISTER
276 const word& fldName =
io.name();
294 readStoreFile<label>(
io, ioNew)
295 || readStoreFile<scalar>(
io, ioNew)
296 || readStoreFile<vector>(
io, ioNew)
297 || readStoreFile<sphericalTensor>(
io, ioNew)
298 || readStoreFile<symmTensor>(
io, ioNew)
299 || readStoreFile<tensor>(
io, ioNew)
305 <<
"Unhandled field:" << fldName
306 <<
" type:" <<
io.headerClassName() <<
endl;
312 template<
class ParticleType>
319 template<
class ParticleType>
326 writeCloudUniformProperties();
329 return cloud::writeObject(streamOpt, (this->size() > 0));
335 template<
class ParticleType>
336 Foam::Ostream& Foam::operator<<(Ostream& os, const Cloud<ParticleType>&
c)
void readFromFiles(objectRegistry &obr, const wordRes &selectFields, const wordRes &excludeFields=wordRes::null()) const
Read from files into objectRegistry.
void size(const label n)
Older name for setAddressableSize.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & name() const noexcept
Return the object name.
constexpr char nl
The newline '\n' character (0x0a)
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType >, DataType > &data) const
Check lagrangian data fieldfield.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple container for options an IOstream can normally have.
bool readStoreFile(const IOobject &io, const IOobject &ioNew) const
Helper function to store a cloud field on its registry.
static word cloudPropertiesName
Name of cloud properties dictionary.
#define forAll(list, i)
Loop across all elements in list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const word cloudName(propsDict.get< word >("cloud"))
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
A class for handling words, derived from Foam::string.
Functor wrapper of allow/deny lists of wordRe for filtering.
A List of wordRe with additional matching capabilities.
Cloud(const polyMesh &mesh, const Foam::zero, const word &cloudName)
Construct without particles.
errorManip< error > abort(error &err)
Base cloud calls templated on particle type.
#define DebugInfo
Report an information message using Foam::Info.
void writeFields(const fvMesh &mesh, const wordHashSet &selectedFields, const bool writeFaceFields)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c
Speed of light in a vacuum.
IOobject fieldIOobject(const word &fieldName, IOobjectOption::readOption rOpt=IOobjectOption::NO_READ) const
Helper to construct IOobject for field and current time.
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
A primitive field of type <T> with automated input and output.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
forAllConstIters(mixture.phases(), phase)
static constexpr const zero Zero
Global zero (0)
readOption
Enumeration defining read preferences.