MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbdyn_siconos.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  solver_parameters
 

Enumerations

enum  LCPsolver {
  QP, CPG, PGS, RPGS,
  PSOR, NSQP, LATIN, LATIN_W,
  LEXICO_LEMKE, NEWTON_MIN, NEWTON_FB
}
 

Functions

void mbdyn_siconos_LCP_call (int size, double M[], double blcp[], double zlem[], double wlem[], solver_parameters &solparam)
 

Enumeration Type Documentation

enum LCPsolver
Enumerator
QP 
CPG 
PGS 
RPGS 
PSOR 
NSQP 
LATIN 
LATIN_W 
LEXICO_LEMKE 
NEWTON_MIN 
NEWTON_FB 

Definition at line 40 of file mbdyn_siconos.h.

40  {
41  // quadratic programming formulation
42  QP,
43 
44  // CPG (Conjugated Projected Gradient) solver for LCP based on quadratic minimization.
45  CPG,
46 
47  // PGS is a basic Projected Gauss-Seidel solver for LCP.
48  PGS,
49 
50  // Regularized Projected Gauss-Seidel, is a solver for LCP,
51  // able to handle matrices with null diagonal terms
52  RPGS,
53 
54  // Projected Succesive over relaxation solver for LCP. See cottle, Pang Stone Chap 5
55  PSOR,
56 
57  // quadratic programm formulation for solving an non symmetric LCP
58  NSQP,
59 
60  // (LArge Time INcrements) is a basic latin solver for LCP.
61  LATIN,
62 
63  // (LArge Time INcrements) is a basic latin solver with relaxation for LCP
64  LATIN_W,
65 
66  // direct solver for LCP based on pivoting method principle for degenerate problem.
67  // Choice of pivot variable is performed via lexicographic ordering
69 
70  // nonsmooth Newton method based on the min formulation (or max formulation) of the LCP
71  NEWTON_MIN,
72 
73  // uses a nonsmooth newton method based on the Fischer-Bursmeister convex function
74  NEWTON_FB
75 
76 #if 0
77  // Gauss-Seidel solver based on a Sparse-Block storage for the matrix M of the LCP.
78  // Can't be used here because Matrix M of the LCP must be formulated as SparseBlockStructuredMatrix.
79  NSGS_SBM
80 #endif
81 };

Function Documentation

void mbdyn_siconos_LCP_call ( int  size,
double  M[],
double  blcp[],
double  zlem[],
double  wlem[],
solver_parameters solparam 
)

Definition at line 43 of file mbdyn_siconos.cc.

References CPG, solver_parameters::info, LATIN, LATIN_W, LEXICO_LEMKE, NEWTON_FB, NEWTON_MIN, NSQP, PGS, solver_parameters::processed_iterations, PSOR, QP, solver_parameters::resulting_error, RPGS, solver_parameters::solver, solver_parameters::solveritermax, and solver_parameters::solvertol.

Referenced by ModuleNonsmoothNode::mbs_get_force(), and ModuleNonsmoothNode::mbs_get_force_frictional().

