SPHinXsys  alpha version
neighbor_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 * and HU1527/12-1. *
14 * *
15 * Portions copyright (c) 2017-2020 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 NEIGHBOR_RELATION_H
32 #define NEIGHBOR_RELATION_H
33 
34 #include "base_data_package.h"
35 #include "all_kernels.h"
36 
37 namespace SPH
38 {
39 
40  class SPHBody;
41  class BodyPart;
42 
48  {
49  public:
50  size_t current_size_;
51  size_t allocated_size_;
53  StdLargeVec<size_t> j_;
60  ~Neighborhood(){};
61 
62  void removeANeighbor(size_t neighbor_n);
63  };
64 
66  using ParticleConfiguration = StdLargeVec<Neighborhood>;
68  using ContactParticleConfiguration = StdVec<ParticleConfiguration>;
69 
75  {
76  protected:
77  Kernel *kernel_;
78  //----------------------------------------------------------------------
79  // Below are for constant smoothing length.
80  //----------------------------------------------------------------------
81  void createRelation(Neighborhood &neighborhood, Real &distance,
82  Vecd &displacement, size_t j_index) const;
83  void initializeRelation(Neighborhood &neighborhood, Real &distance,
84  Vecd &displacement, size_t j_index) const;
85  //----------------------------------------------------------------------
86  // Below are for variable smoothing length.
87  //----------------------------------------------------------------------
88  void createRelation(Neighborhood &neighborhood, Real &distance,
89  Vecd &displacement, size_t j_index, Real i_h_ratio, Real h_ratio_min) const;
90  void initializeRelation(Neighborhood &neighborhood, Real &distance,
91  Vecd &displacement, size_t j_index, Real i_h_ratio, Real h_ratio_min) const;
92 
93  public:
94  NeighborRelation() : kernel_(nullptr){};
95  virtual ~NeighborRelation(){};
96  };
97 
103  {
104  public:
105  explicit NeighborRelationInner(SPHBody *body);
106  void operator()(Neighborhood &neighborhood,
107  Vecd &displacement, size_t i_index, size_t j_index) const;
108  };
109 
115  {
116  public:
118  void operator()(Neighborhood &neighborhood,
119  Vecd &displacement, size_t i_index, size_t j_index) const;
120 
121  protected:
122  StdLargeVec<Real> &h_ratio_;
123  };
124 
130  {
131  public:
132  explicit NeighborRelationSelfContact(SPHBody *body);
133  virtual ~NeighborRelationSelfContact(){};
134  void operator()(Neighborhood &neighborhood,
135  Vecd &displacement, size_t i_index, size_t j_index) const;
136 
137  protected:
138  StdLargeVec<Vecd> &pos0_;
139  };
140 
146  {
147  public:
148  NeighborRelationContact(SPHBody *body, SPHBody *contact_body);
149  virtual ~NeighborRelationContact(){};
150  void operator()(Neighborhood &neighborhood,
151  Vecd &displacement, size_t i_index, size_t j_index) const;
152  };
153 
159  {
160  private:
161  UniquePtrKeeper<Kernel> kernel_keeper_;
162 
163  public:
164  NeighborRelationSolidContact(SPHBody *body, SPHBody *contact_body);
165  virtual ~NeighborRelationSolidContact(){};
166  };
167 
173  {
174  public:
175  NeighborRelationContactBodyPart(SPHBody *body, BodyPart *contact_body_part);
176  virtual ~NeighborRelationContactBodyPart(){};
177  void operator()(Neighborhood &neighborhood,
178  Vecd &displacement, size_t i_index, size_t j_index) const;
179 
180  protected:
181  StdLargeVec<int> part_indicator_;
182  };
183 }
184 #endif //NEIGHBOR_RELATION_H
A neighborhood around particle i.
Definition: neighbor_relation.h:47
A contact neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:172
size_t current_size_
Definition: neighbor_relation.h:50
StdLargeVec< Real > r_ij_
Definition: neighbor_relation.h:56
A wrapper to provide an ownership for a new derived object which previous often generated by new a ra...
Definition: ownership.h:90
A inner neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:102
StdLargeVec< Vecd > e_ij_
Definition: neighbor_relation.h:57
An auxillary class for SPHBody to indicate a part of the body.
Definition: base_body_part.h:45
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< Real > W_ij_
Definition: neighbor_relation.h:54
A contact neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:145
A solid contact neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:158
Base neighbor relation between particles i and j.
Definition: neighbor_relation.h:74
StdLargeVec< Real > dW_ij_
Definition: neighbor_relation.h:55
StdVec< ParticleConfiguration > ContactParticleConfiguration
Definition: neighbor_relation.h:68
A inner neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:114
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
A solid contact neighbor relation functor between particles i and j.
Definition: neighbor_relation.h:129
size_t allocated_size_
Definition: neighbor_relation.h:51
StdLargeVec< int > part_indicator_
Definition: neighbor_relation.h:181
StdLargeVec< size_t > j_
Definition: neighbor_relation.h:53
Definition: solid_body_supplementary.cpp:9