SPHinXsys  alpha version
fluid_surface_inner.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 * --------------------------------------------------------------------------*/
30 #ifndef FLUID_SURFACE_INNER_H
31 #define FLUID_SURFACE_INNER_H
32 
33 #include "fluid_dynamics_inner.hpp"
34 
35 namespace SPH
36 {
37  namespace fluid_dynamics
38  {
48  public FluidDataInner
49  {
50  public:
51  explicit FreeSurfaceIndicationInner(BaseBodyRelationInner &inner_relation, Real thereshold = 0.75);
52  virtual ~FreeSurfaceIndicationInner(){};
53 
54  protected:
55  Real thereshold_by_dimensions_;
56  StdLargeVec<Real> &Vol_;
57  StdLargeVec<int> &surface_indicator_;
58  StdLargeVec<Real> pos_div_;
59  Real smoothing_length_;
60 
61  virtual void Interaction(size_t index_i, Real dt = 0.0) override;
62  virtual void Update(size_t index_i, Real dt = 0.0) override;
63  };
64 
69  template <class FreeSurfaceIdentification>
71  {
72  public:
73  template <typename... ConstructorArgs>
74  explicit SpatialTemporalFreeSurfaceIdentification(ConstructorArgs &&...args);
76 
77  protected:
78  StdLargeVec<int> previous_surface_indicator_;
79 
80  virtual void Interaction(size_t index_i, Real dt = 0.0) override;
81  virtual void Update(size_t index_i, Real dt = 0.0) override;
82 
83  void checkNearPreviousFreeSurface(size_t index_i);
84  };
87 
93  {
94  public:
96  : DensitySummationInner(inner_relation){};
98 
99  protected:
100  virtual Real ReinitializedDensity(Real rho_sum, Real rho_0, Real rho_n) override
101  {
102  return rho_sum + SMAX(0.0, (rho_n - rho_sum)) * rho_0 / rho_n;
103  };
104  };
105 
111  {
112  public:
114  : DensitySummationFreeSurfaceInner(inner_relation),
115  surface_indicator_(*particles_->getVariableByName<int>("SurfaceIndicator")){};
116  virtual ~DensitySummationFreeStreamInner(){};
117 
118  protected:
119  StdLargeVec<int> &surface_indicator_;
120  virtual void Update(size_t index_i, Real dt = 0.0) override;
121  bool isNearSurface(size_t index_i);
122  };
123 
130  {
131  public:
133  : ParticleDynamicsSimple(*inner_relation.sph_body_),
134  FluidDataInner(inner_relation), u_ref_(1.0), t_ref_(2.0),
135  rho_ref_(material_->ReferenceDensity()), rho_sum(particles_->rho_sum_),
136  vel_(particles_->vel_), acc_(particles_->acc_),
137  surface_indicator_(*particles_->getVariableByName<int>("SurfaceIndicator")){};
139 
140  protected:
141  Real u_ref_, t_ref_, rho_ref_;
142  StdLargeVec<Real> &rho_sum;
143  StdLargeVec<Vecd> &vel_, &acc_;
144  StdLargeVec<int> &surface_indicator_;
145 
146  virtual void Update(size_t index_i, Real dt = 0.0) override;
147  };
148 
153  class FreeSurfaceProbeOnFluidBody : public PartDynamicsByCellReduce<Real, ReduceMax>,
154  public FluidDataSimple
155  {
156  public:
157  FreeSurfaceProbeOnFluidBody(FluidBody &fluid_body, BodyPartByCell &body_part)
158  : PartDynamicsByCellReduce<Real, ReduceMax>(fluid_body, body_part), FluidDataSimple(fluid_body),
159  pos_(particles_->pos_)
160  {
161  quantity_name_ = body_part.BodyPartName() + "FreeSurface";
162  initial_reference_ = 0.0;
163  }
164  virtual ~FreeSurfaceProbeOnFluidBody(){};
165 
166  protected:
167  StdLargeVec<Vecd> &pos_;
168  virtual void SetupReduce() override{};
169  virtual Real ReduceFunction(size_t index_i, Real dt = 0.0) override { return pos_[index_i][1]; };
170  };
176  {
177  public:
178  explicit ColorFunctionGradientInner(BaseBodyRelationInner &inner_relation);
179  virtual ~ColorFunctionGradientInner(){};
180 
181  protected:
182  Real thereshold_by_dimensions_;
183  StdLargeVec<Real> &Vol_;
184  StdLargeVec<int> &surface_indicator_;
185  StdLargeVec<Vecd> color_grad_;
186  StdLargeVec<Vecd> surface_norm_;
187  StdLargeVec<Real> &pos_div_;
188 
189  virtual void Interaction(size_t index_i, Real dt = 0.0) override;
190  };
191 
197  {
198  public:
201 
202  protected:
203  Real thereshold_by_dimensions_;
204  StdLargeVec<Real> &Vol_;
205  StdLargeVec<int> &surface_indicator_;
206  StdLargeVec<Vecd> &color_grad_;
207  StdLargeVec<Vecd> &surface_norm_;
208  StdLargeVec<Real> &pos_div_;
209 
210  virtual void Interaction(size_t index_i, Real dt = 0.0) override;
211  };
212 
218  {
219  public:
220  SurfaceTensionAccelerationInner(BaseBodyRelationInner &inner_relation, Real gamma);
221  explicit SurfaceTensionAccelerationInner(BaseBodyRelationInner &inner_relation);
222  virtual ~SurfaceTensionAccelerationInner(){};
223 
224  protected:
225  Real gamma_;
226  StdLargeVec<Real> &Vol_, &mass_;
227  StdLargeVec<Vecd> &acc_prior_;
228  StdLargeVec<int> &surface_indicator_;
229  StdLargeVec<Vecd> &color_grad_;
230  StdLargeVec<Vecd> &surface_norm_;
231 
232  virtual void Interaction(size_t index_i, Real dt = 0.0) override;
233  };
234  }
235 }
236 #endif //FLUID_SURFACE_INNER_H
Fluid body uses smoothing length to particle spacing 1.3 and carry out particle sorting every 100 ite...
Definition: fluid_body.h:43
virtual void Update(size_t index_i, Real dt=0.0) override
Definition: fluid_surface_inner.cpp:37
The density is smoothed if the particle is near fluid surface.
Definition: fluid_surface_inner.h:110
prepare data for inner particle dynamics
Definition: base_particle_dynamics.h:216
A body part with a collection of cell lists.
Definition: base_body_part.h:100
indicate the particles near the interface of a fluid-fluid interaction and computing norm ...
Definition: fluid_surface_inner.h:175
Simple particle dynamics without considering particle interaction.
Definition: particle_dynamics_algorithms.h:48
Abstract class for reduce operation in a Eulerian constrain region.
Definition: particle_dynamics_bodypart.h:162
indicate the particles near the free surface of a fluid body. Note that, SPHinXsys does not require t...
Definition: fluid_surface_inner.h:46
virtual void Interaction(size_t index_i, Real dt=0.0) override
Definition: fluid_surface_inner.cpp:177
using the spatial-temporal method to indicate the surface particles to avoid mis-judgement.
Definition: fluid_surface_inner.h:70
computing density by summation
Definition: fluid_dynamics_inner.h:68
computing density by summation with a re-normalization for free surface flows
Definition: fluid_surface_inner.h:92
This is the class for particle interaction with other particles.
Definition: particle_dynamics_algorithms.h:115
Probe the free surface profile for a fluid body part by reduced operation.
Definition: fluid_surface_inner.h:153
This class includes an interaction and a update steps.
Definition: particle_dynamics_algorithms.h:160
The abstract relation within a SPH body.
Definition: base_body_relation.h:117
prepare data for simple particle dynamics.
Definition: base_particle_dynamics.h:185
the viscous force induced acceleration
Definition: fluid_surface_inner.h:217
the viscous force induced acceleration
Definition: fluid_surface_inner.h:196
this function is applied to freestream flows
Definition: fluid_surface_inner.h:129
Definition: solid_body_supplementary.cpp:9