44 {
45  solparam.info = 0;
46 
47  LCPsolver lcpsol = solparam.solver;
48  double tolerance = solparam.solvertol;
49  int maxiternum = solparam.solveritermax;
50 
51  // LCP problem description:
52  LinearComplementarityProblem OSNSProblem;
53  OSNSProblem.size = sizep;
54  OSNSProblem.q = bLCP;
55 
56  NumericsMatrix MM;
57  MM.storageType = 0;
58  MM.matrix0 = W_NN; // W_delassus
59  MM.size0 = sizep;
60  MM.size1 = sizep;
61  OSNSProblem.M = &MM;
62 
63  SolverOptions numerics_solver_options = { 0 };
64 
65  solparam.resulting_error = 0.;
66 
67  // Solving LCP problem
68  // FIXME: initialize once, keep alive?
69  switch (lcpsol) {
70  case LEXICO_LEMKE:
71  linearComplementarity_lexicolemke_setDefaultSolverOptions(&numerics_solver_options);
72  numerics_solver_options.iparam[0] = maxiternum;
73  lcp_lexicolemke(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
74  solparam.processed_iterations = numerics_solver_options.iparam[1];
75  break;
76 
77  case RPGS:
78  linearComplementarity_rpgs_setDefaultSolverOptions(&numerics_solver_options);
79  numerics_solver_options.iparam[0] = maxiternum;
80  numerics_solver_options.dparam[0] = tolerance;
81  lcp_rpgs(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
82  solparam.processed_iterations = numerics_solver_options.iparam[1];
83  solparam.resulting_error = numerics_solver_options.dparam[1];
84  break;
85 
86  case QP:
87  linearComplementarity_qp_setDefaultSolverOptions(&numerics_solver_options);
88  numerics_solver_options.dparam[0] = tolerance;
89  lcp_qp(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
90  break;
91 
92  case CPG:
93  linearComplementarity_cpg_setDefaultSolverOptions(&numerics_solver_options);
94  numerics_solver_options.iparam[0] = maxiternum;
95  numerics_solver_options.dparam[0] = tolerance;
96  lcp_cpg(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
97  solparam.processed_iterations = numerics_solver_options.iparam[1];
98  solparam.resulting_error = numerics_solver_options.dparam[1];
99  break;
100 
101  case PGS:
102  linearComplementarity_pgs_setDefaultSolverOptions(&numerics_solver_options);
103  numerics_solver_options.iparam[0] = maxiternum;
104  numerics_solver_options.dparam[0] = tolerance;
105  lcp_pgs(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
106  solparam.processed_iterations = numerics_solver_options.iparam[1];
107  solparam.resulting_error = numerics_solver_options.dparam[1];
108  break;
109 
110  case PSOR:
111  linearComplementarity_psor_setDefaultSolverOptions(&numerics_solver_options);
112  numerics_solver_options.iparam[0] = maxiternum;
113  numerics_solver_options.dparam[0] = tolerance;
114  lcp_psor(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
115  solparam.processed_iterations = numerics_solver_options.iparam[1];
116  solparam.resulting_error = numerics_solver_options.dparam[1];
117  break;
118 
119  case NSQP:
120  linearComplementarity_nsqp_setDefaultSolverOptions(&numerics_solver_options);
121  numerics_solver_options.dparam[0] = tolerance;
122  lcp_nsqp(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
123  break;
124 
125  case LATIN:
126  linearComplementarity_latin_setDefaultSolverOptions(&numerics_solver_options);
127  numerics_solver_options.iparam[0] = maxiternum;
128  numerics_solver_options.dparam[0] = tolerance;
129  lcp_latin(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
130  break;
131 
132  case LATIN_W:
133  linearComplementarity_latin_w_setDefaultSolverOptions(&numerics_solver_options);
134  numerics_solver_options.iparam[0] = maxiternum;
135  numerics_solver_options.dparam[0] = tolerance;
136  lcp_latin_w(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
137  break;
138 
139  case NEWTON_MIN:
140  linearComplementarity_newton_min_setDefaultSolverOptions(&numerics_solver_options);
141  numerics_solver_options.iparam[0] = maxiternum;
142  numerics_solver_options.dparam[0] = tolerance;
143  lcp_newton_min(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
144  solparam.processed_iterations = numerics_solver_options.iparam[1];
145  solparam.resulting_error = numerics_solver_options.dparam[1];
146  break;
147 
148  case NEWTON_FB:
149  linearComplementarity_newton_FB_setDefaultSolverOptions(&numerics_solver_options);
150  numerics_solver_options.iparam[0] = maxiternum;
151  numerics_solver_options.dparam[0] = tolerance;
152  lcp_newton_FB(&OSNSProblem, Pkp1, wlem, &solparam.info, &numerics_solver_options);
153  solparam.processed_iterations = numerics_solver_options.iparam[1];
154  solparam.resulting_error = numerics_solver_options.dparam[1];
155  break;
156  }
157 
158 #if 0
159  // analyzing the LCP solver final status
160  switch (solparam.info) {
161  case 0: // convergence
162  break;
163 
164  case 1: // iter=itermax
165  std::cout << std::endl
166  << "loadable element nonsmooth node: max iterations reached in LCP solver "
167  << std::endl;
168  std::cout << "processed_iterations "<< solparam.processed_iterations
169  << " resulting_error " << solparam.resulting_error <<std::endl;
170  break;
171 
172  default: // other problem
173  std::cout << std::endl
174  <<"loadable element nonsmooth node: problem in solution of LCP"
175  << std::endl;
176  std::cout << "processed_iterations "<< solparam.processed_iterations
177  << " resulting_error " << solparam.resulting_error <<std::endl;
178  break;
179  }
180 #endif
181 
182  deleteSolverOptions(&numerics_solver_options);
183 }
LCPsolver
Definition: mbdyn_siconos.h:40