37 template<
class ParticleType>
43 template<
class ParticleType>
50 "uniform"/cloud::prefix/
name(),
52 IOobject::MUST_READ_IF_MODIFIED,
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_;
107 Pstream::listCombineReduce(np, maxEqOp<label>());
112 cloud::geometryTypeNames[geometryType_]
118 uniformPropsDict.add(procName, dictionary());
119 uniformPropsDict.subDict(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
176 geometryType_(
cloud::geometryType::COORDINATES)
180 (void)polyMesh_.tetBasePtIs();
181 (void)polyMesh_.oldCellCentres();
183 initCloud(checkClass);
189 template<
class ParticleType>
192 const word& fieldName,
202 IOobjectOption::NO_WRITE,
203 IOobjectOption::NO_REGISTER
208 template<
class ParticleType>
209 template<
class DataType>
216 if (
data.size() !=
c.size())
220 <<
" field " <<
data.size()
221 <<
" does not match the number of particles " <<
c.size()
227 template<
class ParticleType>
228 template<
class DataType>
231 const Cloud<ParticleType>&
c,
232 const CompactIOField<Field<DataType>, DataType>& data
235 if (data.
size() !=
c.size())
238 <<
"Size of " << data.
name()
239 <<
" field " << data.
size()
240 <<
" does not match the number of particles " <<
c.size()
246 template<
class ParticleType>
251 const IOobject& ioNew
254 if (
io.isHeaderClass<IOField<Type>>())
256 IOField<Type>
fld(
io);
257 auto* fldNewPtr =
new IOField<Type>(ioNew, std::move(
fld));
258 return fldNewPtr->store();
265 template<
class ParticleType>
277 IOobject::NO_REGISTER
285 const word& fldName =
io.name();
303 readStoreFile<label>(
io, ioNew)
304 || readStoreFile<scalar>(
io, ioNew)
305 || readStoreFile<vector>(
io, ioNew)
306 || readStoreFile<sphericalTensor>(
io, ioNew)
307 || readStoreFile<symmTensor>(
io, ioNew)
308 || readStoreFile<tensor>(
io, ioNew)
314 <<
"Unhandled field:" << fldName
315 <<
" type:" <<
io.headerClassName() <<
endl;
321 template<
class ParticleType>
328 template<
class ParticleType>
335 writeCloudUniformProperties();
338 return cloud::writeObject(streamOpt, (this->size() > 0));
344 template<
class ParticleType>
345 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.
Cloud(const polyMesh &mesh, const word &cloudName, const IDLList< ParticleType > &particles)
Construct from mesh and a list of particles.
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 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 cloud is a registry collection of lagrangian particles.
A List of wordRe with additional matching capabilities.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
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)
Database for solution data, solver performance and other reduced data.
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.
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.