Skip to main content

Rocky Solver SDK 2025 R2

rocky_sph_element_scalars

Last update: 16.07.2025
1// (C) 2024 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
2#pragma once
3
4// Includes =======================================================================================
5#include "../rocky_scalars.h"
6#include <rocky20/sph/sph_particle_scalars.h>
7
8using rocky20::KnownSPHParticleScalars;
9
10// Forward declarations ===========================================================================
11class cuda_host;
12struct SPHDeviceModel;
13typedef cuda_host RockyModel;
14
15enum ESPHOperationType
16{
17 sphotReset,
18 sphotSum,
19 sphotUpdate
20};
21
29struct IRockySPHElementScalarsModel : ScalarsModel<rocky20::SPHParticleScalarsController>
30{
31 // Scalars Operations ------------------------------------------------------------------------
32
82 void set_operation(int scalar_index, ESPHOperationType operation, ESPHOperationPlace place);
83
88 void enable_velocity_gradient() const;
89
97
98#ifdef ONLY_FOR_DOXYGEN
99
101 int find(const char* name);
102
104 void reset(int scalar_index);
105
107 void set_dimension(int scalar_index, double dimension_factor);
108
109#endif
110
112 template <class _data_type = float>
113 int add(const char* name, const char* unit, bool output = true)
114 {
115 // By definition, SPH Scalars are default-typed accumulation for mGPU combine operations.
116 // Although, this is a convention that must be enforced by a set_operation call indicating
117 // where the accumulation/sum must occur.
118 return this->_impl.template add_scalars<_data_type>(
119 name, unit, rocky20::ScalarsInfo::cotAccumulateOnDemand, output);
120 }
121
124 IRockySPHElementScalarsModel(SPHModel* sph_model, const std::vector<int>& device_ids);
125
127};
128
135struct IRockySPHElementScalars : EntityScalars<rocky20::SPHParticleScalars>
136{
138 using base_type = EntityScalars<rocky20::SPHParticleScalars>;
141 // get ----------------------------------------------------------------------------------------
142
144 template <class _data_type = float>
145 ROCKY_FUNCTIONS _data_type get_scalar(int scalar_index) const
146 {
147 return base_type::get_scalar<_data_type>(scalar_index);
148 }
149
155 ROCKY_FUNCTIONS inline float get_turbulent_viscosity() const
156 {
157 return this->get_known_scalar<float>(KnownSPHParticleScalars::TurbulentViscosity);
158 }
159
165 ROCKY_FUNCTIONS inline float get_temperature() const
166 {
167 return this->get_known_scalar<float>(KnownSPHParticleScalars::Temperature);
168 }
169
175 ROCKY_FUNCTIONS inline float get_heat_transfer() const
176 {
177 return this->get_known_scalar<float>(KnownSPHParticleScalars::HeatTransferRate);
178 }
179
186 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_x() const
187 {
188 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityX);
189 }
190
197 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_y() const
198 {
199 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityY);
200 }
201
208 ROCKY_FUNCTIONS inline float3 get_velocity_gradient_z() const
209 {
210 return this->get_known_scalar<float3>(KnownSPHParticleScalars::GradientVelocityZ);
211 }
212
213 // set ----------------------------------------------------------------------------------------
214
216 template <class _data_type = float>
217 ROCKY_FUNCTIONS void set_scalar(int scalar_index, _data_type value) const
218 {
219 base_type::set_scalar<_data_type>(scalar_index, value);
220 }
221
228 ROCKY_FUNCTIONS inline void set_turbulent_viscosity(const float value)
229 {
230 this->get_known_scalar<float>(KnownSPHParticleScalars::TurbulentViscosity) = value;
231 }
232
239 ROCKY_FUNCTIONS inline void set_temperature(const float value)
240 {
241 this->get_known_scalar<float>(KnownSPHParticleScalars::Temperature) = value;
242 }
243
250 ROCKY_FUNCTIONS inline void set_heat_transfer(const float value)
251 {
252 this->get_known_scalar<float>(KnownSPHParticleScalars::HeatTransferRate) = value;
253 }
254
255 // add ----------------------------------------------------------------------------------------
256
258 template <class _data_type = float>
259 ROCKY_FUNCTIONS void add_scalar(int scalar_index, _data_type value) const
260 {
261 base_type::add_scalar<_data_type>(scalar_index, value);
262 }
263
269 ROCKY_FUNCTIONS inline void add_turbulent_viscosity(const float value)
270 {
271 this->add_known_scalar(KnownSPHParticleScalars::TurbulentViscosity, value);
272 }
273
279 ROCKY_FUNCTIONS inline void add_temperature(const float value)
280 {
281 this->add_known_scalar(KnownSPHParticleScalars::Temperature, value);
282 }
283
291 ROCKY_FUNCTIONS inline void add_heat_transfer(const float value)
292 {
293 this->add_known_scalar(KnownSPHParticleScalars::HeatTransferRate, value);
294 }
295
296 // max ----------------------------------------------------------------------------------------
297
299 template <class _data_type = float>
300 ROCKY_FUNCTIONS void max_scalar(int scalar_index, _data_type value) const
301 {
302 base_type::max_scalar<_data_type>(scalar_index, value);
303 }
304
307 ROCKY_FUNCTIONS IRockySPHElementScalars(
308 rocky20::SPHParticleScalars& _scalars, int _element_index)
309 : EntityScalars<rocky20::SPHParticleScalars>(_scalars, _element_index)
310 {
311 }
312
314};
Definition rocky_sph_element_scalars.hpp:30
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:12
void enable_variable_molecular_viscosity() const
Definition rocky_sph_element_scalars.cpp:37
void reset(int scalar_index)
int add(const char *name, const char *unit, bool output=true)
Definition rocky_sph_element_scalars.hpp:113
void enable_velocity_gradient() const
Definition rocky_sph_element_scalars.cpp:32
Definition rocky_sph_element_scalars.hpp:136
ROCKY_FUNCTIONS float3 get_velocity_gradient_y() const
Definition rocky_sph_element_scalars.hpp:197
ROCKY_FUNCTIONS float3 get_velocity_gradient_x() const
Definition rocky_sph_element_scalars.hpp:186
ROCKY_FUNCTIONS void add_turbulent_viscosity(const float value)
Definition rocky_sph_element_scalars.hpp:269
ROCKY_FUNCTIONS void set_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:217
ROCKY_FUNCTIONS void add_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:259
ROCKY_FUNCTIONS float get_heat_transfer() const
Definition rocky_sph_element_scalars.hpp:175
ROCKY_FUNCTIONS void set_temperature(const float value)
Definition rocky_sph_element_scalars.hpp:239
ROCKY_FUNCTIONS float get_temperature() const
Definition rocky_sph_element_scalars.hpp:165
ROCKY_FUNCTIONS void add_heat_transfer(const float value)
Definition rocky_sph_element_scalars.hpp:291
ROCKY_FUNCTIONS float3 get_velocity_gradient_z() const
Definition rocky_sph_element_scalars.hpp:208
ROCKY_FUNCTIONS _data_type get_scalar(int scalar_index) const
Definition rocky_sph_element_scalars.hpp:145
ROCKY_FUNCTIONS void add_temperature(const float value)
Definition rocky_sph_element_scalars.hpp:279
ROCKY_FUNCTIONS void set_turbulent_viscosity(const float value)
Definition rocky_sph_element_scalars.hpp:228
ROCKY_FUNCTIONS void max_scalar(int scalar_index, _data_type value) const
Definition rocky_sph_element_scalars.hpp:300
ROCKY_FUNCTIONS void set_heat_transfer(const float value)
Definition rocky_sph_element_scalars.hpp:250
ROCKY_FUNCTIONS float get_turbulent_viscosity() const
Definition rocky_sph_element_scalars.hpp:155

Connect with Ansys