SPH
Factory.cpp
Go to the documentation of this file.
1 #include "system/Factory.h"
2 #include "gravity/BarnesHut.h"
5 #include "gravity/Collision.h"
8 #include "io/LogWriter.h"
9 #include "io/Logger.h"
10 #include "io/Output.h"
11 #include "math/rng/Rng.h"
12 #include "objects/Exceptions.h"
15 #include "objects/finders/KdTree.h"
16 #include "objects/finders/Octree.h"
19 #include "physics/Damage.h"
20 #include "physics/Eos.h"
21 #include "physics/Rheology.h"
22 #include "sph/Materials.h"
23 #include "sph/boundary/Boundary.h"
29 #include "sph/initial/UvMapping.h"
39 #include "thread/OpenMp.h"
40 #include "thread/Pool.h"
41 #include "thread/Tbb.h"
44 
46 
48  const EosEnum id = body.get<EosEnum>(BodySettingsId::EOS);
49  switch (id) {
50  case EosEnum::IDEAL_GAS:
51  return makeAuto<IdealGasEos>(body.get<Float>(BodySettingsId::ADIABATIC_INDEX));
52  case EosEnum::TAIT:
53  return makeAuto<TaitEos>(body);
55  return makeAuto<MieGruneisenEos>(body);
56  case EosEnum::TILLOTSON:
57  return makeAuto<TillotsonEos>(body);
59  return makeAuto<SimplifiedTillotsonEos>(body);
60  case EosEnum::MURNAGHAN:
61  return makeAuto<MurnaghanEos>(body);
62  case EosEnum::NONE:
63  return nullptr;
64  default:
66  }
67 }
68 
71  switch (id) {
72  case YieldingEnum::NONE:
73  return nullptr;
75  return makeAuto<ElasticRheology>();
77  return makeAuto<VonMisesRheology>(Factory::getDamage(body));
79  return makeAuto<DruckerPragerRheology>(Factory::getDamage(body));
80  default:
82  }
83 }
84 
87  switch (id) {
88  case FractureEnum::NONE:
89  return makeAuto<NullFracture>();
91  return makeAuto<ScalarGradyKippModel>();
93  return makeAuto<TensorGradyKippModel>();
94  default:
96  }
97 }
98 
99 template <typename T>
100 AutoPtr<IEquationTerm> makeAV(const RunSettings& settings, const bool balsara) {
101  if (balsara) {
102  return makeAuto<BalsaraSwitch<T>>(settings);
103  } else {
104  return makeAuto<T>();
105  }
106 }
107 
110  const bool balsara = settings.get<bool>(RunSettingsId::SPH_AV_USE_BALSARA);
111  switch (id) {
113  return nullptr;
115  return makeAV<StandardAV>(settings, balsara);
117  return makeAV<RiemannAV>(settings, balsara);
119  return makeAV<MorrisMonaghanAV>(settings, balsara);
120  default:
122  }
123 }
124 
126  const SharedPtr<Storage>& storage) {
128  switch (id) {
130  return makeAuto<EulerExplicit>(storage, settings);
132  return makeAuto<PredictorCorrector>(storage, settings);
134  return makeAuto<LeapFrog>(storage, settings);
136  return makeAuto<BulirschStoer>(storage, settings);
138  return makeAuto<ModifiedMidpointMethod>(storage, settings);
140  return makeAuto<RungeKutta>(storage, settings);
141  default:
143  }
144 }
145 
147  const Flags<TimeStepCriterionEnum> flags =
149  if (flags == EMPTY_FLAGS) {
150  // no criterion
151  return nullptr;
152  }
153  return makeAuto<MultiCriterion>(settings);
154 }
155 
157  const FinderEnum id = settings.get<FinderEnum>(RunSettingsId::SPH_FINDER);
158  switch (id) {
160  return makeAuto<BruteForceFinder>();
161  case FinderEnum::KD_TREE: {
162  const Size leafSize = settings.get<int>(RunSettingsId::FINDER_LEAF_SIZE);
163  const Size maxDepth = settings.get<int>(RunSettingsId::FINDER_MAX_PARALLEL_DEPTH);
164  return makeAuto<KdTree<KdNode>>(leafSize, maxDepth);
165  }
166  case FinderEnum::OCTREE:
168  // return makeAuto<Octree>();
170  return makeAuto<UniformGridFinder>();
172  return makeAuto<HashMapFinder>(settings);
173  default:
175  }
176 }
177 
179  const Size threadCnt = settings.get<int>(RunSettingsId::RUN_THREAD_CNT);
180  const Size granularity = settings.get<int>(RunSettingsId::RUN_THREAD_GRANULARITY);
181  if (threadCnt == 1) {
182  // optimization - use directly SequentialScheduler instead of thread pool with 1 thread
184  } else {
185 #ifdef SPH_USE_TBB
187  scheduler->setGranularity(granularity);
188  return scheduler;
189 #elif SPH_USE_OPENMP
191  scheduler->setGranularity(granularity);
192  return scheduler;
193 #else
195  if (SharedPtr<ThreadPool> global = weakGlobal.lock()) {
196  if (global->getThreadCnt() == threadCnt) {
197  // scheduler is already used by some component and has the same thread count, we can reuse the
198  // instance instead of creating a new one
199  global->setGranularity(granularity);
200  return global;
201  }
202  }
203 
204  SharedPtr<ThreadPool> newPool = makeShared<ThreadPool>(threadCnt, granularity);
205  weakGlobal = newPool;
206  return newPool;
207 #endif
208  }
209 }
210 
212  const bool enableUvws = settings.get<bool>(RunSettingsId::GENERATE_UVWS);
213  if (!enableUvws) {
214  return nullptr;
215  }
216 
217  const UvMapEnum type = settings.get<UvMapEnum>(RunSettingsId::UVW_MAPPING);
218  switch (type) {
219  case UvMapEnum::PLANAR:
220  return makeAuto<PlanarUvMapping>();
222  return makeAuto<SphericalUvMapping>();
223  default:
225  }
226 }
227 
229  Function<bool(Float)> progressCallback) {
231  const bool center = body.get<bool>(BodySettingsId::CENTER_PARTICLES);
232  const bool sort = body.get<bool>(BodySettingsId::PARTICLE_SORTING);
233  const bool sph5mode = body.get<bool>(BodySettingsId::DISTRIBUTE_MODE_SPH5);
234  switch (id) {
237  flags.setIf(HexagonalPacking::Options::CENTER, center || sph5mode);
240  return makeAuto<HexagonalPacking>(flags, progressCallback);
241  }
243  return makeAuto<CubicPacking>();
246  return makeAuto<RandomDistribution>(1234);
248  return makeAuto<StratifiedDistribution>(1234);
250  DiehlParams diehl;
251  diehl.particleDensity = [](const Vector&) { return 1._f; };
254  return makeAuto<DiehlDistribution>(diehl);
255  }
257  return makeAuto<ParametrizedSpiralingDistribution>(1234);
259  return makeAuto<LinearDistribution>();
260  default:
262  }
263 }
264 
265 template <typename TSolver>
266 static AutoPtr<ISolver> getActualSolver(IScheduler& scheduler,
267  const RunSettings& settings,
268  EquationHolder&& eqs,
271  if (forces.has(ForceEnum::SELF_GRAVITY)) {
272  return makeAuto<GravitySolver<TSolver>>(scheduler, settings, std::move(eqs), std::move(bc));
273  } else {
274  return makeAuto<TSolver>(scheduler, settings, std::move(eqs), std::move(bc));
275  }
276 }
277 
279  return getSolver(scheduler, settings, makeAuto<NullBoundaryCondition>());
280 }
281 
283  const RunSettings& settings,
285  return getSolver(scheduler, settings, std::move(bc), {});
286 }
287 
289  const RunSettings& settings,
291  const EquationHolder& additionalTerms) {
292  EquationHolder eqs = getStandardEquations(settings, additionalTerms);
294  auto throwIfGravity = [&settings] {
296  if (forces.has(ForceEnum::SELF_GRAVITY)) {
297  throw InvalidSetup("Using solver incompatible with gravity.");
298  }
299  };
300  switch (id) {
302  return getActualSolver<SymmetricSolver<DIMENSIONS>>(
303  scheduler, settings, std::move(eqs), std::move(bc));
305  return getActualSolver<AsymmetricSolver>(scheduler, settings, std::move(eqs), std::move(bc));
307  return getActualSolver<EnergyConservingSolver>(scheduler, settings, std::move(eqs), std::move(bc));
309  throwIfGravity();
310  return makeAuto<ElasticDeformationSolver>(scheduler, settings, std::move(bc));
312  throwIfGravity();
313  return makeAuto<SummationSolver<DIMENSIONS>>(scheduler, settings);
315  throwIfGravity();
316  return makeAuto<DensityIndependentSolver>(scheduler, settings);
318  throwIfGravity();
319  return makeAuto<SimpleSolver>(scheduler, settings);
320  default:
322  }
323 }
324 
328  GravityLutKernel kernel;
329  switch (kernelId) {
331  // do nothing, keep default-constructed kernel
332  break;
334  kernel = Factory::getGravityKernel(settings);
335  break;
337  kernel = SolidSphereKernel();
338  break;
339  default:
341  }
342 
344  switch (id) {
346  gravity = makeAuto<SphericalGravity>();
347  break;
349  gravity = makeAuto<BruteForceGravity>(std::move(kernel));
350  break;
352  const Float theta = settings.get<Float>(RunSettingsId::GRAVITY_OPENING_ANGLE);
353  const MultipoleOrder order =
355  const Size leafSize = settings.get<int>(RunSettingsId::FINDER_LEAF_SIZE);
356  const Size maxDepth = settings.get<int>(RunSettingsId::FINDER_MAX_PARALLEL_DEPTH);
357  const Float constant = settings.get<Float>(RunSettingsId::GRAVITY_CONSTANT);
358  gravity = makeAuto<BarnesHut>(theta, order, std::move(kernel), leafSize, maxDepth, constant);
359  break;
360  }
361  default:
363  }
364 
365  // wrap gravity in case of symmetric boundary conditions
367  gravity = makeAuto<SymmetricGravity>(std::move(gravity));
368  }
369 
370  // wrap if gravity recomputation period is specified
372  if (period > 0._f) {
373  gravity = makeAuto<CachedGravity>(period, std::move(gravity));
374  }
375 
376  return gravity;
377 }
378 
381  switch (id) {
383  return nullptr;
385  return makeAuto<ElasticBounceHandler>(settings);
387  return makeAuto<MergingCollisionHandler>(0._f, 0._f);
389  return makeAuto<FallbackHandler<MergingCollisionHandler, ElasticBounceHandler>>(settings);
390  default:
392  }
393 }
394 
397  switch (id) {
398  case OverlapEnum::NONE:
399  return makeAuto<NullOverlapHandler>();
401  return makeAuto<MergeOverlapHandler>();
402  case OverlapEnum::REPEL:
403  return makeAuto<RepelHandler<ElasticBounceHandler>>(settings);
406  return makeAuto<RepelHandler<FollowupHandler>>(settings);
408  return makeAuto<InternalBounceHandler>(settings);
410  return makeAuto<MergeBoundHandler>(settings);
411  default:
413  }
414 }
415 
417  const DomainEnum id = settings.get<DomainEnum>(RunSettingsId::DOMAIN_TYPE);
418  const Vector center = settings.get<Vector>(RunSettingsId::DOMAIN_CENTER);
419  switch (id) {
420  case DomainEnum::NONE:
421  return nullptr;
422  case DomainEnum::BLOCK:
423  return makeAuto<BlockDomain>(center, settings.get<Vector>(RunSettingsId::DOMAIN_SIZE));
425  return makeAuto<CylindricalDomain>(center,
428  true);
430  return makeAuto<SphericalDomain>(center, settings.get<Float>(RunSettingsId::DOMAIN_RADIUS));
432  return makeAuto<EllipsoidalDomain>(center, settings.get<Vector>(RunSettingsId::DOMAIN_SIZE));
434  return makeAuto<HalfSpaceDomain>();
435  default:
437  }
438 }
439 
442  const Vector center = settings.get<Vector>(BodySettingsId::BODY_CENTER);
443  switch (id) {
445  return makeAuto<SphericalDomain>(center, settings.get<Float>(BodySettingsId::BODY_RADIUS));
446  case DomainEnum::BLOCK:
447  return makeAuto<BlockDomain>(center, settings.get<Vector>(BodySettingsId::BODY_DIMENSIONS));
449  return makeAuto<CylindricalDomain>(center,
452  true);
454  return makeAuto<EllipsoidalDomain>(center, settings.get<Vector>(BodySettingsId::BODY_DIMENSIONS));
455  default:
457  }
458 }
459 
461  SharedPtr<IDomain> domain) {
462  const BoundaryEnum id =
464 
465  switch (id) {
466  case BoundaryEnum::NONE:
467  return makeAuto<NullBoundaryCondition>();
469  SPH_ASSERT(domain != nullptr);
470  return makeAuto<GhostParticles>(std::move(domain), settings);
472  throw InvalidSetup("FixedParticles cannot be create from Factory, use manual setup.");
474  if (domain) {
476  return makeAuto<FrozenParticles>(std::move(domain), radius);
477  } else {
478  return makeAuto<FrozenParticles>();
479  }
481  SPH_ASSERT(domain != nullptr);
483  return makeAuto<WindTunnel>(std::move(domain), radius);
484  }
485  case BoundaryEnum::PERIODIC: {
486  const Box box = domain->getBoundingBox();
487  return makeAuto<PeriodicBoundary>(box);
488  }
490  return makeAuto<SymmetricBoundary>();
492  SPH_ASSERT(domain != nullptr);
493  return makeAuto<KillEscapersBoundary>(domain);
495  SPH_ASSERT(domain != nullptr);
496  const Box box = domain->getBoundingBox();
497  return makeAuto<Projection1D>(Interval(box.lower()[X], box.upper()[X]));
498  }
499  default:
501  }
502 }
503 
505  return getBoundaryConditions(settings, Factory::getDomain(settings));
506 }
507 
510  const EosEnum eosId = body.get<EosEnum>(BodySettingsId::EOS);
511  switch (yieldId) {
515  return makeAuto<SolidMaterial>(body);
516  case YieldingEnum::NONE:
517  switch (eosId) {
518  case EosEnum::NONE:
519  return makeAuto<NullMaterial>(body);
520  default:
521  return makeAuto<EosMaterial>(body);
522  }
523 
524  default:
526  }
527 }
528 
530  const LoggerEnum id = settings.get<LoggerEnum>(RunSettingsId::RUN_LOGGER);
531  switch (id) {
532  case LoggerEnum::NONE:
533  return makeAuto<NullLogger>();
534  case LoggerEnum::STD_OUT:
535  return makeAuto<StdOutLogger>();
536  case LoggerEnum::FILE: {
537  const Path path(settings.get<std::string>(RunSettingsId::RUN_LOGGER_FILE));
538  const Flags<FileLogger::Options> flags =
540  return makeAuto<FileLogger>(path, flags);
541  }
542  default:
544  }
545 }
546 
548  const int verbosity = clamp(settings.get<int>(RunSettingsId::RUN_LOGGER_VERBOSITY), 0, 3);
549  switch (verbosity) {
550  case 0:
551  return makeAuto<NullLogWriter>();
552  case 1:
553  return makeAuto<BriefLogWriter>(logger, settings);
554  case 2:
555  return makeAuto<StandardLogWriter>(logger, settings);
556  case 3:
557  return makeAuto<VerboseLogWriter>(logger, settings);
558  default:
560  }
561 }
562 
564  const IoEnum id = settings.get<IoEnum>(RunSettingsId::RUN_OUTPUT_TYPE);
565  const Path outputPath(settings.get<std::string>(RunSettingsId::RUN_OUTPUT_PATH));
566  const Path fileMask(settings.get<std::string>(RunSettingsId::RUN_OUTPUT_NAME));
567  const Size firstIndex = settings.get<int>(RunSettingsId::RUN_OUTPUT_FIRST_INDEX);
568  const OutputFile file(outputPath / fileMask, firstIndex);
569  switch (id) {
570  case IoEnum::NONE:
571  return makeAuto<NullOutput>();
572  case IoEnum::TEXT_FILE: {
573  const std::string name = settings.get<std::string>(RunSettingsId::RUN_NAME);
574  const Flags<OutputQuantityFlag> flags =
576  return makeAuto<TextOutput>(file, name, flags);
577  }
578  case IoEnum::BINARY_FILE: {
579  const RunTypeEnum runType = settings.get<RunTypeEnum>(RunSettingsId::RUN_TYPE);
580  return makeAuto<BinaryOutput>(file, runType);
581  }
583  const RunTypeEnum runType = settings.get<RunTypeEnum>(RunSettingsId::RUN_TYPE);
584  return makeAuto<CompressedOutput>(file, CompressionEnum::NONE /*TODO*/, runType);
585  }
586  case IoEnum::VTK_FILE: {
587  const Flags<OutputQuantityFlag> flags =
589  return makeAuto<VtkOutput>(file, flags);
590  }
591  case IoEnum::PKDGRAV_INPUT: {
592  PkdgravParams pkd;
594  return makeAuto<PkdgravOutput>(file, std::move(pkd));
595  }
596  default:
598  }
599 }
600 
602  const std::string ext = path.extension().native();
603  if (ext == "ssf") {
604  return makeAuto<BinaryInput>();
605  } else if (ext == "scf") {
606  return makeAuto<CompressedInput>();
607  } else if (ext == "h5") {
608  return makeAuto<Hdf5Input>();
609  } else if (ext == "tab") {
610  return makeAuto<TabInput>();
611  } else if (ext == "dat") {
612  return makeAuto<MpcorpInput>();
613  } else {
614  if (ext.size() > 3 && ext.substr(ext.size() - 3) == ".bt") {
615  return makeAuto<PkdgravInput>();
616  }
617  }
618  throw InvalidSetup("Unknown file type: " + path.native());
619 }
620 
622  const RngEnum id = settings.get<RngEnum>(RunSettingsId::RUN_RNG);
623  const int seed = settings.get<int>(RunSettingsId::RUN_RNG_SEED);
624  switch (id) {
625  case RngEnum::UNIFORM:
626  return makeAuto<RngWrapper<UniformRng>>(seed);
627  case RngEnum::HALTON:
628  return makeAuto<RngWrapper<HaltonQrng>>();
630  return makeAuto<RngWrapper<BenzAsphaugRng>>(seed);
631  default:
633  }
634 }
635 
636 template <Size D>
638  const KernelEnum id = settings.get<KernelEnum>(RunSettingsId::SPH_KERNEL);
639  switch (id) {
641  return CubicSpline<D>();
643  return FourthOrderSpline<D>();
645  return Gaussian<D>();
647  return TriangleKernel<D>();
649  SPH_ASSERT(D == 3);
650  // original core triangle has radius 1, rescale to 2 for drop-in replacement of cubic spline
651  return ScalingKernel<3, CoreTriangle>(2._f);
653  return ThomasCouchmanKernel<D>();
655  SPH_ASSERT(D == 3);
656  return WendlandC2();
658  SPH_ASSERT(D == 3);
659  return WendlandC4();
661  SPH_ASSERT(D == 3);
662  return WendlandC6();
663  default:
665  }
666 }
667 
668 template LutKernel<1> Factory::getKernel(const RunSettings& settings);
669 template LutKernel<2> Factory::getKernel(const RunSettings& settings);
670 template LutKernel<3> Factory::getKernel(const RunSettings& settings);
671 
673  const KernelEnum id = settings.get<KernelEnum>(RunSettingsId::SPH_KERNEL);
675  switch (id) {
692  default:
694  }
695 }
696 
#define SPH_ASSERT(x,...)
Definition: Assert.h:94
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Definition: Assert.h:100
SPH solver with asymmetric particle evaluation.
Implementation of the Balsara switch.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Barnes-Hut algorithm for computation of gravitational acceleration.
Boundary conditions.
Object finding nearest neighbours by evaluating all partice pairs.
Simple gravity solver evaluating all particle pairs.
Wrapper of other IGravity object that uses cached accelerations to speed-up the evaluation.
Collision handling.
const float radius
Definition: CurveDialog.cpp:18
Density-independent formulation of SPH.
Filling spatial domain with SPH particles.
Object defining computational domain.
Equations of state.
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
Smoothing kernels for including gravity into SPH.
auto getAssociatedGravityKernel(const TKernel &W, const Size resolution=40000)
Computes the gravitational softening kernel from the associated SPH kernel by integrating the Poisson...
SPH solver including gravity.
Finding neighbors using hash map.
K-d tree for efficient search of neighbouring particles.
Logging routines of the run.
SPH-specific implementation of particle materials.
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
Definition: MathBasic.h:35
MultipoleOrder
Definition: Moments.h:309
Time-dependent artificial viscosity by Morris & Monaghan (1997).
#define NAMESPACE_SPH_END
Definition: Object.h:12
Implementation of Octree algorithm for kNN queries.
Saving and loading particle data.
OutputQuantityFlag
List of quantities we can write to text output.
Definition: Output.h:108
RunTypeEnum
Type of simulation, stored as metadata in the binary file.
Definition: Output.h:237
Simple thread pool with fixed number of threads.
Rheology of materials.
Artificial viscosity based on Riemann solver.
Random number generators.
Simple model of gravity, valid only for homogeneous spheres.
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.
Standard SPH artificial viscosity.
Solver using direction summation to compute density and smoothing length.
Wrapper of gravity implementation to be used with symmetric boundary conditions.
Implements IScheduler interface using TBB.
Criteria for computing the time step.
Algorithms for temporal evolution of the physical model.
Simple algorithm for finding nearest neighbours using spatial partitioning of particles.
@ X
Definition: Vector.h:22
Helper object defining three-dimensional interval (box).
Definition: Box.h:17
INLINE const Vector & lower() const
Returns lower bounds of the box.
Definition: Box.h:82
INLINE const Vector & upper() const
Returns upper bounds of the box.
Definition: Box.h:94
Kernel proposed by Read et al. (2010) with improved stability.
Definition: Kernel.h:242
Cubic spline (M4) kernel.
Definition: Kernel.h:150
Container holding equation terms.
Definition: EquationTerm.h:238
Composite handler, choosing another collision handler if the primary handler rejects the collision by...
Definition: Collision.h:331
@ ADD_TIMESTAMP
Adds a time of writing before each message.
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
INLINE void setIf(const TEnum flag, const bool use)
Sets or removes given flag based given boolean value.
Definition: Flags.h:108
Fourth-order spline (M5) kernel.
Definition: Kernel.h:192
Gaussian kernel.
Definition: Kernel.h:420
Gravity smoothing kernels associated with standard SPH kernels.
Definition: GravityKernel.h:19
Gravitational kernel approximated by LUT for close particles.
Definition: GravityKernel.h:35
@ SORTED
Particles are sorted using its Morton code.
@ SPH5_COMPATIBILITY
Generates the grid to match code SPH5 for 1-1 comparison.
@ CENTER
Move particle lattice so that their center of mass matches center of domain.
virtual Box getBoundingBox() const =0
Returns the bounding box of the domain.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Definition: Scheduler.h:27
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
Thrown when components of the run are mutually incompatible.
Definition: Exceptions.h:24
A look-up table approximation of the kernel.
Definition: Kernel.h:51
static SharedPtr< OmpScheduler > getGlobalInstance()
Helper file generating file names for output files.
Definition: Output.h:21
Object representing a path on a filesystem.
Definition: Path.h:17
std::string native() const
Returns the native version of the path.
Definition: Path.cpp:71
Path extension() const
Returns the extension of the filename.
Definition: Path.cpp:59
Helper kernel wrapper that modifies the support of another kernel.
Definition: Kernel.h:485
static SharedPtr< SequentialScheduler > getGlobalInstance()
Definition: Scheduler.cpp:38
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
Gravity kernel of a solid sphere.
void setGranularity(const Size newGranularity)
static SharedPtr< Tbb > getGlobalInstance()
Kernel introduced by Thomas & Couchman (1992).
Definition: Kernel.h:286
static SharedPtr< ThreadPool > getGlobalInstance()
Returns the global instance of the thread pool.
Definition: Pool.cpp:211
Triangular (piecewise linear) kernel.
Definition: Kernel.h:452
SharedPtr< T > lock() const
Definition: SharedPtr.h:373
AutoPtr< IEquationTerm > makeAV(const RunSettings &settings, const bool balsara)
Definition: Factory.cpp:100
Creating code components based on values from settings.
CollisionHandlerEnum
Definition: Settings.h:808
@ NONE
No collision handling.
ForceEnum
Definition: Settings.h:658
@ SELF_GRAVITY
Use gravitational force in the model.
LoggerEnum
Definition: Settings.h:846
@ STD_OUT
Print log to standard output.
@ FILE
Print log to file.
@ NONE
Do not log anything.
YieldingEnum
Definition: Settings.h:743
@ ELASTIC
No yielding, just elastic deformations following Hooke's law.
@ NONE
Gass or material with no stress tensor.
@ VON_MISES
Von Mises criterion.
@ DRUCKER_PRAGER
Drucker-Prager pressure dependent yielding stress.
FinderEnum
Definition: Settings.h:584
@ UNIFORM_GRID
Partitioning particles into a grid uniform in space.
@ BRUTE_FORCE
Brute-force search by going through each pair of particles (O(N^2) complexity)
@ KD_TREE
Using K-d tree.
@ OCTREE
Using octree.
@ HASH_MAP
Using hash map.
RngEnum
Definition: Settings.h:929
@ HALTON
Halton QRNG.
@ UNIFORM
Mersenne Twister PRNG from Standard library.
@ BENZ_ASPHAUG
Same RNG as used in SPH5, used for 1-1 comparison.
TimeStepCriterionEnum
Definition: Settings.h:567
GravityEnum
Definition: Settings.h:785
@ BRUTE_FORCE
Brute-force summation over all particle pairs (O(N^2) complexity)
@ SPHERICAL
Approximated gravity, assuming the matter is a simple homogeneous sphere.
@ BARNES_HUT
Use Barnes-Hut algorithm, approximating gravity by multipole expansion (up to octupole order)
IoEnum
Definition: Settings.h:859
@ TEXT_FILE
Formatted human-readable text file.
@ BINARY_FILE
@ PKDGRAV_INPUT
Pkdgrav input file.
@ NONE
No input/output.
@ COMPRESSED_FILE
TimesteppingEnum
Definition: Settings.h:547
@ LEAP_FROG
Leap-frog 2nd-order integration.
@ MODIFIED_MIDPOINT
Modified midpoint method with constant number of substeps.
@ BULIRSCH_STOER
Bulirsch-Stoer integrator.
@ RUNGE_KUTTA
Runge-Kutta 4-th order integration.
@ PREDICTOR_CORRECTOR
Predictor-corrector scheme.
@ EULER_EXPLICIT
Explicit (forward) 1st-order integration.
UvMapEnum
Definition: Settings.h:940
@ PLANAR
Planar mapping.
@ SPHERICAL
Spherical mapping.
GravityKernelEnum
Definition: Settings.h:796
@ SPH_KERNEL
Use gravity smoothing kernel corresponding to selected SPH kernel.
@ POINT_PARTICLES
Point-like particles with zero radius.
OverlapEnum
Definition: Settings.h:826
@ INTERNAL_BOUNCE
Particles are allowed to overlap and they bounce if moving towards each other.
@ REPEL
Particles are shifted until no overlap happens.
@ NONE
All overlaps are ignored.
@ FORCE_MERGE
Overlapping particles are merged.
SolverEnum
Definition: Settings.h:697
@ SUMMATION_SOLVER
Density is obtained by direct summation over nearest SPH particles.
@ ENERGY_CONSERVING_SOLVER
Solver advancing internal energy using pair-wise work done by particles, by Owen (2009).
@ ELASTIC_DEFORMATION_SOLVER
Special solver used to simulate deformations of perfectly elastic bodies.
@ SYMMETRIC_SOLVER
SPH formulation using symmetrized evaluation of derivatives.
@ DENSITY_INDEPENDENT
Density independent solver by Saitoh & Makino (2013).
@ ASYMMETRIC_SOLVER
Generic solver evaluating all derivatives asymmetrically.
ArtificialViscosityEnum
Definition: Settings.h:683
@ RIEMANN
Artificial viscosity term analogous to Riemann solvers by Monaghan (1997)
@ MORRIS_MONAGHAN
Time-dependent artificial viscosity by Morris & Monaghan (1997).
@ STANDARD
Standard artificial viscosity term by Monaghan (1989).
@ NONE
No artificial viscosity.
DistributionEnum
Definition: Settings.h:1339
@ STRATIFIED
Stratified distribution to reduce clustering.
@ RANDOM
Random distribution of particles.
@ PARAMETRIZED_SPIRALING
Parametrized spiraling scheme by Saff & Kuijlaars (1997)
@ HEXAGONAL
Hexagonally close packing.
@ DIEHL_ET_AL
Isotropic uniform distribution by Diehl et al. (2012)
@ LINEAR
Distributes particles uniformly on line.
@ CUBIC
Cubic close packing.
KernelEnum
Definition: Settings.h:518
@ THOMAS_COUCHMAN
Modification of the standard M4 B-spline kernel, used to avoid particle clustering.
@ GAUSSIAN
Gaussian function.
@ FOURTH_ORDER_SPLINE
M5 B-spline (piecewise 4th-order polynomial)
@ CORE_TRIANGLE
Core Triangle (CT) kernel by Read et al. (2010)
@ WENDLAND_C2
Wendland kernel C2.
@ TRIANGLE
Simple triangle (piecewise linear) kernel.
@ WENDLAND_C6
Wendland kernel C6.
@ WENDLAND_C4
Wendland kernel C4.
@ CUBIC_SPLINE
M4 B-spline (piecewise cubic polynomial)
FractureEnum
Definition: Settings.h:757
@ SCALAR_GRADY_KIPP
Grady-Kipp model of fragmentation using scalar damage.
@ NONE
No fragmentation.
@ TENSOR_GRADY_KIPP
Grady-Kipp model of fragmentation using tensor damage.
EosEnum
Definition: Settings.h:1363
@ MIE_GRUNEISEN
Mie-Gruneisen equation of state.
@ TAIT
Tait equation of state for simulations of liquids.
@ IDEAL_GAS
Equation of state for ideal gas.
@ NONE
No equation of state.
@ TILLOTSON
Tillotson (1962) equation of state.
@ MURNAGHAN
Murnaghan equation of state.
@ SIMPLIFIED_TILLOTSON
Simplified version of the Tillotson equation of state.
@ BODY_CENTER
Center point of the body. Currently used only by StabilizationSolver.
@ DIEHL_STRENGTH
Strength parameter of the Diehl's distribution.
@ PARTICLE_SORTING
If true, particles are sorted using Morton code, preserving locality in memory.
@ RHEOLOGY_DAMAGE
Model of fragmentation used within the rheological model.
@ INITIAL_DISTRIBUTION
Initial distribution of SPH particles within the domain, see DistributionEnum for options.
@ ADIABATIC_INDEX
Adiabatic index used by some equations of state (such as ideal gas)
@ EOS
Equation of state for this material, see EosEnum for options.
@ RHEOLOGY_YIELDING
Model of stress reducing used within the rheological model.
BoundaryEnum
Definition: Settings.h:604
@ FIXED_PARTICLES
Creates dummy particles along the boundary.
@ SYMMETRIC
Particles are duplicated along the z=0 plane.
@ PROJECT_1D
Project all movement onto a line, effectivelly reducing the simulation to 1D.
@ KILL_ESCAPERS
Removes particles outside the domain.
@ GHOST_PARTICLES
Create ghosts to keep particles inside domain.
@ NONE
Do not use any boundary conditions (= vacuum conditions)
@ FROZEN_PARTICLES
Highest derivatives of all particles close to the boundary are set to zero.
@ PERIODIC
Periodic boundary conditions.
@ WIND_TUNNEL
Extension of Frozen Particles, pushing particles inside the domain and removing them on the other end...
@ RUN_OUTPUT_QUANTITIES
List of quantities to write to text output. Binary output always stores all quantitites.
@ DOMAIN_CENTER
Center point of the domain.
@ DOMAIN_HEIGHT
Height of a cylindrical domain.
@ RUN_LOGGER
Selected logger of a run, see LoggerEnum.
@ FINDER_LEAF_SIZE
Maximum number of particles in a leaf node.
@ SPH_KERNEL
Index of SPH Kernel, see KernelEnum.
@ GENERATE_UVWS
If true, the mapping coordinates will be computed and saved for all bodies in the simulation.
@ COLLISION_HANDLER
Specifies how the collisions of particles should be handler; see CollisionHandlerEnum.
@ SPH_SOLVER_FORCES
List of forces to compute by the solver.
@ RUN_THREAD_CNT
Number of threads used by the code. If 0, all available threads are used.
@ SPH_AV_TYPE
Type of used artificial viscosity.
@ RUN_LOGGER_FILE
Path of a file where the log is printed, used only when selected logger is LoggerEnum::FILE.
@ RUN_OUTPUT_PATH
Path where all output files (dumps, logs, ...) will be written.
@ DOMAIN_FROZEN_DIST
Distance to the boundary in units of smoothing length under which the particles are frozen.
@ SPH_SOLVER_TYPE
Selected solver for computing derivatives of physical variables.
@ GRAVITY_SOLVER
Algorithm to compute gravitational acceleration.
@ RUN_OUTPUT_TYPE
Selected format of the output file, see IoEnum.
@ UVW_MAPPING
Type of the UV mapping.
@ RUN_RNG
Selected random-number generator used within the run.
@ RUN_OUTPUT_FIRST_INDEX
Index of the first generated output file. Might not be zero if the simulation is resumed.
@ TIMESTEPPING_INTEGRATOR
Selected timestepping integrator.
@ GRAVITY_MULTIPOLE_ORDER
Order of multipole expansion.
@ SPH_FINDER
Structure for searching nearest neighbours of particles.
@ COLLISION_OVERLAP
Specifies how particle overlaps should be handled.
@ DOMAIN_TYPE
Computational domain, enforced by boundary conditions.
@ RUN_LOGGER_VERBOSITY
Number specifying log verbosity. Can be between 0 and 3, going from least to most verbose.
@ RUN_NAME
User-specified name of the run, used in some output files.
@ GRAVITY_RECOMPUTATION_PERIOD
@ GRAVITY_OPENING_ANGLE
Opening angle Theta for multipole approximation of gravity.
@ DOMAIN_SIZE
(Vector) size of a block domain
@ DOMAIN_BOUNDARY
Type of boundary conditions.
@ GRAVITY_CONSTANT
Gravitational constant. To be generalized.
@ GRAVITY_KERNEL
Gravity smoothing kernel.
@ DOMAIN_RADIUS
Radius of a spherical and cylindrical domain.
@ RUN_RNG_SEED
Seed for the random-number generator.
@ FINDER_MAX_PARALLEL_DEPTH
@ RUN_OUTPUT_NAME
File name of the output file (including extension), where d is a placeholder for output number.
DomainEnum
Definition: Settings.h:633
@ BLOCK
Block with edge sizes given by vector.
@ HALF_SPACE
Half-space z>0.
@ SPHERICAL
Sphere with given radius.
@ NONE
No computational domain (can only be used with BoundaryEnum::NONE)
@ ELLIPSOIDAL
Axis-aligned ellipsoid.
@ CYLINDER
Cylindrical domain aligned with z axis.
constexpr Float gravity
Gravitational constant (CODATA 2014)
Definition: Constants.h:29
AutoPtr< ITimeStepCriterion > getTimeStepCriterion(const RunSettings &settings)
Definition: Factory.cpp:146
AutoPtr< IGravity > getGravity(const RunSettings &settings)
Definition: Factory.cpp:325
AutoPtr< IOutput > getOutput(const RunSettings &settings)
Definition: Factory.cpp:563
AutoPtr< ISolver > getSolver(IScheduler &scheduler, const RunSettings &settings)
Definition: Factory.cpp:278
AutoPtr< IFractureModel > getDamage(const BodySettings &settings)
Definition: Factory.cpp:85
AutoPtr< IMaterial > getMaterial(const BodySettings &settings)
Definition: Factory.cpp:508
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
Definition: Factory.cpp:156
AutoPtr< ICollisionHandler > getCollisionHandler(const RunSettings &settings)
Definition: Factory.cpp:379
AutoPtr< IUvMapping > getUvMapping(const RunSettings &settings)
Definition: Factory.cpp:211
AutoPtr< IRheology > getRheology(const BodySettings &settings)
Definition: Factory.cpp:69
AutoPtr< IEquationTerm > getArtificialViscosity(const RunSettings &settings)
Definition: Factory.cpp:108
AutoPtr< IOverlapHandler > getOverlapHandler(const RunSettings &settings)
Definition: Factory.cpp:395
AutoPtr< ITimeStepping > getTimeStepping(const RunSettings &settings, const SharedPtr< Storage > &storage)
Definition: Factory.cpp:125
GravityLutKernel getGravityKernel(const RunSettings &settings)
Definition: Factory.cpp:672
AutoPtr< IDistribution > getDistribution(const BodySettings &settings, Function< bool(Float)> progressCallback=nullptr)
Definition: Factory.cpp:228
AutoPtr< ILogWriter > getLogWriter(SharedPtr< ILogger > logger, const RunSettings &settings)
Definition: Factory.cpp:547
AutoPtr< ILogger > getLogger(const RunSettings &settings)
Definition: Factory.cpp:529
AutoPtr< IEos > getEos(const BodySettings &settings)
Definition: Factory.cpp:47
AutoPtr< IDomain > getDomain(const RunSettings &settings)
Definition: Factory.cpp:416
AutoPtr< IRng > getRng(const RunSettings &settings)
Definition: Factory.cpp:621
LutKernel< D > getKernel(const RunSettings &settings)
Definition: Factory.cpp:637
AutoPtr< IBoundaryCondition > getBoundaryConditions(const RunSettings &settings, SharedPtr< IDomain > domain)
Definition: Factory.cpp:460
SharedPtr< IScheduler > getScheduler(const RunSettings &settings=RunSettings::getDefaults())
Definition: Factory.cpp:178
AutoPtr< IInput > getInput(const Path &path)
Definition: Factory.cpp:601
Parameters of DiehlDistribution.
Definition: Distribution.h:108
DensityFunc particleDensity
Function specifies the particle density in space.
Definition: Distribution.h:115
Float strength
Magnitude of a repulsive force between particles that moves them to their final locations.
Definition: Distribution.h:131
Size maxDifference
Allowed difference between the expected and actual number of particles.
Definition: Distribution.h:120
Vector omega
Definition: Output.h:516