AGX Dynamics 2.41.3.2
Loading...
Searching...
No Matches
NlmcpCallback.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/Vector.h>
20#include <agx/Vec3.h>
21#include <agx/Range.h>
23
24namespace agx
25{
26 class FrictionModel;
27 class INlSolveDataH5;
28 class SparseRangeReal;
29 class ConstraintImplementation;
30 class DirectSolverData;
31 class RigidBody;
32
33 namespace Physics
34 {
35 class RigidBodyData;
36 class RigidBodyPtr;
37 }
38
43 {
44 public:
45 struct Args
46 {
48 const RealValarray& z,
49 const SparseRangeReal& bounds,
50 const Real* iterativeSolutionContacts,
51 const Real* iterativeSolutionBinaryConstraints,
52 const Real* iterativeSolutionManyBodyConstraints,
53 INlSolveDataH5* solveDataH5 )
54 : q( q )
55 , z( z )
56 , bounds( bounds )
57 , iterativeSolutionContacts( iterativeSolutionContacts )
58 , iterativeSolutionBinaryConstraints( iterativeSolutionBinaryConstraints )
59 , iterativeSolutionManyBodyConstraints( iterativeSolutionManyBodyConstraints )
60 , solveDataH5( solveDataH5 )
61 {
62 }
63
64 Args( const Args& ) = delete;
65 Args& operator = ( const Args& ) = delete;
66
74 };
75
76 public:
82 virtual Bool initialize( const NlmcpCallback::Args& args ) = 0;
83
87 virtual Real calculateResidual( const NlmcpCallback::Args& args ) const = 0;
88
92 virtual void update( const NlmcpCallback::Args& args ) const = 0;
93
97 virtual void postIterativeSolve( const NlmcpCallback::Args& args ) const = 0;
98
102 UInt getDirectRow() const;
103
109 void setDirectRow( UInt directRow );
110
114 UInt getIterativeRow() const;
115
121 void setIterativeRow( UInt iterativeRow );
122
126 UInt getSparseBoundsIndex() const;
127
133 void setSparseBoundsIndex( UInt sparseBoundsIndex );
134
138 UInt getNumRows() const;
139
145 void setNumRows( UInt numRows );
146
147 protected:
152
156 virtual ~NlmcpCallback();
157
158 private:
159 UInt m_directRow;
160 UInt m_iterativeRow;
161 UInt m_sparseBoundsIndex;
162 UInt m_numRows;
163 };
164
166
168 {
169 return m_directRow;
170 }
171
173 {
174 return m_iterativeRow;
175 }
176
178 {
179 return m_sparseBoundsIndex;
180 }
181
183 {
184 return m_numRows;
185 }
186
192 {
193 const Physics::RigidBodyData& rigidBody;
201
207
213
220 UInt32 getNumRows( const RigidBody* rb ) const;
221
229
236 UInt32 getRigidBodyNumRows( Index globalIndex ) const;
237
239 NlmcpCallbackSolverData& operator = ( const NlmcpCallbackSolverData& ) = delete;
240 };
241
247 {
248 public:
253
258
263
264 protected:
267
272 virtual void onSetContext( const NlmcpCallbackSolverData& solverData );
273
274 private:
276 void setContext( const ConstraintImplementation* context,
277 UInt contextDirectRow,
278 UInt contextIterativeRow,
279 const NlmcpCallbackSolverData& solverData );
280
281 private:
282 const ConstraintImplementation* m_context;
283 UInt m_contextDirectRow;
284 UInt m_contextIterativeRow;
285 };
286
288} // namespace agx
#define AGXPHYSICS_EXPORT
Constraint solver callback interface with context and start rows for context.
virtual void onSetContext(const NlmcpCallbackSolverData &solverData)
Called when context constraint has been set and all data is valid.
const ConstraintImplementation * getContext() const
UInt getContextIterativeRow() const
Interface class for solver callbacks.
Definition: NlmcpCallback.h:43
UInt getDirectRow() const
virtual Bool initialize(const NlmcpCallback::Args &args)=0
This method is a test for the non-linear solver if this callback is active for non-linear solve.
virtual void postIterativeSolve(const NlmcpCallback::Args &args) const =0
Before direct solve, after iterative solve.
virtual void update(const NlmcpCallback::Args &args) const =0
Update call when bounds and/or q may be updated given the current solution z.
UInt getIterativeRow() const
void setDirectRow(UInt directRow)
void setSparseBoundsIndex(UInt sparseBoundsIndex)
virtual Real calculateResidual(const NlmcpCallback::Args &args) const =0
Calculate residual given current solution.
virtual ~NlmcpCallback()
Protected destructor, reference counted object.
void setNumRows(UInt numRows)
NlmcpCallback()
Default constructor.
UInt getNumRows() const
UInt getSparseBoundsIndex() const
void setIterativeRow(UInt iterativeRow)
Pointer to a entity instance of type Physics.RigidBody.
Base class providing referencing counted objects.
Definition: Referenced.h:120
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
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:32
bool Bool
Definition: Integer.h:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:42
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
UInt32 Index
Definition: Integer.h:44
Data from the solver the ConstraintNlmcpCallback is part of.
UInt32 getRigidBodyNumRows(Index globalIndex) const
Finds number of rows the given rigid body index has allocated in the solver.
UInt32 getPermutedDirectStartRow(const RigidBody *rb) const
const Physics::RigidBodyData & rigidBody
Global rigid body data.
UInt32 getNumRows(const RigidBody *rb) const
Finds number of rows the given rigid body has allocated in the solver.
NlmcpCallbackSolverData(const NlmcpCallbackSolverData &)=delete
UInt32 getPermutedDirectStartRow(const Physics::RigidBodyPtr &entity) const
UInt32 getNumRows(const Physics::RigidBodyPtr &entity) const
Finds number of rows the given rigid body entity has allocated in the solver.
const DirectSolverData & directSolverData
Direct solver data the ConstraintNlmcpCallback constraint is part of.
UInt32 getRigidBodyPermutedDirectStartRow(Index globalIndex) const
const Real * iterativeSolutionContacts
Definition: NlmcpCallback.h:70
const SparseRangeReal & bounds
Definition: NlmcpCallback.h:69
const Real * iterativeSolutionBinaryConstraints
Definition: NlmcpCallback.h:71
Args(const Args &)=delete
Args(RealValarray &q, const RealValarray &z, const SparseRangeReal &bounds, const Real *iterativeSolutionContacts, const Real *iterativeSolutionBinaryConstraints, const Real *iterativeSolutionManyBodyConstraints, INlSolveDataH5 *solveDataH5)
Definition: NlmcpCallback.h:47
const RealValarray & z
Definition: NlmcpCallback.h:68
INlSolveDataH5 * solveDataH5
Definition: NlmcpCallback.h:73
const Real * iterativeSolutionManyBodyConstraints
Definition: NlmcpCallback.h:72