AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
StrongInteraction.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agx/Interaction.h>
20
21#if defined(_MSC_VER)
22#pragma warning( push )
23#pragma warning( disable : 4589 ) // Disable: 4589: Constructor of abstract class 'agx::FrictionModel' ignores initializer for virtual base class 'agxStream::Serializable'
24#endif
25
26
27namespace agxRender
28{
29 class RenderManager;
30}
31
32namespace agx
33{
34 class SparseRangeReal;
35
37
43 {
44 public:
45
46#if (!defined SWIG ) || (!defined SWIGCSHARP && !defined SWIGJAVA)
48 {
49 MatrixData( agx::Physics::RigidBodyPtr rb ) : rb( rb ), data( nullptr ), writeTranspose( false ), leadingDimension( agx::InvalidIndex ), blockRowIndex( agx::InvalidIndex ) {}
50
51 template< typename T >
52 void plusEqual( const T& rhs, const agx::UInt numRows, const agx::UInt numCols );
53
57 unsigned int leadingDimension; // Argument to Sabre, has to be 'unsigned int'.
59 };
60#endif
61
62 public:
67 void setEnable( agx::Bool enable );
68
73
78
79 public:
83 virtual agx::RigidBody* getRigidBody1() const = 0;
84
88 virtual agx::RigidBody* getRigidBody2() const = 0;
89
93 virtual void addNotification() override;
94
98 virtual void removeNotification() override;
99
103 virtual void preSystemCallback( agx::DynamicsSystem* dynamicsSystem ) override;
104
108 virtual void postSystemCallback( agx::DynamicsSystem* dynamicsSystem ) override;
109
113 virtual void render( agxRender::RenderManager* mgr, float scale );
114
118 virtual void prepare();
119
120#if (!defined SWIG ) || (!defined SWIGCSHARP && !defined SWIGJAVA)
125 agx::StrongInteraction::MatrixData rb2DiagonalBlock,
126 agx::StrongInteraction::MatrixData offDiagonalBlock ) = 0;
127
137 agx::Real* rb1Rhs,
139 agx::Real* rb2Rhs,
140 agx::Bool isRestingSolve ) = 0;
141#endif
142
146 virtual void addNlCallbacks( agx::SparseRangeReal& sparseRangeReal ) const;
147
149
150 protected:
155
160
165 void setValid( agx::Bool valid );
166
170 virtual void store( agxStream::OutputArchive& out ) const override;
171
175 virtual void restore( agxStream::InputArchive& in ) override;
176
177 private:
178 Bool m_valid;
179 Bool m_enable;
180 };
181
182 template< typename T >
183 void StrongInteraction::MatrixData::plusEqual( const T& rhs, const agx::UInt numRows, const agx::UInt numCols )
184 {
185 agxAssert( data != nullptr );
186 if ( writeTranspose )
187 for ( agx::UInt i = 0; i < numRows; ++i )
188 for ( agx::UInt j = 0; j < numCols; ++j )
189 data[ j * leadingDimension + i ] += rhs[ i ][ j ];
190 else
191 for ( agx::UInt i = 0; i < numRows; ++i )
192 for ( agx::UInt j = 0; j < numCols; ++j )
193 data[ i * leadingDimension + j ] += rhs[ i ][ j ];
194 }
195}
196
197#if defined(_MSC_VER)
198#pragma warning( pop ) // restoring: warning( disable : 4127 )
199#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXPHYSICS_EXPORT
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
The complete physical system with bodies, interactions, data layout, time stepper,...
The base class for interactions.
Definition: Interaction.h:33
Pointer to a entity instance of type Physics.RigidBody.
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:52
Essentially a sparse array of bounds.
Definition: SparseTypes.h:74
Base class for a strong interaction concept where there interaction is defined in the mass matrix par...
virtual void writeRhs(agx::Physics::RigidBodyPtr rb1, agx::Real *rb1Rhs, agx::Physics::RigidBodyPtr rb2, agx::Real *rb2Rhs, agx::Bool isRestingSolve)=0
Write data to the right hand side, for dynamic bodies.
virtual void writeMatrixData(agx::StrongInteraction::MatrixData rb1DiagonalBlock, agx::StrongInteraction::MatrixData rb2DiagonalBlock, agx::StrongInteraction::MatrixData offDiagonalBlock)=0
Write data for dynamic bodies.
virtual void restore(agxStream::InputArchive &in) override
Restore local content.
agx::Bool getEnable() const
virtual void removeNotification() override
Called when removed from a simulation.
virtual void preSystemCallback(agx::DynamicsSystem *dynamicsSystem) override
Called before solver executes.
void setValid(agx::Bool valid)
Valid if enable and configuration is ok for solver.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::StrongInteraction)
virtual void addNlCallbacks(agx::SparseRangeReal &sparseRangeReal) const
Interface for non-linear callback from solver.
virtual agx::RigidBody * getRigidBody2() const =0
void setEnable(agx::Bool enable)
Enable or disable this interaction.
virtual void prepare()
Prepares for solve.
virtual ~StrongInteraction()
Reference counted object, protected destructor.
virtual void postSystemCallback(agx::DynamicsSystem *dynamicsSystem) override
Called after the solver is done.
StrongInteraction()
Construct given one or two rigid bodies.
virtual void addNotification() override
Called when added to a simulation.
virtual void store(agxStream::OutputArchive &out) const override
Store local content.
virtual void render(agxRender::RenderManager *mgr, float scale)
Render the interaction.
agx::Bool getValid() const
virtual agx::RigidBody * getRigidBody1() const =0
#define agxAssert(expr)
Definition: debug.h:143
Namespace containing classes for handling debug rendering of collision geometries,...
Definition: Constraint.h:36
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:42
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
agx::Physics::RigidBodyPtr rb
MatrixData(agx::Physics::RigidBodyPtr rb)
void plusEqual(const T &rhs, const agx::UInt numRows, const agx::UInt numCols)