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
21
main(void)22 int main(void)
23 {
24 int info = 0 ;
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 0.000000e+00, 0.000000e+00, 0.000000e+00, 7.457348e-14, 0.000000e+00, 0.000000e+00, 7.288212e-14, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00
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
65 double *reaction = (double*)malloc(3 * nc * sizeof(double));
66 double *velocity = (double*)malloc(3 * nc * sizeof(double));
67 for(int i = 0; i < 3 * nc; i++)
68 {
69 reaction[i] = 0.0;
70 velocity[i] = 0.0;
71 }
72
73 int solver_id = SICONOS_FRICTION_3D_NSGS; // 500
74 double tolerance = 1e-16;
75 int itermax = 100;
76
77 info = fc3d_LmgcDriver(reaction,
78 velocity,
79 q,
80 mu,
81 W,
82 row,
83 column,
84 nc,
85 nb,
86 solver_id,
87 tolerance,
88 itermax,
89 0, 0, 0, 0);
90
91 free(reaction);
92 free(velocity);
93
94 return info;
95 }
96