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 
36     Christoph Kloss (DCS Computing GmbH, Linz)
37     Christoph Kloss (JKU Linz)
38     Philippe Seil (JKU Linz)
39 
40     Copyright 2012-     DCS Computing GmbH, Linz
41     Copyright 2009-2012 JKU Linz
42 ------------------------------------------------------------------------- */
43 
44 #ifndef LMP_TRI_MESH_H
45 #define LMP_TRI_MESH_H
46 
47 #include "surface_mesh.h"
48 #include "atom.h"
49 #include "math_extra_liggghts.h"
50 #include "tri_line.h"
51 #include "region_neighbor_list.h"
52 
53 #ifdef TRI_LINE_ACTIVE_FLAG
54 #include "math_extra_dist_lineTriangle.h"
55 #endif
56 
57 #ifdef SUPERQUADRIC_ACTIVE_FLAG
58 #include "math_extra_liggghts_superquadric.h"
59 using namespace MathExtraLiggghtsNonspherical;
60 #endif
61 
62 #include <fstream>
63 
64 namespace LAMMPS_NS
65 {
66 
67   typedef SurfaceMesh<3,5> SurfaceMeshBase;
68 
69   class TriMesh : public SurfaceMeshBase
70   {
71       public:
72 
73         TriMesh(LAMMPS *lmp);
74         virtual ~TriMesh();
75 
76         double resolveTriSphereContact    (int iPart, int nTri, double rSphere, double *cSphere,
77                                            double *delta,int &barysign);
78         double resolveTriSphereContactBary(int iPart, int nTri, double rSphere, double *cSphere,
79                                            double *contactPoint,double *bary,int &barysign,bool skip_inactive=true);
80 
81         #ifdef SUPERQUADRIC_ACTIVE_FLAG
82 
83         double resolveTriSuperquadricContact(int nTri, double *normal, double *contactPoint, Superquadric particle);
84         double resolveTriSuperquadricContact(int nTri, double *normal, double *contactPoint, Superquadric particle, double *bary);
85 
86         bool sphereTriangleIntersection(int nTri, double rSphere, double *cSphere);
87         int superquadricTriangleIntersection(int nTri, double *point_of_lowest_potential, Superquadric particle);
88         double pointToTriangleDistance(int iTri, double *Csphere, double *delta, bool treatActiveFlag, double *bary);
89 
90         #endif
91 
92         bool resolveTriSphereNeighbuild(int nTri, double rSphere, double *cSphere, double treshold);
93 
94         #ifdef TRI_LINE_ACTIVE_FLAG
95         // Extra for Line Contact Calculation ********
96         double resolveTriSegmentContact    (int iPart, int nTri, double *line, double *cLine, double length, double cylRadius,
97                                             double *delta, double &segmentParameter,int &barysign);
98         double resolveTriSegmentContactBary(int iPart, int nTri, double *line, double *cLine, double length, double cylRadius,
99                                             double *delta, double  &segmentParameter, double *bary,int &barysign);
100         bool resolveTriSegmentNeighbuild(int nTri, double *cLine, double length, double cylRadius, double treshold);
101         // Extra for Line Contact Calculation ********
102         #endif
103 
104         int generateRandomOwnedGhost(double *pos);
105         int generateRandomSubbox(double *pos);
106 
107         virtual int generateRandomOwnedGhostWithin(double *pos,double delta);
108 
109       protected:
110 
111         double calcArea(int n);
112         bool isInElement(double *pos,int i);
113 
114       private:
115 
precision_trimesh()116         inline double precision_trimesh()
117         { return MultiNodeMesh<3>::precision(); }
118 
119         double calcDist(double *cs, double *closestPoint, double *en0);
120         double calcDistToPlane(double *p, double *pPlane, double *nPlane);
121 
122         double resolveCornerContactBary(int iTri, int iNode, bool obtuse,
123                                     double *p, double *delta, double *bary,bool skip_inactive = true);
124         double resolveEdgeContactBary(int iTri, int iEdge, double *p, double *delta, double *bary,bool skip_inactive = true);
125         double resolveFaceContactBary(int iTri, double *p, double *node0ToSphereCenter, double *delta);
126   };
127 
128   // *************************************
129   #include "tri_mesh_I.h"
130   #ifdef SUPERQUADRIC_ACTIVE_FLAG
131   #include "tri_mesh_I_superquadric.h"
132   #endif
133 
134   #ifdef TRI_LINE_ACTIVE_FLAG
135   #include "tri_mesh_I_line.h"
136   #endif
137   // *************************************
138 
139 } /* LAMMPS_NS */
140 #endif /* TRIMESH_H_ */
141