Skip to main content

Rocky Solver SDK 2024 R2

rocky_sph_element_api

Last update: 17.07.2025
1#pragma once
2
3// Includes =======================================================================================
4#include "rocky_sph_element.hpp"
5#include "rocky_sph_element_scalars.hpp"
6#include <rocky20/api/rocky_particle_api.hpp>
7
8// ================================================================================================
9// IRockySPHElementImpl
10// ================================================================================================
11
14template <typename Model, typename ModelSPH>
15struct IRockySPHElementImpl
16{
17 ROCKY_FUNCTIONS bool is_dem_coupled() const
18 {
19 return this->_impl.is_dem_coupled();
20 }
21
22 ROCKY_FUNCTIONS bool is_enabled() const
23 {
24 return this->_impl.is_enabled();
25 }
26
27 ROCKY_FUNCTIONS int get_input_index() const
28 {
29 return this->_impl.get_input_index();
30 }
31
32 ROCKY_FUNCTIONS float get_density() const
33 {
34 return this->_impl.get_density();
35 }
36
37 ROCKY_FUNCTIONS float get_pressure() const
38 {
39 return this->_impl.get_pressure();
40 }
41
42 ROCKY_FUNCTIONS float get_release_time() const
43 {
44 return this->_impl.get_release_time();
45 }
46
47 ROCKY_FUNCTIONS float3 get_position() const
48 {
49 return this->_impl.get_adjusted_coordinates();
50 }
51
52 ROCKY_FUNCTIONS float3 get_velocity() const
53 {
54 return this->_impl.get_velocity();
55 }
56
57 ROCKY_FUNCTIONS float3 get_normal() const
58 {
59 return this->_impl.get_normal();
60 }
61
62 ROCKY_FUNCTIONS float3 get_force() const
63 {
64 return this->_impl.get_force();
65 }
66
67 ROCKY_FUNCTIONS float3 get_acceleration() const
68 {
69 return this->_impl.get_acceleration();
70 }
71
72 ROCKY_FUNCTIONS IRockySPHElementScalars get_scalars()
73 {
74 return this->_impl.get_scalars();
75 }
76
77 ROCKY_FUNCTIONS IRockySPHElementImpl(
78 Model* model, ModelSPH* sph_model, int index, cuda_particle_sph* particle)
79 : _impl(model, sph_model)
80 {
81 _impl.reset(index, particle);
82 }
83
84 ROCKY_FUNCTIONS IRockySPHElementImpl(RockySPHElement<Model, ModelSPH> impl)
85 : _impl(impl)
86 {
87 }
88
89 RockySPHElement<Model, ModelSPH> _impl;
90};
91
94// ================================================================================================
95// IRockySPHElement
96// ================================================================================================
97
105struct IRockySPHElement : public IRockySPHElementImpl<SDeviceModel, SPHDeviceModel>
106{
109 ROCKY_FUNCTIONS IRockySPHElement(SDeviceModel* model, SPHDeviceModel* sph_model, int index)
110 : IRockySPHElementImpl(model, sph_model, index, sph_model->prt_sph + index)
111 {
112 }
113
114 ROCKY_FUNCTIONS IRockySPHElement(RockySPHElement<SDeviceModel, SPHDeviceModel> impl)
115 : IRockySPHElementImpl(impl)
116 {
117 }
118
126 {
127 return this->_impl.get_linked_dem_particle<IRockyParticle>();
128 }
129
135 ROCKY_FUNCTIONS void add_force(const float3& force) const
136 {
137 this->_impl.add_force(force);
138 }
139
146 ROCKY_FUNCTIONS void add_acceleration(const float3& acceleration) const
147 {
148 this->_impl.add_acceleration(acceleration);
149 }
150
157 ROCKY_FUNCTIONS void set_frozen(bool frozen)
158 {
159 this->_impl.set_frozen(frozen);
160 }
161
165 ROCKY_FUNCTIONS bool is_frozen() const
166 {
167 return this->_impl.is_frozen();
168 }
169
170#ifdef ONLY_FOR_DOXYGEN
171
176 ROCKY_FUNCTIONS bool is_dem_coupled() const;
177
181 ROCKY_FUNCTIONS float get_density() const;
182
186 ROCKY_FUNCTIONS float get_pressure() const;
187
191 ROCKY_FUNCTIONS float get_release_time() const;
192
196 ROCKY_FUNCTIONS float3 get_position() const;
197
202 ROCKY_FUNCTIONS float3 get_velocity() const;
203
217 ROCKY_FUNCTIONS float3 get_normal() const;
218
224 ROCKY_FUNCTIONS float3 get_force() const;
225
231 ROCKY_FUNCTIONS float3 get_acceleration() const;
232
238
239#endif
240};
241
242// ================================================================================================
243// IRockySPHElementHost
244// ================================================================================================
245
252struct IRockySPHElementHost : public IRockySPHElementImpl<RockyModel, SPHModel>
253{
256 IRockySPHElementHost(RockyModel* model, SPHModel* sph_model, int index)
257 : IRockySPHElementImpl(model, sph_model, index, sph_model->prt_sph.data() + index)
258 {
259 }
260
261 IRockySPHElementHost(RockySPHElement<RockyModel, SPHModel> impl)
262 : IRockySPHElementImpl(impl)
263 {
264 }
265
273 {
274 return this->_impl.get_linked_dem_particle<IRockyParticleHost>();
275 }
276
277#ifdef ONLY_FOR_DOXYGEN
278
280 ROCKY_FUNCTIONS bool is_dem_coupled() const;
281
283 ROCKY_FUNCTIONS float get_density() const;
284
286 ROCKY_FUNCTIONS float get_pressure() const;
287
289 ROCKY_FUNCTIONS float get_release_time() const;
290
292 ROCKY_FUNCTIONS float3 get_position() const;
293
295 ROCKY_FUNCTIONS float3 get_velocity() const;
296
298 ROCKY_FUNCTIONS float3 get_normal() const;
299
301 ROCKY_FUNCTIONS float3 get_force() const;
302
304 ROCKY_FUNCTIONS float3 get_acceleration() const;
305
308
309#endif
310};
Definition rocky_particle_api.hpp:766
Definition rocky_particle_api.hpp:27
Definition rocky_sph_element_api.hpp:253
ROCKY_FUNCTIONS float3 get_force() const
ROCKY_FUNCTIONS IRockySPHElementScalars get_scalars()
ROCKY_FUNCTIONS float3 get_velocity() const
ROCKY_FUNCTIONS float get_pressure() const
ROCKY_FUNCTIONS float3 get_normal() const
ROCKY_FUNCTIONS IRockyParticleHost get_linked_dem_particle() const
Definition rocky_sph_element_api.hpp:272
ROCKY_FUNCTIONS float get_density() const
ROCKY_FUNCTIONS float3 get_acceleration() const
ROCKY_FUNCTIONS float get_release_time() const
ROCKY_FUNCTIONS float3 get_position() const
ROCKY_FUNCTIONS bool is_dem_coupled() const
Definition rocky_sph_element_scalars.hpp:121
Definition rocky_sph_element_api.hpp:106
ROCKY_FUNCTIONS void add_force(const float3 &force) const
Definition rocky_sph_element_api.hpp:135
ROCKY_FUNCTIONS void set_frozen(bool frozen)
Definition rocky_sph_element_api.hpp:157
ROCKY_FUNCTIONS IRockySPHElementScalars get_scalars()
ROCKY_FUNCTIONS bool is_dem_coupled() const
ROCKY_FUNCTIONS float get_pressure() const
ROCKY_FUNCTIONS float get_density() const
ROCKY_FUNCTIONS IRockyParticle get_linked_dem_particle() const
Definition rocky_sph_element_api.hpp:125
ROCKY_FUNCTIONS float3 get_position() const
ROCKY_FUNCTIONS bool is_frozen() const
Definition rocky_sph_element_api.hpp:165
ROCKY_FUNCTIONS void add_acceleration(const float3 &acceleration) const
Definition rocky_sph_element_api.hpp:146
ROCKY_FUNCTIONS float3 get_acceleration() const
ROCKY_FUNCTIONS float get_release_time() const
ROCKY_FUNCTIONS float3 get_velocity() const
ROCKY_FUNCTIONS float3 get_force() const
ROCKY_FUNCTIONS float3 get_normal() const

Connect with Ansys