AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
DirectSolverData.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#ifndef AGX_DIRECTSOLVERDATA_H
18#define AGX_DIRECTSOLVERDATA_H
19
20#include <agx/MixedLCP.h>
21#include <agx/Solver.h>
22#include <agx/RigidBodyState.h>
23#include <agx/StabilityReport.h>
25
28
29#include <agxData/Array.h>
30
31#define to_permuted_matrix_index( lId ) matrix.getBlockPermutedStartRowIndex( lId )
32
33namespace agx
34{
36 {
37 public:
38 typedef std::valarray< unsigned int > UIntContainer;
39 public:
40 LogicalStructure() : m_riCounter( 0 ), m_riIndex( 0 ), m_ciIndex( 0 ), m_dimIndex( 0 ) {}
41
42 void resize( size_t riSize, size_t ciSize, size_t dimSize )
43 {
44 m_ri.resize( riSize, UIntContainer::value_type(-1) );
45 m_ci.resize( ciSize, UIntContainer::value_type(-1) );
46 m_dim.resize( dimSize, UIntContainer::value_type(-1) );
47 m_riCounter = 0;
48 m_riIndex = 0;
49 m_ciIndex = 0;
50 m_dimIndex = 0;
51 }
52
53 inline void newRow( size_t dim )
54 {
55 agxAssert( m_riIndex < m_ri.size() );
56 m_ri[ m_riIndex ] = (UIntContainer::value_type)m_riCounter;
57 m_dim[ m_dimIndex ] = (UIntContainer::value_type)dim;
58 ++m_riIndex;
59 ++m_dimIndex;
60 }
61
62 inline void insertBlock( size_t colIndex )
63 {
64 agxAssert( m_ciIndex < m_ci.size() );
65 m_ci[ m_ciIndex ] = (UIntContainer::value_type)colIndex;
66 ++m_ciIndex;
67 ++m_riCounter;
68 }
69
70 void finalize()
71 {
72 agxAssert( m_riIndex == m_ri.size() - 1 );
73 agxAssert( m_ciIndex == m_ci.size() );
74 m_ri[ m_riIndex ] = (UIntContainer::value_type)m_riCounter;
75 }
76
77 unsigned int* riPtr() { return &( m_ri[0]); }
78 unsigned int* ciPtr() { return &( m_ci[0]); }
79 unsigned int* dimPtr() { return &(m_dim[0]); }
80
81 bool operator==(const LogicalStructure& rhs) const;
82 private:
83 UIntContainer m_ri;
84 UIntContainer m_ci;
85 UIntContainer m_dim;
86 size_t m_riCounter;
87 size_t m_riIndex;
88 size_t m_ciIndex;
89 size_t m_dimIndex;
90 };
91
93 {
94 public:
96
97 public:
102 {
103 public:
105 enum Buffers { SPLIT, DIRECT, DIRECT_AND_ITERATIVE, NUM_BUFFERS };
106
108
113
114 AGX_FORCE_INLINE const GroupsContainer& getBuffer( Buffers buffer ) const { return m_buffers[ buffer ]; }
115
116 protected:
117 virtual ~ContactGroups() {}
118
119 private:
120 ContactGroups( const ContactGroups& ) {}
121
122 private:
123 GroupsContainer m_buffers[ NUM_BUFFERS ];
124 };
125
127
128 public:
138 agx::UInt numBlockRows,
139 agx::UInt numBlocks,
140 agx::Solver::NlMcpConfig nlMcpConfig,
141 agx::Bool gatherStatistics,
142 INlSolveDataH5* nlSolveDataH5 );
143
149
154
161 agx::Physics::StrongInteractionData& strongInteractions,
162 const agxData::IndexArray& globalToLocalIndexArray );
163
169
175
180
186
192
199
204 const agx::RealValarray& getQ() const;
205
211
216
221
226
231
236
241
250 agxData::Array< agx::Vec3 >& linearVelocities,
251 agxData::Array< agx::Vec3 >& angularVelocities,
252 const agxData::Array< agx::RigidBodyState >& states ) const;
253
254 protected:
257
258
259 protected:
270 };
271
273}
274
275#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXPHYSICS_EXPORT
Class that handles the grouping.
agx::VectorPOD< agx::Index > GroupsContainer
bool initialize(Physics::SolveIslandPtr &island)
const GroupsContainer & getBuffer(Buffers buffer) const
agx::IndexSet & getIndexSet()
StrongInteractionTable m_strongInteractionTable
agx::RealValarray & getQ()
const agx::NlMixedCp::McpAlgorithm * getAlgorithm() const
const agx::SparseMatrix & getMatrix() const
const agx::SparseRangeReal & getSparseBounds() const
agx::SparseRangeReal & getSparseBounds()
agx::HashTable< agx::UInt, agx::UIntVector > StrongInteractionTable
DirectSolverData * clone()
Clones solver data.
void setContactGroups(agx::DirectSolverData::ContactGroups *contactGroups)
Assign new contact groups object.
const agx::RealValarray & getSigns() const
const agx::RealValarray & solve()
Solve the current configuration of the matrix, right hand side and bounds.
const agx::RealValarray & getSolution() const
agx::DirectSolverData::ContactGroups * getContactGroups() const
agx::StabilityReport * getStabilityReport() const
const agx::DirectSolverData::StrongInteractionTable & getStrongInteractionTable() const
void buildStrongInteractionTable(agx::Physics::InteractionGroupPtr islandGroup, agx::Physics::StrongInteractionData &strongInteractions, const agxData::IndexArray &globalToLocalIndexArray)
Builds table that maps a rigid body to the other bodies it interacts with.
void initialize()
Initialize for a new solve.
LogicalStructure m_logicalStructure
void commitVelocities(const agxData::IndexArray &indices, agxData::Array< agx::Vec3 > &linearVelocities, agxData::Array< agx::Vec3 > &angularVelocities, const agxData::Array< agx::RigidBodyState > &states) const
Copy solution to velocity buffers.
const agx::LogicalStructure & getLogicalStructure() const
virtual ~DirectSolverData()
DirectSolverData(agx::UInt numEquations, agx::UInt numBlockRows, agx::UInt numBlocks, agx::Solver::NlMcpConfig nlMcpConfig, agx::Bool gatherStatistics, INlSolveDataH5 *nlSolveDataH5)
Construct given total number of equations in the direct system, number of block rows and the total nu...
agx::RealValarray & getSolution()
agx::ref_ptr< ContactGroups > ContactGroupsRef
agx::LogicalStructure & getLogicalStructure()
agx::SparseMatrix & getMatrix()
INlSolveDataH5 * m_nlSolveDataH5
agx::UInt getNumBlockRows() const
StabilityReportRef m_stabilityReport
ContactGroupsRef m_contactGroups
agx::RealValarray & getSigns()
const agx::RealValarray & getQ() const
Inheritance with partial specialization due to bug with ref_ptr containers.
std::valarray< unsigned int > UIntContainer
bool operator==(const LogicalStructure &rhs) const
void insertBlock(size_t colIndex)
unsigned int * ciPtr()
void newRow(size_t dim)
unsigned int * riPtr()
unsigned int * dimPtr()
void resize(size_t riSize, size_t ciSize, size_t dimSize)
Interface class for algorithm to solve general mixed complementarity problem.
Definition: MixedLCP.h:115
Pointer to a entity instance of type Physics.InteractionGroup.
Pointer to a entity instance of type Physics.SolveIsland.
Base class providing referencing counted objects.
Definition: Referenced.h:120
agx::SparseMatrix holds a matrix representation which contains the data.
Definition: SparseMatrix.h:86
Essentially a sparse array of bounds.
Definition: SparseTypes.h:74
#define agxAssert(expr)
Definition: debug.h:143
#define AGX_FORCE_INLINE
Definition: macros.h:58
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
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.