Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
ggem_system.h
Go to the documentation of this file.
1 // Parallel Finite Element-General Geometry Ewald-like Method.
2 // Copyright (C) 2015-2016 Xujun Zhao, Jiyuan Li, Xikai Jiang
3 
4 // This code is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 
10 // This code is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 
15 
16 // You should have received a copy of the GNU General Public
17 // License along with this code; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20 
21 
22 #include <stdio.h>
23 #include <cmath>
24 
25 #include "libmesh/dense_matrix.h"
26 #include "libmesh/dense_vector.h"
27 #include "libmesh/elem.h"
28 #include "libmesh/point.h"
29 
30 
31 #include "point_mesh.h"
32 //#include "particle_mesh.h"
33 
34 
35 using namespace libMesh;
36 
37 
38 
39 namespace libMesh
40 {
41 
42 
43  /*
44  * Type of a Dirac Delta function(for a point force)
45  */
46  enum DeltaFunType {
47  SINGULAR = 0, // Original Dirac delta function with singularity
48  SMOOTHED_EXP = 1, // Smoothed force(Exponent/Gaussian form)
49  SMOOTHED_POL1 = 2, // Smoothed force(Polynomial type 1)
50  SMOOTHED_POL2 = 3 // Smoothed force(Polynomial type 2)
51  };
52 
53 
54 
55 
56 /*
57  * Remember that:
58  * The PMLinearImplicitSystem is designed to solve
59  * the Stokes equation with regularized Gaussian
60  * point forces due to particles using mixed FEM, which
61  * is usually known as 'global' part of the solution
62  *
63  * This class GGEMSystem will provide the main functionalities of
64  * GGEM (General Geometry Ewald-like Method), and it will provide
65  * the 'local' solution. Together with 'PMLI_system', this will
66  * provide the complete solution for the Stokes system with
67  * multiple point forces.
68  *
69  *
70  * The current Green's functions are only for 3D cases!
71  * Green's function for 2D situation is different.
72  */
73 
74 class GGEMSystem : public ReferenceCountedObject<GGEMSystem>
75 {
76 public:
77 
78  // Constructor
79  GGEMSystem();
80 
81 
82  // Destructor
83  ~GGEMSystem();
84 
85 
86  // PI constant
87  const Real PI = libMesh::pi;
88  const Real sqrt_pi = std::sqrt(PI);
89  const Real pi_23 = std::pow(PI, 3./2.);
90  const Real r_eps = 1E-6; // a small value
91 
92 
93  /*
94  * Kronecker delta function
95  */
96  inline Real kronecker_delta(const std::size_t i,
97  const std::size_t j) const
98  { return i==j ? 1.0 : 0.0; };
99 
100 
101  /*
102  * Determine the regularization parameter according to the point type:
103  * regularization parameter ksi=sqrt(PI)/(3*R0) for a polymer bead;
104  * and we ksi ~ hc^-1 for tracking points in IBM
105  * See Phys. Fluids 22, 123103(2010) Pranay et al., in which they took (ksi*hc)^-1=0.75
106  */
107  Real regularization_parameter(const Real& hc,
108  const Real& ibm_beta,
109  const Real& R0,
110  const PointType& point_type) const;
111 
112 
113 
114  /*
115  * Modified smoothed Dirac delta function with exponent form
116  * 'alpha' is a regularization parameter
117  */
118  Real smoothed_force_exp(const Real& r,
119  const Real& alpha) const;
120 
121 
122 
123  /*
124  * Green tensors for different types of Dirac Delta function
125  */
126  DenseMatrix<Number> green_tensor(const Point& x, /* vector x = pt1 - pt0 */
127  const Real& alpha, /* smoothing parameter */
128  const Real& mu, /* kinematic viscosity */
129  const std::size_t& dim, /* dim==3 */
130  const bool& zero_limit, /* x-->0 */
131  const DeltaFunType& delta_type) const;
132 
133 
134 
135  /*
136  * Original Green's function for a point force, which is singular at x = 0.
137  */
138  DenseMatrix<Number> green_tensor_exact(const Point& x, /* vector x = pt1 - pt0 */
139  const Real& mu, /* kinematic viscosity */
140  const std::size_t& dim) const; /*dim==3*/
141 
142 
143 
144  /*
145  * Green function for unbounded Stokes due to a 'local' smoothed force with exp form
146  * rho = sum[v=1:N] f_v*( g ).
147  * The solution is u_loc(i) = sum[v=1:N] G_v(x-x_v; i,j)*f_v(j)
148  * Eqn (2) - (3) in PRL 98, 140602(2007), JP Hernandez-Ortiz et al.
149  */
150  DenseMatrix<Number> green_tensor_exp(const Point& x, /* vector x = pt1 - pt0 */
151  const Real& alpha, /* alpha parameter */
152  const Real& mu, /* kinematic viscosity */
153  const std::size_t& dim, /* dim==3 */
154  const bool& zero_limit) const; /* x-->0 */
155 
156 
157  /*
158  * Green function for unbounded Stokes due to a point force + a 'local' smoothed force
159  * with exp form: rho = sum[v=1:N] f_v*( delta - g ).
160  * The solution is u_loc(i) = sum[v=1:N] G_v(x-x_v; i,j)*f_v(j)
161  * Eqn (3) in PRL 98, 140602(2007), JP Hernandez-Ortiz et al.
162  * or Eqn (30) in J Chem Phys. 136, 014901(2012), Yu Zhang, de Pablo and Graham.
163  */
164  DenseMatrix<Number> green_tensor_local(const Point& x, /* vector x = pt1 - pt0 */
165  const Real& alpha, /* alpha parameter */
166  const Real& mu, /* kinematic viscosity */
167  const std::size_t& dim, /* dim==3 */
168  const bool& zero_limit) const; /* x-->0 */
169 
170 
171  /*
172  * Regularized Green function in order to remove the singularity of v
173  * For ksi^-1 = 3a/sqrt(PI), the max fluid velocity is equal to that
174  * of a particle with radius a and the pair mobility remains positive definite.
175  *
176  * See Eqn (4) in PRL 98, 140602(2007), JP Hernandez-Ortiz et al.
177  * or Eqn (31)(32) in J Chem Phys. 136, 014901(2012), Yu Zhang, de Pablo and Graham.
178  */
179  DenseMatrix<Number> green_tensor_regularized(const Point& x, /* vector x = pt1 - pt0 */
180  const Real& alpha, /* alpha parameter */
181  const Real& mu, /* kinematic viscosity */
182  const Real& ksi, /* regularization parameter */
183  const std::size_t& dim, /* dim==3 */
184  const bool& zero_limit) const; /* x-->0 */
185 
186 
187  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
188  Difference between green_tensor_local(Gl) and green_tensor_regularized(Gr):
189  G_reg(x) = G_exp(x,ksi) - G_exp(x,alpha)
190  G_loc(x) = G_exact(x) - G_exp(x,alpha)
191  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
192  DenseMatrix<Number> green_tensor_diff(const Point& x, /* vector x = pt1 - pt0 */
193  const Real& alpha, /* alpha parameter */
194  const Real& mu, /* kinematic viscosity */
195  const Real& ksi, /* regularization parameter */
196  const std::size_t& dim, /* dim==3 */
197  const bool& zero_limit, /* x-->0 */
198  const DeltaFunType& delta_type_a, /* delta type of alpha */
199  const DeltaFunType& delta_type_k) const; /* delta type of ksi */
200 
201 
202 
203  /* Compute the local vel-solution of the fluid at a given point ptx
204  * due to smoothed/regularized point forces.
205  * force_type: regularized, smooth
206  *
207  * NOTE: due to the fast convergence of gaussian function, only a small group of
208  * particles within the neighbor list are considered. There are two ways
209  * to construct this neighbor list:
210  * (1) element independent: directly search particles near the given point using KDTree;
211  * (2) element dependent: directly use the neighbor list of the parent element;
212  * this function implement method (1), which contains a short neighbor list
213  *
214  * Eqn (33) in J Chem Phys. 136, 014901(2012), Yu Zhang, de Pablo and Graham.
215  */
216  std::vector<Real> local_velocity_fluid(PointMesh<3>* point_mesh,
217  const Point& ptx, /* a pt in space */
218  const Real& alpha, /* alpha parameter */
219  const Real& ibm_beta, /* beta paramter for IBM particles*/
220  const Real& mu, /* kinematic viscosity */
221  const Real& br0, /* normalized bead radius */
222  const Real& hs, /* mesh size of solids */
223  const std::size_t& dim, /*dim==3*/
224  const std::string& force_type) const;
225 
226  /* Compute the local vel-solution of the fluid at a given point ptx
227  * due to smoothed/regularized point forces.
228  * force_type: regularized, smooth
229  *
230  * NOTE: due to the fast convergence of gaussian function, only a small group of
231  * particles within the neighbor list are considered. There are two ways
232  * to construct this neighbor list:
233  * (1) element independent: directly search particles near the given point using KDTree;
234  * (2) element dependent: directly use the neighbor list of the parent element;
235  * this function implement method (1), which contains a short neighbor list
236  *
237  * Eqn (33) in J Chem Phys. 136, 014901(2012), Yu Zhang, de Pablo and Graham.
238  */
239  std::vector<Real> local_velocity_fluid(PointMesh<3>* point_mesh,
240  const Elem* elem,
241  const Point& ptx, /* a pt in space */
242  const Real& alpha, /* alpha parameter */
243  const Real& ibm_beta, /* beta parameter for IBM particles*/
244  const Real& mu, /* kinematic viscosity */
245  const Real& br0, /* normalized bead radius */
246  const Real& hs, /* mesh size of solids */
247  const std::size_t& dim, /*dim==3*/
248  const std::string& force_type) const;
249 
250 
251  /*
252  * Compute the local velocity of a point/bead with point_id = pid0.
253  * force_type: regularized, smooth
254  *
255  * Eqn (34)&(35) in J Chem Phys. 136, 014901(2012), Yu Zhang, de Pablo and Graham.
256  */
257  Point local_velocity_bead(PointMesh<3>* point_mesh,
258  const std::size_t& pid0, /* point id */
259  const Real& alpha, /* alpha parameter */
260  const Real& ibm_beta, /* beta paramter for IBM particles*/
261  const Real& mu, /* kinematic viscosity */
262  const Real& br0, /* normalized bead radius */
263  const Real& hs, /* mesh size of solids*/
264  const std::size_t& dim, /*dim==3*/
265  const std::string& force_type) const;
266 
267 
268 
269  /* Compute the local v-solution at a point ptx in an unbounded domain
270  * due to smoothed/regularized point forces.
271  * NOTE: due to the fast convergence of gaussian function, only a small group of
272  * particles within the neighbor list are considered. There are two ways
273  * to construct this neighbor list:
274  * (1) element independent: directly search particles near the given point using KDTree;
275  * (2) element dependent: directly use the neighbor list of the parent element;
276  * this function implement method (2), which contains a longer neighbor list
277  */
278 // std::vector<Real> local_velocity(ParticleMesh<3>* particle_mesh,
279 // const Elem* elem, /* the parent element */
280 // const Point& ptx, /* a pt in space */
281 // const Real& alpha, /* alpha parameter */
282 // const Real& mu, /* kinematic viscosity */
283 // const Real& ksi, /* ksi */
284 // const std::size_t& dim, /*dim==3*/
285 // const std::string& option);
286 
287 
288 
289  /*
290  * Self-exclusion term for the GLOBAL velocity at the i-th bead
291  */
292  Point global_self_exclusion(PointMesh<3>* point_mesh,
293  const std::size_t& pid0,
294  const Real& alpha,
295  const Real& mu,
296  const std::size_t& dim) const;
297 
298 
299 
300  /*
301  * Rotne-Prager-Yamakawa(RPY) tensor
302  * Reference: Jendrejack, Schwartz, de Pablo and Graham, J Chem Phys (2003)
303  * Eqn (5) - (9)
304  */
305  DenseMatrix<Number> rpy_tensor(const Point& x, /* vector x = pt1 - pt0 */
306  const Real& mu, /* kinematic viscosity */
307  const Real& a, /* bead radius */
308  const std::size_t& dim) const; /*dim==3*/
309 
310 
311 
312  /*
313  * Mobility tensor in an infinite domain(no walls) using RPY tensor
314  * Reference: Jendrejack, Schwartz, de Pablo and Graham, J Chem Phys (2003)
315  * Eqn (3) & (5)
316  * Note, diffusion tensor eqn(3) = this mobility tensor x kB*T.
317  */
318  DenseMatrix<Number> mobility_tensor(const Point& x, /* vector x = pt1 - pt0 */
319  const Real& mu, /* kinematic viscosity */
320  const Real& a, /* bead radius */
321  const std::size_t& dim) const; /*dim==3*/
322 
323 private:
324 
325  std::vector<std::vector<Real>> _kronecker_delta;
326 
327 };
328 
329 
330 } // end of namespace
Real kronecker_delta(const std::size_t i, const std::size_t j) const
Definition: ggem_system.h:96
Real regularization_parameter(const Real &hc, const Real &ibm_beta, const Real &R0, const PointType &point_type) const
Definition: ggem_system.C:54
DeltaFunType
Definition: ggem_system.h:46
const Real sqrt_pi
Definition: ggem_system.h:88
Point global_self_exclusion(PointMesh< 3 > *point_mesh, const std::size_t &pid0, const Real &alpha, const Real &mu, const std::size_t &dim) const
Definition: ggem_system.C:591
const Real PI
Definition: ggem_system.h:87
Definition: ggem_system.h:47
const Real pi_23
Definition: ggem_system.h:89
DenseMatrix< Number > rpy_tensor(const Point &x, const Real &mu, const Real &a, const std::size_t &dim) const
Definition: ggem_system.C:615
Definition: brownian_system.h:58
Definition: ggem_system.h:48
DenseMatrix< Number > mobility_tensor(const Point &x, const Real &mu, const Real &a, const std::size_t &dim) const
Definition: ggem_system.C:662
Definition: ggem_system.h:74
DenseMatrix< Number > green_tensor_diff(const Point &x, const Real &alpha, const Real &mu, const Real &ksi, const std::size_t &dim, const bool &zero_limit, const DeltaFunType &delta_type_a, const DeltaFunType &delta_type_k) const
Definition: ggem_system.C:318
GGEMSystem()
Definition: ggem_system.C:37
DenseMatrix< Number > green_tensor(const Point &x, const Real &alpha, const Real &mu, const std::size_t &dim, const bool &zero_limit, const DeltaFunType &delta_type) const
Definition: ggem_system.C:112
const Real r_eps
Definition: ggem_system.h:90
Definition: ggem_system.h:49
Definition: ggem_system.h:50
Real smoothed_force_exp(const Real &r, const Real &alpha) const
Definition: ggem_system.C:94
~GGEMSystem()
Definition: ggem_system.C:46
std::vector< Real > local_velocity_fluid(PointMesh< 3 > *point_mesh, const Point &ptx, const Real &alpha, const Real &ibm_beta, const Real &mu, const Real &br0, const Real &hs, const std::size_t &dim, const std::string &force_type) const
Definition: ggem_system.C:346
DenseMatrix< Number > green_tensor_regularized(const Point &x, const Real &alpha, const Real &mu, const Real &ksi, const std::size_t &dim, const bool &zero_limit) const
Definition: ggem_system.C:268
Point local_velocity_bead(PointMesh< 3 > *point_mesh, const std::size_t &pid0, const Real &alpha, const Real &ibm_beta, const Real &mu, const Real &br0, const Real &hs, const std::size_t &dim, const std::string &force_type) const
Definition: ggem_system.C:506
PointType
Definition: point_particle.h:39
DenseMatrix< Number > green_tensor_exp(const Point &x, const Real &alpha, const Real &mu, const std::size_t &dim, const bool &zero_limit) const
Definition: ggem_system.C:176
DenseMatrix< Number > green_tensor_exact(const Point &x, const Real &mu, const std::size_t &dim) const
Definition: ggem_system.C:143
DenseMatrix< Number > green_tensor_local(const Point &x, const Real &alpha, const Real &mu, const std::size_t &dim, const bool &zero_limit) const
Definition: ggem_system.C:223