SPHinXsys  alpha version
general_bounding.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------*
2 * SPHinXsys *
3 * --------------------------------------------------------------------------*
4 * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
5 * Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
6 * physical accurate simulation and aims to model coupled industrial dynamic *
7 * systems including fluid, solid, multi-body dynamics and beyond with SPH *
8 * (smoothed particle hydrodynamics), a meshless computational method using *
9 * particle discretization. *
10 * *
11 * SPHinXsys is partially funded by German Research Foundation *
12 * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1, *
13 * and HU1527/12-1 and HU1527/12-4. *
14 * *
15 * Portions copyright (c) 2017-2022 Technical University of Munich and *
16 * the authors' affiliations. *
17 * *
18 * Licensed under the Apache License, Version 2.0 (the "License"); you may *
19 * not use this file except in compliance with the License. You may obtain a *
20 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
21 * *
22 * --------------------------------------------------------------------------*/
29 #ifndef GENERAL_BOUNDING_H
30 #define GENERAL_BOUNDING_H
31 
32 #include "general_dynamics.h"
33 
34 namespace SPH
35 {
42  {
43  protected:
44  const int axis_;
46  StdLargeVec<Vecd> &pos_;
47  BaseCellLinkedList *cell_linked_list_;
49  public:
50  BoundingInAxisDirection(RealBody &real_body, int axis_direction);
51  virtual ~BoundingInAxisDirection(){};
52  };
53 
59  {
60  protected:
61  Vecd periodic_translation_;
62  StdVec<CellLists> bound_cells_;
63  void setPeriodicTranslation(BoundingBox &body_domain_bounds, int axis_direction);
64 
70  {
71  protected:
72  Vecd &periodic_translation_;
73  StdVec<CellLists> &bound_cells_;
74 
75  virtual void checkLowerBound(size_t index_i, Real dt = 0.0);
76  virtual void checkUpperBound(size_t index_i, Real dt = 0.0);
77 
78  public:
79  PeriodicBounding(Vecd &periodic_translation,
80  StdVec<CellLists> &bound_cells, RealBody &real_body, int axis_direction)
81  : BoundingInAxisDirection(real_body, axis_direction), periodic_translation_(periodic_translation),
82  bound_cells_(bound_cells){};
83  virtual ~PeriodicBounding(){};
84 
85  virtual void exec(Real dt = 0.0) override;
86  virtual void parallel_exec(Real dt = 0.0) override;
87  };
88 
94  {
95  protected:
96  Vecd &periodic_translation_;
97  StdVec<CellLists> &bound_cells_;
98 
99  virtual void checkLowerBound(ListData &list_data, Real dt = 0.0) = 0;
100  virtual void checkUpperBound(ListData &list_data, Real dt = 0.0) = 0;
101 
102  public:
103  PeriodicCondition(Vecd &periodic_translation,
104  StdVec<CellLists> &bound_cells, RealBody &real_body, int axis_direction)
105  : BoundingInAxisDirection(real_body, axis_direction), periodic_translation_(periodic_translation),
106  bound_cells_(bound_cells){};
107  virtual ~PeriodicCondition(){};
108 
112  virtual void exec(Real dt = 0.0) override;
113  virtual void parallel_exec(Real dt = 0.0) override { exec(); };
114  };
115 
116  public:
117  PeriodicConditionInAxisDirection(RealBody &real_body, int axis_direction);
119  };
120 
130  {
131  protected:
137  {
138  protected:
139  virtual void checkLowerBound(ListData &list_data, Real dt = 0.0) override;
140  virtual void checkUpperBound(ListData &list_data, Real dt = 0.0) override;
141 
142  public:
143  PeriodicCellLinkedList(Vecd &periodic_translation,
144  StdVec<CellLists> &bound_cells, RealBody &real_body, int axis_direction)
145  : PeriodicCondition(periodic_translation, bound_cells, real_body, axis_direction){};
146  virtual ~PeriodicCellLinkedList(){};
147  };
148 
149  public:
150  PeriodicConditionInAxisDirectionUsingCellLinkedList(RealBody &real_body, int axis_direction)
151  : PeriodicConditionInAxisDirection(real_body, axis_direction),
152  bounding_(this->periodic_translation_, this->bound_cells_, real_body, axis_direction),
153  update_cell_linked_list_(this->periodic_translation_, this->bound_cells_, real_body, axis_direction){};
155 
156  PeriodicBounding bounding_;
157  PeriodicCellLinkedList update_cell_linked_list_;
158  };
159 
167  {
168  protected:
169  StdVec<CellLists> bound_cells_;
170 
172  {
173  protected:
174  StdVec<CellLists> &bound_cells_;
175  ParticleFunctor checking_bound_;
176  virtual void checkLowerBound(size_t index_i, Real dt = 0.0);
177  virtual void checkUpperBound(size_t index_i, Real dt = 0.0);
178 
179  public:
180  ParticleTypeTransfer(StdVec<CellLists> &bound_cells, RealBody &real_body, int axis_direction, bool positive)
181  : BoundingInAxisDirection(real_body, axis_direction),
182  bound_cells_(bound_cells)
183  {
184  checking_bound_ = positive ? std::bind(&OpenBoundaryConditionInAxisDirection::ParticleTypeTransfer::checkUpperBound, this, _1, _2)
185  : std::bind(&OpenBoundaryConditionInAxisDirection::ParticleTypeTransfer::checkLowerBound, this, _1, _2);
186  };
187  virtual ~ParticleTypeTransfer(){};
188 
192  virtual void exec(Real dt = 0.0) override;
193  virtual void parallel_exec(Real dt = 0.0) override { exec(); };
194  };
195 
196  public:
197  OpenBoundaryConditionInAxisDirection(RealBody &real_body, int axis_direction, bool positive);
199 
200  ParticleTypeTransfer particle_type_transfer;
201  };
202 
214  {
215  protected:
216  StdVec<IndexVector> ghost_particles_;
217 
223  {
224  protected:
225  StdVec<IndexVector> &ghost_particles_;
226  virtual void setupDynamics(Real dt = 0.0) override;
227  virtual void checkLowerBound(size_t index_i, Real dt = 0.0) override;
228  virtual void checkUpperBound(size_t index_i, Real dt = 0.0) override;
229 
230  public:
231  CreatPeriodicGhostParticles(Vecd &periodic_translation, StdVec<CellLists> &bound_cells,
232  StdVec<IndexVector> &ghost_particles, RealBody &real_body, int axis_direction)
233  : PeriodicBounding(periodic_translation, bound_cells, real_body, axis_direction),
234  ghost_particles_(ghost_particles){};
235  virtual ~CreatPeriodicGhostParticles(){};
236 
240  virtual void parallel_exec(Real dt = 0.0) override { exec(); };
241  };
242 
247  class UpdatePeriodicGhostParticles : public PeriodicBounding
248  {
249  protected:
250  StdVec<IndexVector> &ghost_particles_;
251  void checkLowerBound(size_t index_i, Real dt = 0.0) override;
252  void checkUpperBound(size_t index_i, Real dt = 0.0) override;
253 
254  public:
255  UpdatePeriodicGhostParticles(Vecd &periodic_translation, StdVec<CellLists> &bound_cells,
256  StdVec<IndexVector> &ghost_particles, RealBody &real_body, int axis_direction)
257  : PeriodicBounding(periodic_translation, bound_cells, real_body, axis_direction),
258  ghost_particles_(ghost_particles){};
259  virtual ~UpdatePeriodicGhostParticles(){};
260 
261  virtual void exec(Real dt = 0.0) override;
262  virtual void parallel_exec(Real dt = 0.0) override;
263  };
264 
265  public:
266  PeriodicConditionInAxisDirectionUsingGhostParticles(RealBody &real_body, int axis_direction)
267  : PeriodicConditionInAxisDirection(real_body, axis_direction),
268  bounding_(this->periodic_translation_, this->bound_cells_, real_body, axis_direction),
269  ghost_creation_(this->periodic_translation_, this->bound_cells_, this->ghost_particles_, real_body, axis_direction),
270  ghost_update_(this->periodic_translation_, this->bound_cells_, this->ghost_particles_, real_body, axis_direction)
271  {
272  ghost_particles_.resize(2);
273  };
274 
276 
277  PeriodicBounding bounding_;
278  CreatPeriodicGhostParticles ghost_creation_;
279  UpdatePeriodicGhostParticles ghost_update_;
280  };
281 
289  {
290  protected:
291  CellLists bound_cells_;
292  IndexVector ghost_particles_;
293 
295  {
296  protected:
297  CellLists &bound_cells_;
298  virtual void checkLowerBound(size_t index_i, Real dt = 0.0);
299  virtual void checkUpperBound(size_t index_i, Real dt = 0.0);
300  ParticleFunctor checking_bound_;
301 
302  StdLargeVec<Vecd> &vel_;
303  void mirrorInAxisDirection(size_t particle_index_i, Vecd body_bound, int axis_direction);
304 
305  public:
306  MirrorBounding(CellLists &bound_cells, RealBody &real_body, int axis_direction, bool positive);
307  virtual ~MirrorBounding(){};
308  virtual void exec(Real dt = 0.0) override;
309  virtual void parallel_exec(Real dt = 0.0) override;
310  };
311 
317  {
318  protected:
319  IndexVector &ghost_particles_;
320  virtual void setupDynamics(Real dt = 0.0) override { ghost_particles_.clear(); };
321  virtual void checkLowerBound(size_t index_i, Real dt = 0.0) override;
322  virtual void checkUpperBound(size_t index_i, Real dt = 0.0) override;
323 
324  public:
325  CreatingGhostParticles(IndexVector &ghost_particles, CellLists &bound_cells,
326  RealBody &real_body, int axis_direction, bool positive);
327  virtual ~CreatingGhostParticles(){};
329  virtual void parallel_exec(Real dt = 0.0) override { exec(); };
330  };
331 
337  {
338  protected:
339  IndexVector &ghost_particles_;
340  void checkLowerBound(size_t index_i, Real dt = 0.0) override;
341  void checkUpperBound(size_t index_i, Real dt = 0.0) override;
342  ParticleFunctor checking_bound_update_;
343 
344  public:
345  UpdatingGhostStates(IndexVector &ghost_particles, CellLists &bound_cells,
346  RealBody &real_body, int axis_direction, bool positive);
347  virtual ~UpdatingGhostStates(){};
348 
349  virtual void exec(Real dt = 0.0) override;
350  virtual void parallel_exec(Real dt = 0.0) override;
351  };
352 
353  public:
354  MirrorBounding bounding_;
355  CreatingGhostParticles creating_ghost_particles_;
356  UpdatingGhostStates updating_ghost_states_;
357 
358  MirrorBoundaryConditionInAxisDirection(RealBody &real_body, int axis_direction, bool positive);
360 
361  virtual void exec(Real dt = 0.0) override{};
362  virtual void parallel_exec(Real dt = 0.0) override{};
363  };
364 }
365 #endif //GENERAL_BOUNDING_H
virtual void parallel_exec(Real dt=0.0) override
Definition: general_bounding.h:329
virtual void exec(Real dt=0.0) override
Definition: general_bounding.cpp:53
virtual void exec(Real dt=0.0) override
Definition: general_bounding.cpp:111
Real cut_off_radius_max_
Definition: general_bounding.h:48
update ghost particles in an axis direction
Definition: general_bounding.h:247
the state of a ghost particle updated according to its corresponding real particle ...
Definition: general_bounding.h:336
StdVec< size_t > IndexVector
Definition: sph_data_containers.h:37
virtual void setupDynamics(Real dt=0.0) override
Definition: general_bounding.h:320
create ghost particles in an axis direction
Definition: general_bounding.h:222
This is the particle dynamics aplliable for all type bodies.
StdLargeVec< CellList * > CellLists
Definition: sph_data_containers.h:46
The method imposing periodic boundary condition in an axis direction by using ghost particles...
Definition: general_bounding.h:213
Bounding particle position in a axis direction. The axis_direction must be 0, 1 for 2d and 0...
Definition: general_bounding.h:41
virtual void exec(Real dt=0.0) override
Definition: general_bounding.cpp:188
Periodic bounding particle position in an axis direction.
Definition: general_bounding.h:69
virtual void checkLowerBound(size_t index_i, Real dt=0.0) override
Definition: general_bounding.cpp:219
Abstract class for mesh cell linked list.
Definition: cell_linked_list.h:69
const int axis_
Definition: general_bounding.h:44
virtual void parallel_exec(Real dt=0.0) override
Definition: general_bounding.h:240
virtual void exec(Real dt=0.0) override
Definition: general_bounding.h:361
implement periodic condition in an axis direction
Definition: general_bounding.h:93
std::pair< size_t, Vecd > ListData
Definition: sph_data_containers.h:42
virtual void exec(Real dt=0.0) override
Definition: general_bounding.cpp:421
Base class for two different type periodic boundary conditions.
Definition: general_bounding.h:58
virtual void checkUpperBound(ListData &list_data, Real dt=0.0) override
Definition: general_bounding.cpp:135
ghost particle created according to its corresponding real particle
Definition: general_bounding.h:316
virtual void exec(Real dt=0.0) override
Definition: general_bounding.cpp:349
virtual void checkLowerBound(size_t index_i, Real dt=0.0) override
Definition: general_bounding.cpp:377
Periodic boundary condition in an axis direction.
In open boundary case, we transfer fluid particles to buffer particles at outlet. ...
Definition: general_bounding.h:166
virtual void checkUpperBound(size_t index_i, Real dt=0.0) override
Definition: general_bounding.cpp:234
BoundingBox body_domain_bounds_
Definition: general_bounding.h:45
Mirror bounding particle position and velocity in an axis direction Note that, currently, this class is not for mirror condition in combined directions, such as mirror condition in both x and y directions.
Definition: general_bounding.h:288
virtual void checkUpperBound(size_t index_i, Real dt=0.0) override
Definition: general_bounding.cpp:393
std::function< void(size_t, Real)> ParticleFunctor
Definition: base_particle_dynamics.h:49
Derived body with inner particle configuration or inner interactions. After construction, the particle and material must be specified.
Definition: base_body.h:182
virtual void checkLowerBound(ListData &list_data, Real dt=0.0) override
Definition: general_bounding.cpp:148
The method imposing periodic boundary condition in an axis direction. It includes two different steps...
Definition: general_bounding.h:129
Definition: solid_body_supplementary.cpp:9
The base class for all particle dynamics This class contains the only two interface functions availab...
Definition: base_particle_dynamics.h:145