Skip to main content

Rocky Solver SDK 2025 R2

rocky_contact_api

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 <rocky20/api/rocky_contact.hpp>
6#include <rocky20/api/rocky_material_api.hpp>
7#include <rocky20/device/device_contact.hpp>
8
9
10// ================================================================================================
11// IRockyContact
12// ================================================================================================
13
47{
53 ROCKY_FUNCTIONS IRockyMaterial get_home_material() const;
54
60 ROCKY_FUNCTIONS IRockyMaterial get_near_material() const;
61
68
75 ROCKY_FUNCTIONS int get_material_interaction_index() const;
76
82 ROCKY_FUNCTIONS IRockyParticle get_home_particle() const;
83
88 ROCKY_FUNCTIONS int get_home_particle_group_index() const;
89
95 ROCKY_FUNCTIONS IRockyParticle get_near_particle() const;
96
101 ROCKY_FUNCTIONS int get_near_particle_group_index() const;
102
108 ROCKY_FUNCTIONS IRockyGeometryTriangle get_near_triangle() const;
109
114 ROCKY_FUNCTIONS int get_near_geometry_index() const;
115
119 ROCKY_FUNCTIONS bool is_particle_particle_contact() const;
120
124 ROCKY_FUNCTIONS bool is_particle_triangle_contact() const;
125
130 ROCKY_FUNCTIONS bool is_frictional() const;
131
136 ROCKY_FUNCTIONS bool is_adhesive() const;
137
141 ROCKY_FUNCTIONS double get_previous_overlap() const;
142
156 ROCKY_FUNCTIONS double get_overlap() const;
157
162 ROCKY_FUNCTIONS double3 get_normal_unit_vector() const;
163
168 ROCKY_FUNCTIONS double3 get_contact_position() const;
169
177 ROCKY_FUNCTIONS double get_scale_factor() const;
178
183 ROCKY_FUNCTIONS bool just_started_frictional() const;
184
189 ROCKY_FUNCTIONS bool just_started_adhesive() const;
190
198 ROCKY_FUNCTIONS bool just_finished_frictional() const;
199
207 ROCKY_FUNCTIONS bool just_finished_adhesive() const;
208
213 ROCKY_FUNCTIONS bool is_loading() const;
214
219 ROCKY_FUNCTIONS bool is_unloading() const;
220
225 ROCKY_FUNCTIONS bool is_positive_oriented() const;
226
230 ROCKY_FUNCTIONS double get_current_time() const;
231
235 ROCKY_FUNCTIONS double get_timestep() const;
236
242
248
256 ROCKY_FUNCTIONS double get_home_stiffness() const;
257
265 ROCKY_FUNCTIONS double get_near_stiffness() const;
266
273 ROCKY_FUNCTIONS double get_equivalent_stiffness() const;
274
281 ROCKY_FUNCTIONS double get_home_stiffness_fraction() const;
282
290 ROCKY_FUNCTIONS double get_reduced_young_modulus() const;
291
296 ROCKY_FUNCTIONS double get_equivalent_mass() const;
297
302 ROCKY_FUNCTIONS double get_equivalent_radius() const;
303
316 ROCKY_FUNCTIONS double get_normal_contact_force() const;
317
337 ROCKY_FUNCTIONS double3 get_tangential_contact_force() const;
338
358 ROCKY_FUNCTIONS double3 calculate_relative_velocity() const;
359
366 ROCKY_FUNCTIONS double get_restitution_coefficient() const;
367
379 ROCKY_FUNCTIONS void set_restitution_coefficient(double value);
380
387 ROCKY_FUNCTIONS double get_dynamic_friction_coefficient() const;
388
400 ROCKY_FUNCTIONS void set_dynamic_friction_coefficient(double value);
401
408 ROCKY_FUNCTIONS double get_static_friction_coefficient() const;
409
421 ROCKY_FUNCTIONS void set_static_friction_coefficient(double value);
422
430 ROCKY_FUNCTIONS double get_sliding_distance() const;
431
439 ROCKY_FUNCTIONS bool get_is_sliding_marker() const;
440
448 ROCKY_FUNCTIONS double get_normal_relative_velocity() const;
449
457 ROCKY_FUNCTIONS double3 get_tangential_relative_velocity() const;
458
466 ROCKY_FUNCTIONS double get_normal_adhesion_force() const;
467
475 ROCKY_FUNCTIONS double3 get_tangential_adhesion_force() const;
476
483 ROCKY_FUNCTIONS double3 get_previous_normal_vector() const;
484
493 ROCKY_FUNCTIONS double3 get_previous_moment_vector() const;
494
507 ROCKY_FUNCTIONS void set_previous_moment_vector(double3 value);
508
510 RockyContact *_impl;
511 double current_time;
513};
514
516{
517 return IRockyMaterial(this->_impl->get_home_material());
518}
519
521{
522 return IRockyMaterial(this->_impl->get_near_material());
523}
524
526{
527 return IRockyMaterialInteraction(this->_impl->get_material_interaction());
528}
529
530inline ROCKY_FUNCTIONS int IRockyContact::get_material_interaction_index() const
531{
532 return this->_impl->get_material_interaction_index();
533}
534
535inline ROCKY_FUNCTIONS bool IRockyContact::is_particle_particle_contact() const
536{
537 return this->_impl->is_particle_particle();
538}
539
540inline ROCKY_FUNCTIONS bool IRockyContact::is_particle_triangle_contact() const
541{
542 return this->_impl->is_particle_triangle();
543}
544
545inline ROCKY_FUNCTIONS bool IRockyContact::is_frictional() const
546{
547 return this->_impl->is_frictional();
548}
549
550inline ROCKY_FUNCTIONS bool IRockyContact::is_adhesive() const
551{
552 return this->_impl->is_adhesive();
553}
554
556{
557 return IRockyParticle(this->_impl->get_home_particle_index(), this->_impl->model);
558}
559
560inline ROCKY_FUNCTIONS int IRockyContact::get_home_particle_group_index() const
561{
562 return this->_impl->get_home_particle_base_group_index();
563}
564
566{
567 return IRockyParticle(this->_impl->get_near_particle_index(), this->_impl->model);
568}
569
570inline ROCKY_FUNCTIONS int IRockyContact::get_near_particle_group_index() const
571{
572 return this->_impl->get_near_particle_base_group_index();
573}
574
576{
577 return IRockyGeometryTriangle(this->_impl->get_near_triangle_index(), this->_impl->model);
578}
579
580inline ROCKY_FUNCTIONS int IRockyContact::get_near_geometry_index() const
581{
582 return this->_impl->get_near_boundary_index();
583}
584
585inline ROCKY_FUNCTIONS double IRockyContact::get_overlap() const
586{
587 return this->_impl->get_overlap();
588}
589
590inline ROCKY_FUNCTIONS double IRockyContact::get_previous_overlap() const
591{
592 return this->_impl->get_previous_overlap();
593}
594
595inline ROCKY_FUNCTIONS double3 IRockyContact::get_normal_unit_vector() const
596{
597 return this->_impl->get_normal_unit_vector();
598}
599
600inline ROCKY_FUNCTIONS double3 IRockyContact::get_contact_position() const
601{
602 return this->_impl->get_contact_position();
603}
604
605inline ROCKY_FUNCTIONS double IRockyContact::get_scale_factor() const
606{
607 return this->_impl->get_scale_factor();
608}
609
610inline ROCKY_FUNCTIONS double IRockyContact::get_current_time() const
611{
612 return this->current_time;
613}
614
615inline ROCKY_FUNCTIONS double IRockyContact::get_timestep() const
616{
617 return this->_impl->get_timestep();
618}
619
620inline ROCKY_FUNCTIONS bool IRockyContact::just_started_frictional() const
621{
622 return this->_impl->just_started_frictional();
623}
624
625inline ROCKY_FUNCTIONS bool IRockyContact::just_started_adhesive() const
626{
627 return this->_impl->just_started_adhesive();
628}
629
630inline ROCKY_FUNCTIONS bool IRockyContact::just_finished_frictional() const
631{
632 return this->_impl->just_finished_frictional();
633}
634
635inline ROCKY_FUNCTIONS bool IRockyContact::just_finished_adhesive() const
636{
637 return this->_impl->just_finished_adhesive();
638}
639
640inline ROCKY_FUNCTIONS bool IRockyContact::is_loading() const
641{
642 return this->_impl->is_loading();
643}
644
645inline ROCKY_FUNCTIONS bool IRockyContact::is_unloading() const
646{
647 return this->_impl->is_unloading();
648}
649
650inline ROCKY_FUNCTIONS double IRockyContact::get_normal_contact_force() const
651{
652 return this->_impl->get_scaled_normal_force();
653}
654
655inline ROCKY_FUNCTIONS double3 IRockyContact::get_tangential_contact_force() const
656{
657 if (this->_impl->get_scalars().has_tangential_force_enabled())
658 return this->_impl->get_scaled_tangential_force();
659 else
660 return double3{};
661}
662
663inline ROCKY_FUNCTIONS bool IRockyContact::is_positive_oriented() const
664{
665 return this->_impl->is_positive_oriented();
666}
667
668// Composite properties
669
670inline ROCKY_FUNCTIONS double IRockyContact::get_home_stiffness() const
671{
672 return this->_impl->get_home_stiffness();
673}
674
675inline ROCKY_FUNCTIONS double IRockyContact::get_near_stiffness() const
676{
677 return this->_impl->get_near_stiffness();
678}
679
680inline ROCKY_FUNCTIONS double IRockyContact::get_equivalent_stiffness() const
681{
682 return this->_impl->get_equivalent_stiffness();
683}
684
685inline ROCKY_FUNCTIONS double IRockyContact::get_home_stiffness_fraction() const
686{
687 return this->_impl->get_home_stiffness_fraction();
688}
689
690inline ROCKY_FUNCTIONS double IRockyContact::get_reduced_young_modulus() const
691{
692 return this->_impl->get_reduced_young_modulus();
693}
694
695inline ROCKY_FUNCTIONS double IRockyContact::get_equivalent_mass() const
696{
697 return this->_impl->get_equivalent_mass();
698}
699
700inline ROCKY_FUNCTIONS double IRockyContact::get_equivalent_radius() const
701{
702 return this->_impl->get_equivalent_radius();
703}
704
705inline ROCKY_FUNCTIONS double3 IRockyContact::calculate_relative_velocity() const
706{
707 double3 home_trans_velocity, near_trans_velocity;
708 double3 home_rotat_velocity, near_rotat_velocity;
709 double3 home_arm, near_arm;
710 deformable_fractions deformable_output;
711
712 // For deformables, calculate the vertices weights for nodal forces
713 if (this->_impl->get_home_particle_group().is_deformable())
714 device::get_deformable_forces_nodal_fractions(
715 *this->_impl,
716 deformable_output.n_nde_h,
717 deformable_output.nde_h,
718 deformable_output.nde_fr_h,
719 true,
720 this->is_frictional());
721 if (this->_impl->is_particle_particle()
722 && this->_impl->get_near_particle_group().is_deformable())
723 device::get_deformable_forces_nodal_fractions(
724 *this->_impl,
725 deformable_output.n_nde_n,
726 deformable_output.nde_n,
727 deformable_output.nde_fr_n,
728 false,
729 this->is_frictional());
730
731 device::calculate_contact_velocities(
732 *this->_impl,
733 home_trans_velocity,
734 near_trans_velocity,
735 home_rotat_velocity,
736 near_rotat_velocity,
737 home_arm,
738 near_arm,
739 this->current_time,
740 deformable_output);
741
743 {
744 return device::get_relative_velocity_particle_particle(
745 home_trans_velocity, near_trans_velocity,
746 home_rotat_velocity, near_rotat_velocity,
747 home_arm, near_arm
748 );
749 }
750 else
751 {
752 return device::get_relative_velocity_particle_triangle(
753 home_trans_velocity, near_trans_velocity,
754 home_rotat_velocity, home_arm
755 );
756 }
757}
758
759// Scalars
760
762{
763 return this->_impl->get_particle_contact_scalars();
764}
765
767{
768 return this->_impl->get_triangle_contact_scalars();
769}
770
771inline ROCKY_FUNCTIONS double3 IRockyContact::get_previous_normal_vector() const
772{
773 return this->_impl->get_previous_normal_vector();
774}
775
776inline ROCKY_FUNCTIONS double3 IRockyContact::get_previous_moment_vector() const
777{
778 return this->_impl->get_previous_moment_vector();
779}
780
781inline ROCKY_FUNCTIONS void IRockyContact::set_previous_moment_vector(double3 value)
782{
783 this->_impl->set_previous_moment_vector(value);
784}
785
786// Variable Properties
787inline ROCKY_FUNCTIONS double IRockyContact::get_dynamic_friction_coefficient() const
788{
789 return this->_impl->get_dynamic_friction_coefficient();
790}
791
792inline ROCKY_FUNCTIONS double IRockyContact::get_static_friction_coefficient() const
793{
794 return this->_impl->get_static_friction_coefficient();
795}
796
797inline ROCKY_FUNCTIONS void IRockyContact::set_dynamic_friction_coefficient(double value)
798{
799 this->_impl->set_dynamic_friction_coefficient(value);
800}
801
802inline ROCKY_FUNCTIONS void IRockyContact::set_static_friction_coefficient(double value)
803{
804 this->_impl->set_static_friction_coefficient(value);
805}
806
807inline ROCKY_FUNCTIONS double IRockyContact::get_restitution_coefficient() const
808{
809 return this->_impl->get_restitution_coefficient();
810}
811
812inline ROCKY_FUNCTIONS void IRockyContact::set_restitution_coefficient(double value)
813{
814 this->_impl->set_restitution_coefficient(value);
815}
816
817inline ROCKY_FUNCTIONS double IRockyContact::get_sliding_distance() const
818{
819 return this->_impl->get_sliding_distance();
820}
821
822inline ROCKY_FUNCTIONS bool IRockyContact::get_is_sliding_marker() const
823{
824 return this->_impl->get_is_sliding_marker();
825}
826
827inline ROCKY_FUNCTIONS double IRockyContact::get_normal_relative_velocity() const
828{
829 return this->_impl->get_normal_relative_velocity();
830}
831
832inline ROCKY_FUNCTIONS double3 IRockyContact::get_tangential_relative_velocity() const
833{
834 return this->_impl->get_tangential_relative_velocity();
835}
836
837inline ROCKY_FUNCTIONS double IRockyContact::get_normal_adhesion_force() const
838{
839 return this->_impl->get_normal_adhesion_force();
840}
841
842inline ROCKY_FUNCTIONS double3 IRockyContact::get_tangential_adhesion_force() const
843{
844 return this->_impl->get_tangential_adhesion_force();
845}
Definition rocky_contact_scalars.hpp:279
Definition rocky_contact_api.hpp:47
ROCKY_FUNCTIONS double get_dynamic_friction_coefficient() const
Definition rocky_contact_api.hpp:787
ROCKY_FUNCTIONS double3 get_normal_unit_vector() const
Definition rocky_contact_api.hpp:595
ROCKY_FUNCTIONS bool is_particle_particle_contact() const
Definition rocky_contact_api.hpp:535
ROCKY_FUNCTIONS double get_home_stiffness() const
Definition rocky_contact_api.hpp:670
ROCKY_FUNCTIONS bool get_is_sliding_marker() const
Definition rocky_contact_api.hpp:822
ROCKY_FUNCTIONS double3 get_tangential_adhesion_force() const
Definition rocky_contact_api.hpp:842
ROCKY_FUNCTIONS double get_normal_adhesion_force() const
Definition rocky_contact_api.hpp:837
ROCKY_FUNCTIONS int get_near_particle_group_index() const
Definition rocky_contact_api.hpp:570
ROCKY_FUNCTIONS double get_overlap() const
Definition rocky_contact_api.hpp:585
ROCKY_FUNCTIONS int get_home_particle_group_index() const
Definition rocky_contact_api.hpp:560
ROCKY_FUNCTIONS void set_previous_moment_vector(double3 value)
Definition rocky_contact_api.hpp:781
ROCKY_FUNCTIONS bool just_started_adhesive() const
Definition rocky_contact_api.hpp:625
ROCKY_FUNCTIONS double get_normal_relative_velocity() const
Definition rocky_contact_api.hpp:827
ROCKY_FUNCTIONS bool is_loading() const
Definition rocky_contact_api.hpp:640
ROCKY_FUNCTIONS int get_near_geometry_index() const
Definition rocky_contact_api.hpp:580
ROCKY_FUNCTIONS bool is_adhesive() const
Definition rocky_contact_api.hpp:550
ROCKY_FUNCTIONS double get_equivalent_radius() const
Definition rocky_contact_api.hpp:700
ROCKY_FUNCTIONS double get_timestep() const
Definition rocky_contact_api.hpp:615
ROCKY_FUNCTIONS double3 get_previous_moment_vector() const
Definition rocky_contact_api.hpp:776
ROCKY_FUNCTIONS bool just_finished_adhesive() const
Definition rocky_contact_api.hpp:635
ROCKY_FUNCTIONS void set_static_friction_coefficient(double value)
Definition rocky_contact_api.hpp:802
ROCKY_FUNCTIONS IRockyParticle get_near_particle() const
Definition rocky_contact_api.hpp:565
ROCKY_FUNCTIONS double get_current_time() const
Definition rocky_contact_api.hpp:610
ROCKY_FUNCTIONS double get_restitution_coefficient() const
Definition rocky_contact_api.hpp:807
ROCKY_FUNCTIONS bool is_positive_oriented() const
Definition rocky_contact_api.hpp:663
ROCKY_FUNCTIONS IRockyMaterial get_near_material() const
Definition rocky_contact_api.hpp:520
ROCKY_FUNCTIONS double get_static_friction_coefficient() const
Definition rocky_contact_api.hpp:792
ROCKY_FUNCTIONS bool is_particle_triangle_contact() const
Definition rocky_contact_api.hpp:540
ROCKY_FUNCTIONS double get_normal_contact_force() const
Definition rocky_contact_api.hpp:650
ROCKY_FUNCTIONS double3 get_tangential_relative_velocity() const
Definition rocky_contact_api.hpp:832
ROCKY_FUNCTIONS IRockyGeometryTriangle get_near_triangle() const
Definition rocky_contact_api.hpp:575
ROCKY_FUNCTIONS double get_equivalent_stiffness() const
Definition rocky_contact_api.hpp:680
ROCKY_FUNCTIONS double get_near_stiffness() const
Definition rocky_contact_api.hpp:675
ROCKY_FUNCTIONS void set_dynamic_friction_coefficient(double value)
Definition rocky_contact_api.hpp:797
ROCKY_FUNCTIONS double3 get_contact_position() const
Definition rocky_contact_api.hpp:600
ROCKY_FUNCTIONS int get_material_interaction_index() const
Definition rocky_contact_api.hpp:530
ROCKY_FUNCTIONS IRockyContactScalars get_triangle_contact_scalars() const
Definition rocky_contact_api.hpp:766
ROCKY_FUNCTIONS bool just_started_frictional() const
Definition rocky_contact_api.hpp:620
ROCKY_FUNCTIONS double get_previous_overlap() const
Definition rocky_contact_api.hpp:590
ROCKY_FUNCTIONS bool is_unloading() const
Definition rocky_contact_api.hpp:645
ROCKY_FUNCTIONS double3 get_tangential_contact_force() const
Definition rocky_contact_api.hpp:655
ROCKY_FUNCTIONS double get_reduced_young_modulus() const
Definition rocky_contact_api.hpp:690
ROCKY_FUNCTIONS double get_scale_factor() const
Definition rocky_contact_api.hpp:605
ROCKY_FUNCTIONS void set_restitution_coefficient(double value)
Definition rocky_contact_api.hpp:812
ROCKY_FUNCTIONS IRockyMaterial get_home_material() const
Definition rocky_contact_api.hpp:515
ROCKY_FUNCTIONS double get_equivalent_mass() const
Definition rocky_contact_api.hpp:695
ROCKY_FUNCTIONS bool is_frictional() const
Definition rocky_contact_api.hpp:545
ROCKY_FUNCTIONS IRockyParticle get_home_particle() const
Definition rocky_contact_api.hpp:555
ROCKY_FUNCTIONS double3 calculate_relative_velocity() const
Definition rocky_contact_api.hpp:705
ROCKY_FUNCTIONS IRockyContactScalars get_particle_contact_scalars() const
Definition rocky_contact_api.hpp:761
ROCKY_FUNCTIONS double3 get_previous_normal_vector() const
Definition rocky_contact_api.hpp:771
ROCKY_FUNCTIONS bool just_finished_frictional() const
Definition rocky_contact_api.hpp:630
ROCKY_FUNCTIONS double get_sliding_distance() const
Definition rocky_contact_api.hpp:817
ROCKY_FUNCTIONS IRockyMaterialInteraction get_material_interaction() const
Definition rocky_contact_api.hpp:525
ROCKY_FUNCTIONS double get_home_stiffness_fraction() const
Definition rocky_contact_api.hpp:685
Definition rocky_boundary_api.hpp:146
Definition rocky_material_api.hpp:72
Definition rocky_material_api.hpp:21
Definition rocky_particle_api.hpp:28

Connect with Ansys