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 #include <stdlib.h> // for free, malloc
19 #include "Friction_cst.h" // for SICONOS_FRICTION_3D_NSGS
20 #include "NonSmoothDrivers.h" // for fc3d_LmgcDriver
main(void)21 int main(void)
22 {
23 int info = 0 ;
24
25
26 int nc = 4 ;
27 int nb = 16 ;
28 double mu[4] =
29 {
30 7.500000e-01, 7.500000e-01, 7.500000e-01, 7.500000e-01
31 };
32 unsigned int row[16] =
33 {
34 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4
35 };
36 unsigned int column[16] =
37 {
38 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4
39 };
40 double q[12] =
41 {
42 -9.810000e-03, 0.000000e+00, -6.006893e-19, -9.810000e-03, 0.000000e+00, -6.006893e-19, -9.810000e-03, 0.000000e+00, -6.006893e-19, -9.810000e-03, 0.000000e+00, -6.006893e-19
43 };
44 double W[144] =
45 {
46 9.906380e+00, -2.190000e+00, -2.166000e+00, -2.190000e+00, 5.643519e+00, -2.470594e+00, -2.166000e+00, -2.470594e+00, 5.697969e+00,
47 2.087120e+00, -2.190000e+00, 2.166000e+00, -2.190000e+00, 7.564814e-01, 2.470594e+00, -2.166000e+00, -2.470594e+00, 5.697969e+00,
48 -5.818780e+00, 2.142000e+00, 2.166000e+00, -2.190000e+00, 7.564814e-01, 2.470594e+00, -2.166000e+00, 2.416444e+00, 7.567814e-01,
49 2.000480e+00, 2.142000e+00, -2.166000e+00, -2.190000e+00, 5.643519e+00, -2.470594e+00, -2.166000e+00, 2.416444e+00, 7.567814e-01,
50 2.087120e+00, -2.190000e+00, -2.166000e+00, -2.190000e+00, 7.564814e-01, -2.470594e+00, 2.166000e+00, 2.470594e+00, 5.697969e+00,
51 9.906380e+00, -2.190000e+00, 2.166000e+00, -2.190000e+00, 5.643519e+00, 2.470594e+00, 2.166000e+00, 2.470594e+00, 5.697969e+00,
52 2.000480e+00, 2.142000e+00, 2.166000e+00, -2.190000e+00, 5.643519e+00, 2.470594e+00, 2.166000e+00, -2.416444e+00, 7.567814e-01,
53 -5.818780e+00, 2.142000e+00, -2.166000e+00, -2.190000e+00, 7.564814e-01, -2.470594e+00, 2.166000e+00, -2.416444e+00, 7.567814e-01,
54 -5.818780e+00, -2.190000e+00, -2.166000e+00, 2.142000e+00, 7.564814e-01, 2.416444e+00, 2.166000e+00, 2.470594e+00, 7.567814e-01,
55 2.000480e+00, -2.190000e+00, 2.166000e+00, 2.142000e+00, 5.643519e+00, -2.416444e+00, 2.166000e+00, 2.470594e+00, 7.567814e-01,
56 9.733100e+00, 2.142000e+00, 2.166000e+00, 2.142000e+00, 5.643519e+00, -2.416444e+00, 2.166000e+00, -2.416444e+00, 5.589669e+00,
57 1.913840e+00, 2.142000e+00, -2.166000e+00, 2.142000e+00, 7.564814e-01, 2.416444e+00, 2.166000e+00, -2.416444e+00, 5.589669e+00,
58 2.000480e+00, -2.190000e+00, -2.166000e+00, 2.142000e+00, 5.643519e+00, 2.416444e+00, -2.166000e+00, -2.470594e+00, 7.567814e-01,
59 -5.818780e+00, -2.190000e+00, 2.166000e+00, 2.142000e+00, 7.564814e-01, -2.416444e+00, -2.166000e+00, -2.470594e+00, 7.567814e-01,
60 1.913840e+00, 2.142000e+00, 2.166000e+00, 2.142000e+00, 7.564814e-01, -2.416444e+00, -2.166000e+00, 2.416444e+00, 5.589669e+00,
61 9.733100e+00, 2.142000e+00, -2.166000e+00, 2.142000e+00, 5.643519e+00, 2.416444e+00, -2.166000e+00, 2.416444e+00, 5.589669e+00
62 };
63
64 double *reaction = (double*)malloc(3 * nc * sizeof(double));
65 double *velocity = (double*)malloc(3 * nc * sizeof(double));
66 for(int i = 0; i < 3 * nc; i++)
67 {
68 reaction[i] = 0.0;
69 velocity[i] = 0.0;
70 }
71
72 int solver_id = SICONOS_FRICTION_3D_NSGS; // 500
73 double tolerance = 1e-5;
74 int itermax = 500;
75
76 info = fc3d_LmgcDriver(reaction,
77 velocity,
78 q,
79 mu,
80 W,
81 row,
82 column,
83 nc,
84 nb,
85 solver_id,
86 tolerance,
87 itermax,
88 0, 0, 0, 0);
89
90 free(reaction);
91 free(velocity);
92
93 return info;
94 }
95