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     Andreas Aigner (JKU Linz)
36 
37     Copyright 2009-2012 JKU Linz
38 ------------------------------------------------------------------------- */
39 
40 #ifndef LMP_SPH_KERNELS
41 #define LMP_SPH_KERNELS
42 
43 #include "style_sph_kernel.h"
44 
45 namespace SPH_KERNEL_NS {
46   inline int sph_kernels_unique_id();
47   inline int sph_kernel_id(char *style);
48   inline double sph_kernel(int id,double s,double h,double hinv);
49   inline double sph_kernel_der(int id,double s,double h,double hinv);
50   inline double sph_kernel_cut(int id);
51 }
52 
53 /* ---------------------------------------------------------------------- */
54 
sph_kernels_unique_id()55 inline int SPH_KERNEL_NS::sph_kernels_unique_id()
56 {
57   int ids[50];
58   int nkernels = 0;
59 
60   if (0) return 0.;
61   #define SPH_KERNEL_CLASS
62   #define SPHKernel(kernel_id,kernelstyle,SPHKernelCalculation,SPHKernelCalculationDer,SPHKernelCalculationCut) \
63   ids[nkernels++] = kernel_id;
64   #include "style_sph_kernel.h"
65   #undef SPH_KERNEL_CLASS
66   #undef SPHKernel
67 
68   // check if double ids
69   for (int i = 0; i < nkernels; i++)
70       for (int j = i+1; j < nkernels; j++)
71          if(ids[i] == ids[j]) return -1;
72 
73   return 0;
74 }
75 
76 /* ---------------------------------------------------------------------- */
77 
sph_kernel_id(char * style)78 inline int SPH_KERNEL_NS::sph_kernel_id(char *style)
79 {
80   if (0) return 0.;
81   #define SPH_KERNEL_CLASS
82   #define SPHKernel(kernel_id,kernelstyle,SPHKernelCalculation,SPHKernelCalculationDer,SPHKernelCalculationCut) \
83   else if (strcmp(style,#kernelstyle) == 0) return kernel_id;
84   #include "style_sph_kernel.h"
85   #undef SPH_KERNEL_CLASS
86   #undef SPHKernel
87   return -1;
88 }
89 
90 /* ---------------------------------------------------------------------- */
91 
sph_kernel(int id,double s,double h,double hinv)92 inline double SPH_KERNEL_NS::sph_kernel(int id,double s,double h,double hinv)
93 {
94   if (0) return 0.;
95   #define SPH_KERNEL_CLASS
96   #define SPHKernel(kernel_id,kernelstyle,SPHKernelCalculation,SPHKernelCalculationDer,SPHKernelCalculationCut) \
97   else if (kernel_id == id) return SPH_KERNEL_NS::SPHKernelCalculation(s,h,hinv);
98   #include "style_sph_kernel.h"
99   #undef SPH_KERNEL_CLASS
100   #undef SPHKernel
101   return 0.;
102 }
103 
104 /* ---------------------------------------------------------------------- */
105 
sph_kernel_der(int id,double s,double h,double hinv)106 inline double SPH_KERNEL_NS::sph_kernel_der(int id,double s,double h,double hinv)
107 {
108   if (0) return 0.;
109   #define SPH_KERNEL_CLASS
110   #define SPHKernel(kernel_id,kernelstyle,SPHKernelCalculation,SPHKernelCalculationDer,SPHKernelCalculationCut) \
111   else if (kernel_id == id) return SPH_KERNEL_NS::SPHKernelCalculationDer(s,h,hinv);
112   #include "style_sph_kernel.h"
113   #undef SPH_KERNEL_CLASS
114   #undef SPHKernel
115   return 0.;
116 }
117 
118 /* ---------------------------------------------------------------------- */
119 
sph_kernel_cut(int id)120 inline double SPH_KERNEL_NS::sph_kernel_cut(int id)
121 {
122   if (0) return 0.;
123   #define SPH_KERNEL_CLASS
124   #define SPHKernel(kernel_id,kernelstyle,SPHKernelCalculation,SPHKernelCalculationDer,SPHKernelCalculationCut) \
125   else if (kernel_id == id) return SPH_KERNEL_NS::SPHKernelCalculationCut();
126   #include "style_sph_kernel.h"
127   #undef SPH_KERNEL_CLASS
128   #undef SPHKernel
129   return 0.;
130 }
131 
132 #endif
133