MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbdyn_siconos.cc File Reference
#include "SiconosNumerics.h"
#include <iostream>
#include "mbdyn_siconos.h"
Include dependency graph for mbdyn_siconos.cc:

Go to the source code of this file.

Functions

void mbdyn_siconos_LCP_call (int sizep, double W_NN[], double bLCP[], double Pkp1[], double wlem[], solver_parameters &solparam)
 

Function Documentation

void mbdyn_siconos_LCP_call ( int  sizep,
double  W_NN[],
double  bLCP[],
double  Pkp1[],
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