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 #ifndef MechanicsIO_hpp
20 #define MechanicsIO_hpp
21 
22 #include <MechanicsFwd.hpp>
23 #ifdef HAVE_SICONOS_MECHANISMS
24 #include <MechanismsFwd.hpp>
25 #endif
26 #include <SiconosPointers.hpp>
27 #include <SiconosFwd.hpp>
28 
29 class MechanicsIO
30 {
31 protected:
32 
33   template<typename T, typename G>
34   SP::SimpleMatrix visitAllVerticesForVector(const G& graph) const;
35 
36   template<typename T, typename G>
37   SP::SiconosVector visitAllVerticesForDouble(const G& graph) const;
38 
39 public:
40   /** default constructor
41    */
MechanicsIO()42   MechanicsIO() {};
43 
44   /** get all positions: translation (x,y,z) + orientation quaternion
45    * (qw, qx, qy, qz)
46    * \param nsds current nonsmooth dynamical system
47    * \return a SP::SimpleMatrix where the columns are
48    *          id, x, y, z, qw, qx, qy, qz
49    *   id is the DynamicalSystem number + 1
50    */
51   SP::SimpleMatrix positions(const NonSmoothDynamicalSystem& nsds) const;
52 
53   /** get all velocities: translation (xdot, ydot, zdot) + orientation velocities
54    * ox, oy, oz
55    * \param nsds current nonsmooth dynamical system
56    *   \return a matrix where the columns are id, xdot, ydot, zdot,
57    *   ox, oy, oz
58    * id is the DynamicalSystem number + 1
59    */
60   SP::SimpleMatrix velocities(const NonSmoothDynamicalSystem& nsds) const;
61 
62   /** get the coordinates of all contact points, normals, reactions and velocities
63    * \param nsds current nonsmooth dynamical system
64    * \param index_set the index set number.
65    \return a matrix where the columns are mu x y z, nx, ny, nz, rx, ry, rz, vx, vy, vz, ox, oy, oz, id
66   */
67   SP::SimpleMatrix contactPoints(const NonSmoothDynamicalSystem& nsds, unsigned int index_set=1) const;
68 
69   /** get the domain of each contact point
70    * \param nsds current nonsmooth dynamical system
71    * \return a matrix where the columns are domain, id
72   */
73   SP::SimpleMatrix domains(const NonSmoothDynamicalSystem& nsds) const;
74 };
75 
76 
77 #endif
78