SPH
Boundary.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "common/ForwardDecl.h"
14 #include "quantities/Storage.h"
15 #include <set>
16 
18 
19 class ISymmetricFinder;
20 
30 public:
34  virtual void initialize(Storage& storage) = 0;
35 
39  virtual void finalize(Storage& storage) = 0;
40 };
41 
43  virtual void initialize(Storage& UNUSED(storage)) override {}
44  virtual void finalize(Storage& UNUSED(storage)) override {}
45 };
46 
49 private:
50  Array<Ghost> ghosts;
51 
52 public:
53  explicit GhostParticlesData(Array<Ghost>&& ghosts)
54  : ghosts(std::move(ghosts)) {}
55 
57  Ghost& getGhost(const Size idx) {
58  return ghosts[idx];
59  }
60 
62  Size size() const {
63  return ghosts.size();
64  }
65 };
66 
72 public:
74  static constexpr Size FLAG = Size(-1);
75 
76 private:
77  Array<Ghost> ghosts;
78  Array<Size> ghostIdxs;
79  SharedPtr<IDomain> domain;
80 
82  struct {
85  } params;
86 
88  Function<Optional<Vector>(const Vector& r)> ghostVelocity;
89 
92  Size particleCnt;
93 
94 public:
100 
102  GhostParticles(SharedPtr<IDomain> domain, const RunSettings& settings);
103 
113  void setVelocityOverride(Function<Optional<Vector>(const Vector& r)> ghostVelocity);
114 
115  virtual void initialize(Storage& storage) override;
116 
117  virtual void finalize(Storage& storage) override;
118 };
119 
124 public:
125  struct Params {
128 
131 
135 
139  };
140 
141 private:
143  Storage fixedParticles;
144 
145 public:
146  FixedParticles(const RunSettings& settings, Params&& params);
147 
148  virtual void initialize(Storage& storage) override;
149 
150  virtual void finalize(Storage& storage) override;
151 };
152 
153 
161 protected:
164 
165  std::set<Size> frozen;
166 
169 
170 public:
175 
177 
183 
185  void freeze(const Size flag);
186 
190  void thaw(const Size flag);
191 
192  virtual void initialize(Storage& UNUSED(storage)) override {}
193 
194  virtual void finalize(Storage& storage) override;
195 };
196 
197 
203 class WindTunnel : public FrozenParticles {
204 public:
206 
207  virtual void initialize(Storage& UNUSED(storage)) override {}
208 
209  virtual void finalize(Storage& storage) override;
210 };
211 
214 private:
215  Box domain;
216 
217  Array<Ghost> ghosts;
218  Array<Size> ghostIdxs;
219 
220 public:
221  explicit PeriodicBoundary(const Box& domain);
222 
223  virtual void initialize(Storage& storage) override;
224 
225  virtual void finalize(Storage& storage) override;
226 };
227 
233 private:
234  Array<Ghost> ghosts;
235  Array<Size> ghostIdxs;
236 
237 public:
238  virtual void initialize(Storage& storage) override;
239 
240  virtual void finalize(Storage& storage) override;
241 };
242 
245 private:
246  SharedPtr<IDomain> domain;
247 
248 public:
249  explicit KillEscapersBoundary(SharedPtr<IDomain> domain);
250 
251  virtual void initialize(Storage& storage) override;
252 
253  virtual void finalize(Storage& storage) override;
254 };
255 
258 private:
259  Interval domain;
260  ArrayView<Vector> r, v;
261 
262 public:
264  explicit Projection1D(const Interval& domain);
265 
266  virtual void initialize(Storage& UNUSED(storage)) override {}
267 
268  virtual void finalize(Storage& storage) override;
269 };
270 
271 
Generic dynamically allocated resizable storage.
Simplified implementation of std::unique_ptr, using only default deleter.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Object defining computational domain.
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
Object representing interval of real values.
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
Container for storing particle quantities and materials.
Basic vector algebra. Computations are accelerated using SIMD.
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
INLINE TCounter size() const noexcept
Definition: Array.h:193
Helper object defining three-dimensional interval (box).
Definition: Box.h:17
Places immovable particles along boundary.
Definition: Boundary.h:123
FixedParticles(const RunSettings &settings, Params &&params)
Definition: Boundary.cpp:120
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:172
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
Definition: Boundary.cpp:164
Boundary condition that nulls all highest derivates of selected particles.
Definition: Boundary.h:160
void freeze(const Size flag)
Adds body ID particles of which shall be frozen by boundary conditions.
Definition: Boundary.cpp:199
std::set< Size > frozen
Definition: Boundary.h:165
Array< Size > idxs
Definition: Boundary.h:168
FrozenParticles()
Constructs boundary conditions with no particles frozen.
SharedPtr< IDomain > domain
Definition: Boundary.h:162
void thaw(const Size flag)
Remove a body from the list of frozen bodies.
Definition: Boundary.cpp:204
Array< Float > distances
Definition: Boundary.h:167
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:208
virtual void initialize(Storage &UNUSED(storage)) override
Definition: Boundary.h:192
Provides a way to access ghost particle data outside the solver.
Definition: Boundary.h:48
GhostParticlesData(Array< Ghost > &&ghosts)
Definition: Boundary.h:53
Ghost & getGhost(const Size idx)
Returns the reference to ghost particle with given index.
Definition: Boundary.h:57
Size size() const
Returns the total number of ghost particles.
Definition: Boundary.h:62
Adds ghost particles symmetrically for each SPH particle close to boundary.
Definition: Boundary.h:71
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:104
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
Definition: Boundary.cpp:33
Float minimalDist
Definition: Boundary.h:84
GhostParticles(SharedPtr< IDomain > domain, const Float searchRadius, const Float minimalDist)
Creates new boundary conditions.
Definition: Boundary.cpp:19
void setVelocityOverride(Function< Optional< Vector >(const Vector &r)> ghostVelocity)
Specifies a functor that overrides the default velocity assinged to each ghost.
Definition: Boundary.cpp:100
Float searchRadius
Definition: Boundary.h:83
static constexpr Size FLAG
Special flag denoting ghost particles.
Definition: Boundary.h:74
Base object for boundary conditions.
Definition: Boundary.h:29
virtual void finalize(Storage &storage)=0
Applies the boundary conditions after the derivatives are computed.
virtual void initialize(Storage &storage)=0
Applies the boundary conditions before the derivatives are computed.
Base class for arbitrary data stored in the storage alongside particles.
Definition: Storage.h:122
Extension of IBasicFinder, allowing to search only particles with lower rank in smoothing length.
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
Boundary condition that removes particles outside the domain.
Definition: Boundary.h:244
KillEscapersBoundary(SharedPtr< IDomain > domain)
Definition: Boundary.cpp:420
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
Definition: Boundary.cpp:423
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:434
Wrapper of type value of which may or may not be present.
Definition: Optional.h:23
Boundary condition moving all particles passed through the domain to the other side of the domain.
Definition: Boundary.h:213
PeriodicBoundary(const Box &domain)
Definition: Boundary.cpp:308
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
Definition: Boundary.cpp:317
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:368
Helper tool for 1D tests, projects all particles onto a 1D line.
Definition: Boundary.h:257
Projection1D(const Interval &domain)
Constructs using range as 1D domain.
Definition: Boundary.cpp:440
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:443
virtual void initialize(Storage &UNUSED(storage)) override
Definition: Boundary.h:266
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Boundary duplicating particles along z=0 plane.
Definition: Boundary.h:232
virtual void initialize(Storage &storage) override
Applies the boundary conditions before the derivatives are computed.
Definition: Boundary.cpp:379
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:409
Boundary conditions creating particles with given velocity at the boundary of the domain.
Definition: Boundary.h:203
WindTunnel(SharedPtr< IDomain > domain, const Float radius)
Definition: Boundary.cpp:251
virtual void finalize(Storage &storage) override
Applies the boundary conditions after the derivatives are computed.
Definition: Boundary.cpp:254
virtual void initialize(Storage &UNUSED(storage)) override
Definition: Boundary.h:207
Overload of std::swap for Sph::Array.
Definition: Array.h:578
AutoPtr< IMaterial > material
Definition: Boundary.h:134
AutoPtr< IDomain > domain
Computational domain; dummy particles will be placed outside of the domain.
Definition: Boundary.h:127
AutoPtr< IDistribution > distribution
Distribution used to create the dummy particles.
Definition: Boundary.h:130
Definition: Domain.h:22
virtual void initialize(Storage &UNUSED(storage)) override
Definition: Boundary.h:43
virtual void finalize(Storage &UNUSED(storage)) override
Definition: Boundary.h:44
Base class for all polymorphic objects.
Definition: Object.h:88