29 cat.
connect(
"File",
"file", path)
32 cat.
connect(
"Unit system",
"units", units);
38 throw InvalidSetup(
"File '" + path.
native() +
"' does not exist or cannot be accessed.");
43 Outcome outcome = input->load(path, storage, stats);
48 result = makeShared<ParticleData>();
86 [](
const std::string&
UNUSED(name)) {
return makeAuto<LoadFileJob>(); },
87 "Loads particle state from a file");
98 inputCat.
connect(
"First file",
"first_file", firstFile)
101 inputCat.
connect(
"Maximum framerate",
"max_fps", maxFps);
114 if (!referenceMask) {
123 const Path path = dir / relativePath;
125 if (pathMask && pathMask->getMask() == referenceMask->getMask()) {
145 const Size firstIndex = sequence.
begin()->key;
146 const Size lastIndex = (sequence.
end() - 1)->key;
147 for (
auto& element : sequence) {
148 const Size index = element.key;
151 Outcome outcome = input->load(element.value, storage, stats);
157 if (sequence.
size() > 1) {
163 if (index == firstIndex) {
164 callbacks.
onSetUp(storage, stats);
173 const Size minElapsed = 1000 / maxFps;
174 if (elapsed < minElapsed) {
175 std::this_thread::sleep_for(std::chrono::milliseconds(minElapsed - elapsed));
179 result = makeShared<ParticleData>();
188 [](
const std::string& name) {
return makeAuto<FileSequenceJob>(name); },
189 "Loads and displays a sequence of particle states.");
234 [](
const std::string& name) {
return makeAuto<SaveFileJob>(name); },
235 "Saves the input particle state into a file.");
246 outputCat.
connect(
"File",
"file", path)
249 {
"Wavefront OBJ file",
"obj" },
250 {
"Stanford PLY file",
"ply" },
254 meshCat.
connect<
Float>(
"Resolution",
"resolution", resolution);
255 meshCat.
connect<
Float>(
"Surface level",
"level", level);
256 meshCat.
connect<
Float>(
"Smoothing multiplier",
"smoothing_mult", smoothingMult);
257 meshCat.
connect<
bool>(
"Refine mesh",
"refine", refine);
258 meshCat.
connect<
bool>(
"Anisotropic kernels",
"aniso", anisotropic);
259 meshCat.
connect<
bool>(
"Scale to unit size",
"scale_to_unit", scaleToUnit);
288 for (
Size i = 0; i < 3; ++i) {
289 t[i] = (t[i] - bbox.
center()) / boxSize;
296 for (
Size i = 0; i < 5; ++i) {
303 Outcome outcome = saver->save(path, std::move(triangles));
314 [](
const std::string& name) {
return makeAuto<SaveMeshJob>(name); },
315 "Creates a triangular mesh from the input particles and saves it to file.");
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
INLINE Float maxElement(const T &value)
Returns maximum element, simply the value iself by default.
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.
Basic interface defining a single run.
FlatMap< Size, Path > getFileSequence(const Path &firstFile)
VirtualSettings::Category & addGenericCategory(VirtualSettings &connector, std::string &instanceName)
Adds a common settings category, used by all jobs.
Array< Triangle > getSurfaceMesh(IScheduler &scheduler, const Storage &storage, const McConfig &config)
Returns the triangle mesh of the body surface (or surfaces of bodies).
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
AutoPtr< IMeshFile > getMeshFile(const Path &path)
Deduces mesh type from extension of given path.
void refineMesh(Mesh &mesh)
Improves mesh quality using edge flips (valence equalization) and tangential relaxation.
Mesh getMeshFromTriangles(ArrayView< const Triangle > triangles, const Float eps)
Converts array of triangles into a mesh.
Array< Triangle > getTrianglesFromMesh(const Mesh &mesh)
Expands the mesh into an array of triangles.
#define NAMESPACE_SPH_END
Saving and loading particle data.
@ VELOCITY
Current velocities of particles, always a vector quantity.
@ POSITION
Positions of particles, always a vector quantity.
Statistics gathered and periodically displayed during the run.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
@ TIMESTEP_VALUE
Current value of timestep.
@ INDEX
Current number of time step, indexed from 0.
Box getBoundingBox(const Storage &storage, const Float radius)
Convenience function to get the bounding box of all particles.
Measuring time intervals and executing periodic events.
Array< IVirtualEntry::FileFormat > getInputFormats()
Convenience function, returning the list of input file formats defined by IoEnum.
Array< IVirtualEntry::FileFormat > getOutputFormats()
Convenience function, returning the list of output file formats defined by IoEnum.
Wrapper of pointer that deletes the resource from destructor.
INLINE const TError & error() const
Returns the error message.
Helper object defining three-dimensional interval (box).
INLINE Vector center() const
Returns the center of the box.
INLINE Vector size() const
Returns box dimensions.
EntryControl & setPathType(const PathType &newType)
Sets the type of the path.
EntryControl & setFileFormats(Array< FileFormat > &&formats)
Sets the allowed file formats.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
Container of key-value pairs.
INLINE Iterator< Element > end()
Returns the iterator pointing to the one-past-last element.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
INLINE Iterator< Element > begin()
Returns the iterator pointing to the first element.
INLINE Size size() const
Returns the number of elements in the map.
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats)=0
Saves data from particle storage into the file.
Base class for all jobs providing particle data.
SharedPtr< ParticleData > result
Data filled by the job when it finishes.
Callbacks executed by the simulation to provide feedback to the user.
virtual bool shouldAbortRun() const =0
Returns whether current run should be aborted or not.
virtual void onSetUp(const Storage &storage, Statistics &stats)=0
Called right before the run starts, i.e. after initial conditions are set up.
virtual void onTimeStep(const Storage &storage, Statistics &stats)=0
Called every timestep.
Thrown when components of the run are mutually incompatible.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
INLINE Type & value()
Returns the reference to the stored value.
static Optional< Size > getDumpIdx(const Path &path)
Extracts the dump index from given path generated by OutputFile.
static Optional< OutputFile > getMaskFromPath(const Path &path, const Size firstDumpIdx=0)
Attemps to get the OutputFile from one of the path generated from it.
Object representing a path on a filesystem.
std::string native() const
Returns the native version of the path.
Path parentPath() const
Returns the parent directory. If the path is empty or root, return empty path.
SaveFileJob(const std::string &name)
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
Settings & set(const TEnum idx, TValue &&value, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0)
Saves a value into the settings.
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value of a statistic.
Statistics & set(const StatisticsId idx, TValue &&value)
Sets new values of a statistic.
bool has(const StatisticsId idx) const
Checks if the object contains a statistic with given ID.
Container storing all quantities used within the simulations.
Basic time-measuring tool. Starts automatically when constructed.
int64_t elapsed(const TimerUnit unit) const
Returns elapsed time in timer units. Does not reset the timer.
EntryControl & connect(const std::string &name, const std::string &key, TValue &value)
Connects to given reference.
Holds a map of virtual entries, associated with a unique name.
Category & addCategory(const std::string &name)
Creates a new category of entries.
Creating code components based on values from settings.
@ TEXT_FILE
Formatted human-readable text file.
@ RUN_OUTPUT_QUANTITIES
List of quantities to write to text output. Binary output always stores all quantitites.
@ RUN_OUTPUT_PATH
Path where all output files (dumps, logs, ...) will be written.
@ TIMESTEPPING_INITIAL_TIMESTEP
@ RUN_OUTPUT_TYPE
Selected format of the output file, see IoEnum.
@ RUN_OUTPUT_FIRST_INDEX
Index of the first generated output file. Might not be zero if the simulation is resumed.
@ GRAVITY_CONSTANT
Gravitational constant. To be generalized.
@ RUN_OUTPUT_NAME
File name of the output file (including extension), where d is a placeholder for output number.
constexpr Float gravity
Gravitational constant (CODATA 2014)
AutoPtr< IOutput > getOutput(const RunSettings &settings)
SharedPtr< IScheduler > getScheduler(const RunSettings &settings=RunSettings::getDefaults())
AutoPtr< IInput > getInput(const Path &path)
bool pathExists(const Path &path)
Checks if a file or directory exists (or more precisely, if a file or directory is accessible).
DirectoryAdapter iterateDirectory(const Path &directory)
Helper class, allowing to register job into the global list of jobs.
Function< bool(Float progress)> progressCallback
Generic functor called during MC evaluation.
Float smoothingMult
Multiplier of the smoothing lengths.
Float gridResolution
Absolute size of each produced triangle.
bool useAnisotropicKernels
If true, anisotropic kernels of Yu & Turk (2010) are used instead of normal isotropic kernels.
Storage storage
Holds all particle positions and other quantities.
Statistics stats
Final statistics of the simulation.
RunSettings overrides
Overrides associated with the particle state.
Helper class for adding individual enums to the enum map.