Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
point_particle.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 #pragma once
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/reference_counted_object.h"
27 #include "libmesh/point.h"
28 #include "libmesh/id_types.h"
29 
30 
31 
32 //
33 namespace libMesh
34 {
35 
36  /*
37  * Type of a point
38  */
39  enum PointType {
44  };
45 
46 
47  /*
48  * This basic class only defines the point-type particle,
49  * which is only a point without radius.
50  * It is also the key component to define other types of structures
51  */
52 
53 
54 class PointParticle : public ReferenceCountedObject<PointParticle>
55 {
56 public:
57 
58  // Constructor
59  PointParticle(const Point pt,
60  const dof_id_type point_id);
61 
62 
63  // Constructor
64  PointParticle(const Point pt,
65  const dof_id_type point_id,
66  const PointType point_type);
67 
68  // Constructor
69  PointParticle(const Point pt,
70  const dof_id_type point_id,
71  const PointType point_type,
72  const std::vector<Real>& rot_vec);
73 
74 
75  // Copy constructor
76  PointParticle(const PointParticle& particle);
77 
78 
79  // ~ Destructor
81 
82 
83  /*
84  * The coordinate of the particle center(point) which is set writeable!
85  */
86  Point& point() { return _center; };
87  Point& center() { return _center; };
88 
89 
90 
91  /*
92  * The counter that counts how many times a point has crossed boundaries
93  */
94  std::vector<int> & counter() { return _counter; };
95 
96 
97  /*
98  * Set values for counter
99  */
100  void set_pbc_counter(int nx, int ny, int nz) { _counter[0]=nx; _counter[1]=ny; _counter[2]=nz; };
101 
102 
103  /*
104  * Return particle id, which is an unique id for a given particle.
105  * This id is set during the initialization,and NOT allowed to be changed.
106  */
107  dof_id_type id() const { return _id; };
108 
109 
110  /*
111  * Get and set parent id.
112  * A point may be part of another upper level object, for example,
113  * it may be a bead of a chain, or a node of a solid particle, which
114  * may also have its id.
115  *
116  * It is also possible that this point doesn't have a parent. In this case,
117  * this parent_id is set -1 (by default)
118  */
119  int parent_id() const { return _parent_id; };
120  void set_parent_id(const int pid) { _parent_id = pid; };
121 
122 
123  /*
124  * Get the point type: 0 - polymer point; 1 - tracking point; ...
125  * This can be either a point on immersed bodies or a bead on the polymer chains.
126  *
127  * Note that points with the same type may have different parent id. For example,
128  * They can be bead type points on two different polymer chains, or tracking points
129  * on two different immersed bodies, whose parent ids are different.
130  */
131  PointType point_type() const { return _point_type; };
132  void set_point_type(const PointType p_type) { _point_type = p_type; };
133 
134 
135  /*
136  * The processor that the particle belongs to, which is the same as the
137  * processor id of its hosting element.
138  */
139  int processor_id() const { return _processor_id; };
140  void set_processor_id(const int pid) { _processor_id = pid; };
141 
142 
143  /*
144  * Elem id that the particle resides in.
145  * Note this id will change when a particle moves from one element to another.
146  * Therefore, it needs to be reset in this situation.
147  */
148  dof_id_type elem_id() const { return _elem_id; };
149  void set_elem_id(const dof_id_type e_id) { _elem_id = e_id; };
150 
151 
152  /*
153  * Set the neighbor list of the particle
154  * This is used by the member function in the class "ParticleMesh"
155  */
156  void set_neighbor_list(const std::vector<std::pair<std::size_t,Real> >& nei_list)
157  {
158  if (nei_list.size() > 0) {
159  _neighbor_list = nei_list;
160  }
161  };
162 
163 
164  /*
165  * Return the neighbor list of the particle.
166  * NOTE, this includes the particle ids and distance values to this particle.
167  */
168  std::vector<std::pair<std::size_t,Real> > neighbor_list() const
169  { return _neighbor_list; };
170 
171 
175  void set_neighbor_vector(std::vector<Point>& neighbor_vector)
176  { _neighbor_vector = neighbor_vector;};
177 
181  const std::vector<Point> neighbor_vector() const{
182  return _neighbor_vector;
183  }
184  /*
185  * Set the force vector on the particle
186  * This is set by the member function in the class "ParticleMesh"
187  */
188  void set_particle_force(const Point& pforce);
189 
190 
191  /*
192  * Add the force vector
193  */
194  void add_particle_force(const Point& pforce);
195 
196 
197  /*
198  * set the force vector equal to zeros
199  */
200  void zero_particle_force();
201 
205  const Point& particle_force() {return _force;};
206 
207  /*
208  * Set particle velocity
209  */
210  void set_particle_velocity(const Point& p_velocity) {_velocity = p_velocity;};
211 
212  /*
213  * Return the velocity vector of the particle
214  */
215  const Point& particle_velocity() const {return _velocity; };
216 
217 
218 
219  /*
220  * Return the orientation vector of the particle
221  */
222  const std::vector<Real> orientation() const { return _orientation; };
223  void set_orientation(const std::vector<Real>& rot_vec);
224 
225 
226 
227  /*
228  * Re-init the point particle quantities:
229  * clean neighbor_list
230  * _processor_id = -1;
231  * _elem_id = -1
232  * The following members are NOT changed during the reinit:
233  * (1)_center; (2) force; (3)_counter; (4)_id; (5)_parent_id; (6)_point_type; (7)_orientation;
234  */
235  void reinit_particle();
236 
237 
238  /*
239  * Print information of this particle
240  */
241  void print_info(const bool & print_neighbor_list = true) const;
242 
243 
244 
245 private:
246 
247  // The coordinate of the particle center
248  Point _center;
249 
250  // The velocity of the particle center
251  Point _velocity;
252 
253  // the force vector excerted on this particle(non-hydrodynamic and non-Brownian)
254  Point _force;
255 
256 
257  // Count how many times the point has crossed a boundary
258  // Used to unfold point's coordinate with periodic boundaries
259  std::vector<int> _counter;
260 
261  // particle id
262  dof_id_type _id;
263 
264 
265  // type of the point
266  PointType _point_type;
267 
268 
269  // id of its parent that it belongs to
270  // Its parents can be either an immersed body or a polymer chain.
271  // Knowing the parent's property will facilitate the computation of force field.
272  // -1 by default, which means it has no parent.
273  int _parent_id;
274 
275 
276  // the processor that the particle belongs to
277  int _processor_id;
278 
279 
280  // Elem id that the particle reside in
281  dof_id_type _elem_id; //unsigned int _elem_id (uint32 by default!);
282 
283 
284  // neighbor particles around the present particle: particle id and distance value.
285  std::vector<std::pair<std::size_t,Real> > _neighbor_list;
286 
287  // neighbor distance
288  std::vector<Point> _neighbor_vector;
289 
290 
291  // Define the orientation of this point(bending, torque)
292  // Use the definition of quaternions to describe the orientation
293  // as specified in lammps(http://lammps.sandia.gov/doc/set.html)
294  std::vector<Real> _orientation;
295 };
296 
297 
298 } // end of namespace
void set_point_type(const PointType p_type)
Definition: point_particle.h:132
void set_particle_force(const Point &pforce)
Definition: point_particle.C:110
Definition: point_particle.h:42
~PointParticle()
Definition: point_particle.C:102
void add_particle_force(const Point &pforce)
Definition: point_particle.C:119
void set_processor_id(const int pid)
Definition: point_particle.h:140
void set_particle_velocity(const Point &p_velocity)
Definition: point_particle.h:210
const std::vector< Real > orientation() const
Definition: point_particle.h:222
void print_info(const bool &print_neighbor_list=true) const
Definition: point_particle.C:152
Definition: brownian_system.h:58
void set_parent_id(const int pid)
Definition: point_particle.h:120
PointParticle(const Point pt, const dof_id_type point_id)
Definition: point_particle.C:36
std::vector< std::pair< std::size_t, Real > > neighbor_list() const
Definition: point_particle.h:168
void reinit_particle()
Definition: point_particle.C:134
const Point & particle_velocity() const
Definition: point_particle.h:215
const Point & particle_force()
Definition: point_particle.h:205
void set_elem_id(const dof_id_type e_id)
Definition: point_particle.h:149
Point & point()
Definition: point_particle.h:86
Definition: point_particle.h:40
Definition: point_particle.h:43
dof_id_type id() const
Definition: point_particle.h:107
void set_orientation(const std::vector< Real > &rot_vec)
Definition: point_particle.C:146
Definition: point_particle.h:41
std::vector< int > & counter()
Definition: point_particle.h:94
void set_neighbor_vector(std::vector< Point > &neighbor_vector)
Definition: point_particle.h:175
void zero_particle_force()
Definition: point_particle.C:127
void set_pbc_counter(int nx, int ny, int nz)
Definition: point_particle.h:100
const std::vector< Point > neighbor_vector() const
Definition: point_particle.h:181
void set_neighbor_list(const std::vector< std::pair< std::size_t, Real > > &nei_list)
Definition: point_particle.h:156
Point & center()
Definition: point_particle.h:87
Definition: point_particle.h:54
PointType
Definition: point_particle.h:39
dof_id_type elem_id() const
Definition: point_particle.h:148
int parent_id() const
Definition: point_particle.h:119
int processor_id() const
Definition: point_particle.h:139
PointType point_type() const
Definition: point_particle.h:131