SPH
Initial.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "common/ForwardDecl.h"
12 #include "quantities/IMaterial.h"
13 
15 
20 class BodyView {
21 private:
23  RawPtr<Storage> storage;
24 
26  Size bodyIndex;
27 
28 public:
29  BodyView(Storage& storage, const Size bodyIndex);
30 
36  BodyView& displace(const Vector& dr);
37 
44  BodyView& addVelocity(const Vector& v);
45 
47  enum class RotationOrigin {
48  FRAME_ORIGIN,
50  };
51 
58  BodyView& addRotation(const Vector& omega, const RotationOrigin origin);
59 
66  BodyView& addRotation(const Vector& omega, const Vector& origin);
67 
68 private:
69  Vector getOrigin(const RotationOrigin origin) const;
70 };
71 
73 struct PowerLawSfd {
79 
82 
87  INLINE Float operator()(const Float x) const {
88  SPH_ASSERT(x >= 0._f && x <= 1._f);
89  SPH_ASSERT(exponent != 1._f);
90  const Float Rmin = pow(interval.lower(), 1._f - exponent);
91  const Float Rmax = pow(interval.upper(), 1._f - exponent);
92  const Float R = pow((Rmax - Rmin) * x + Rmin, 1._f / (1._f - exponent));
93  SPH_ASSERT(R >= interval.lower() && R <= interval.upper(), R);
94  return R;
95  }
96 };
97 
98 
107 private:
109  MaterialInitialContext context;
110 
112  Size bodyIndex = 0;
113 
114 public:
118  explicit InitialConditions(const RunSettings& settings);
119 
121 
129  BodyView addMonolithicBody(Storage& storage, const BodySettings& body);
130 
141  BodyView addMonolithicBody(Storage& storage, const IDomain& domain, const BodySettings& body);
142 
145  BodyView addMonolithicBody(Storage& storage, const IDomain& domain, SharedPtr<IMaterial> material);
146 
148  const IDomain& domain,
149  SharedPtr<IMaterial> material,
150  const IDistribution& distribution);
151 
152 
154  struct BodySetup {
157 
160 
163 
166 
168  };
169 
183  const BodySetup& environment,
185 
202  void addRubblePileBody(Storage& storage,
203  const IDomain& domain,
204  const PowerLawSfd& sfd,
205  const BodySettings& bodySettings);
206 
207 private:
209  void setQuantities(Storage& storage, IMaterial& material, const Float volume);
210 };
211 
218 
226 
229 void moveToCenterOfMassSystem(Storage& storage);
230 
Simple non-owning view of a container.
#define SPH_ASSERT(x,...)
Definition: Assert.h:94
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
const float radius
Definition: CurveDialog.cpp:18
Generic wrappers of lambdas, functors and other callables.
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
Base class for all particle materials.
Vector moveToCenterOfMassSystem(ArrayView< const Float > m, ArrayView< Vector > r)
Modifies particle positions so that their center of mass lies at the origin.
Definition: Initial.cpp:363
void repelParticles(ArrayView< Vector > r, const Float radius)
Displaces particles so that no two particles overlap.
Definition: Initial.cpp:335
constexpr INLINE Float pow(const Float v)
Power for floats.
#define INLINE
Macros for conditional compilation based on selected compiler.
Definition: Object.h:31
#define NAMESPACE_SPH_END
Definition: Object.h:12
Basic vector algebra. Computations are accelerated using SIMD.
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
Non-owning view of particles belonging to the same body.
Definition: Initial.h:20
RotationOrigin
Predefined types of center point.
Definition: Initial.h:47
@ CENTER_OF_MASS
Rotate the body around its center of mass.
@ FRAME_ORIGIN
Add angular velocity with respect to origin of coordinates.
BodyView(Storage &storage, const Size bodyIndex)
Definition: Initial.cpp:19
BodyView & addRotation(const Vector &omega, const RotationOrigin origin)
Adds an angular velocity to all particles of the body.
Definition: Initial.cpp:72
BodyView & addVelocity(const Vector &v)
Adds a velocity vector to all particles of the body.
Definition: Initial.cpp:38
BodyView & displace(const Vector &dr)
Moves the particles of the body in given direction.
Definition: Initial.cpp:23
Base class for generating vertices with specific distribution.
Definition: Distribution.h:21
Base class for computational domains.
Definition: Domain.h:29
Material settings and functions specific for one material.
Definition: IMaterial.h:110
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
InitialConditions(const RunSettings &settings)
Creates new initial conditions.
Definition: Initial.cpp:76
BodyView addHeterogeneousBody(Storage &storage, const BodySetup &environment, ArrayView< const BodySetup > bodies)
Creates particles composed of different materials.
Definition: Initial.cpp:140
void addRubblePileBody(Storage &storage, const IDomain &domain, const PowerLawSfd &sfd, const BodySettings &bodySettings)
Creates a rubble-pile body, composing of monolithic spheres.
Definition: Initial.cpp:193
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
INLINE Float lower() const
Returns lower bound of the interval.
Definition: Interval.h:74
INLINE Float upper() const
Returns upper bound of the interval.
Definition: Interval.h:79
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Holds data needed to create a single body in addHeterogeneousBody function.
Definition: Initial.h:154
SharedPtr< IDomain > domain
Definition: Initial.h:155
SharedPtr< IMaterial > material
Definition: Initial.h:156
BodySetup()
Creates a body with undefined domain and material.
Shared data used when creating all bodies in the simulation.
Definition: IMaterial.h:89
Object with deleted copy constructor and copy operator.
Definition: Object.h:54
Holds the information about a power-law size-frequency distributions.
Definition: Initial.h:73
Interval interval
Minimal and maximal value of the SFD.
Definition: Initial.h:81
INLINE Float operator()(const Float x) const
Generates a new value of the SFD by transforming given value from interval [0, 1].
Definition: Initial.h:87
Float exponent
Definition: Initial.h:78