AGXDynamics  2.31.1.0
NlmcpCallback.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/Vector.h>
20 #include <agx/Vec3.h>
21 #include <agx/Range.h>
22 #include <agx/agx_valarray_types.h>
23 
24 namespace agx
25 {
26  class FrictionModel;
27  class INlSolveDataH5;
28  class SparseRangeReal;
29  class ConstraintImplementation;
30 
35  {
36  public:
37  struct Args
38  {
40  const agx::RealValarray& z,
41  const agx::SparseRangeReal& bounds,
42  const agx::Real* iterativeSolutionContacts,
43  const agx::Real* iterativeSolutionBinaryConstraints,
44  const agx::Real* iterativeSolutionManyBodyConstraints,
45  agx::INlSolveDataH5* solveDataH5 )
46  : q( q ),
47  z( z ),
48  bounds( bounds ),
49  iterativeSolutionContacts( iterativeSolutionContacts ),
50  iterativeSolutionBinaryConstraints( iterativeSolutionBinaryConstraints ),
51  iterativeSolutionManyBodyConstraints( iterativeSolutionManyBodyConstraints ),
52  solveDataH5( solveDataH5 )
53  {
54  }
55 
56  Args( const Args& ) = delete;
57  Args& operator = ( const Args& ) = delete;
58 
66  };
67 
68  public:
74  virtual agx::Bool initialize( const agx::NlmcpCallback::Args& args ) = 0;
75 
79  virtual agx::Real calculateResidual( const agx::NlmcpCallback::Args& args ) const = 0;
80 
84  virtual void update( const agx::NlmcpCallback::Args& args ) const = 0;
85 
89  virtual void postIterativeSolve( const agx::NlmcpCallback::Args& args ) const = 0;
90 
94  agx::UInt getDirectRow() const;
95 
101  void setDirectRow( agx::UInt directRow );
102 
106  agx::UInt getIterativeRow() const;
107 
113  void setIterativeRow( agx::UInt iterativeRow );
114 
118  agx::UInt getSparseBoundsIndex() const;
119 
125  void setSparseBoundsIndex( agx::UInt sparseBoundsIndex );
126 
130  agx::UInt getNumRows() const;
131 
137  void setNumRows( agx::UInt numRows );
138 
139  protected:
143  NlmcpCallback();
144 
148  virtual ~NlmcpCallback();
149 
150  private:
151  agx::UInt m_directRow;
152  agx::UInt m_iterativeRow;
153  agx::UInt m_sparseBoundsIndex;
154  agx::UInt m_numRows;
155  };
156 
158 
160  {
161  return m_directRow;
162  }
163 
165  {
166  return m_iterativeRow;
167  }
168 
170  {
171  return m_sparseBoundsIndex;
172  }
173 
175  {
176  return m_numRows;
177  }
178 
184  {
185  public:
189  const agx::ConstraintImplementation* getContext() const;
190 
194  agx::UInt getContextDirectRow() const;
195 
199  agx::UInt getContextIterativeRow() const;
200 
201  protected:
203  virtual ~ConstraintNlmcpCallback();
204 
205  virtual void onSetContext();
206 
207  private:
209  void setContext( const agx::ConstraintImplementation* context,
210  agx::UInt contextDirectRow,
211  agx::UInt contextIterativeRow );
212 
213  private:
214  const agx::ConstraintImplementation* m_context;
215  agx::UInt m_contextDirectRow;
216  agx::UInt m_contextIterativeRow;
217  };
218 
224  {
225  public:
226  ScaleBoxCallback( const agx::FrictionModel* frictionModel,
227  agx::UInt numNormals,
228  const agx::Vec3& frictionCoefficients );
229 
230  virtual agx::Bool initialize( const agx::NlmcpCallback::Args& args ) override;
231  virtual agx::Real calculateResidual( const agx::NlmcpCallback::Args& args ) const override;
232  virtual void update( const agx::NlmcpCallback::Args& args ) const override;
233  virtual void postIterativeSolve( const agx::NlmcpCallback::Args& args ) const override;
234 
235  protected:
236  virtual ~ScaleBoxCallback();
237 
238  protected:
240  agx::Real m_frictionCoefficients[ 2 ];
242  };
243 
245 } // namespace agx
const agx::Real * iterativeSolutionManyBodyConstraints
Definition: NlmcpCallback.h:64
agx::UInt getNumRows() const
agx::UInt getSparseBoundsIndex() const
bool Bool
Definition: Integer.h:48
Base class for all friction models with interface and some utility/necessary methods implemented...
Definition: FrictionModel.h:45
agx::RealValarray & q
Definition: NlmcpCallback.h:59
#define AGXPHYSICS_EXPORT
agx::UInt getDirectRow() const
#define AGX_FORCE_INLINE
Definition: Object.h:63
ref_ptr< NlmcpCallback > NlmcpCallbackRef
Base class providing referencing counted objects.
Definition: Referenced.h:113
Interface class for solver callbacks.
Definition: NlmcpCallback.h:34
Essentially a sparse array of bounds.
Definition: SparseTypes.h:73
Constraint solver callback interface with context and start rows for context.
Scale box friction model solver callback.
uint32_t UInt
Definition: Integer.h:34
agx::UInt getIterativeRow() const
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
const agx::FrictionModel * m_frictionModel
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
const agx::Real * iterativeSolutionContacts
Definition: NlmcpCallback.h:62
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::INlSolveDataH5 * solveDataH5
Definition: NlmcpCallback.h:65
Args(agx::RealValarray &q, const agx::RealValarray &z, const agx::SparseRangeReal &bounds, const agx::Real *iterativeSolutionContacts, const agx::Real *iterativeSolutionBinaryConstraints, const agx::Real *iterativeSolutionManyBodyConstraints, agx::INlSolveDataH5 *solveDataH5)
Definition: NlmcpCallback.h:39
ref_ptr< ScaleBoxCallback > ScaleBoxCallbackRef
const agx::Real * iterativeSolutionBinaryConstraints
Definition: NlmcpCallback.h:63
const agx::RealValarray & z
Definition: NlmcpCallback.h:60
double Real
Definition: Real.h:42
const agx::SparseRangeReal & bounds
Definition: NlmcpCallback.h:61