7 #include "openvdb/openvdb.h"
22 io.
load(path, storage, stats);
27 return openvdb::Vec3R(v[
X], v[
Y], v[
Z]);
57 openvdb::GridPtrVec vdbGrids;
60 openvdb::FloatGrid::Ptr colorField = openvdb::FloatGrid::create(0._f);
61 openvdb::Vec3SGrid::Ptr velocityField = openvdb::Vec3SGrid::create(
vectorToVec3R(
Vector(0._f)));
62 openvdb::FloatGrid::Ptr energyField = openvdb::FloatGrid::create(0._f);
64 typename openvdb::FloatGrid::Accessor colorAccessor = colorField->getAccessor();
65 colorField->setName(
"Density");
66 colorField->setGridClass(openvdb::GRID_LEVEL_SET);
68 typename openvdb::Vec3SGrid::Accessor velocityAccessor = velocityField->getAccessor();
69 velocityField->setName(
"Velocity");
71 typename openvdb::FloatGrid::Accessor energyAccessor = energyField->getAccessor();
72 energyField->setName(
"Emission");
97 for (
Size i = 0; i < r.
size(); ++i) {
100 for (
int x = from[
X]; x <= to[
X]; ++x) {
101 for (
int y = from[
Y]; y <= to[
Y]; ++y) {
102 for (
int z = from[
Z]; z <= to[
Z]; ++z) {
106 const Float p = m[i] / 2700._f;
107 Record& record = grid[idxs];
108 record.density += p * w;
109 record.energy += u[i] * p * w;
122 ASSERT(
isReal(record.density));
123 ASSERT(
isReal(record.energy));
124 openvdb::Coord coords(idxs[0], idxs[1], idxs[2]);
129 colorAccessor.setValue(coords, record.density - params.
surfaceLevel);
134 const Float e = log(1._f + record.energy / record.density / u_iv);
135 energyAccessor.setValue(coords, e);
146 vdbGrids.push_back(colorField);
148 vdbGrids.push_back(energyField);
152 openvdb::io::File vdbFile(vdbPath.
native());
153 vdbFile.write(vdbGrids);
157 int main(
int argc,
char* argv[]) {
159 std::cout <<
"Usage: ssftovdb parentDir" << std::endl;
162 openvdb::initialize();
166 const Path directory(argv[1]);
167 std::set<Path> paths;
169 if (file.extension() !=
Path(
"ssf")) {
177 for (
Path file : paths) {
178 pool.
submit([¶ms, &mutex, file] {
180 std::unique_lock<std::mutex> lock(mutex);
181 std::cout <<
"Processing: " << file.native() << std::endl;
190 openvdb::uninitialize();
INLINE bool isReal(const AntisymmetricTensor &t)
Object representing a three-dimensional axis-aligned box.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Three-dimensional dynamically-allocated container.
Base class for all particle materials.
Vectorized computations with integral numbers.
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
INLINE auto floor(const T &f)
INLINE auto ceil(const T &f)
#define INLINE
Macros for conditional compilation based on selected compiler.
Saving and loading particle data.
Simple thread pool with fixed number of threads.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ ENERGY
Specific internal energy, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
int main(int argc, char *argv[])
Tuple< Indices, Indices > getParticleBox(const Vector &r, const VdbParams ¶ms)
Vector worldToRelative(const Vector &r, const VdbParams ¶ms)
INLINE openvdb::Vec3R vectorToVec3R(const Vector &v)
void convert(const Path &path, const VdbParams params)
Storage loadSsf(const Path &path)
Vector relativeToWorld(const Vector &r, const VdbParams ¶ms)
Statistics gathered and periodically displayed during the run.
Measuring time intervals and executing periodic events.
INLINE Tuple< TArgs &... > tieToTuple(TArgs &... args)
Creates a tuple of l-value references. Use IGNORE placeholder to omit one or more parameters.
BasicVector< Float > Vector
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Helper object defining three-dimensional interval (box).
INLINE const Vector & lower() const
Returns lower bounds of the box.
INLINE Vector size() const
Returns box dimensions.
Helper object for storing three (possibly four) int or bool values.
INLINE Float value(const Vector &r, const Float h) const noexcept
Object representing a path on a filesystem.
Path & replaceExtension(const std::string &newExtension)
Changes the extension of the file.
std::string native() const
Returns the native version of the path.
static const Settings & getDefaults()
\brief Returns a reference to object containing default values of all settings.
void iterate(const TFunctor &functor)
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Thread pool capable of executing tasks concurrently.
virtual SharedPtr< ITask > submit(const Function< void()> &task) override
Submits a task into the thread pool.
void waitForAll()
Blocks until all submitted tasks has been finished.
Heterogeneous container capable of storing a fixed number of values.
Creating code components based on values from settings.
@ TILLOTSON_ENERGY_IV
Specific energy of incipient vaporization.
DirectoryAdapter iterateDirectory(const Path &directory)