37template<
class ParticleType>
43template<
class ParticleType>
44void Foam::Cloud<ParticleType>::readCloudUniformProperties()
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;
87template<
class ParticleType>
88void Foam::Cloud<ParticleType>::writeCloudUniformProperties()
const
90 IOdictionary uniformPropsDict
96 "uniform"/cloud::prefix/
name(),
100 IOobject::NO_REGISTER
105 np[UPstream::myProcNo()] = ParticleType::particleCount_;
106 Pstream::allGatherList(np);
111 cloud::geometryTypeNames[geometryType_]
116 const word procName(
"processor" +
Foam::name(i));
117 uniformPropsDict.subDictOrAdd(procName).add(
"particleCount", np[i]);
120 uniformPropsDict.writeObject
122 IOstreamOption(IOstreamOption::ASCII, time().writeCompression()),
128template<
class ParticleType>
129void Foam::Cloud<ParticleType>::initCloud(
const bool checkClass)
131 readCloudUniformProperties();
133 IOPosition<Cloud<ParticleType>> ioP(*
this, geometryType_);
135 const bool haveFile = ioP.headerOk();
136 Istream& is = ioP.readStream(checkClass ? typeName : word::null, haveFile);
139 ioP.readData(is, *
this);
143 if (!haveFile && debug)
145 Pout<<
"Not reading particle positions file: "
146 << ioP.objectRelPath() <<
nl
147 <<
"Assuming the initial cloud contains 0 particles." <<
endl;
151 geometryType_ = cloud::geometryType::COORDINATES;
156 (void)polyMesh_.tetBasePtIs();
162template<
class ParticleType>
167 const bool checkClass
172 initCloud(checkClass);
178template<
class ParticleType>
179template<
class DataType>
186 if (data.
size() != c.size())
189 <<
"Size of " << data.
name()
190 <<
" field " << data.
size()
191 <<
" does not match the number of particles " << c.size()
197template<
class ParticleType>
198template<
class DataType>
201 const Cloud<ParticleType>& c,
202 const CompactIOField<Field<DataType>>& data
205 if (data.size() != c.size())
208 <<
"Size of " << data.name()
209 <<
" field " << data.size()
210 <<
" does not match the number of particles " << c.size()
216template<
class ParticleType>
221 const IOobject& ioNew
224 if (
io.isHeaderClass<IOField<Type>>())
226 IOField<Type>
fld(
io);
227 auto* fldNewPtr =
new IOField<Type>(ioNew, std::move(
fld));
228 return fldNewPtr->store();
235template<
class ParticleType>
239 const wordRes& selectFields,
243 IOobjectList cloudObjects
254 const IOobject&
io = *(iter.val());
255 const word& fldName =
io.name();
273 readStoreFile<label>(
io, ioNew)
274 || readStoreFile<scalar>(
io, ioNew)
275 || readStoreFile<vector>(
io, ioNew)
276 || readStoreFile<sphericalTensor>(
io, ioNew)
277 || readStoreFile<symmTensor>(
io, ioNew)
278 || readStoreFile<tensor>(
io, ioNew)
284 <<
"Unhandled field:" << fldName
285 <<
" type:" <<
io.headerClassName() <<
endl;
291template<
class ParticleType>
294 ParticleType::writeFields(*
this);
298template<
class ParticleType>
305 writeCloudUniformProperties();
314template<
class ParticleType>
const word cloudName(propsDict.get< word >("cloud"))
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Base cloud calls templated on particle type.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
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.
void readFromFiles(objectRegistry &obr, const wordRes &selectFields, const wordRes &excludeFields=wordRes::null()) const
Read from files into objectRegistry.
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
Cloud(const polyMesh &mesh, const Foam::zero, const word &cloudName)
Construct without particles.
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
const polyMesh & pMesh() const noexcept
Return the polyMesh reference.
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType > > &data) const
Check lagrangian data fieldfield.
A Field of objects of type <T> with automated input and output using a compact storage....
label size() const noexcept
The number of elements in list.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A primitive field of type <T> with automated input and output.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
A simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void size(const label n)
Older name for setAddressableSize.
Registry of regIOobjects.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write the objects using stream options.
const Time & time() const noexcept
Return time registry.
Mesh consisting of general polyhedral cells.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
List< label > labelList
A List of labels.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
void writeFields(const fvMesh &mesh, const wordHashSet &selectedFields, const bool writeFaceFields)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Functor wrapper of allow/deny lists of wordRe for filtering.