SPH
CliffCollapse.cpp
Go to the documentation of this file.
1 
6 #include "Common.h"
7 #include "catch.hpp"
9 
10 using namespace Sph;
11 
12 class CliffCollapse : public IRun {
13 private:
14  // scale of the experiment; should only affect timestep.
15  static constexpr Float SCALE = 1.e3_f;
16 
17 public:
19  settings.set(RunSettingsId::RUN_NAME, std::string("Cliff Collapse Problem"))
23  .set(RunSettingsId::RUN_END_TIME, 200._f)
26  .set(RunSettingsId::RUN_OUTPUT_PATH, std::string("cliff_collapse"))
27  .set(RunSettingsId::RUN_OUTPUT_NAME, std::string("cliff_%d.ssf"))
34  .set(RunSettingsId::SPH_AV_ALPHA, 1.5_f)
35  .set(RunSettingsId::SPH_AV_BETA, 3._f)
46  .set(RunSettingsId::DOMAIN_CENTER, Vector(3._f, 3._f, 0._f) * SCALE)
47  .set(RunSettingsId::DOMAIN_SIZE, Vector(6.01_f, 6.01_f, 3.01_f) * SCALE);
48 
49  scheduler = Factory::getScheduler(settings);
50  }
51 
52  virtual void setUp(SharedPtr<Storage> storage) override {
53  Size N = 10000;
54 
55  BodySettings body;
56  body.set(BodySettingsId::ENERGY, 10._f)
71 
72  EquationHolder eqs = getStandardEquations(settings);
73  eqs += makeExternalForce([](const Vector UNUSED(r), const Float UNUSED(t)) { //
74  return Vector(0._f, -9.81_f, 0._f);
75  });
76 
77  AutoPtr<IDomain> boundary = Factory::getDomain(settings);
78  AutoPtr<GhostParticles> bc = makeAuto<GhostParticles>(std::move(boundary), settings);
79  bc->setVelocityOverride([](const Vector& r) -> Optional<Vector> {
80  if (r[Y] < 1.e3_f) {
81  return Vector(0._f); // zero velocity (=> friction)
82  } else {
83  return NOTHING;
84  }
85  });
86 
87  solver = makeAuto<AsymmetricSolver>(*scheduler, settings, eqs, std::move(bc));
88 
89  const Vector dimension = Vector(1._f, 3.2_f, 3._f) * SCALE;
90  BlockDomain block(0.5_f * Vector(dimension[X], dimension[Y], 0._f), dimension);
91  InitialConditions ic(settings);
92  ic.addMonolithicBody(*storage, block, body);
93  solver->create(*storage, storage->getMaterial(0));
94 
95  logWriter = makeAuto<NullLogWriter>();
96 
98  triggers.pushBack(makeAuto<ProgressLog>(10._f));
99  }
100 
101 protected:
102  virtual void tearDown(const Storage& storage, const Statistics& stats) override {
103  output->dump(storage, stats);
104  }
105 };
106 
107 TEST_CASE("Cliff Collapse", "[rheology]") {
108  Array<Path> filesToCheck = { Path("cliff_collapse/cliff_0000.ssf"),
109  Path("cliff_collapse/cliff_0001.ssf") };
110 
111  for (Path file : filesToCheck) {
113  }
114 
115  measureRun(Path("cliff_collapse/stats"), [] {
116  CliffCollapse run;
117  Storage storage;
118  run.run(storage);
119  });
120 
121  for (Path file : filesToCheck) {
122  REQUIRE(areFilesApproxEqual(file, REFERENCE_DIR / file.fileName()) == SUCCESS);
123  }
124 }
TEST_CASE("Cliff Collapse", "[rheology]")
void measureRun(const Path &file, Function< void()> run)
Definition: Common.cpp:67
Outcome areFilesApproxEqual(const Path &path1, const Path &path2)
Checks if two .ssf files are almost equal (may have eps-differences in quantities).
Definition: Common.cpp:29
const EmptyFlags EMPTY_FLAGS
Definition: Flags.h:16
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
constexpr Float INFTY
Definition: MathUtils.h:38
#define UNUSED(x)
Definition: Object.h:37
const NothingType NOTHING
Definition: Optional.h:16
const SuccessTag SUCCESS
Global constant for successful outcome.
Definition: Outcome.h:141
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.
constexpr int N
BasicVector< Float > Vector
Definition: Vector.h:539
@ Y
Definition: Vector.h:23
@ X
Definition: Vector.h:22
Generic dynamically allocated resizable storage.
Definition: Array.h:43
Block aligned with coordinate axes, defined by its center and length of each side.
Definition: Domain.h:185
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.
Container holding equation terms.
Definition: EquationTerm.h:238
Defines the interface for a run.
Definition: IRun.h:61
Statistics run(Storage &storage)
Runs the simulation.
Definition: IRun.cpp:187
Object for adding one or more bodies with given material into a Storage.
Definition: Initial.h:106
BodyView addMonolithicBody(Storage &storage, const BodySettings &body)
Creates a monolithic body by filling given domain with particles.
Definition: Initial.cpp:81
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
Wrapper of type value of which may or may not be present.
Definition: Optional.h:23
Object representing a path on a filesystem.
Definition: Path.h:17
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.
Definition: Settings.h:226
Object holding various statistics about current run.
Definition: Statistics.h:22
Container storing all quantities used within the simulations.
Definition: Storage.h:230
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Definition: Storage.cpp:366
@ PRESSURE
Use force from pressure gradient in the solver.
@ DRUCKER_PRAGER
Drucker-Prager pressure dependent yielding stress.
@ KD_TREE
Using K-d tree.
@ BINARY_FILE
@ PREDICTOR_CORRECTOR
Predictor-corrector scheme.
@ STANDARD
P_i / rho_i^2 + P_j / rho_j^2.
@ ASYMMETRIC_SOLVER
Generic solver evaluating all derivatives asymmetrically.
@ STANDARD
Standard artificial viscosity term by Monaghan (1989).
@ HEXAGONAL
Hexagonally close packing.
@ CUBIC_SPLINE
M4 B-spline (piecewise cubic polynomial)
@ SCALAR_GRADY_KIPP
Grady-Kipp model of fragmentation using scalar damage.
@ TILLOTSON
Tillotson (1962) equation of state.
@ DRY_FRICTION
Coefficient of friction for fully damaged material.
@ MELT_ENERGY
Melting energy, used for temperature-dependence of the stress tensor.
@ ENERGY_MIN
Estimated minimal value of energy used to determine timestepping error.
@ DAMAGE_MIN
Estimate minimal value of damage used to determine timestepping error.
@ RHEOLOGY_DAMAGE
Model of fragmentation used within the rheological model.
@ INITIAL_DISTRIBUTION
Initial distribution of SPH particles within the domain, see DistributionEnum for options.
@ DAMAGE
Initial damage of the body.
@ ENERGY
Initial specific internal energy.
@ SHEAR_MODULUS
Shear modulus mu (a.k.a Lame's second parameter) of the material.
@ PARTICLE_COUNT
Number of SPH particles in the body.
@ STRESS_TENSOR_MIN
Estimated minial value of stress tensor components used to determined timestepping error.
@ 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.
@ GHOST_PARTICLES
Create ghosts to keep particles inside domain.
@ DOMAIN_CENTER
Center point of the domain.
@ SPH_STRAIN_RATE_CORRECTION_TENSOR
@ RUN_OUTPUT_INTERVAL
Time interval of dumping data to disk.
@ TIMESTEPPING_MAX_TIMESTEP
@ DOMAIN_GHOST_MIN_DIST
Minimal distance between a particle and its ghost, in units of smoothing length.
@ SPH_KERNEL
Index of SPH Kernel, see KernelEnum.
@ SPH_SOLVER_FORCES
List of forces to compute by the solver.
@ SPH_AV_TYPE
Type of used artificial viscosity.
@ 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.
@ SPH_SOLVER_TYPE
Selected solver for computing derivatives of physical variables.
@ TIMESTEPPING_INITIAL_TIMESTEP
@ SPH_ADAPTIVE_SMOOTHING_LENGTH
Solution for evolutions of the smoothing length.
@ SPH_AV_USE_STRESS
Whether to use artificial stress.
@ TIMESTEPPING_DERIVATIVE_FACTOR
Multiplicative factor k for the derivative criterion; dt = k * v / dv.
@ SPH_DISCRETIZATION
Specifies a discretization of SPH equations; see DiscretizationEnum.
@ RUN_OUTPUT_TYPE
Selected format of the output file, see IoEnum.
@ TIMESTEPPING_INTEGRATOR
Selected timestepping integrator.
@ TIMESTEPPING_COURANT_NUMBER
Courant number.
@ SPH_FINDER
Structure for searching nearest neighbours of particles.
@ DOMAIN_TYPE
Computational domain, enforced by boundary conditions.
@ RUN_NAME
User-specified name of the run, used in some output files.
@ DOMAIN_SIZE
(Vector) size of a block domain
@ DOMAIN_BOUNDARY
Type of boundary conditions.
@ RUN_OUTPUT_NAME
File name of the output file (including extension), where d is a placeholder for output number.
@ BLOCK
Block with edge sizes given by vector.
AutoPtr< IDomain > getDomain(const RunSettings &settings)
Definition: Factory.cpp:416
SharedPtr< IScheduler > getScheduler(const RunSettings &settings=RunSettings::getDefaults())
Definition: Factory.cpp:178
Outcome removePath(const Path &path, const Flags< RemovePathFlag > flags=EMPTY_FLAGS)
Definition: FileSystem.cpp:137
Definition: MemoryPool.h:5