SPHinXsys  alpha version
base_body_relation.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  * -----------------------------------------------------------------------------*/
29 #ifndef BASE_BODY_RELATION_H
30 #define BASE_BODY_RELATION_H
31 
32 #include "complex_body.h"
33 #include "base_particles.h"
34 #include "cell_linked_list.h"
35 #include "neighbor_relation.h"
36 #include "base_geometry.h"
37 
38 namespace SPH
39 {
42  {
43  size_t operator()(size_t particle_index) const { return particle_index; };
44  };
45 
48  {
49  IndexVector &body_part_particles_;
50  explicit BodyPartParticlesIndex(IndexVector &body_part_particles)
51  : body_part_particles_(body_part_particles){};
52  size_t operator()(size_t particle_entry) const { return body_part_particles_[particle_entry]; };
53  };
54 
57  {
58  int operator()(size_t particle_index) const { return 1; };
59  };
60 
65  {
66  int search_depth_;
67  SearchDepthMultiResolution(SPHBody &sph_body, CellLinkedList *target_cell_linked_list)
68  : search_depth_(1)
69  {
70  Real inv_grid_spacing_ = 1.0 / target_cell_linked_list->GridSpacing();
71  Kernel *kernel_ = sph_body.sph_adaptation_->getKernel();
72  search_depth_ = 1 + (int)floor(kernel_->CutOffRadius() * inv_grid_spacing_);
73  };
74  int operator()(size_t particle_index) const { return search_depth_; };
75  };
76 
81  {
82  Real inv_grid_spacing_;
83  Kernel *kernel_;
84  StdLargeVec<Real> &h_ratio_;
85  SearchDepthVariableSmoothingLength(SPHBody &sph_body, CellLinkedList *target_cell_linked_list)
86  : inv_grid_spacing_(1.0 / target_cell_linked_list->GridSpacing()),
87  kernel_(sph_body.sph_adaptation_->getKernel()),
88  h_ratio_(*sph_body.base_particles_->getVariableByName<Real>("SmoothingLengthRatio")){};
89  int operator()(size_t particle_index) const
90  {
91  return 1 + (int)floor(kernel_->CutOffRadius(h_ratio_[particle_index]) * inv_grid_spacing_);
92  };
93  };
94 
100  {
101  public:
102  SPHBody *sph_body_;
103  BaseParticles *base_particles_;
104 
105  explicit SPHBodyRelation(SPHBody &sph_body);
106  virtual ~SPHBodyRelation(){};
107 
108  void subscribeToBody() { sph_body_->body_relations_.push_back(this); };
109  virtual void updateConfigurationMemories() = 0;
110  virtual void updateConfiguration() = 0;
111  };
112 
118  {
119  protected:
120  virtual void resetNeighborhoodCurrentSize();
121 
122  public:
123  RealBody *real_body_;
126  explicit BaseBodyRelationInner(RealBody &real_body);
127  virtual ~BaseBodyRelationInner(){};
128 
129  virtual void updateConfigurationMemories() override;
130  };
131 
137  {
138  protected:
139  UniquePtrKeepers<SearchDepthMultiResolution> search_depth_multi_resolution_ptr_vector_keeper_;
140  UniquePtrKeepers<NeighborRelationContact> neighbor_relation_contact_ptr_vector_keeper_;
141 
142  protected:
143  StdVec<CellLinkedList *> target_cell_linked_lists_;
144  StdVec<SearchDepthMultiResolution *> get_search_depths_;
145  StdVec<NeighborRelationContact *> get_contact_neighbors_;
146 
147  virtual void resetNeighborhoodCurrentSize();
148 
149  public:
150  RealBodyVector contact_bodies_;
153  BaseBodyRelationContact(SPHBody &sph_body, RealBodyVector contact_bodies);
154  BaseBodyRelationContact(SPHBody &sph_body, BodyPartVector contact_body_parts);
155  virtual ~BaseBodyRelationContact(){};
156 
157  virtual void updateConfigurationMemories() override;
158  };
159 }
160 #endif //BASE_BODY_RELATION_H
a small functor for obtaining search depth for variable smoothing length
Definition: base_body_relation.h:80
StdVec< SPHBodyRelation * > body_relations_
Definition: base_body.h:89
Particles with essential (geometric and kinematic) data. There are three types of particles, all par...
Definition: base_particles.h:81
The base relation between a SPH body and its contact SPH bodies.
Definition: base_body_relation.h:136
Defining a mesh cell linked list for a body. The meshes for all bodies share the same global coordina...
Definition: cell_linked_list.h:113
StdVec< size_t > IndexVector
Definition: sph_data_containers.h:37
Here gives the classes for managing cell linked lists. This is the basic class for building the parti...
There are the classes for neighboring particles. It saves the information for carring out pair intera...
Definition: base_body_relation.h:41
ContactParticleConfiguration contact_configuration_
Definition: base_body_relation.h:151
Abstract base class of a general SPH kernel function which is a smoothed Dirac delta function...
Definition: base_kernel.h:63
StdLargeVec< Neighborhood > ParticleConfiguration
Definition: neighbor_relation.h:66
StdLargeVec< VariableType > * getVariableByName(const std::string &variable_name)
Definition: base_particles.hpp:74
Definition: base_body_relation.h:56
a small functor for obtaining search depth across resolution
Definition: base_body_relation.h:64
Shape is the base class for all geometries.
A wrapper to provide an ownership for a vector of base class pointers which point to derived objects...
Definition: ownership.h:127
StdVec< ParticleConfiguration > ContactParticleConfiguration
Definition: neighbor_relation.h:68
This is the base class of SPH particles. The basic data of the particles is saved in separated large ...
A complex body is characterized with a secondary structure, which can be imported externally or creat...
BaseParticles * base_particles_
Definition: base_body.h:88
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
ParticleConfiguration inner_configuration_
Definition: base_body_relation.h:124
The abstract class for all relations within a SPH body or with its contact SPH bodies.
Definition: base_body_relation.h:99
The abstract relation within a SPH body.
Definition: base_body_relation.h:117
SPHAdaptation * sph_adaptation_
Definition: base_body.h:86
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
Definition: base_body_relation.h:47