15 const Float w =
exp(-(x - 0.5_f) / 0.0005_f);
18 }
else if (x < 0.48_f) {
21 return (x1 * w + x2) / (1._f * w + 1._f);
23 return (x > 0._f) ? x2 : x1;
33 Float delta = 2 * 0.0127_f;
34 Float dx1 = delta * rho2 / (rho1 + rho2);
35 Float dx2 = delta * rho1 / (rho1 + rho2);
37 for (
Float x = x1; x <= x2; x += dx) {
38 dx = (x < 0._f) ? dx1 : dx2;
54 main = makeAuto<TextOutput>(
Path(
"sod/sod_%d.txt"), name, flags);
55 analytic = makeAuto<TextOutput>(
Path(
"sod/sod_analytic_%d.txt"), name, flags);
62 analytic->
dump(an, stats);
63 return main->dump(storage, stats);
94 for (
Size i = 0; i < v.
size(); ++i) {
95 if (r[i][
X] > 0.5_f - eta) {
96 v[i] = dv[i] =
Vector(0._f);
99 u[i] = mat.getEos().getInternalEnergy(rho[i], p[i]);
101 }
else if (r[i][
X] < -0.5_f + eta) {
102 v[i] = dv[i] =
Vector(0._f);
105 u[i] = mat.getEos().getInternalEnergy(rho[i], p[i]);
108 v[i][
X] =
max(v[i][
X], 0._f);
155 const Float x1 = -0.5_f;
156 const Float x2 = 0.5_f;
165 for (
Size i = 0; i < r.size(); ++i) {
173 makeAuto<SummationSolver<1>>(*scheduler, settings,
EquationHolder{}, makeAuto<SodBc>(conf));
174 this->solver->create(*storage, storage->
getMaterial(0));
178 mat.
create(*storage, context);
184 for (
Size i = 0; i < r.size(); ++i) {
190 solver->integrate(*storage, stats);
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.
constexpr INLINE T max(const T &f1, const T &f2)
#define INLINE
Macros for conditional compilation based on selected compiler.
@ PRESSURE
Pressure, reduced by yielding and fracture model (multiplied by 1-damage); always a scalar quantity.
@ VELOCITY
Current velocities of particles, always a vector quantity.
@ POSITION
Positions of particles, always a vector quantity.
@ ENERGY
Specific internal energy, always a scalar quantity.
@ DENSITY
Density, always a scalar quantity.
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ ENERGY
Specific internal energy, always a scalar 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.
INLINE Float smoothingFunc(const Float x, const Float x1, const Float x2)
Array< Vector > sodDistribution(const Float x1, const Float x2, const Float rho1, const Float rho2, const Float eta)
TEST_CASE("Sod", "[sod]")
Storage analyticSod(const SodConfig &sod, const Float t)
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
Solver using direction summation to compute density and smoothing length.
BasicVector< Float > Vector
int main(int argc, char *argv[])
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Generic dynamically allocated resizable storage.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
INLINE TCounter size() const noexcept
Material holding equation of state.
const IEos & getEos() const
Returns the equation of state.
virtual void create(Storage &storage, const MaterialInitialContext &context) override
Create all quantities needed by the material.
Container holding equation terms.
Wrapper of type that either contains a value of given type, or an error message.
Base object for boundary conditions.
virtual Float getInternalEnergy(const Float rho, const Float p) const =0
Inverted function; computes specific internal energy u from given density rho and pressure p.
Interface for saving quantities of SPH particles to a file.
Defines the interface for a run.
Statistics run(Storage &storage)
Runs the simulation.
Object representing a 1D interval of real numbers.
INLINE IMaterial & material()
Returns the reference to the material of the particles.
Object representing a path on a filesystem.
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.
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.
SodBc(const SodConfig &sod)
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats) override
Saves data from particle storage into the file.
SodOutput(const std::string &name)
virtual void setUp(SharedPtr< Storage > storage) override
Prepares the run, creates logger, output, ...
virtual void tearDown(const Storage &UNUSED(storage), const Statistics &UNUSED(stats)) override
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value 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.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers from the storage, given its key and value type.
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.
virtual Expected< Path > dump(const Storage &storage, const Statistics &stats) override
Saves data from particle storage into the file.
@ PRESSURE
Use force from pressure gradient in the solver.
@ NONE
Gass or material with no stress tensor.
@ UNIFORM_GRID
Partitioning particles into a grid uniform in space.
@ COURANT
Time step determined using CFL condition.
@ PREDICTOR_CORRECTOR
Predictor-corrector scheme.
@ CUBIC_SPLINE
M4 B-spline (piecewise cubic polynomial)
@ IDEAL_GAS
Equation of state for ideal gas.
@ ENERGY_MIN
Estimated minimal value of energy used to determine timestepping error.
@ RHEOLOGY_DAMAGE
Model of fragmentation used within the rheological model.
@ DENSITY_RANGE
Allowed range of density. Densities of all particles all clamped to fit in the range.
@ ENERGY
Initial specific internal energy.
@ ADIABATIC_INDEX
Adiabatic index used by some equations of state (such as ideal gas)
@ DENSITY
Density at zero pressure.
@ SMOOTHING_LENGTH_ETA
Eta-factor between smoothing length and particle concentration (h = eta * n^(-1/d) )
@ EOS
Equation of state for this material, see EosEnum for options.
@ ENERGY_RANGE
Allowed range of specific internal energy.
@ RHEOLOGY_YIELDING
Model of stress reducing used within the rheological model.
@ RUN_OUTPUT_INTERVAL
Time interval of dumping data to disk.
@ TIMESTEPPING_MAX_TIMESTEP
@ SPH_KERNEL
Index of SPH Kernel, see KernelEnum.
@ SPH_SOLVER_FORCES
List of forces to compute by the solver.
@ SPH_AV_BETA
Artificial viscosity beta coefficient.
@ SPH_AV_ALPHA
Artificial viscosity alpha coefficient.
@ RUN_OUTPUT_PATH
Path where all output files (dumps, logs, ...) will be written.
@ TIMESTEPPING_INITIAL_TIMESTEP
@ TIMESTEPPING_INTEGRATOR
Selected timestepping integrator.
@ TIMESTEPPING_COURANT_NUMBER
Courant number.
@ SPH_FINDER
Structure for searching nearest neighbours of particles.
@ RUN_NAME
User-specified name of the run, used in some output files.
@ RUN_OUTPUT_NAME
File name of the output file (including extension), where d is a placeholder for output number.
AutoPtr< IMaterial > getMaterial(const BodySettings &settings)
Shared data used when creating all bodies in the simulation.
SharedPtr< IScheduler > scheduler