Skip to main content

Rocky Solver SDK 2025 R2

rocky_api_functions

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

Connect with Ansys