Skip to main content

Rocky Solver SDK 2025 R1

rocky_sph_element_scalars

Last update: 17.07.2025
1#pragma once
2
3// Includes =======================================================================================
4#include "../rocky_scalars.h"
5#include <rocky20/sph/sph_particle_scalars.h>
6
7using rocky20::KnownSPHParticleScalars;
8
9// Forward declarations ===========================================================================
10class cuda_host;
11struct SPHDeviceModel;
12typedef cuda_host RockyModel;
13
14enum ESPHOperationType
15{
16 sphotReset,
17 sphotSum,
18 sphotUpdate
19};
20
28struct IRockySPHElementScalarsModel : ScalarsModel<rocky20::SPHParticleScalarsController>
29{
30 // Scalars Operations ------------------------------------------------------------------------
31
81 void set_operation(int scalar_index, ESPHOperationType operation, ESPHOperationPlace place);
82
87 void enable_velocity_gradient() const;
88
89#ifdef ONLY_FOR_DOXYGEN
90
92 int find(const char* name);
93
95 void reset(int scalar_index);
96
98 void set_dimension(int scalar_index, double dimension_factor);
99
100#endif
101
103 template <class _data_type = float>
104 int add(const char* name, const char* unit, bool output = true)
105 {
106 // By definition, SPH Scalars are default-typed accumulation for mGPU combine operations.
107 // Although, this is a convention that must be enforced by a set_operation call indicating
108 // where the accumulation/sum must occur.
109 return this->_impl.template add_scalars<_data_type>(
110 name, unit, rocky20::ScalarsInfo::cotAccumulateOnDemand, output);
111 }
112
115 IRockySPHElementScalarsModel(SPHModel* sph_model, const std::vector<int>& device_ids);
116
118};
119
126struct IRockySPHElementScalars : EntityScalars<rocky20::SPHParticleScalars>
127{
129 using base_type = EntityScalars<rocky20::SPHParticleScalars>;
132 // get ----------------------------------------------------------------------------------------
133
135 template <class _data_type = float>
136 ROCKY_FUNCTIONS _data_type get_scalar(int scalar_index) const
137 {
138 return base_type::get_scalar<_data_type>(scalar_index);
139 }
140
146 ROCKY_FUNCTIONS inline float get_turbulent_viscosity() const
147 {
148 return this->get_known_scalar<float>(KnownSPHParticleScalars::TurbulentViscosity);
149 }
150
156 ROCKY_FUNCTIONS inline float get_temperature() const
157 {
158 return this->get_known_scalar<float>(KnownSPHParticleScalars::Temperature);
159 }
160
166 ROCKY_FUNCTIONS inline float get_heat_transfer() const
167 {
168 return this->get_known_scalar<float>(KnownSPHParticleScalars::HeatTransferRate);
169 }
170
177 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_x() const
178 {
179 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityX);
180 }
181
188 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_y() const
189 {
190 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityY);
191 }
192
199 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_z() const
200 {
201 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityZ);
202 }
203
204 // set ----------------------------------------------------------------------------------------
205
207 template <class _data_type = float>
208 ROCKY_FUNCTIONS void set_scalar(int scalar_index, _data_type value) const
209 {
210 base_type::set_scalar<_data_type>(scalar_index, value);
211 }
212
219 ROCKY_FUNCTIONS inline void set_turbulent_viscosity(const float value)
220 {
221 this->get_known_scalar<float>(KnownSPHParticleScalars::TurbulentViscosity) = value;
222 }
223
230 ROCKY_FUNCTIONS inline void set_temperature(const float value)
231 {
232 this->get_known_scalar<float>(KnownSPHParticleScalars::Temperature) = value;
233 }
234
241 ROCKY_FUNCTIONS inline void set_heat_transfer(const float value)
242 {
243 this->get_known_scalar<float>(KnownSPHParticleScalars::HeatTransferRate) = value;
244 }
245
246 // add ----------------------------------------------------------------------------------------
247
249 template <class _data_type = float>
250 ROCKY_FUNCTIONS void add_scalar(int scalar_index, _data_type value) const
251 {
252 base_type::add_scalar<_data_type>(scalar_index, value);
253 }
254
260 ROCKY_FUNCTIONS inline void add_turbulent_viscosity(const float value)
261 {
262 this->add_known_scalar(KnownSPHParticleScalars::TurbulentViscosity, value);
263 }
264
270 ROCKY_FUNCTIONS inline void add_temperature(const float value)
271 {
272 this->add_known_scalar(KnownSPHParticleScalars::Temperature, value);
273 }
274
282 ROCKY_FUNCTIONS inline void add_heat_transfer(const float value)
283 {
284 this->add_known_scalar(KnownSPHParticleScalars::HeatTransferRate, value);
285 }
286
287 // max ----------------------------------------------------------------------------------------
288
290 template <class _data_type = float>
291 ROCKY_FUNCTIONS void max_scalar(int scalar_index, _data_type value) const
292 {
293 base_type::max_scalar<_data_type>(scalar_index, value);
294 }
295
298 ROCKY_FUNCTIONS IRockySPHElementScalars(
299 rocky20::SPHParticleScalars& _scalars, int _element_index)
300 : EntityScalars<rocky20::SPHParticleScalars>(_scalars, _element_index)
301 {
302 }
303
305};
Definition rocky_sph_element_scalars.hpp:29
int find(const char *name)
void set_dimension(int scalar_index, double dimension_factor)
void set_operation(int scalar_index, ESPHOperationType operation, ESPHOperationPlace place)
Definition rocky_sph_element_scalars.cpp:11
void reset(int scalar_index)
int add(const char *name, const char *unit, bool output=true)
Definition rocky_sph_element_scalars.hpp:104
void enable_velocity_gradient() const
Definition rocky_sph_element_scalars.cpp:31
Definition rocky_sph_element_scalars.hpp:127
ROCKY_FUNCTIONS float3 get_velocity_gradient_y() const
Definition rocky_sph_element_scalars.hpp:188
ROCKY_FUNCTIONS float3 get_velocity_gradient_x() const
Definition rocky_sph_element_scalars.hpp:177
ROCKY_FUNCTIONS void add_turbulent_viscosity(const float value)
Definition rocky_sph_element_scalars.hpp:260
ROCKY_FUNCTIONS void set_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:208
ROCKY_FUNCTIONS void add_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:250
ROCKY_FUNCTIONS float get_heat_transfer() const
Definition rocky_sph_element_scalars.hpp:166
ROCKY_FUNCTIONS void set_temperature(const float value)
Definition rocky_sph_element_scalars.hpp:230
ROCKY_FUNCTIONS float get_temperature() const
Definition rocky_sph_element_scalars.hpp:156
ROCKY_FUNCTIONS void add_heat_transfer(const float value)
Definition rocky_sph_element_scalars.hpp:282
ROCKY_FUNCTIONS float3 get_velocity_gradient_z() const
Definition rocky_sph_element_scalars.hpp:199
ROCKY_FUNCTIONS _data_type get_scalar(int scalar_index) const
Definition rocky_sph_element_scalars.hpp:136
ROCKY_FUNCTIONS void add_temperature(const float value)
Definition rocky_sph_element_scalars.hpp:270
ROCKY_FUNCTIONS void set_turbulent_viscosity(const float value)
Definition rocky_sph_element_scalars.hpp:219
ROCKY_FUNCTIONS void max_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:291
ROCKY_FUNCTIONS void set_heat_transfer(const float value)
Definition rocky_sph_element_scalars.hpp:241
ROCKY_FUNCTIONS float get_turbulent_viscosity() const
Definition rocky_sph_element_scalars.hpp:146

Connect with Ansys