Skip to main content

Rocky Solver SDK 2024 R2

rocky_joint_api

Last update: 17.07.2025
1#pragma once
2
3// Includes =======================================================================================
4#include <rocky20/api/rocky_particle_api.hpp>
5#include <rocky20/device/device_joint_api.hpp>
6
7#include "rocky_joint_scalars.hpp"
8
9// ================================================================================================
10// IRockyJoint
11// ================================================================================================
12
32{
33
34 // -----------------------------------------------------------------------
35 // Forces and moments according to the default linear elastic model
36 // -----------------------------------------------------------------------
37
51 inline ROCKY_FUNCTIONS
52 double3 get_elastic_force() const
53 {
54 return this->_impl.get_elastic_force();
55 }
56
57
70 inline ROCKY_FUNCTIONS
71 thrust::tuple<double3, double3> get_moments_due_to_force(double3 force) const
72 {
73 return this->_impl.get_moments_due_to_force(force);
74 }
75
76
93 inline ROCKY_FUNCTIONS
94 double3 get_elastic_moment() const
95 {
96 return this->_impl.get_elastic_moment();
97 }
98
99
113 inline ROCKY_FUNCTIONS
114 double3 get_damping_force() const
115 {
116 return this->_impl.get_damping_force();
117 }
118
119
136 inline ROCKY_FUNCTIONS
137 double3 get_damping_moment() const
138 {
139 return this->_impl.get_damping_moment();
140 }
141
142 // ------------------------------------------------------
143 // Deformations and deformation velocities
144 // ------------------------------------------------------
145
158 inline ROCKY_FUNCTIONS
160 {
161 return this->_impl.state.normal_deformation;
162 }
163
164
175 inline ROCKY_FUNCTIONS
177 {
178 return this->_impl.state.tangential_deformation;
179 }
180
181
196 inline ROCKY_FUNCTIONS
198 {
199 return this->_impl.state.normal_deformation_velocity;
200 }
201
202
217 inline ROCKY_FUNCTIONS
219 {
220 return this->_impl.state.tangential_deformation_velocity;
221 }
222
223
231 inline ROCKY_FUNCTIONS
233 {
234 return this->_impl.state.get_n_angular_deformations();
235 }
236
237
252 inline ROCKY_FUNCTIONS
253 double get_angular_deformation(int deformation_direction) const
254 {
255 return this->_impl.state.angular_deformation[deformation_direction];
256 }
257
258
272 inline ROCKY_FUNCTIONS
273 double get_angular_deformation_velocity(int deformation_direction) const
274 {
275 return this->_impl.state.angular_deformation_velocity[deformation_direction];
276 }
277
278
292 inline ROCKY_FUNCTIONS
293 double3 get_angular_deformation_direction(int deformation_direction) const
294 {
295 return this->_impl.state.local_basis[deformation_direction];
296 }
297
298
299 // ------------------------------------------------------
300 // Stiffnesses and damping coefficients
301 // ------------------------------------------------------
302
313 inline ROCKY_FUNCTIONS
314 double get_normal_stiffness() const
315 {
316 return this->_impl.state.particle_group->joint_elastic_ratio.normal * this->_impl.state.normal_stiffness;
317 }
318
319
330 inline ROCKY_FUNCTIONS
332 {
333 return this->_impl.state.particle_group->joint_elastic_ratio.tangential * this->_impl.state.tangential_stiffness;
334 }
335
336
355 inline ROCKY_FUNCTIONS
356 double get_angular_stiffness(int deformation_direction) const
357 {
358 cu_real geometric_factor = this->get_area_moment_of_inertia(deformation_direction) / this->get_area();
359 return (deformation_direction == 0) ?
360 this->_impl.state.particle_group->joint_elastic_ratio.torsion * this->_impl.state.tangential_stiffness * geometric_factor :
361 this->_impl.state.particle_group->joint_elastic_ratio.bending * this->_impl.state.normal_stiffness * geometric_factor;
362 }
363
364
373 inline ROCKY_FUNCTIONS
375 {
376 return this->_impl.state.particle_group->sqrt_joint_elastic_ratio.normal * this->_impl.state.normal_damping;
377 }
378
379
388 inline ROCKY_FUNCTIONS
390 {
391 return this->_impl.state.particle_group->sqrt_joint_elastic_ratio.tangential * this->_impl.state.tangential_damping;
392 }
393
394
411 inline ROCKY_FUNCTIONS
412 double get_angular_damping_coefficient(int deformation_direction) const
413 {
414 cu_real geometric_factor = this->get_area_moment_of_inertia(deformation_direction) / this->get_area();
415 return (deformation_direction == 0) ?
416 this->_impl.state.particle_group->sqrt_joint_elastic_ratio.torsion * this->_impl.state.tangential_damping * geometric_factor :
417 this->_impl.state.particle_group->sqrt_joint_elastic_ratio.bending * this->_impl.state.normal_damping * geometric_factor;
418 }
419
420 //---------------------------------------------------------------
421 // Low-level parameters
422 //---------------------------------------------------------------
423
430 inline ROCKY_FUNCTIONS
431 double3 get_normal_vector() const { return this->_impl.state.normal_vector; }
432
433
444 inline ROCKY_FUNCTIONS
445 double get_area() const { return this->_impl.state.area; }
446
447
459 inline ROCKY_FUNCTIONS
460 double get_area_moment_of_inertia(int deformation_direction) const
461 {
462 return this->_impl.state.area_moment[deformation_direction];
463 }
464
465
471 inline ROCKY_FUNCTIONS
472 double get_young_modulus() const {
473 int material_index = this->_impl.state.particle_group->get_material_index();
474 return this->_impl.model->get_material(material_index).kn_load;
475 }
476
477
485 inline ROCKY_FUNCTIONS double get_poisson_ratio() const
486 {
487 const SDeviceModel* model = this->_impl.model;
488 if (model->particle_scalars->is_poisson_ratio_enabled())
489 {
490 const cuda_particle_joint& particle_joint = model->jnt_prt[this->_impl.joint_index];
491 const int home_index = particle_joint.nh;
492 const int near_index = particle_joint.nn;
493 return 0.5
494 * (this->_impl.model->particle_scalars->get_poisson_ratio(home_index)
495 + this->_impl.model->particle_scalars->get_poisson_ratio(near_index));
496 }
497 else
498 {
499 int material_index = this->_impl.state.particle_group->get_material_index();
500 return model->get_material(material_index).poisson_ratio;
501 }
502 }
503
504
516 inline ROCKY_FUNCTIONS
518 {
519 return this->_impl.state.particle_group->joint_elastic_ratio.normal;
520 }
521
522
534 inline ROCKY_FUNCTIONS
536 {
537 return this->_impl.state.particle_group->joint_elastic_ratio.tangential;
538 }
539
540
552 inline ROCKY_FUNCTIONS
554 {
555 return this->_impl.state.particle_group->joint_elastic_ratio.torsion;
556 }
557
558
570 inline ROCKY_FUNCTIONS
572 {
573 return this->_impl.state.particle_group->joint_elastic_ratio.bending;
574 }
575
576
584 inline ROCKY_FUNCTIONS
586 {
587 return this->_impl.state.particle_group->joint_damping_ratio;
588 }
589
590
606 inline ROCKY_FUNCTIONS
607 double get_angle_scaling_factor() const { return this->_impl.get_angle_scaling_factor(); }
608
609
616 inline ROCKY_FUNCTIONS
617 double get_equivalent_mass() const
618 {
619 return this->_impl.state.equivalent_mass;
620 }
621
622
630 inline ROCKY_FUNCTIONS
632 {
633 return this->_impl.state.particle_group->kn_dgb;
634 }
635
636
644 inline ROCKY_FUNCTIONS
646 {
647 return this->_impl.state.particle_group->kt_dgb;
648 }
649
650
657 inline ROCKY_FUNCTIONS
658 double get_young_modulus_multiplier() const { return this->_impl.state.stiffness_multiplier; }
659
660 // ---------------------------------------------------------------------
661 // Access to joint scalars
662 // ---------------------------------------------------------------------
663
673 inline ROCKY_FUNCTIONS
675 {
676 return IRockyJointScalars(*this->_impl.model->joint_scalars, this->_impl.joint_index);
677 }
678
679 // ---------------------------------------------------------------------
680 // home and near elements data
681 // ---------------------------------------------------------------------
682
688 ROCKY_FUNCTIONS thrust::tuple<double3, double> get_home_element_orientation() const
689 {
690 return this->_impl.get_home_element_orientation();
691 }
692
698 ROCKY_FUNCTIONS thrust::tuple<double3, double> get_near_element_orientation() const
699 {
700 return this->_impl.get_near_element_orientation();
701 }
702
706 ROCKY_FUNCTIONS double3 get_home_element_centroid_position() const
707 {
708 return this->_impl.get_home_element_centroid_position();
709 }
710
714 ROCKY_FUNCTIONS double3 get_near_element_centroid_position() const
715 {
716 return this->_impl.get_near_element_centroid_position();
717 }
718
722 ROCKY_FUNCTIONS double3 get_home_arm() const
723 {
724 return this->_impl.get_home_arm();
725 }
726
730 ROCKY_FUNCTIONS double3 get_near_arm() const
731 {
732 return this->_impl.get_near_arm();
733 }
734
743 ROCKY_FUNCTIONS thrust::tuple<int, int> get_element_tags() const
744 {
745 return this->_impl.get_element_tags();
746 }
747
748
751 ROCKY_FUNCTIONS IRockyJoint(SDeviceModel *_model, int _device_index) :
752 _impl(_model, _device_index) {}
753
754 device::RockyJoint _impl;
755
757};
758
759// =================================================================================================
760// IRockyJointOutputData
761// =================================================================================================
762
763struct IRockyJointOutputData
764{
765
778 ROCKY_FUNCTIONS void set_force(const double3& value);
779
780
791 ROCKY_FUNCTIONS void set_home_moment(const double3& value);
792
793
804 ROCKY_FUNCTIONS void set_near_moment(const double3& value);
805
806
809 double3 _force{}, _home_moment{}, _near_moment{};
810
812};
813
814inline ROCKY_FUNCTIONS void IRockyJointOutputData::set_force(const double3& value)
815{
816 this->_force = value;
817}
818
819inline ROCKY_FUNCTIONS void IRockyJointOutputData::set_home_moment(const double3& value)
820{
821 this->_home_moment = value;
822}
823
824inline ROCKY_FUNCTIONS void IRockyJointOutputData::set_near_moment(const double3& value)
825{
826 this->_near_moment = value;
827}
Definition rocky_joint_scalars.hpp:53
Definition rocky_joint_api.hpp:32
ROCKY_FUNCTIONS double get_normal_elastic_ratio() const
Definition rocky_joint_api.hpp:517
ROCKY_FUNCTIONS double get_poisson_ratio() const
Definition rocky_joint_api.hpp:485
ROCKY_FUNCTIONS double get_tangential_stiffness_per_area() const
Definition rocky_joint_api.hpp:645
ROCKY_FUNCTIONS double get_angular_deformation_velocity(int deformation_direction) const
Definition rocky_joint_api.hpp:273
ROCKY_FUNCTIONS double get_angle_scaling_factor() const
Definition rocky_joint_api.hpp:607
ROCKY_FUNCTIONS double get_area_moment_of_inertia(int deformation_direction) const
Definition rocky_joint_api.hpp:460
ROCKY_FUNCTIONS double get_torsion_elastic_ratio() const
Definition rocky_joint_api.hpp:553
ROCKY_FUNCTIONS double get_tangential_damping_coefficient() const
Definition rocky_joint_api.hpp:389
ROCKY_FUNCTIONS double get_angular_stiffness(int deformation_direction) const
Definition rocky_joint_api.hpp:356
ROCKY_FUNCTIONS double get_young_modulus() const
Definition rocky_joint_api.hpp:472
ROCKY_FUNCTIONS double get_young_modulus_multiplier() const
Definition rocky_joint_api.hpp:658
ROCKY_FUNCTIONS thrust::tuple< double3, double3 > get_moments_due_to_force(double3 force) const
Definition rocky_joint_api.hpp:71
ROCKY_FUNCTIONS double3 get_tangential_deformation_velocity() const
Definition rocky_joint_api.hpp:218
ROCKY_FUNCTIONS thrust::tuple< int, int > get_element_tags() const
Definition rocky_joint_api.hpp:743
ROCKY_FUNCTIONS double3 get_near_element_centroid_position() const
Definition rocky_joint_api.hpp:714
ROCKY_FUNCTIONS double3 get_tangential_deformation() const
Definition rocky_joint_api.hpp:176
ROCKY_FUNCTIONS double3 get_near_arm() const
Definition rocky_joint_api.hpp:730
ROCKY_FUNCTIONS double3 get_home_element_centroid_position() const
Definition rocky_joint_api.hpp:706
ROCKY_FUNCTIONS double get_angular_deformation(int deformation_direction) const
Definition rocky_joint_api.hpp:253
ROCKY_FUNCTIONS double get_normal_stiffness() const
Definition rocky_joint_api.hpp:314
ROCKY_FUNCTIONS double get_tangential_stiffness() const
Definition rocky_joint_api.hpp:331
ROCKY_FUNCTIONS double get_equivalent_mass() const
Definition rocky_joint_api.hpp:617
ROCKY_FUNCTIONS double3 get_damping_moment() const
Definition rocky_joint_api.hpp:137
ROCKY_FUNCTIONS double3 get_damping_force() const
Definition rocky_joint_api.hpp:114
ROCKY_FUNCTIONS int get_number_angular_deformations() const
Definition rocky_joint_api.hpp:232
ROCKY_FUNCTIONS double get_bending_elastic_ratio() const
Definition rocky_joint_api.hpp:571
ROCKY_FUNCTIONS double get_angular_damping_coefficient(int deformation_direction) const
Definition rocky_joint_api.hpp:412
ROCKY_FUNCTIONS double3 get_home_arm() const
Definition rocky_joint_api.hpp:722
ROCKY_FUNCTIONS double3 get_elastic_moment() const
Definition rocky_joint_api.hpp:94
ROCKY_FUNCTIONS double get_joint_damping_ratio() const
Definition rocky_joint_api.hpp:585
ROCKY_FUNCTIONS double3 get_elastic_force() const
Definition rocky_joint_api.hpp:52
ROCKY_FUNCTIONS double3 get_normal_deformation_velocity() const
Definition rocky_joint_api.hpp:197
ROCKY_FUNCTIONS thrust::tuple< double3, double > get_home_element_orientation() const
Definition rocky_joint_api.hpp:688
ROCKY_FUNCTIONS double get_normal_damping_coefficient() const
Definition rocky_joint_api.hpp:374
ROCKY_FUNCTIONS double get_normal_stiffness_per_area() const
Definition rocky_joint_api.hpp:631
ROCKY_FUNCTIONS double3 get_normal_deformation() const
Definition rocky_joint_api.hpp:159
ROCKY_FUNCTIONS thrust::tuple< double3, double > get_near_element_orientation() const
Definition rocky_joint_api.hpp:698
ROCKY_FUNCTIONS double3 get_angular_deformation_direction(int deformation_direction) const
Definition rocky_joint_api.hpp:293
ROCKY_FUNCTIONS double get_tangential_elastic_ratio() const
Definition rocky_joint_api.hpp:535
ROCKY_FUNCTIONS double get_area() const
Definition rocky_joint_api.hpp:445
ROCKY_FUNCTIONS double3 get_normal_vector() const
Definition rocky_joint_api.hpp:431
ROCKY_FUNCTIONS IRockyJointScalars get_scalars()
Definition rocky_joint_api.hpp:674

Connect with Ansys