SPHinXsys  alpha version
adaptation.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  * -----------------------------------------------------------------------------*/
30 #ifndef ADAPTATION_H
31 #define ADAPTATION_H
32 
33 #include "base_data_package.h"
34 #include "sph_data_containers.h"
35 #include "cell_linked_list.h"
36 #include "level_set.h"
37 
38 namespace SPH
39 {
40 
41  class SPHBody;
42  class RealBody;
43  class Shape;
44  class Kernel;
45  class BaseParticles;
46  class BaseLevelSet;
47 
56  {
57  protected:
61  Real spacing_ref_;
62  Real h_ref_;
63  UniquePtr<Kernel> kernel_ptr_;
64  Real spacing_min_;
65  Real h_ratio_max_;
66  Real number_density_min_;
67  Real number_density_max_;
68 
69  public:
70  explicit SPHAdaptation(SPHBody *sph_body, Real h_spacing_ratio = 1.3, Real system_refinement_ratio = 1.0);
71  virtual ~SPHAdaptation(){};
72 
73  int LocalRefinementLevel() { return local_refinement_level_; };
74  Real ReferenceSpacing() { return spacing_ref_; };
75  Real ReferenceSmoothingLength() { return h_ref_; };
76  Kernel *getKernel() { return kernel_ptr_.get(); };
77  void resetAdaptationRatios(Real h_spacing_ratio, Real new_system_refinement_ratio = 1.0);
78  template <class KernelType, typename... ConstructorArgs>
79  void resetKernel(ConstructorArgs &&...args)
80  {
81  kernel_ptr_.reset(new KernelType(h_ref_, std::forward<ConstructorArgs>(args)...));
82  };
83  Real MinimumSpacing() { return spacing_min_; };
84  Real computeReferenceNumberDensity(Vec2d zero, Real h_ratio);
85  Real computeReferenceNumberDensity(Vec3d zero, Real h_ratio);
86  Real ReferenceNumberDensity();
87  virtual Real SmoothingLengthRatio(size_t particle_index_i) { return 1.0; };
88 
89  virtual UniquePtr<BaseCellLinkedList> createCellLinkedList(const BoundingBox &domain_bounds, RealBody &real_body);
90  virtual UniquePtr<BaseLevelSet> createLevelSet(Shape &shape, Real refinement_ratio);
91 
92  protected:
93  Real RefinedSpacing(Real coarse_particle_spacing, int refinement_level);
94  };
95 
103  {
104  public:
108  Real system_refinement_ratio,
109  int local_refinement_level);
110  virtual ~ParticleWithLocalRefinement(){};
111 
112  size_t getCellLinkedListTotalLevel();
113  size_t getLevelSetTotalLevel();
114  virtual Real SmoothingLengthRatio(size_t particle_index_i) override
115  {
116  return h_ratio_[particle_index_i];
117  };
118 
119  StdLargeVec<Real> &registerSmoothingLengthRatio(BaseParticles *base_particles);
120  virtual UniquePtr<BaseCellLinkedList> createCellLinkedList(const BoundingBox &domain_bounds, RealBody &real_body) override;
121  virtual UniquePtr<BaseLevelSet> createLevelSet(Shape &shape, Real refinement_ratio) override;
122  };
123 
129  {
130  public:
131  ParticleSpacingByBodyShape(SPHBody *sph_body, Real smoothing_length_ratio,
132  Real system_refinement_ratio,
133  int local_refinement_level);
134  virtual ~ParticleSpacingByBodyShape(){};
135 
136  Real getLocalSpacing(Shape &shape, const Vecd &position);
137  };
138 }
139 #endif // ADAPTATION_H
Base class for all adaptations. The base class defines essential global parameters. It is also used for single-resolution method. In the constructor parameter, system_refinement_ratio defines the relation between present resolution to the system reference resolution. The derived classes are defined for more complex adaptations.
Definition: adaptation.h:55
Real spacing_min_
Definition: adaptation.h:64
Real h_ratio_max_
Definition: adaptation.h:65
Base class for all volumetric geometries Note that checkContain and findClosest point are basic funct...
Definition: base_geometry.h:64
Here gives the classes for managing cell linked lists. This is the basic class for building the parti...
Base class for particle with local refinement.
Definition: adaptation.h:102
Real system_refinement_ratio_
Definition: adaptation.h:59
int local_refinement_level_
Definition: adaptation.h:60
Adaptive resolutions within a SPH body according to the distance to the body surface.
Definition: adaptation.h:128
Real h_ref_
Definition: adaptation.h:62
Set up of basic data structure.
StdLargeVec< Real > h_ratio_
Definition: adaptation.h:105
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
Level set is a function which is defined as signed distance to a surface or interface.
Real spacing_ref_
Definition: adaptation.h:61
Definition: solid_body_supplementary.cpp:9
Real h_spacing_ratio_
Definition: adaptation.h:58
UniquePtr< Kernel > kernel_ptr_
Definition: adaptation.h:63