1 /* ----------------------------------------------------------------------
2     This is the
3 
4     ██╗     ██╗ ██████╗  ██████╗  ██████╗ ██╗  ██╗████████╗███████╗
5     ██║     ██║██╔════╝ ██╔════╝ ██╔════╝ ██║  ██║╚══██╔══╝██╔════╝
6     ██║     ██║██║  ███╗██║  ███╗██║  ███╗███████║   ██║   ███████╗
7     ██║     ██║██║   ██║██║   ██║██║   ██║██╔══██║   ██║   ╚════██║
8     ███████╗██║╚██████╔╝╚██████╔╝╚██████╔╝██║  ██║   ██║   ███████║
9     ╚══════╝╚═╝ ╚═════╝  ╚═════╝  ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝®
10 
11     DEM simulation engine, released by
12     DCS Computing Gmbh, Linz, Austria
13     http://www.dcs-computing.com, office@dcs-computing.com
14 
15     LIGGGHTS® is part of CFDEM®project:
16     http://www.liggghts.com | http://www.cfdem.com
17 
18     Core developer and main author:
19     Christoph Kloss, christoph.kloss@dcs-computing.com
20 
21     LIGGGHTS® is open-source, distributed under the terms of the GNU Public
22     License, version 2 or later. It is distributed in the hope that it will
23     be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have
25     received a copy of the GNU General Public License along with LIGGGHTS®.
26     If not, see http://www.gnu.org/licenses . See also top-level README
27     and LICENSE files.
28 
29     LIGGGHTS® and CFDEM® are registered trade marks of DCS Computing GmbH,
30     the producer of the LIGGGHTS® software and the CFDEM®coupling software
31     See http://www.cfdem.com/terms-trademark-policy for details.
32 
33 -------------------------------------------------------------------------
34     Contributing author and copyright for this file:
35     Alexander Podlozhnyuk (DCS Computing GmbH, Linz)
36 
37     Copyright 2015-     DCS Computing GmbH, Linz
38 ------------------------------------------------------------------------- */
39 
40 #ifndef LMP_MATH_EXTRA_LIGGGHTS_SUPERQUADRIC_H
41 #define LMP_MATH_EXTRA_LIGGGHTS_SUPERQUADRIC_H
42 
43 #include "math_extra_liggghts_nonspherical.h"
44 #include "superquadric.h"
45 
46 using namespace LIGGGHTS::ContactModels;
47 
48 namespace MathExtraLiggghtsNonspherical {
49 
50   void area_superquadric(const double *shape, const double *blockiness, double *result);
51   double crossSectionalArea(const double* u_, const double* shape, const double *blockiness, const double* quat, int& index);
52   void inertia_superquadric(const double *shape, const double *blockiness, const double density, double *inertia);
53   void volume_superquadric(const double *shape, const double *blockiness, double *volume);
54   void bounding_sphere_radius_superquadric(const double *shape, const double *blockiness, double *radius);
55 
56   double check_inequalities(const int i, const double *delta, const double *a, const double *b,
57                           const double *A_delta, const double *B_delta, const double *C);
58   bool obb_intersect(Superquadric *particle_i, Superquadric *particle_j);
59   bool obb_intersect(Superquadric *particle_i, Superquadric *particle_j, unsigned int &inequality_to_start);
60 
61   double minimal_distance(Superquadric *particle1, Superquadric *particle2, const double *initial_point1, const double *initial_point2,
62       double *result_point1, double *result_point2, bool *fail);
63 
64   void calc_contact_point(Superquadric *particle_i, Superquadric *particle_j,
65       double ratio, const double *initial_point1, double *result_point, double &fi, double &fj, bool *fail, LAMMPS_NS::Error *error);
66 
67   bool capsules_intersect(Superquadric *particle_i, Superquadric *particle_j, double *capsule_contact_point);
68 
69   bool calc_contact_point_if_no_previous_point_avaialable(SurfacesIntersectData & sidata, Superquadric *particle_i, Superquadric *particle_j,
70       double *contact_point, double &fi, double &fj,LAMMPS_NS::Error *error);
71   bool calc_contact_point_using_prev_step(SurfacesIntersectData & sidata, Superquadric *particle_i, Superquadric *particle_j,
72       double ratio, double dt, double *prev_step_point, double *contact_point, double &fi, double &fj, LAMMPS_NS::Error *error);
73   void basic_overlap_algorithm(SurfacesIntersectData & sidata, Superquadric *particle_i, Superquadric *particle_j,
74       double &alphai, double &alphaj, const double *contact_point, double *contact_point_i, double *contact_point_j);
75   double extended_overlap_algorithm(Superquadric *particleA, Superquadric *particleB,
76       double *en, double *const alpha_i, double *const alpha_j,
77       const double *contact_point, double *contact_pointA, double *contact_pointB, double *delta);
78   double common_normal(SurfacesIntersectData & sidata, Superquadric *particle_i, Superquadric *particle_j, bool particles_were_in_contact_flag,
79       double *const contact_point_i_local, double *contact_point_j_local, double *contact_point_i, double *contact_point_j);
80   double inverseMatrix4x4(const double *m, double *out);
81   double determinant_4x4(double *mat);
82 #ifdef LIGGGHTS_DEBUG
83   void printf_debug_data(Superquadric *particle_i, Superquadric *particle_j, double *initial_guess, LAMMPS_NS::Error *error);
84 #endif
85 };
86 
87 #endif
88 
89