SPH
StandardSets.cpp
Go to the documentation of this file.
3 #include "sph/equations/Fluids.h"
7 #include "sph/equations/XSph.h"
10 #include "system/Factory.h"
11 
13 
15  EquationHolder equations;
16 
17  if (settings.get<bool>(RunSettingsId::SPH_USE_XSPH)) {
18  // add XSPH as the very first term (it modifies velocities used by other terms)
19  equations += makeTerm<XSph>();
20  }
21 
24  if (forces.has(ForceEnum::PRESSURE)) {
25  equations += makeTerm<PressureForce>();
26 
27  if (forces.has(ForceEnum::NAVIER_STOKES)) {
28  equations += makeTerm<NavierStokesForce>();
29  } else if (forces.has(ForceEnum::SOLID_STRESS)) {
30  equations += makeTerm<SolidStressForce>(settings);
31  }
32  }
33 
34  if (forces.has(ForceEnum::INTERNAL_FRICTION)) {
38  equations += makeTerm<ViscousStress>();
39  }
40 
41  if (forces.has(ForceEnum::SURFACE_TENSION)) {
42  equations += makeTerm<CohesionTerm>();
43  }
44 
45  if (forces.has(ForceEnum::INERTIAL)) {
47  equations += makeTerm<InertialForce>(omega);
48  }
49 
51  if (g != Vector(0._f)) {
52  equations += makeExternalForce([g](const Vector& UNUSED(r), const Float UNUSED(t)) { return g; });
53  }
54 
55  const Float M = settings.get<Float>(RunSettingsId::FRAME_TIDES_MASS);
56  if (M != 0._f) {
58  const Vector dir = getNormalized(R);
59  equations += makeExternalForce([M, R, dir](const Vector& r, const Float UNUSED(t)) {
60  return Constants::gravity * M * dot(r, dir) * dir / pow<3>(getLength(R));
61  });
62  }
63 
64  if (settings.get<bool>(RunSettingsId::SPH_SCRIPT_ENABLE)) {
65  const Path scriptPath(settings.get<std::string>(RunSettingsId::SPH_SCRIPT_FILE));
66  const Float period = settings.get<Float>(RunSettingsId::SPH_SCRIPT_PERIOD);
67  const bool oneshot = settings.get<bool>(RunSettingsId::SPH_SCRIPT_ONESHOT);
68  equations += makeTerm<ChaiScriptTerm>(scriptPath, period, oneshot);
69  }
70 
71  equations += makeTerm<ContinuityEquation>(settings);
72 
73  if (settings.get<bool>(RunSettingsId::SPH_USE_DELTASPH)) {
74  equations += makeTerm<DeltaSph::DensityDiffusion>();
75  equations += makeTerm<DeltaSph::VelocityDiffusion>();
76  }
77 
78  // artificial viscosity
79  equations += EquationHolder(Factory::getArtificialViscosity(settings));
80 
81  if (settings.get<bool>(RunSettingsId::SPH_AV_USE_STRESS)) {
82  equations += makeTerm<StressAV>(settings);
83  }
84 
85  if (settings.get<bool>(RunSettingsId::SPH_USE_AC)) {
86  equations += makeTerm<ArtificialConductivity>(settings);
87  }
88 
89  // add all the additional equations
90  equations += other;
91 
92  // adaptivity of smoothing length should be last as it sets 4th component of velocities (and
93  // accelerations), this should be improved (similarly to derivatives - equation phases)
97  equations += makeTerm<AdaptiveSmoothingLength>(settings);
98  } else {
100  equations += makeTerm<ConstSmoothingLength>();
101  }
102 
103  return equations;
104 }
105 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Artificial thermal conductivity.
Delta-SPH modification of the standard SPH formulation.
Equations for simulations of water and other fluids.
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
Additional equation terms computing SPH statistics rather than physical quantities.
constexpr INLINE Float pow< 3 >(const Float v)
Definition: MathUtils.h:132
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
Additional forces that do not depend on spatial derivatives.
EquationHolder makeExternalForce(TFunctor &&functor)
Definition: Potentials.h:52
NAMESPACE_SPH_BEGIN EquationHolder getStandardEquations(const RunSettings &settings, const EquationHolder &other)
Standard SPH equation set, using density and specific energy as independent variables.
Standard SPH formulation that uses continuity equation for solution of density.
Form of tensor artificial viscosity for SPH with stress tensor.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
Definition: Vector.h:579
BasicVector< Float > Vector
Definition: Vector.h:539
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
Definition: Vector.h:548
INLINE Vector getNormalized(const Vector &v)
Definition: Vector.h:590
XSPH correction to the integration of particle positions.
Container holding equation terms.
Definition: EquationTerm.h:238
Wrapper of an integral value providing functions for reading and modifying individual bits.
Definition: Flags.h:20
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
Definition: Flags.h:77
Object representing a path on a filesystem.
Definition: Path.h:17
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.
Definition: Settings.h:326
Flags< TValue > getFlags(const TEnum idx) const
Returns Flags from underlying value stored in settings.
Definition: Settings.h:348
Creating code components based on values from settings.
ForceEnum
Definition: Settings.h:658
@ INTERNAL_FRICTION
Use internal friction given by the viscosity in the material.
@ INERTIAL
Use centrifugal force and Coriolis forces given by angular frequency of the coordinate frame.
@ PRESSURE
Use force from pressure gradient in the solver.
@ SURFACE_TENSION
Surface force proportional to surface curvature.
SmoothingLengthEnum
Definition: Settings.h:768
@ CONTINUITY_EQUATION
Smoothing length is evolved using continuity equation.
@ SPH_SCRIPT_FILE
Path of an arbitrary ChaiScript script executed each timestep.
@ SPH_USE_AC
Enables the artificial thermal conductivity term.
@ SPH_SOLVER_FORCES
List of forces to compute by the solver.
@ SPH_ADAPTIVE_SMOOTHING_LENGTH
Solution for evolutions of the smoothing length.
@ SPH_AV_USE_STRESS
Whether to use artificial stress.
@ SPH_USE_XSPH
Turn on the XSPH correction.
@ SPH_SCRIPT_ENABLE
Enables or disables scripted term.
@ SPH_USE_DELTASPH
Turn on the delta-SPH correction.
@ SPH_SCRIPT_ONESHOT
Whether to execute the script only once or periodically.
@ FRAME_CONSTANT_ACCELERATION
constexpr Float gravity
Gravitational constant (CODATA 2014)
Definition: Constants.h:29
AutoPtr< IEquationTerm > getArtificialViscosity(const RunSettings &settings)
Definition: Factory.cpp:108