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 #ifndef FRICTIONCONTACT3D_onecontact_nonsmooth_Newton_solvers_H
19 #define FRICTIONCONTACT3D_onecontact_nonsmooth_Newton_solvers_H
20 
21 /*!\file fc3d_onecontact_nonsmooth_Newton_solvers.h
22   \brief Typedef and functions declarations related to Newton solver for 3 dimension frictional contact problems.
23 
24   Each solver must have 4 functions in its interface:
25   - initialize: link local static variables to the global ones (M,q,...)
26   - update: link/fill the local variables corresponding to sub-blocks of the full problem, for a specific contact
27   - solve: solve the local problem
28   - free
29 
30 */
31 
32 #include "NumericsFwd.h"  // for FrictionContactProblem, SolverOptions
33 #include "SiconosConfig.h" // for BUILD_AS_CPP // IWYU pragma: keep
34 
35 #if defined(__cplusplus) && !defined(BUILD_AS_CPP)
36 extern "C"
37 {
38 #endif
39 
40 
41 typedef void (*computeNonsmoothFunction)(double *, double * , double , double * , double *, double *, double *);
42 
43   /** initialize friction-contact 3D Newton solver
44    * \param problem to solve
45    * \param localproblem to solve
46    * \param options of the solver
47    */
48   void fc3d_onecontact_nonsmooth_Newton_solvers_initialize(FrictionContactProblem* problem, FrictionContactProblem* localproblem, SolverOptions * options);
49 
50   /** solve friction-contact 3D problem with Newton
51    * \param localproblem to solve
52    * \param options of the solver
53    * \return 0 iff successful.
54    */
55   int fc3d_onecontact_nonsmooth_Newton_solvers_solve(FrictionContactProblem* localproblem, double*, SolverOptions * options);
56 
57   /** free memory for friction contact 3D Newton solver
58       \param problem the global problem to solve
59       \param localproblem for freeing matrix0
60       \param localsolver_options options of the solver
61    */
62   void fc3d_onecontact_nonsmooth_Newton_solvers_free(FrictionContactProblem * problem, FrictionContactProblem * localproblem, SolverOptions* localsolver_options);
63 
64   /** compute error for friction-contact 3D problem with Newton
65    *  \param dimension of the global problem
66    *  \param[in,out] velocity vector
67    *  \param reaction global reaction vector
68    *  \param output_error
69    */
70   void fc3d_onecontact_nonsmooth_Newton_solvers_computeError(int dimension, double* velocity, double*reaction, double * output_error);
71 
72   /** Update friction-contact 3D problem: formalize local problem for one contact
73       \param problem the global problem to solve
74       \param localproblem the local problem to solve
75       \param number (position in global matrix) of the considered contact
76       \param reaction global reaction (only the block corresponding to the
77       current contact will be modified
78       \param options of the solver
79 
80       the rest is used to formalize the local problem)
81   */
82   void fc3d_onecontact_nonsmooth_Newton_AC_update(int number, FrictionContactProblem* problem, FrictionContactProblem* localproblem ,
83                                    double * reaction, SolverOptions* options);
84 
85   int fc3d_onecontact_nonsmooth_Newton_solvers_solve_direct(FrictionContactProblem* localproblem,
86                                                             double * R, SolverOptions * options);
87 
88   int fc3d_onecontact_nonsmooth_Newton_solvers_solve_damped(FrictionContactProblem* localproblem,
89                                                             double * R, SolverOptions * options);
90 
91   int fc3d_onecontact_nonsmooth_Newton_solvers_solve_hybrid(FrictionContactProblem* localproblem,
92                                                             double * local_reaction, SolverOptions* options);
93 
94 
95 #if defined(__cplusplus) && !defined(BUILD_AS_CPP)
96 }
97 #endif
98 
99 #endif
100