Skip to main content

Rocky Solver SDK 2024 R2

api_omp_cfd_coupling

Last update: 17.07.2025
1#pragma once
2
3#include <rocky20/device/omp_backend.hpp>
4#include <rocky20/api/device/api_device_cfd_coupling.hpp>
5
6namespace rocky::omp
7{
8
9template <class _Plugin=device::EmptyCustomCouplingPlugin>
10void select_and_dispatch_cfd_coupling_kernel(
11 IRockyModel& model,
12 DeviceParticleGroupData* device_group_data,
13 void** udf_devices_data
14)
15{
16 if (model.get_number_of_active_particles() <= 0)
17 return;
18
19 // shut up nvcc compile warnings when compiling device function version using OMPBackend
20#ifndef __CUDA_ARCH__
21
22 bool collect_cfd_data = model._impl->GetDeviceModel(0).cfd_data_recorder != nullptr;
23 #pragma omp parallel num_threads(model.get_number_of_processes())
24 {
25 const auto& group_device_data = device_group_data[0];
26 model._impl->GetDeviceModel(0).cfd_monitor->thread_bins[OMPBackend::ThreadIndex()].reset();
27
28 unsigned int* group_particle_indexes = group_device_data.d_group_2_particles;
29 for (int i = 0; i < group_device_data.group_indexes.size(); ++i)
30 {
31 const int particle_group_index = group_device_data.group_indexes[i];
32 device::select_and_dispatch_coupling_kernel<_Plugin>(
33 false,
34 collect_cfd_data,
35 model.get_device_data(0),
36 group_particle_indexes,
37 group_device_data.n_particles_per_group[i],
38 (udf_devices_data != nullptr ? udf_devices_data[0] : nullptr),
39 model._impl->cfd_data.gen_cfd,
40 model._impl->cfd_data.cfd_particle_groups[particle_group_index]);
41 group_particle_indexes += group_device_data.n_particles_per_group[i];
42 }
43 }
44
45#endif
46}
47
48template <typename _Op>
49inline
50void dispatch_fluid_kernel(IRockyModel& model, _Op op, void** udf_devices_data)
51{
52 if (model.get_number_of_active_particles() <= 0)
53 return;
54
55 // shut up nvcc compile warnings when compiling device function version using OMPBackend
56#ifndef __CUDA_ARCH__
57
58 #pragma omp parallel num_threads(model.get_number_of_processes())
59 device::api_compute_cfd_data_coupling<OMPBackend>(
60 model.get_device_data(0),
61 model.get_current_time(),
62 op,
63 (udf_devices_data != nullptr ? udf_devices_data[0] : nullptr)
64 );
65
66#endif
67}
68
69}
Definition rocky_api.h:60
int get_number_of_active_particles() const
Definition rocky_api.cpp:139
double get_current_time() const
Definition rocky_api.cpp:129

Connect with Ansys