1 /* Siconos is a program dedicated to modeling, simulation and control 2 * of non smooth dynamical systems. 3 * 4 * Copyright 2021 INRIA. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /*!\file NonSmoothDrivers.h 20 \brief This file provides all generic functions (drivers), interfaces to the different formulations for Non-Smooth Problems available in Numerics. 21 \todo solve_qp does not exist 22 23 Use fc3d tools. 24 */ 25 #ifndef NonSmoothSolvers_H 26 #define NonSmoothSolvers_H 27 28 #include "SiconosConfig.h" 29 30 /* #include "mlcp_cst.h" */ 31 /* #include "MCP_cst.h" */ 32 /* #include "NCP_cst.h" */ 33 /* #include "lcp_cst.h" */ 34 /* #include "relay_cst.h" */ 35 /* #include "Friction_cst.h" */ 36 /* #include "VI_cst.h" */ 37 /* #include "AVI_cst.h" */ 38 /* #include "SOCLCP_cst.h" */ 39 //#include "VariationalInequality.h" 40 //#include "VariationalInequality_Solvers.h" 41 //#include "SecondOrderConeLinearComplementarityProblem.h" 42 /* #include "SOCLCP_Solvers.h" */ 43 /* #include "Relay_Solvers.h" */ 44 /* #include "LCP_Solvers.h" */ 45 /* #include "AVI_Solvers.h" */ 46 /* #include "MLCP_Solvers.h" */ 47 /* #include "NCP_Solvers.h" */ 48 /* #include "MCP_Solvers.h" */ 49 //#include "SolverOptions.h" 50 #include "NumericsFwd.h" 51 //#include "MixedComplementarityProblem.h" 52 /* #include "fc2d_Solvers.h" */ 53 /* #include "fc3d_Solvers.h" */ 54 /* #include "gfc3d_Solvers.h" */ 55 //#include "GenericMechanical_Solvers.h" 56 57 //#include "NonSmoothNewton.h" 58 59 #if defined(__cplusplus) && !defined(BUILD_AS_CPP) 60 extern "C" 61 { 62 #endif 63 64 /** General interface to solvers for Linear Complementarity Problems 65 \param[in] problem the LinearComplementarityProblem structure which handles the problem (M,q) 66 \param[in,out] z a n-vector of doubles which contains the solution of the problem. 67 \param[in,out] w a n-vector of doubles which contains the solution of the problem. 68 \param[in,out] options structure used to define the solver(s) and their parameters 69 \return info termination value 70 - 0 : successful 71 - >0 : otherwise see each solver for more information about the log info 72 */ 73 int linearComplementarity_driver(LinearComplementarityProblem* problem, double *z , double *w, SolverOptions* options); 74 75 /** General interface to solver for MLCP problems 76 \param[in] problem the MixedLinearComplementarityProblem structure which handles the problem (M,q) 77 \param[in,out] z a m+n-vector of doubles which contains the solution of the problem. 78 \param[in,out] w a m+n-vector of doubles which contains the solution of the problem. 79 \param[in,out] options structure used to define the solver(s) and their parameters 80 \return info termination value 81 - 0 : successful 82 - >0 : otherwise see each solver for more information about the log info 83 \todo Sizing the regularization parameter and apply it only on null diagnal term 84 */ 85 int mlcp_driver(MixedLinearComplementarityProblem* problem, double *z, double *w, SolverOptions* options); 86 87 /** General interface to solvers for friction-contact 2D problem 88 * \param[in] problem the structure which handles the Friction-Contact problem 89 * \param[in,out] reaction global vector (n) 90 * \param[in,out] velocity global vector (n) 91 * \param[in,out] options structure used to define the solver(s) and their parameters 92 * \return result (0 if successful otherwise 1). 93 */ 94 int fc2d_driver(FrictionContactProblem* problem, double *reaction , double *velocity, SolverOptions* options); 95 96 97 /** General interface to solvers for friction-contact 3D problem 98 * \param[in] problem the structure which handles the Friction-Contact problem 99 * \param[in,out] reaction global vector (n) 100 * \param[in,out] velocity global vector (n) 101 * \param[in,out] options structure used to define the solver(s) and their parameters 102 * \return result (0 if successful otherwise 1). 103 */ 104 int fc3d_driver(FrictionContactProblem* problem, double *reaction , double *velocity, SolverOptions* options); 105 106 /** General interface to solvers for rolling friction-contact 3D problem 107 * \param[in] problem the structure which handles the Friction-Contact problem 108 * \param[in,out] reaction global vector (n) 109 * \param[in,out] velocity global vector (n) 110 * \param[in,out] options structure used to define the solver(s) and their parameters 111 * \return result (0 if successful otherwise 1). 112 */ 113 int rolling_fc3d_driver(RollingFrictionContactProblem* problem, double *reaction , double *velocity, SolverOptions* options); 114 115 /** General interface to solvers for rolling friction-contact 2D problem 116 * \param[in] problem the structure which handles the Friction-Contact problem 117 * \param[in,out] reaction global vector (n) 118 * \param[in,out] velocity global vector (n) 119 * \param[in,out] options structure used to define the solver(s) and their parameters 120 * \return result (0 if successful otherwise 1). 121 */ 122 int rolling_fc2d_driver(RollingFrictionContactProblem* problem, double *reaction , double *velocity, SolverOptions* options); 123 124 /** General interface to solvers for global friction-contact 3D problem 125 \param[in] problem the structure which handles the Friction-Contact problem 126 \param[in,out] reaction global vector (n) 127 \param[in,out] velocity global vector (n) 128 \param[in,out] globalVelocity global vector 129 \param[in,out] options structure used to define the solver(s) and their parameters 130 \return result (0 if successful otherwise 1). 131 */ 132 int gfc3d_driver(GlobalFrictionContactProblem* problem, double *reaction , 133 double *velocity, double* globalVelocity, 134 SolverOptions* options); 135 136 /** General interface to solvers for global rolling friction-contact 3D problem 137 * \param[in] problem the structure which handles the Friction-Contact problem 138 * \param[in,out] reaction global vector (n) 139 * \param[in,out] velocity global vector (n) 140 * \param[in,out] options structure used to define the solver(s) and their parameters 141 * \return result (0 if successful otherwise 1). 142 */ 143 int g_rolling_fc3d_driver(GlobalRollingFrictionContactProblem* problem, 144 double *reaction, double *velocity, double* globalVelocity, 145 SolverOptions* options); 146 147 /** General interface to solvers for friction-contact 3D problem 148 * \param[in] problem the structure which handles the Friction-Contact problem 149 * \param[in,out] x global vector (n) 150 * \param[in,out] w global vector (n) 151 * \param[in,out] options structure used to define the solver(s) and their parameters 152 * \return result (0 if successful otherwise 1). 153 */ 154 int variationalInequality_driver(VariationalInequality* problem, double *x , double *w, SolverOptions* options); 155 156 /** General interface to solvers for Affine Variational Inequalities (AVI) 157 \param[in] problem the AffineVariationalInequalities structure which handles the problem (M,q) 158 \param[in,out] z a n-vector of doubles which contains the solution of the problem. 159 \param[in,out] w a n-vector of doubles which contains the solution of the problem. 160 \param[in,out] options structure used to define the solver(s) and their parameters 161 \return info termination value 162 - 0 : successful 163 - >0 : otherwise see each solver for more information about the log info 164 */ 165 int avi_driver(AffineVariationalInequalities* problem, double* z, double* w, SolverOptions* options); 166 167 /** General interface to solver for MCP problems 168 \param[in] problem the MixedComplementarityProblem_old structure which handles the problem 169 \param[in,out] z a m+n-vector of doubles which contains the solution of the problem. 170 \param[in,out] w a m+n-vector of doubles which contains the solution of the problem. 171 \param[in,out] options structure used to define the solver(s) and its(their) parameters 172 \return info termination value 0 : successful, else error. 173 */ 174 int mcp_old_driver(MixedComplementarityProblem_old* problem, double *z, double *w, SolverOptions* options); 175 176 /** General interface to solver for MCP problems -- new version 177 \param[in] problem the MixedComplementarityProblem structure which handles the problem 178 \param[in,out] z a m+n-vector of doubles which contains the solution of the problem. 179 \param[in,out] w a m+n-vector of doubles which contains the solution of the problem. 180 \param[in,out] options structure used to define the solver(s) and its(their) parameters 181 \return info termination value 0 : successful, else error. 182 */ 183 int mcp_driver(MixedComplementarityProblem* problem, double *z, double *w, SolverOptions* options); 184 185 /** General interface to solver for NCP problems 186 \param[in] problem the NonlinearComplementarityProblem structure which handles the problem 187 \param[in,out] z a n-vector of doubles which contains the solution of the problem. 188 \param[in,out] F a n-vector of doubles which contains value of the function evaluated at the solution of the problem. 189 \param[in,out] options structure used to define the solver(s) and its(their) parameters 190 \return info termination value 0 : successful, else error 191 */ 192 int ncp_driver(NonlinearComplementarityProblem* problem, double *z , double *F, SolverOptions* options); 193 194 /** General interface to solvers for SOCLCP problem 195 \param[in] problem the structure which handles the Friction-Contact problem 196 \param[in,out] r global vector (n) 197 \param[in,out] v global vector (n) 198 \param[in,out] options structure used to define the solver(s) and their parameters 199 \return result (0 if successful otherwise 1). 200 */ 201 int soclcp_driver(SecondOrderConeLinearComplementarityProblem* problem, double *r , double *v, SolverOptions* options); 202 203 /** LMGC interface to solvers for friction-contact 3D problem 204 * \param[in,out] reaction global vector (nc*3) 205 * \param[in,out] velocity global vector (nc*3) 206 * \param[in] q global vector (nc*3) 207 * \param[in] mu global vector (nc) 208 * \param[in] W the block matrix in coordinate format 209 * \param[in] row block row indices 210 * \param[in] column block column indices 211 * \param[in] nc number of contacts 212 * \param[in] nb number of blocks 213 * \param[in] solver_id id an int to be mapped to actual solver in Numerics 214 * \param[in] tolerance threshold used to validate the solution: if the error is less than this value, the solution is accepted 215 * \param[in] itermax the maximum number of iteration 216 * \param[in] verbose level 0 : nothing, 1: mid level 2: high level 217 * \param[in] outputFile outputFile option 0 : nothing 1 : dat file 2: FCLIB HDF5 file if FCLIB is found 218 * \param[in] freq_output 219 * \param[in] ndof the numbe of dof in the dynamical systems involved in contact (for output in file.) 220 * \return result (0 if successful otherwise 1). 221 * 222 */ 223 int fc3d_LmgcDriver(double *reaction, 224 double *velocity, 225 double *q, 226 double *mu, 227 double* W, 228 unsigned int *row, 229 unsigned int *column, 230 unsigned int nc, 231 unsigned int nb, 232 int solver_id, 233 double tolerance, 234 int itermax, 235 int verbose, 236 int outputFile, 237 int freq_output, 238 int ndof); 239 240 /** LMGC interface to solvers for global friction-contact 3D problem 241 * \param[in,out] reaction global vector (nc*3) 242 * \param[in,out] velocity global vector (nc*3) 243 * \param[in,out] globalVelocity global velocity vector (n) 244 * \param[in] q global vector (n) 245 * \param[in] b global vector (nc*3) 246 * \param[in] mu global vector (nc) 247 * \param[in] Mdata the sparse matrix in coordinate format 248 * \param[in] nzM number of non zeros in Mdata 249 * \param[in] rowM row indices of M 250 * \param[in] colM column indices of M 251 * \param[in] Hdata the sparse matrix in coordinate format 252 * \param[in] nzH number of non zeros in Hdata 253 * \param[in] rowH row indices of H 254 * \param[in] colH column indices of H 255 * \param[in] n size of global velocity 256 * \param[in] nc number of contacts 257 * \param[in] solver_id id an int to be mapped to actual solver in Numerics 258 * \param[in] isize sive of integer parameters array 259 * \param[in] iparam integer parameters array 260 * \param[in] dsize sive of double parameters array 261 * \param[in] dparam double parameters array 262 * \param[in] verbose level 0 : nothing, 1: mid level 2: high level 263 * \param[in] outputFile outputFile option 0 : nothing 1 : C file , 1 : dat file 3: FCLIB HDF5 file if FCLIB is found 264 * \param[in] freq_output 265 * \return result (0 if successful otherwise 1). 266 * 267 */ 268 int gfc3d_LmgcDriver(double *reaction, 269 double *velocity, 270 double *globalVelocity, 271 double *q, 272 double *b, 273 double *mu, 274 double *Mdata, 275 unsigned int nzM, 276 unsigned int *rowM, 277 unsigned int *colM, 278 double* Hdata, 279 unsigned int nzH, 280 unsigned int *rowH, 281 unsigned int *colH, 282 unsigned int n, 283 unsigned int nc, 284 int solver_id, 285 int isize, 286 int *iparam, 287 int dsize, 288 double *dparam, 289 int verbose, 290 int outputFile, 291 int freq_output); 292 293 /** General interface to solver for relay problems 294 \param[in] problem the RelayProblem structure which handles the problem (M,q) 295 \param[in,out] z a n-vector of doubles which contains the solution of the problem. 296 \param[in,out] w a n-vector of doubles which contains the solution of the problem. 297 \param[in,out] options structure used to define the solver(s) and its (their) parameters 298 \return info termination value 299 - 0 : successful 300 - >0 : otherwise see each solver for more information about the log info 301 */ 302 int relay_driver(RelayProblem* problem, double *z , double *w, SolverOptions* options); 303 304 305 306 #if defined(__cplusplus) && !defined(BUILD_AS_CPP) 307 } 308 #endif 309 310 #endif 311