Skip to main content

Rocky Solver SDK 2024 R2

api_omp_sph

Last update: 17.07.2025
1#pragma once
2
3// Includes ---------------------------------------------------------------------------------------
4#include <rocky20/api/rocky_api.h>
5
6#include <rocky20/api/sph/api_device_sph.hpp>
7#include <rocky20/device/omp_backend.hpp>
8
9namespace rocky::omp {
10
11// Dispatchers ------------------------------------------------------------------------------------
12template <typename Operator = device::DefaultOperator<OMPBackend>, typename Functor>
13inline void dispatch_sph_elements_kernel(
14 IRockyModel& model, Functor& omp_dispatch_particle_f, void* udf_data)
15{
16 SPHModel* sph_model = &(*model._impl->sph_model);
17 SPHDeviceModel* sph_device = model._impl->sph_model->get_device_data(0);
18 SDeviceModel* device_data = model.get_device_data(0);
19
20 if (sph_model->gen_sph.nprt_active <= 0)
21 return;
22
23#ifndef __CUDA_ARCH__
24 #pragma omp parallel num_threads(model.get_number_of_processes())
25 {
26 device::launch_sph_particles_function<OMPBackend, Operator>(
27 device_data, sph_device, model.get_current_time(), omp_dispatch_particle_f, udf_data);
28 }
29#endif
30}
31
32template <typename Operator = device::DefaultElementsOperator<OMPBackend>, typename Functor>
33inline void dispatch_sph_interactions_elements_kernel(
34 IRockyModel& model,
35 Functor& sph_particle_interaction_f,
36 void* udf_data,
37 IterationType it_type = itAll)
38{
39 SPHModel* sph_model = &(*model._impl->sph_model);
40 SPHDeviceModel* sph_device = model._impl->sph_model->get_device_data(0);
41 SDeviceModel* device_data = model.get_device_data(0);
42
43 if (sph_model->gen_sph.nprt_active <= 0)
44 return;
45
46#ifndef __CUDA_ARCH__
47 #pragma omp parallel num_threads(model.get_number_of_processes())
48 {
49 // SPH -> SPH
50 device::launch_sph_interactions_particles<OMPBackend, Operator>(
51 device_data,
52 sph_device,
53 model.get_current_time(),
54 sph_particle_interaction_f,
55 udf_data,
56 it_type);
57 }
58#endif
59}
60
61template <typename Operator = device::DefaultTrianglesOperator<OMPBackend>, typename Functor>
62inline void dispatch_sph_interactions_triangles_kernel(
63 IRockyModel& model, Functor& sph_triangle_interaction_f, void* udf_data)
64{
65 SPHModel* sph_model = &(*model._impl->sph_model);
66 SPHDeviceModel* sph_device = model._impl->sph_model->get_device_data(0);
67 SDeviceModel* device_data = model.get_device_data(0);
68
69 if (sph_model->gen_sph.nprt_active <= 0)
70 return;
71
72#ifndef __CUDA_ARCH__
73 #pragma omp parallel num_threads(model.get_number_of_processes())
74 {
75 // SPH -> triangles
76 device::launch_sph_interactions_triangles<OMPBackend, Operator>(
77 device_data,
78 sph_device,
79 model.get_current_time(),
80 sph_triangle_interaction_f,
81 udf_data);
82 }
83#endif
84}
85
86} // namespace rocky::omp
Definition rocky_api.h:60
double get_current_time() const
Definition rocky_api.cpp:129

Connect with Ansys