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 #include <stdlib.h> // for malloc
20 #include "Friction_cst.h" // for SICONOS_FRICTION_3D_ONECONTA...
21 #include "NumericsFwd.h" // for SolverOptions
22 #include "SolverOptions.h" // for SolverOptions, solver_option...
23 #include "frictionContact_test_utils.h" // for build_test_collection
24 #include "test_utils.h" // for TestCase
25
build_test_collection(int n_data,const char ** data_collection,int * number_of_tests)26 TestCase * build_test_collection(int n_data, const char ** data_collection, int* number_of_tests)
27 {
28 *number_of_tests = 22;//n_data * n_solvers;
29 TestCase * collection = (TestCase*)malloc((*number_of_tests) * sizeof(TestCase));
30
31
32 // "External" solver parameters
33 // -> same values for all tests.
34 // The differences between tests are only for internal solvers and input data.
35 int topsolver = SICONOS_FRICTION_3D_NSGS;
36 int current = 0;
37
38
39 {
40 // Projection on cone, default values.
41 int d = 0; // FC3D_Example1_SBM.dat
42 collection[current].filename = data_collection[d];
43 collection[current].options = solver_options_create(topsolver);
44 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-16;
45 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
46
47 solver_options_update_internal(collection[current].options, 0, SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnCone);
48
49 current++;
50 }
51
52 {
53 int d = 0; // FC3D_Example1_SBM.dat
54 // Projection on cone with diagonalization, default value.
55 collection[current].filename = data_collection[d];
56 collection[current].options = solver_options_create(topsolver);
57 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-16;
58 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
59
60 solver_options_update_internal(collection[current].options, 0,
61 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithDiagonalization);
62
63 current++;
64 }
65
66 {
67 int d = 0; // FC3D_Example1_SBM.dat
68 // Projection on cone with local iteration, set tol and max iter.
69 collection[current].filename = data_collection[d];
70 collection[current].options = solver_options_create(topsolver);
71 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-16;
72 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
73
74 solver_options_update_internal(collection[current].options, 0,
75 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
76 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-3;
77 collection[current].options->internalSolvers[0]->iparam[SICONOS_IPARAM_MAX_ITER] = 10;
78 current++;
79 }
80
81 {
82 int d= 0; // FC3D_Example1_SBM.dat
83 // Projection on cone with regularization, set rho
84 collection[current].filename = data_collection[d];
85 collection[current].options = solver_options_create(topsolver);
86 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-16;
87 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
88
89 solver_options_update_internal(collection[current].options, 0,
90 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithRegularization);
91 collection[current].options->internalSolvers[0]->dparam[SICONOS_FRICTION_3D_NSN_RHO] = 0.1;
92 current++;
93 }
94
95
96 {
97 int d=1; // "./data/Capsules-i122-1617.dat"
98
99 // Projection on cone with local iteration, set tol, itermax, d[9], i[8]
100 collection[current].filename = data_collection[d];
101 collection[current].options = solver_options_create(topsolver);
102 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-16;
103 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
104
105 solver_options_update_internal(collection[current].options, 0,
106 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
107
108 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 20;
109 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
110 collection[current].options->internalSolvers[0]->dparam[9] = 1.; // ???
111 collection[current].options->internalSolvers[0]->iparam[8] = 1; // ???
112 // Expected to fail ...
113 collection[current].will_fail = 1;
114 current++;
115 }
116
117 {
118 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
119 // Projection on cone set d[9], i[8]
120 collection[current].filename = data_collection[d];
121 collection[current].options = solver_options_create(topsolver);
122 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
123 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
124
125 solver_options_update_internal(collection[current].options, 0,
126 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnCone);
127
128 collection[current].options->internalSolvers[0]->dparam[9] = 1.; // ???
129 collection[current].options->internalSolvers[0]->iparam[8] = 1; // ???
130 // Expected to fail ...
131 collection[current].will_fail = 1;
132 current++;
133 }
134
135 {
136 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
137 // nonsmooth newton. Set tol, max iter and i[1]. Default for other parameters
138 collection[current].filename = data_collection[d];
139 collection[current].options = solver_options_create(topsolver);
140 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
141 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
142
143 solver_options_update_internal(collection[current].options, 0,
144 SICONOS_FRICTION_3D_ONECONTACT_NSN);
145
146 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
147 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-18;
148 collection[current].options->internalSolvers[0]->iparam[1] = 1; // ???
149 current++;
150 }
151
152
153 {
154 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
155 // Projection on cone with local iteration, set tol and maxiter
156 collection[current].filename = data_collection[d];
157 collection[current].options = solver_options_create(topsolver);
158 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
159 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
160
161 solver_options_update_internal(collection[current].options, 0,
162 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
163
164 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 100;
165 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-6;
166 current++;
167 }
168
169
170 {
171 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
172 // Projection on cone with regularization, default values.
173 collection[current].filename = data_collection[d];
174 collection[current].options = solver_options_create(topsolver);
175 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
176 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
177
178 solver_options_update_internal(collection[current].options, 0,
179 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithRegularization);
180
181 current++;
182 }
183
184 {
185 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
186 // Projection on cone, default values.
187 collection[current].filename = data_collection[d];
188 collection[current].options = solver_options_create(topsolver);
189 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-2;
190 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
191
192 solver_options_update_internal(collection[current].options, 0,
193 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnCone);
194
195 current++;
196 }
197
198 {
199 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
200 // nonsmooth newton. Set tol and i[1]. Default for other parameters
201 collection[current].filename = data_collection[d];
202 collection[current].options = solver_options_create(topsolver);
203 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
204 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 1000;
205
206 solver_options_update_internal(collection[current].options, 0,
207 SICONOS_FRICTION_3D_ONECONTACT_NSN);
208 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
209 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
210 current++;
211 }
212
213 {
214 int d = 2; // Confeti-ex13-4contact-Fc3D-SBM.dat
215 // Projection on cone with local iteration, set tol and maxiter
216 collection[current].filename = data_collection[d];
217 collection[current].options = solver_options_create(topsolver);
218 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
219 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
220
221 solver_options_update_internal(collection[current].options, 0,
222 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
223 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 100;
224 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-6;
225 current++;
226
227
228 collection[current].filename = data_collection[d];
229 collection[current].options = solver_options_create(topsolver);
230 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
231 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
232
233 solver_options_update_internal(collection[current].options, 0,
234 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
235 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 100;
236 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
237 current++;
238 }
239
240 {
241 int d = 3; // GFC3D_TwoRods1-condensed.dat
242 // nonsmooth newton. Set tol and i[1]. Default for other parameters
243 collection[current].filename = data_collection[d];
244 collection[current].options = solver_options_create(topsolver);
245 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
246 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
247
248 solver_options_update_internal(collection[current].options, 0,
249 SICONOS_FRICTION_3D_ONECONTACT_NSN);
250 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
251 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-18;
252 current++;
253 }
254
255
256 {
257 int d = 4; // FC3D_Example1.dat
258
259 // nonsmooth newton. Set tol and max iter. Default for other parameters
260 collection[current].filename = data_collection[d];
261 collection[current].options = solver_options_create(topsolver);
262 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-12;
263 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
264
265 solver_options_update_internal(collection[current].options, 0,
266 SICONOS_FRICTION_3D_ONECONTACT_NSN);
267 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
268 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-18;
269 current++;
270 }
271
272 {
273 int d = 5; // Confeti-ex03-Fc3D-SBM.dat
274 // Projection on cone, default values.
275 collection[current].filename = data_collection[d];
276 collection[current].options = solver_options_create(topsolver);
277 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
278 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
279
280 solver_options_update_internal(collection[current].options, 0,
281 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnCone);
282 // Expected to fail ...
283 collection[current].will_fail = 1;
284 current++;
285 }
286
287 {
288 int d = 5;
289 // nonsmooth newton. Set tol and max iter. Default for other parameters
290 collection[current].filename = data_collection[d];
291 collection[current].options = solver_options_create(topsolver);
292 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
293 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
294
295 solver_options_update_internal(collection[current].options, 0,
296 SICONOS_FRICTION_3D_ONECONTACT_NSN);
297 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
298 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
299 // Expected to fail ...
300 collection[current].will_fail = 1;
301 current++;
302 }
303
304 {
305 int d = 5;
306 // Projection on cone with local iteration, set tol and maxiter
307 collection[current].filename = data_collection[d];
308 collection[current].options = solver_options_create(topsolver);
309 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
310 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
311
312 solver_options_update_internal(collection[current].options, 0,
313 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
314 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
315 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-12;
316 current++;
317 }
318
319
320 {
321 int d = 5;
322 // Projection on cone with regularization, set tol and maxiter
323 collection[current].filename = data_collection[d];
324 collection[current].options = solver_options_create(topsolver);
325 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-5;
326 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 10000;
327
328 solver_options_update_internal(collection[current].options, 0,
329 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithRegularization);
330 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 10;
331 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-8;
332 // Expected to fail ...
333 collection[current].will_fail = 1;
334 current++;
335 }
336
337
338
339 {
340 int d = 7;
341 // nonsmooth newton 'damped'. Set tol and max iter. Default for other parameters
342 collection[current].filename = data_collection[d];
343 collection[current].options = solver_options_create(topsolver);
344 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-3;
345 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 1000;
346
347 solver_options_update_internal(collection[current].options, 0,
348 SICONOS_FRICTION_3D_ONECONTACT_NSN_GP);
349 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 1000;
350 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
351 // Expected to fail ...
352 collection[current].will_fail = 1;
353 current++;
354 }
355
356 {
357 int d = 7;
358 // nonsmooth newton. Set tol and max iter. Default for other parameters
359 collection[current].filename = data_collection[d];
360 collection[current].options = solver_options_create(topsolver);
361 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-3;
362 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 2000;
363
364 solver_options_update_internal(collection[current].options, 0,
365 SICONOS_FRICTION_3D_ONECONTACT_NSN);
366 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 1000;
367 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-16;
368 // Expected to fail ...
369 collection[current].will_fail = 1;
370 current++;
371 }
372
373 {
374 int d = 7;
375 // Projection on cone with local iteration, set tol and maxiter
376 collection[current].filename = data_collection[d];
377 collection[current].options = solver_options_create(topsolver);
378 collection[current].options->dparam[SICONOS_DPARAM_TOL] = 1e-3;
379 collection[current].options->iparam[SICONOS_IPARAM_MAX_ITER] = 2000;
380
381 solver_options_update_internal(collection[current].options, 0,
382 SICONOS_FRICTION_3D_ONECONTACT_ProjectionOnConeWithLocalIteration);
383 collection[current].options->internalSolvers[0]->dparam[SICONOS_IPARAM_MAX_ITER] = 100;
384 collection[current].options->internalSolvers[0]->dparam[SICONOS_DPARAM_TOL] = 1e-6;
385 // Expected to fail ...
386 collection[current].will_fail = 1;
387 current++;
388 }
389
390 *number_of_tests = current;
391 return collection;
392
393 }
394