49 const label lastMeshi = (meshes_.size() - 1);
53 meshi = (lastMeshi < 0 ? static_cast<label>(0) : lastMeshi);
56 if (meshi > lastMeshi)
59 <<
"Mesh " << meshi <<
" out of range: " << lastMeshi
63 return meshes_[meshi];
75 auto& gmesh = getMesh(meshi);
77 auto& bv = bufferViews_.create(
name);
78 bv.byteOffset() = bytes_;
79 bv.byteLength() =
fld.size()*3*
sizeof(float);
81 bytes_ += bv.byteLength();
83 auto& acc = accessors_.create(
name);
84 acc.bufferViewId() = bv.id();
87 auto& obj = objects_.create(
name);
95 bv.byteLength() +=
fld.size()*
sizeof(float);
96 bytes_ +=
fld.size()*
sizeof(float);
101 tmp<scalarField> talpha(
alpha);
108 obj.addData(
fld, talpha());
111 gmesh.addColour(acc.id());
119 animations_.create(
name);
120 return animations_.size() - 1;
126 const label animationi,
128 const label outputId,
133 if (animationi > animations_.size() - 1)
136 <<
"Animation " << animationi <<
" out of range " 137 << (animations_.size() - 1)
141 const label nodeId = meshId + 1;
145 if (nodeId > meshes_.size())
148 <<
"Node " << nodeId <<
" out of range " << meshes_.size()
152 animations_[animationi].addTranslation
187 auto& osbin = bin.stdStream();
189 label totalBytes = 0;
190 for (
const auto&
object : objects_.data())
192 for (
const auto& data :
object.data())
196 reinterpret_cast<const char*>(&data),
200 totalBytes +=
sizeof(float);
208 <<
indent <<
"\"generator\" : \"OpenFOAM - www.openfoam.com\"," <<
nl 237 const label nodeId = meshi + 1;
241 if (meshi != meshes_.size() - 1)
os <<
", ";
257 if (meshi != meshes_.size() - 1)
os <<
",";
266 bufferViews_.write(
os,
"bufferViews");
268 accessors_.write(
os,
"accessors");
270 animations_.write(
os,
"animations");
A class for handling file names.
Ostream & indent(Ostream &os)
Indent stream.
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.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void addToAnimation(const label animationi, const label inputId, const label outputId, const label meshId, const string &interpolation="LINEAR")
Add to existing animation.
static std::string path(const std::string &str)
Return directory path name (part before last /)
fileName & replace_ext(const word &ending)
Remove extension (if any) and append a new one.
#define forAll(list, i)
Loop across all elements in list.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
label createAnimation(const word &name)
Returns index of last animation.
scene()
Default construct.
A class for handling words, derived from Foam::string.
word name() const
Return basename (part beyond last /), including its extension.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
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))
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
label addColourToMesh(const vectorField &fld, const word &name, const label meshId, const scalarField &alpha=scalarField::null())
Add a colour field to the mesh, optionally with an alpha channel.
Abstract base class for volume field interpolation.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void write(const fileName &outputFile)
Write to file pair (.gltf, .bin)