22 logger->write(runName,
" #", index,
" time = ", time);
33 const Float targetRadius = 1.e5_f;
40 const Float impactorRadius = 5.e4_f;
49 (targetRadius + impactorRadius) *
Vector(
cos(impactAngle),
sin(impactAngle), 0._f);
51 impactorPosition[
X] += 0.2_f * targetRadius;
72 io.
dump(*storage, stats);
75 logWriter = makeAuto<LogWriter>(settings);
81 io.
dump(storage, stats);
98 Storage spheres(std::move(material));
132 for (
Size i = 0; i < r_nbody.size(); ++i) {
133 r_nbody[i][
H] =
Sph::cbrt(3._f * m_sph[i] / (4._f *
PI * rho_sph[i]));
139 *storage = std::move(spheres);
147 solver = makeAuto<HardSphereSolver>(*scheduler, settings);
172 logWriter = makeAuto<LogWriter>(settings);
178 io.
dump(storage, stats);
188 fragmentation.
run(storage);
192 reaccumulation.
run(storage);
195 std::cout <<
"Error during simulation: " << e.
what() << std::endl;
INLINE AutoPtr< T > makeAuto(TArgs &&... args)
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.
INLINE Float cbrt(const Float f)
Returns a cubed root of a value.
constexpr Float DEG_TO_RAD
constexpr Float PI
Mathematical constants.
@ VELOCITY
Current velocities of particles, always a vector quantity.
@ POSITION
Positions of particles, always a vector quantity.
@ SMOOTHING_LENGTH
Smoothing lenghts of particles.
@ INDEX
Index of particle.
@ MASS
Particle masses, always a scalar quantity.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ SECOND
Quantity with 1st and 2nd derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
@ INDEX
Current number of time step, indexed from 0.
BasicVector< Float > Vector
Generic dynamically allocated resizable storage.
Array clone() const
Performs a deep copy of all elements of the array.
Output saving data to binary data without loss of precision.
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats) override
Saves data from particle storage into the file.
Non-owning view of particles belonging to the same body.
BodyView & addVelocity(const Vector &v)
Adds a velocity vector to all particles of the body.
virtual const char * what() const noexcept
virtual void setUp(SharedPtr< Storage > storage) override
Prepares the run, creates logger, output, ...
virtual void tearDown(const Storage &storage, const Statistics &stats) override
Called after the run.
Base class for objects logging run statistics.
Defines the interface for a run.
Statistics run(Storage &storage)
Runs the simulation.
Object for adding one or more bodies with given material into a Storage.
BodyView addMonolithicBody(Storage &storage, const BodySettings &body)
Creates a monolithic body by filling given domain with particles.
Custom writer of simulation log.
virtual void write(const Storage &UNUSED(storage), const Statistics &stats) override
LogWriter(const RunSettings &settings)
Object representing a path on a filesystem.
virtual void setUp(SharedPtr< Storage > storage) override
Prepares the run, creates logger, output, ...
virtual void tearDown(const Storage &storage, const Statistics &stats) override
Called after the run.
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
static const Settings & getDefaults()
\brief Returns a reference to object containing default values of all settings.
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.
Container storing all quantities used within the simulations.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
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.
@ COURANT
Time step determined using CFL condition.
@ ACCELERATION
Time step computed from ratio of acceleration and smoothing length.
@ LEAP_FROG
Leap-frog 2nd-order integration.
@ BODY_CENTER
Center point of the body. Currently used only by StabilizationSolver.
@ PARTICLE_COUNT
Number of SPH particles in the body.
@ RUN_OUTPUT_QUANTITIES
List of quantities to write to text output. Binary output always stores all quantitites.
@ TIMESTEPPING_MAX_TIMESTEP
@ COLLISION_HANDLER
Specifies how the collisions of particles should be handler; see CollisionHandlerEnum.
@ TIMESTEPPING_INTEGRATOR
Selected timestepping integrator.
@ COLLISION_OVERLAP
Specifies how particle overlaps should be handled.
@ RUN_NAME
User-specified name of the run, used in some output files.
@ GRAVITY_KERNEL
Gravity smoothing kernel.