All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ContactLCP.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROBLEMS_CONTACTLCP_H_
36 #define _BLAZE_MATH_PROBLEMS_CONTACTLCP_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
46 #include <blaze/math/Functions.h>
47 #include <blaze/math/Infinity.h>
48 #include <blaze/system/Precision.h>
49 #include <blaze/util/Types.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
66 struct ContactLCP
67 {
68  //**Utility functions***************************************************************************
71  inline size_t size () const;
72  inline void project ( size_t index );
73  inline real lbound ( size_t index ) const;
74  inline real ubound ( size_t index ) const;
75  inline real residual( size_t index ) const;
76  inline real residual() const;
78  //**********************************************************************************************
79 
80  //**Member variables****************************************************************************
84  VecN b_;
85  VecN x_;
87 
88  //**********************************************************************************************
89 };
90 //*************************************************************************************************
91 
92 
93 
94 
95 //=================================================================================================
96 //
97 // UTILITY FUNCTIONS
98 //
99 //=================================================================================================
100 
101 //*************************************************************************************************
106 inline size_t ContactLCP::size() const
107 {
108  return x_.size();
109 }
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
119 inline void ContactLCP::project( size_t index )
120 {
121  x_[index] = min( ubound( index ), max( lbound( index ), x_[index] ) );
122 }
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
132 inline real ContactLCP::lbound( size_t index ) const
133 {
134  return ( index%3 != 0 ) ? ( -cof_[index/3] * x_[index - index%3] ) : ( real(0) );
135 }
136 //*************************************************************************************************
137 
138 
139 //*************************************************************************************************
145 inline real ContactLCP::ubound( size_t index ) const
146 {
147  return ( index%3 != 0 ) ? ( cof_[index/3] * x_[index - index%3] ) : ( inf );
148 }
149 //*************************************************************************************************
150 
151 
152 //*************************************************************************************************
158 inline real ContactLCP::residual( size_t index ) const
159 {
160  return max( x_[index] - ubound( index ),
161  min( x_[index] - lbound( index ), ( A_ * x_ )[index] + b_[index] ) );
162 }
163 //*************************************************************************************************
164 
165 
166 //*************************************************************************************************
172 {
173  real rmax( 0 );
174 
175  for( size_t i=0; i<A_.rows(); ++i )
176  rmax = max( rmax, std::fabs( residual( i ) ) );
177 
178  return rmax;
179 }
180 //*************************************************************************************************
181 
182 } // namespace blaze
183 
184 #endif
size_t rows() const
Returns the current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:1113
Header file for mathematical functions.
VecN cof_
The corresponding coefficients of friction.
Definition: ContactLCP.h:86
void project(size_t index)
Projects the unknown at the given index on the solution range.
Definition: ContactLCP.h:119
real lbound(size_t index) const
Returns the lower bound of the unknown at the given index.
Definition: ContactLCP.h:132
const StaticMatrix< Type, 3UL, 3UL, false > fabs(const RotationMatrix< Type > &m)
Returns a matrix containing the absolute values of each single element of m.
Definition: RotationMatrix.h:1102
CMatMxN A_
The system matrix .
Definition: ContactLCP.h:83
real ubound(size_t index) const
Returns the upper bound of the unknown at the given index.
Definition: ContactLCP.h:145
Header file for the floating point precision of the Blaze library.
Numerical infinity for built-in data types.
VecN b_
The right-hand side vector .
Definition: ContactLCP.h:84
size_t size() const
Returns the current size/dimension of the vector.
Definition: DynamicVector.h:1050
Header file for the complete DynamicVector implementation.
const Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1098
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
Header file for the complete CompressedMatrix implementation.
real residual() const
Calculates the maximum norm of the residual of the linear complementarity problem.
Definition: ContactLCP.h:171
VecN x_
The vector of unknowns .
Definition: ContactLCP.h:85
A data structure for linear complementarity problems (LCPs) for contact mechanics.TODO.
Definition: ContactLCP.h:66
Header file for basic type definitions.
size_t size() const
Returns the size of the contact linear complementarity problem.
Definition: ContactLCP.h:106