SPHinXsys  alpha version
base_body_part.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  * 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  * -----------------------------------------------------------------------------*/
31 #ifndef BASE_BODY_PART_H
32 #define BASE_BODY_PART_H
33 
34 #include "base_body.h"
35 
36 #include <string>
37 
38 namespace SPH
39 {
44  using namespace std::placeholders;
45  class BodyPart
46  {
47  public:
48  BodyPart(SPHBody &sph_body, const std::string &body_part_name)
49  : sph_body_(&sph_body), body_part_name_(body_part_name){};
50  virtual ~BodyPart(){};
51 
52  SPHBody *getSPHBody() { return sph_body_; };
53  std::string BodyPartName() { return body_part_name_; };
54 
55  protected:
56  SPHBody *sph_body_;
57  std::string body_part_name_;
58  };
59 
65  {
66  public:
69  BodyPartByParticle(SPHBody &sph_body, const std::string &body_part_name)
70  : BodyPart(sph_body, body_part_name), base_particles_(sph_body.base_particles_),
71  body_part_bounds_(Vecd(0), Vecd(0)), body_part_bounds_set_(false){};
72  virtual ~BodyPartByParticle(){};
73 
74  void setBodyPartBounds(BoundingBox bbox)
75  {
76  body_part_bounds_ = bbox;
77  body_part_bounds_set_ = true;
78  };
79 
80  BoundingBox getBodyPartBounds()
81  {
82  if (!body_part_bounds_set_)
83  std::cout << "WARNING: the body part bounds are not set for BodyPartByParticle." << std::endl;
84  return body_part_bounds_;
85  }
86 
87  protected:
88  BaseParticles *base_particles_;
89  BoundingBox body_part_bounds_;
90  bool body_part_bounds_set_;
91 
92  typedef std::function<void(size_t)> TaggingParticleMethod;
93  void tagParticles(TaggingParticleMethod &tagging_particle_method);
94  };
95 
100  class BodyPartByCell : public BodyPart
101  {
102  public:
105  BodyPartByCell(RealBody &real_body, const std::string &body_part_name)
106  : BodyPart(real_body, body_part_name), cell_linked_list_(real_body.cell_linked_list_){};
107  virtual ~BodyPartByCell(){};
108 
109  protected:
110  BaseCellLinkedList *cell_linked_list_;
111  typedef std::function<bool(Vecd, Real)> TaggingCellMethod;
112  void tagCells(TaggingCellMethod &tagging_cell_method);
113  };
114 
120  {
121  private:
122  SharedPtrKeeper<Shape> shape_ptr_keeper_;
123 
124  public:
125  Shape &body_part_shape_;
126 
127  BodyRegionByParticle(SPHBody &sph_body, SharedPtr<Shape> shape_ptr);
128  virtual ~BodyRegionByParticle(){};
129 
130  private:
131  void tagByContain(size_t particle_index);
132  };
133 
139  {
140  public:
141  explicit BodySurface(SPHBody &sph_body);
142  virtual ~BodySurface(){};
143 
144  private:
145  Real particle_spacing_min_;
146  void tagNearSurface(size_t particle_index);
147  };
148 
154  {
155  public:
156  explicit BodySurfaceLayer(SPHBody &sph_body, Real layer_thickness = 3.0);
157  virtual ~BodySurfaceLayer(){};
158 
159  private:
160  Real thickness_threshold_;
161  void tagSurfaceLayer(size_t particle_index);
162  };
163 
169  {
170  private:
171  SharedPtrKeeper<Shape> shape_ptr_keeper_;
172 
173  public:
174  Shape &body_part_shape_;
175 
176  BodyRegionByCell(RealBody &real_body, SharedPtr<Shape> shape_ptr);
177  virtual ~BodyRegionByCell(){};
178 
179  private:
180  bool checkNotFar(Vecd cell_position, Real threshold);
181  };
182 
188  {
189  private:
190  UniquePtrKeeper<LevelSetShape> level_set_shape_keeper_;
191 
192  public:
193  LevelSetShape &level_set_shape_;
194 
196  NearShapeSurface(RealBody &real_body, SharedPtr<Shape> shape_ptr);
198  explicit NearShapeSurface(RealBody &real_body);
200  NearShapeSurface(RealBody &real_body, const std::string &shape_name);
201  virtual ~NearShapeSurface(){};
202 
203  private:
205  bool checkNearSurface(Vecd cell_position, Real threshold);
206  };
207 
212  template <class BodyRegionType>
214  {
215  public:
216  AlignedBoxShape &aligned_box_;
217 
218  AlignedBoxRegion(RealBody &real_body, SharedPtr<AlignedBoxShape> aligned_box_ptr)
219  : BodyRegionType(real_body, aligned_box_ptr), aligned_box_(*aligned_box_ptr.get()){};
220  virtual ~AlignedBoxRegion(){};
221  };
222 
225 }
226 #endif // BASE_BODY_PART_H
A body part with a collection of cell lists.
Definition: base_body_part.h:100
A body part with the collection of particles at surface of a body.
Definition: base_body_part.h:138
StdVec< size_t > IndexVector
Definition: sph_data_containers.h:37
Base class for all volumetric geometries Note that checkContain and findClosest point are basic funct...
Definition: base_geometry.h:64
A body part with a collection of particles.
Definition: base_body_part.h:64
StdLargeVec< CellList * > CellLists
Definition: sph_data_containers.h:46
A body part with the collection of particles within by a prescribed shape.
Definition: base_body_part.h:119
A body part with the cell lists within a prescribed shape.
Definition: base_body_part.h:168
A wrapper to provide an ownership for a new derived object which previous often generated by new a ra...
Definition: ownership.h:90
An auxillary class for SPHBody to indicate a part of the body.
Definition: base_body_part.h:45
This is the base classes of SPH bodies. The real body is for that with cell linked list and the ficti...
IndexVector body_part_particles_
Definition: base_body_part.h:67
Used to describe a bounding box in which the plane vertical to axis direction is aligned to a planar ...
Definition: complex_shape.h:68
A shape using level set to define geometry.
Definition: level_set_shape.h:46
A body part with the cell lists near the surface of a prescribed shape.
Definition: base_body_part.h:187
A template body part with the collection of particles within by an AlignedBoxShape.
Definition: base_body_part.h:213
A wrapper to provide an shared ownership for a new derived object which previous often generated by n...
Definition: ownership.h:170
A body part with the collection of particles within the surface layers of a body. ...
Definition: base_body_part.h:153
CellLists body_part_cells_
Definition: base_body_part.h:103
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
Derived body with inner particle configuration or inner interactions. After construction, the particle and material must be specified.
Definition: base_body.h:182
Definition: solid_body_supplementary.cpp:9