Skip to main content

Rocky Solver SDK 2024 R2

rocky_api_functions

Last update: 17.07.2025
1#pragma once
2
3// Includes =======================================================================================
4#include "dll_export.h"
5
6#include "rocky_boundary_api.hpp"
7
8// Forward declarations ===========================================================================
10struct IRockyModel;
12struct IRockyContact;
13struct IRockyParticle;
16struct IRockyJoint;
17
20struct IRockyTimeCurveData;
22struct IRockyJointOutputData;
25
26// Functions Prototypes ===========================================================================
27#ifdef __linux__
28#define __stdcall
29#endif
30
31typedef void(__stdcall *configure_f_type)(IRockyPluginData &_input, void *&data);
32
33// Setup/Tear Down
34typedef void(__stdcall *initialize_f_type)(IRockyModel &model, void *data);
35
36typedef void(__stdcall *tear_down_f_type)(const IRockyModel &model, void *data);
37
38typedef void(__stdcall *setup_f_type)(IRockyModel &model, void *data);
39
40typedef double(__stdcall *compute_timestep_f_type)(const IRockyTimestepData &timestep_data, void *data);
41
42typedef double(__stdcall *compute_adhesive_distances_f_type)(IRockyAdhesiveDistanceData &adhesive_distance_data, void *data);
43
44typedef void(__stdcall *non_dimensionalize_f_type)(IRockyModel &model, void *data);
45
46typedef void(__stdcall *initialize_cuda_f_type)(const IRockyModel &model, void *host_data, int device_id, void *&device_data);
47
48typedef void(__stdcall *tear_down_cuda_f_type)(const IRockyModel &model, int device_id, void *device_data);
49
50typedef void(__stdcall *sync_cuda_data_f_type)(const IRockyModel &model, void *host_data, int device_id, void *device_data);
51
52typedef void(__stdcall* initialize_particle_f_type)(const IRockyModel& model, IRockyParticleHost& particle, void* data);
53
54typedef void(__stdcall* initialize_triangle_f_type)(const IRockyModel& model, IRockyGeometryTriangleHost& triangle, void* data);
55
56typedef void(__stdcall *initialize_breakage_f_type)(const IRockyBreakableParticle& breakable_particle, void* data);
57
58typedef void(__stdcall* setup_output_properties_f_type)(const IRockyModel& model, IRockyOutputPropertyCollection& output_property_collection, void* data);
59
60typedef bool(__stdcall *is_valid_f_type)(const IRockyModel &model, void *data);
61
62
63// Output
64typedef void(__stdcall *output_f_type)(const IRockyModel &model, void *data);
65
66typedef double(__stdcall* output_particles_f_type)(const IRockyModel& model, const IRockyParticleHost& particle, int property_id, void* data);
67
68typedef double(__stdcall* output_triangles_f_type)(const IRockyModel& model, const IRockyGeometryTriangleHost& triangle, int property_id, void* data);
69
70// Contacts
71typedef void(__stdcall *contacts_f_type)(IRockyDeviceModel &model, IRockyContact &contact, void *data);
72
73typedef void(__stdcall* cuda_contacts_kernel_f_type)(IRockyModel& model, void** plugin_devices_data);
74
75typedef void(__stdcall *triangle_wear_f_type)(IRockyContact& contact, double& wear_volume, void* data);
76
77typedef void(__stdcall* cuda_triangle_wear_kernel_f_type)(IRockyModel& model, void* data);
78
79// Adhesion
80
81typedef void(__stdcall* adhesion_forces_f_type)(IRockyContact& contact, IRockyAdhesionOutputData& output_data, void* data);
82
83typedef void(__stdcall* cuda_adhesion_forces_kernel_f_type)(IRockyModel& model, void** plugin_devices_data);
84
85// Particles
86typedef void(__stdcall *particles_f_type)(IRockyDeviceModel &model, IRockyParticle &particle, void *data);
87
88typedef void(__stdcall *cuda_particles_kernel_f_type)(IRockyModel &model, void **plugin_devices_data);
89
90// Triangles
91typedef void(__stdcall* triangles_f_type)(IRockyDeviceModel& model, IRockyBoundaryTriangle& triangle, void* data);
92
93typedef void(__stdcall* cuda_triangles_kernel_f_type)(IRockyModel& model, void** plugin_devices_data);
94
95// Instantaneous breakage
96typedef void(__stdcall* instantaneous_breakage_f_type)(IRockyParticle& particle, bool& broken, void* data);
97
98typedef void(__stdcall* cuda_instantaneous_breakage_kernel_f_type)(IRockyModel& model, void** plugin_devices_data);
99
100typedef void(__stdcall* fragments_distribution_f_type)(IRockyBreakableParticle& particle, std::vector<double>& distribution, void* data);
101
102// Joints
103typedef void(__stdcall *joints_f_type)(IRockyDeviceModel &model, IRockyJoint &joint, void *data);
104
105typedef void(__stdcall *cuda_joints_kernel_f_type)(IRockyModel &model, void **plugin_devices_data);
106
107typedef void(__stdcall *joint_forces_f_type)(IRockyJoint &joint, IRockyJointOutputData& output_data, void *data);
108
109typedef void(__stdcall *cuda_joint_forces_kernel_f_type)(IRockyModel &model, void **plugin_devices_data);
110
111// Joint breakage
112typedef void(__stdcall* joint_breakage_f_type)(IRockyJoint &joint, bool &broken, void *data);
113
114typedef void(__stdcall* cuda_joint_breakage_kernel_f_type)(IRockyModel &model, void **plugin_devices_data);
115
116// Geometry motion
117typedef void(__stdcall *geometries_motion_f_type)(IRockyModel &model, IRockyGeometriesMotionData &motion, void *data);
118
119// Extra macros for Frictional Contact Forces ------------------------------------------------------
120#include "rocky_api_contact_functions.h"
121
122// Special Functor that wraps a function pointer
123template <typename Function>
124struct Function2Functor
125{
126 template <typename... Args>
127 void operator()(Args&... args)
128 {
129 (*this->function)(args...);
130 }
131 Function function;
132};
133
134// UDF =============================================================================================
135#define ROCKY_PLUGIN(plugin_name, plugin_version) \
136 ROCKY_PLUGIN_INFO(plugin_name, plugin_version) extern "C" {
137
138#define ROCKY_PLUGIN_END \
139 ROCKY_PLUGIN_FINISH_CONTACT_MODEL_FUNCTIONS_SETUP() }
140
141// Initialization ---------------------------------------------------------------------------------
142#define ROCKY_PLUGIN_CONFIGURE(input_data, data) \
143 ROCKYAPI_EXPORT void configure(const IRockyPluginData &input_data, void *&data)
144
145#define ROCKY_PLUGIN_NON_DIMENSIONALIZE(model, data) \
146 extern "C" ROCKYAPI_EXPORT void non_dimensionalize(IRockyModel &model, void *data)
147
148#define ROCKY_PLUGIN_INITIALIZE(model, data) \
149 extern "C" ROCKYAPI_EXPORT void initialize(IRockyModel &model, void *data)
150
151#define ROCKY_PLUGIN_TEAR_DOWN(model, data) \
152 extern "C" ROCKYAPI_EXPORT void finish(const IRockyModel &model, void *data)
153
154#define ROCKY_PLUGIN_SETUP(model, data) \
155 extern "C" ROCKYAPI_EXPORT void setup(IRockyModel &model, void *data)
156
157#define ROCKY_PLUGIN_COMPUTE_TIMESTEP(timestep_data, data) \
158 extern "C" ROCKYAPI_EXPORT double compute_timestep(const IRockyTimestepData &timestep_data, void *data)
159
160#define ROCKY_PLUGIN_IS_VALID(model, data) \
161 extern "C" ROCKYAPI_EXPORT bool is_valid(const IRockyModel &model, void *data)
162
163#ifdef _MSC_VER
164 #define _STR(x) #x
165 #define STR(x) _STR(x)
166 #define DO_PRAGMA_(x) __pragma (message(__FILE__ "(" STR(__LINE__) ") warning: " x))
167 #define DEPRECATED_WARNING(message) DO_PRAGMA_(message)
168#else
169 #define DO_PRAGMA_(x) _Pragma (#x)
170 #define DEPRECATED_WARNING(message) DO_PRAGMA_(GCC warning #message)
171#endif
172
173#define ROCKY_PLUGIN_COMPUTE_ADHESIVE_DISTANCES(adhesive_distance_data, data) \
174 extern "C" ROCKYAPI_EXPORT \
175 DEPRECATED_WARNING("'ROCKY_PLUGIN_COMPUTE_ADHESIVE_DISTANCES' hook is deprecated. Now you can set adhesive distances in ROCKY_PLUGIN_INITIALIZE or ROCKY_PLUGIN_BEGIN_ITERATION") \
176 void compute_adhesive_distances(IRockyAdhesiveDistanceData &adhesive_distance_data, void *data)
177
178#define ROCKY_PLUGIN_INITIALIZE_CUDA(model, host_data, device_id, device_data) \
179 extern "C" ROCKYAPI_EXPORT void initialize_cuda( \
180 const IRockyModel &model, void *host_data, int device_id, void *&device_data)
181
182#define ROCKY_PLUGIN_TEAR_DOWN_CUDA(model, device_id, device_data) \
183 extern "C" ROCKYAPI_EXPORT void finish_cuda(const IRockyModel &model, int device_id, void *device_data)
184
185#define ROCKY_PLUGIN_INITIALIZE_PARTICLE(model, particle, data) \
186 extern "C" ROCKYAPI_EXPORT void initialize_particle( \
187 IRockyModel& model, IRockyParticleHost& particle, void* data)
188
189#define ROCKY_PLUGIN_INITIALIZE_TRIANGLE(model, triangle, data) \
190 extern "C" ROCKYAPI_EXPORT void initialize_triangle( \
191 IRockyModel& model, IRockyGeometryTriangleHost& triangle, void* data)
192
193#define ROCKY_PLUGIN_INITIALIZE_INSTANTANEOUS_BREAKAGE(breakable_particle, data)\
194 extern "C" ROCKYAPI_EXPORT void initialize_breakage( \
195 IRockyBreakableParticle& breakable_particle, void* data)
196
197#define ROCKY_PLUGIN_INITIALIZE_FRAGMENTS_SIZE_DISTRIBUTION(breakable_particle, data) \
198 extern "C" ROCKYAPI_EXPORT void initialize_size_distribution( \
199 IRockyBreakableParticle& breakable_particle, void* data)
200
201#define ROCKY_PLUGIN_SETUP_OUTPUT_PROPERTIES(model, output_property_collection, data) \
202 extern "C" ROCKYAPI_EXPORT void setup_output_properties( \
203 const IRockyModel& model, IRockyOutputPropertyCollection& output_property_collection, void* data)
204
205// Iteration ---------------------------------------------------------------------------------------
206#define ROCKY_PLUGIN_BEGIN_ITERATION_CUDA(model, host_data, device_id, device_data) \
207 extern "C" ROCKYAPI_EXPORT void begin_iteration_cuda( \
208 const IRockyModel &model, void *host_data, int device_id, void *&device_data)
209
210#define ROCKY_PLUGIN_BEGIN_ITERATION(model, data) \
211 extern "C" ROCKYAPI_EXPORT void begin_iteration(IRockyModel &model, void *data)
212
213#define ROCKY_PLUGIN_END_ITERATION_CUDA(model, host_data, device_id, device_data) \
214 extern "C" ROCKYAPI_EXPORT void end_iteration_cuda( \
215 const IRockyModel &model, void *host_data, int device_id, void *&device_data)
216
217#define ROCKY_PLUGIN_END_ITERATION(model, data) \
218 extern "C" ROCKYAPI_EXPORT void end_iteration(IRockyModel &model, void *data)
219
220// Output ------------------------------------------------------------------------------------------
221#define ROCKY_PLUGIN_PRE_OUTPUT_CUDA_SYNC_DATA(model, host_data, device_id, device_data) \
222 extern "C" ROCKYAPI_EXPORT void pre_output_cuda_sync_data( \
223 const IRockyModel& model, void* host_data, int device_id, void* device_data)
224
225#define ROCKY_PLUGIN_PRE_OUTPUT(model, data) \
226 extern "C" ROCKYAPI_EXPORT void pre_output(const IRockyModel& model, void* data)
227
228#define ROCKY_PLUGIN_PRE_OUTPUT_ON_CONTACTS(device_model, contact, data) \
229 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_output_on_active_contacts( \
230 IRockyDeviceModel &device_model, IRockyContact &contact, void *data) {
231
232#ifndef ROCKY_CUDA_API
233#define ROCKY_PLUGIN_PRE_OUTPUT_ON_CONTACTS_END() }
234#endif
235
236#define ROCKY_PLUGIN_OUTPUT_PARTICLE_PROPERTY(model, particle, property_id, data) \
237 extern "C" ROCKYAPI_EXPORT double output_particle_property( \
238 const IRockyModel& model, IRockyParticleHost& particle, int property_id, void* data)
239
240#define ROCKY_PLUGIN_OUTPUT_TRIANGLE_PROPERTY(model, triangle, property_id, data) \
241 extern "C" ROCKYAPI_EXPORT double output_triangle_property( \
242 const IRockyModel& model, IRockyGeometryTriangleHost& triangle, int property_id, void* data)
243
244#define ROCKY_PLUGIN_POST_OUTPUT(model, data) \
245 extern "C" ROCKYAPI_EXPORT void post_output(const IRockyModel& model, void* data)
246
247// Search ------------------------------------------------------------------------------------------
248#define ROCKY_PLUGIN_PRE_SEARCH_ON_PARTICLES(device_model, particle, data) \
249 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_search_on_particles( \
250 IRockyDeviceModel &device_model, IRockyParticle &particle, void *data) {
251
252#ifndef ROCKY_CUDA_API
253#define ROCKY_PLUGIN_PRE_SEARCH_ON_PARTICLES_END() }
254#endif
255
256// Force -------------------------------------------------------------------------------------------
257#define ROCKY_PLUGIN_PRE_FORCE_ON_CONTACTS(device_model, contact, data) \
258 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_force_on_contacts( \
259 IRockyDeviceModel &device_model, IRockyContact &contact, void *data) {
260
261#ifndef ROCKY_CUDA_API
262#define ROCKY_PLUGIN_PRE_FORCE_ON_CONTACTS_END() }
263#endif
264
265#define ROCKY_PLUGIN_PRE_FORCE_ON_PARTICLES(device_model, particle, data) \
266 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_force_on_particles( \
267 IRockyDeviceModel &device_model, IRockyParticle &particle, void *data) {
268
269#ifndef ROCKY_CUDA_API
270#define ROCKY_PLUGIN_PRE_FORCE_ON_PARTICLES_END() }
271#endif
272
273#define ROCKY_PLUGIN_PRE_FORCE_ON_TRIANGLES(device_model, triangle, data) \
274 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_force_on_triangles( \
275 IRockyDeviceModel &device_model, IRockyBoundaryTriangle &triangle, void *data) {
276
277#ifndef ROCKY_CUDA_API
278#define ROCKY_PLUGIN_PRE_FORCE_ON_TRIANGLES_END() }
279#endif
280
281#define ROCKY_PLUGIN_PRE_FORCE_ON_JOINTS(device_model, joint, data) \
282 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_force_on_joints( \
283 IRockyDeviceModel &device_model, IRockyJoint &joint, void *data) {
284
285#ifndef ROCKY_CUDA_API
286#define ROCKY_PLUGIN_PRE_FORCE_ON_JOINTS_END() }
287#endif
288
289#define ROCKY_PLUGIN_POST_FORCE_ON_CONTACTS(device_model, contact, data) \
290 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_force_on_contacts( \
291 IRockyDeviceModel &device_model, IRockyContact &contact, void *data) {
292
293#ifndef ROCKY_CUDA_API
294#define ROCKY_PLUGIN_POST_FORCE_ON_CONTACTS_END() }
295#endif
296
297#define ROCKY_PLUGIN_POST_FORCE_ON_FINISHED_CONTACTS(device_model, contact, data) \
298 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_force_on_finished_contacts( \
299 IRockyDeviceModel &device_model, IRockyContact &contact, void *data) {
300
301#ifndef ROCKY_CUDA_API
302#define ROCKY_PLUGIN_POST_FORCE_ON_FINISHED_CONTACTS_END() }
303#endif
304
305#define ROCKY_PLUGIN_POST_FORCE_ON_PARTICLES(device_model, particle, data) \
306 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_force_on_particles( \
307 IRockyDeviceModel &device_model, IRockyParticle &particle, void *data) {
308
309#ifndef ROCKY_CUDA_API
310#define ROCKY_PLUGIN_POST_FORCE_ON_PARTICLES_END() }
311#endif
312
313#define ROCKY_PLUGIN_POST_FORCE_ON_TRIANGLES(device_model, triangle, data) \
314 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_force_on_triangles( \
315 IRockyDeviceModel &device_model, IRockyBoundaryTriangle &triangle, void *data) {
316
317#ifndef ROCKY_CUDA_API
318#define ROCKY_PLUGIN_POST_FORCE_ON_TRIANGLES_END() }
319#endif
320
321#define ROCKY_PLUGIN_POST_FORCE_ON_JOINTS(device_model, joint, data) \
322 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_force_on_joints( \
323 IRockyDeviceModel &device_model, IRockyJoint &joint, void *data) {
324
325#ifndef ROCKY_CUDA_API
326#define ROCKY_PLUGIN_POST_FORCE_ON_JOINTS_END() }
327#endif
328
329// Move --------------------------------------------------------------------------------------------
330#define ROCKY_PLUGIN_PRE_MOVE_PARTICLES(device_model, particle, data) \
331 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_move_particles( \
332 IRockyDeviceModel &device_model, IRockyParticle &particle, void *data) {
333
334#ifndef ROCKY_CUDA_API
335#define ROCKY_PLUGIN_PRE_MOVE_PARTICLES_END() }
336#endif
337
338#define ROCKY_PLUGIN_POST_MOVE_PARTICLES(device_model, particle, data) \
339 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_move_particles( \
340 IRockyDeviceModel &device_model, IRockyParticle &particle, void *data) {
341
342#ifndef ROCKY_CUDA_API
343#define ROCKY_PLUGIN_POST_MOVE_PARTICLES_END() }
344#endif
345
346#define ROCKY_PLUGIN_PRE_MOVE_ON_TRIANGLES(device_model, triangle, data) \
347 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void pre_move_triangles( \
348 IRockyDeviceModel &device_model, IRockyBoundaryTriangle &triangle, void *data) {
349
350#ifndef ROCKY_CUDA_API
351#define ROCKY_PLUGIN_PRE_MOVE_ON_TRIANGLES_END() }
352#endif
353
354#define ROCKY_PLUGIN_POST_MOVE_ON_TRIANGLES(device_model, triangle, data) \
355 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void post_move_triangles( \
356 IRockyDeviceModel &device_model, IRockyBoundaryTriangle &triangle, void *data) {
357
358#ifndef ROCKY_CUDA_API
359#define ROCKY_PLUGIN_POST_MOVE_ON_TRIANGLES_END() }
360#endif
361
362// Adhesive forces ---------------------------------------------------------------------------------------
363
364#define COMPUTE_CONTACT_ADHESIVE_FORCES_NAME compute_contact_adhesive_forces
365
366#define ROCKY_PLUGIN_COMPUTE_CONTACT_ADHESIVE_FORCES(contact, output, data) \
367 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS void COMPUTE_CONTACT_ADHESIVE_FORCES_NAME( \
368 IRockyContact& contact, IRockyAdhesionOutputData& output_data, void* data) {
369
370#ifndef ROCKY_CUDA_API
371#define ROCKY_PLUGIN_COMPUTE_CONTACT_ADHESIVE_FORCES_END() }
372#endif
373
374// Joint forces ------------------------------------------------------------------------------------------
375
376#define COMPUTE_JOINT_FORCES_NAME compute_joint_forces
377
378#define ROCKY_PLUGIN_COMPUTE_JOINT_FORCES(joint, output_data, data) \
379 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
380 void COMPUTE_JOINT_FORCES_NAME(IRockyJoint &joint, IRockyJointOutputData& output_data, void *data) {
381
382#ifndef ROCKY_CUDA_API
383#define ROCKY_PLUGIN_COMPUTE_JOINT_FORCES_END() }
384#endif
385
386// Joint breakage ----------------------------------------------------------------------------------
387
388#define COMPUTE_JOINT_BREAKAGE_NAME compute_joint_breakage
389
390#define ROCKY_PLUGIN_COMPUTE_JOINT_BREAKAGE(joint, broken, data) \
391 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
392 void COMPUTE_JOINT_BREAKAGE_NAME(IRockyJoint &joint, bool &broken, void *data) {
393
394#ifndef ROCKY_CUDA_API
395#define ROCKY_PLUGIN_COMPUTE_JOINT_BREAKAGE_END() }
396#endif
397
398// Instantaneous breakage --------------------------------------------------------------------------
399
400#define COMPUTE_INSTANTANEOUS_BREAKAGE_NAME compute_instantaneous_breakage
401
402#define ROCKY_PLUGIN_COMPUTE_INSTANTANEOUS_BREAKAGE(particle, broken, data) \
403 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
404 void COMPUTE_INSTANTANEOUS_BREAKAGE_NAME(IRockyParticle &particle, bool &broken, void *data) {
405
406#ifndef ROCKY_CUDA_API
407#define ROCKY_PLUGIN_COMPUTE_INSTANTANEOUS_BREAKAGE_END() }
408#endif
409
410// Fragments size distribution ---------------------------------------------------------------------
411
412#define COMPUTE_SIZE_DISTRIBUTION_NAME compute_fragments_size_distribution
413
414#define ROCKY_PLUGIN_COMPUTE_FRAGMENTS_SIZE_DISTRIBUTION(breakable_particle, distribution, data) \
415 extern "C" ROCKYAPI_EXPORT \
416 void COMPUTE_SIZE_DISTRIBUTION_NAME(IRockyBreakableParticle &breakable_particle, std::vector<double>& distribution, void *data) {
417
418#define ROCKY_PLUGIN_COMPUTE_FRAGMENTS_SIZE_DISTRIBUTION_END() }
419
420// Boundaries wear ---------------------------------------------------------------------------------
421
422#define COMPUTE_BOUNDARIES_WEAR_NAME compute_boundaries_wear
423
424#define ROCKY_PLUGIN_COMPUTE_BOUNDARIES_WEAR(triangle_contact, wear_volume, data) \
425 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
426 void COMPUTE_BOUNDARIES_WEAR_NAME(IRockyContact &triangle_contact, double& wear_volume, void *data) {
427
428#ifndef ROCKY_CUDA_API
429#define ROCKY_PLUGIN_COMPUTE_BOUNDARIES_WEAR_END() }
430#endif
431
432// Thermal -----------------------------------------------------------------------------------------
433#define COMPUTE_FRICTIONAL_HEAT_CONDUCTION_NAME compute_contact_heat_conduction
434
435#define ROCKY_PLUGIN_COMPUTE_CONTACT_HEAT_CONDUCTION(model, contact, data) \
436 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
437 void COMPUTE_FRICTIONAL_HEAT_CONDUCTION_NAME( \
438 IRockyDeviceModel &model, IRockyContact &contact, void *data) {
439
440#ifndef ROCKY_CUDA_API
441#define ROCKY_PLUGIN_COMPUTE_CONTACT_HEAT_CONDUCTION_END() }
442#endif
443
444#define COMPUTE_THERMAL_INTEGRATION_NAME compute_thermal_integration
445
446#define ROCKY_PLUGIN_COMPUTE_THERMAL_INTEGRATION(model, particle, data) \
447 extern "C" ROCKYAPI_EXPORT ROCKY_FUNCTIONS \
448 void COMPUTE_THERMAL_INTEGRATION_NAME( \
449 IRockyDeviceModel &model, IRockyParticle &particle, void *data) {
450
451#ifndef ROCKY_CUDA_API
452#define ROCKY_PLUGIN_COMPUTE_THERMAL_INTEGRATION_END() }
453#endif
454
455// Geometry motion ---------------------------------------------------------------------------------
456#define ROCKY_PLUGIN_COMPUTE_GEOMETRIES_MOTION(model, motion, data) \
457 extern "C" ROCKYAPI_EXPORT void compute_geometries_motion(IRockyModel &model, IRockyGeometriesMotionData &motion, void *data)
458
459// CUDA ============================================================================================
460
461#ifdef ROCKY_CUDA_API
462
463 // on particles
464 #define ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(func_name) \
465 struct f_##func_name##_type \
466 { \
467 ROCKY_FUNCTIONS void operator()( \
468 IRockyDeviceModel& device_model_api, IRockyParticle& particle_api, void* udf_data) \
469 { \
470 func_name(device_model_api, particle_api, udf_data); \
471 } \
472 }; \
473 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
474 IRockyModel& model, void** plugin_device_data) \
475 { \
476 f_##func_name##_type device_functor {}; \
477 rocky::cuda::dispatch_particles_kernel(model, device_functor, plugin_device_data); \
478 }
479
480 // on triangles
481 #define ROCKY_PLUGIN_TRIANGLES_CUDA_KERNEL(func_name) \
482 struct f_##func_name##_type \
483 { \
484 ROCKY_FUNCTIONS void operator()( \
485 IRockyDeviceModel& device_model_api, \
486 IRockyBoundaryTriangle& triangle_api, \
487 void* udf_data) \
488 { \
489 func_name(device_model_api, triangle_api, udf_data); \
490 } \
491 }; \
492 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
493 IRockyModel& model, void** plugin_device_data) \
494 { \
495 f_##func_name##_type device_functor {}; \
496 rocky::cuda::dispatch_triangles_kernel(model, device_functor, plugin_device_data); \
497 }
498
499 // on contacts
500 #define ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(func_name, c_type) \
501 struct f_##func_name##_type \
502 { \
503 ROCKY_FUNCTIONS void operator()( \
504 IRockyDeviceModel& device_model_api, IRockyContact& contact_api, void* udf_data) \
505 { \
506 func_name(device_model_api, contact_api, udf_data); \
507 } \
508 }; \
509 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
510 IRockyModel& model, void** plugin_device_data) \
511 { \
512 f_##func_name##_type device_functor {}; \
513 rocky::cuda::dispatch_##c_type##_contacts_kernel( \
514 model, device_functor, device_functor, plugin_device_data); \
515 }
516
517 // on joints
518 #define ROCKY_PLUGIN_JOINTS_CUDA_KERNEL(func_name) \
519 struct f_##func_name##_type \
520 { \
521 ROCKY_FUNCTIONS void operator()( \
522 IRockyDeviceModel& device_model_api, IRockyJoint& joint_api, void* udf_data) \
523 { \
524 func_name(device_model_api, joint_api, udf_data); \
525 } \
526 }; \
527 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
528 IRockyModel& model, void** plugin_device_data) \
529 { \
530 f_##func_name##_type device_functor {}; \
531 rocky::cuda::dispatch_joints_kernel(model, device_functor, plugin_device_data); \
532 }
533
534 // Search --------------------------------------------------------------------------------------
535 #define ROCKY_PLUGIN_PRE_SEARCH_ON_PARTICLES_END() \
536 } \
537 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(pre_search_on_particles)
538
539 // Force ---------------------------------------------------------------------------------------
540 #define ROCKY_PLUGIN_PRE_FORCE_ON_CONTACTS_END() \
541 } \
542 ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(pre_force_on_contacts, frictional)
543
544 #define ROCKY_PLUGIN_PRE_FORCE_ON_PARTICLES_END() \
545 } \
546 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(pre_force_on_particles)
547
548 #define ROCKY_PLUGIN_PRE_FORCE_ON_TRIANGLES_END() \
549 } \
550 ROCKY_PLUGIN_TRIANGLES_CUDA_KERNEL(pre_force_on_triangles)
551
552 #define ROCKY_PLUGIN_PRE_FORCE_ON_JOINTS_END() \
553 } \
554 ROCKY_PLUGIN_JOINTS_CUDA_KERNEL(pre_force_on_joints)
555
556 #define ROCKY_PLUGIN_POST_FORCE_ON_CONTACTS_END() \
557 } \
558 ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(post_force_on_contacts, frictional)
559
560 #define ROCKY_PLUGIN_POST_FORCE_ON_PARTICLES_END() \
561 } \
562 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(post_force_on_particles)
563
564 #define ROCKY_PLUGIN_POST_FORCE_ON_TRIANGLES_END() \
565 } \
566 ROCKY_PLUGIN_TRIANGLES_CUDA_KERNEL(post_force_on_triangles)
567
568 #define ROCKY_PLUGIN_POST_FORCE_ON_JOINTS_END() \
569 } \
570 ROCKY_PLUGIN_JOINTS_CUDA_KERNEL(post_force_on_joints)
571
572 #define ROCKY_PLUGIN_POST_FORCE_ON_FINISHED_CONTACTS_END() \
573 } \
574 ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(post_force_on_finished_contacts, finished)
575
576 #define ROCKY_PLUGIN_PRE_OUTPUT_ON_CONTACTS_END() \
577 } \
578 ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(pre_output_on_active_contacts, active)
579
580 // Move ----------------------------------------------------------------------------------------
581 #define ROCKY_PLUGIN_PRE_MOVE_PARTICLES_CUDA() \
582 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(pre_move_particles)
583
584 #define ROCKY_PLUGIN_PRE_MOVE_PARTICLES_END() \
585 } \
586 ROCKY_PLUGIN_PRE_MOVE_PARTICLES_CUDA()
587
588 #define ROCKY_PLUGIN_POST_MOVE_PARTICLES_CUDA() \
589 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(post_move_particles)
590
591 #define ROCKY_PLUGIN_POST_MOVE_PARTICLES_END() \
592 } \
593 ROCKY_PLUGIN_POST_MOVE_PARTICLES_CUDA()
594
595 #define ROCKY_PLUGIN_PRE_MOVE_ON_TRIANGLES_CUDA() \
596 ROCKY_PLUGIN_TRIANGLES_CUDA_KERNEL(pre_move_triangles)
597
598 #define ROCKY_PLUGIN_PRE_MOVE_ON_TRIANGLES_END() \
599 } \
600 ROCKY_PLUGIN_PRE_MOVE_ON_TRIANGLES_CUDA()
601
602 #define ROCKY_PLUGIN_POST_MOVE_ON_TRIANGLES_CUDA() \
603 ROCKY_PLUGIN_TRIANGLES_CUDA_KERNEL(post_move_triangles)
604
605 #define ROCKY_PLUGIN_POST_MOVE_ON_TRIANGLES_END() \
606 } \
607 ROCKY_PLUGIN_POST_MOVE_ON_TRIANGLES_CUDA()
608
609// Contact adhesive forces -------------------------------------------------------------------------
610
611 #define ROCKY_PLUGIN_CONTACT_ADHESIVE_FORCES_CUDA_KERNEL(func_name) \
612 struct f_##func_name##_type \
613 { \
614 ROCKY_FUNCTIONS void operator()( \
615 IRockyContact& contact_api, \
616 IRockyAdhesionOutputData& output_data_api, \
617 void* udf_data) \
618 { \
619 func_name(contact_api, output_data_api, udf_data); \
620 } \
621 }; \
622 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
623 IRockyModel& model, void** plugin_device_data) \
624 { \
625 f_##func_name##_type device_functor {}; \
626 rocky::cuda::dispatch_adhesive_contact_forces_kernel( \
627 model, device_functor, device_functor, plugin_device_data); \
628 }
629
630 #define ROCKY_PLUGIN_COMPUTE_CONTACT_ADHESIVE_FORCES_END() \
631 } \
632 ROCKY_PLUGIN_CONTACT_ADHESIVE_FORCES_CUDA_KERNEL(compute_contact_adhesive_forces)
633
634// Joint forces ------------------------------------------------------------------------------------
635
636 #define ROCKY_PLUGIN_JOINT_FORCES_CUDA_KERNEL(func_name) \
637 struct f_##func_name##_type \
638 { \
639 ROCKY_FUNCTIONS void operator()( \
640 IRockyJoint& joint_api, IRockyJointOutputData& output_data_api, void* udf_data) \
641 { \
642 func_name(joint_api, output_data_api, udf_data); \
643 } \
644 }; \
645 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
646 IRockyModel& model, void** plugin_device_data) \
647 { \
648 f_##func_name##_type device_functor {}; \
649 rocky::cuda::dispatch_joint_forces_kernel(model, device_functor, plugin_device_data); \
650 }
651
652 #define ROCKY_PLUGIN_COMPUTE_JOINT_FORCES_END() \
653 } \
654 ROCKY_PLUGIN_JOINT_FORCES_CUDA_KERNEL(compute_joint_forces)
655
656// Joint breakage ------------------------------------------------------------------------------
657
658 #define ROCKY_PLUGIN_JOINT_BREAKAGE_CUDA_KERNEL(func_name) \
659 struct f_##func_name##_type \
660 { \
661 ROCKY_FUNCTIONS void operator()(IRockyJoint& joint_api, bool& broken, void* udf_data) \
662 { \
663 func_name(joint_api, broken, udf_data); \
664 } \
665 }; \
666 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
667 IRockyModel& model, void** plugin_device_data) \
668 { \
669 f_##func_name##_type device_functor {}; \
670 rocky::cuda::dispatch_joint_breakage_kernel( \
671 model, device_functor, plugin_device_data); \
672 }
673
674 #define ROCKY_PLUGIN_COMPUTE_JOINT_BREAKAGE_END() \
675 } \
676 ROCKY_PLUGIN_JOINT_BREAKAGE_CUDA_KERNEL(compute_joint_breakage)
677
678// Instantaneous breakage --------------------------------------------------------------------------
679
680 #define ROCKY_PLUGIN_INSTANTANEOUS_BREAKAGE_CUDA_KERNEL(func_name) \
681 struct f_##func_name##_type \
682 { \
683 ROCKY_FUNCTIONS void operator()( \
684 IRockyParticle& particle_api, bool& broken, void* udf_data) \
685 { \
686 func_name(particle_api, broken, udf_data); \
687 } \
688 }; \
689 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
690 IRockyModel& model, void** plugin_device_data) \
691 { \
692 f_##func_name##_type device_functor {}; \
693 rocky::cuda::dispatch_instantaneous_breakage_kernel( \
694 model, device_functor, plugin_device_data); \
695 }
696
697 #define ROCKY_PLUGIN_COMPUTE_INSTANTANEOUS_BREAKAGE_END() \
698 } \
699 ROCKY_PLUGIN_INSTANTANEOUS_BREAKAGE_CUDA_KERNEL(compute_instantaneous_breakage)
700
701// Boundaries wear ---------------------------------------------------------------------------------
702
703 #define ROCKY_PLUGIN_COMPUTE_BOUNDARIES_WEAR_CUDA_KERNEL(func_name) \
704 struct f_##func_name##_type \
705 { \
706 ROCKY_FUNCTIONS void operator()( \
707 IRockyContact& contact_api, double& wear_volume, void* udf_data) \
708 { \
709 func_name(contact_api, wear_volume, udf_data); \
710 } \
711 }; \
712 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
713 IRockyModel& model, void** plugin_device_data) \
714 { \
715 f_##func_name##_type device_functor {}; \
716 rocky::cuda::dispatch_boundaries_wear_kernel( \
717 model, device_functor, plugin_device_data); \
718 }
719
720 #define ROCKY_PLUGIN_COMPUTE_BOUNDARIES_WEAR_END() \
721 } \
722 ROCKY_PLUGIN_COMPUTE_BOUNDARIES_WEAR_CUDA_KERNEL(compute_boundaries_wear)
723
724// Contact Data Gathering --------------------------------------------------------------------------
725
726 #define ROCKY_PLUGIN_ALL_CONTACTS_CUDA_KERNEL(func_name) \
727 struct f_##func_name##_type \
728 { \
729 ROCKY_FUNCTIONS void operator()( \
730 IRockyDeviceModel& device_model_api, IRockyContact& contact_api, void* udf_data) \
731 { \
732 func_name(device_model_api, contact_api, udf_data); \
733 } \
734 }; \
735 extern "C" ROCKYAPI_EXPORT void cuda_##func_name##_kernel( \
736 IRockyModel& model, void** plugin_device_data) \
737 { \
738 f_##func_name##_type device_functor {}; \
739 rocky::cuda::dispatch_all_contacts_kernel( \
740 model, device_model, device_model, plugin_device_data); \
741 }
742
743 #define ROCKY_PLUGIN_COLLECT_CONTACTS_DATA_END() \
744 } \
745 ROCKY_PLUGIN_ALL_CONTACTS_CUDA_KERNEL(collect_contacts_data)
746
747// Thermal -----------------------------------------------------------------------------------------
748 #define ROCKY_PLUGIN_COMPUTE_CONTACT_HEAT_CONDUCTION_END() \
749 } \
750 ROCKY_PLUGIN_CONTACTS_CUDA_KERNEL(compute_contact_heat_conduction, frictional)
751
752 #define ROCKY_PLUGIN_COMPUTE_THERMAL_INTEGRATION_END() \
753 } \
754 ROCKY_PLUGIN_PARTICLES_CUDA_KERNEL(compute_thermal_integration)
755
756#endif // ROCKY_CUDA_API
Definition rocky_timestep_api.h:189
Definition rocky_plugin_data.h:112
Definition rocky_timestep_api.h:152
Definition rocky_contact_output_data_api.hpp:303
Definition rocky_particle_api.hpp:649
Definition rocky_contact_api.hpp:46
Definition rocky_model_api.hpp:19
Definition rocky_boundary_api.hpp:684
Definition rocky_boundary_api.hpp:285
Definition rocky_boundary_api.hpp:134
Definition rocky_joint_api.hpp:32
Definition rocky_api.h:60
Definition rocky_output_collections_api.hpp:555
Definition rocky_particle_api.hpp:766
Definition rocky_particle_api.hpp:27

Connect with Ansys