Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
mesh_spring_network.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 #include <stdio.h>
25 #include <utility>
26 
27 // Local includes
28 #include "libmesh/libmesh_common.h"
29 #include "libmesh/reference_counted_object.h"
30 #include "libmesh/parallel_object.h"
31 #include "libmesh/point.h"
32 #include "libmesh/elem.h"
33 #include "libmesh/mesh.h"
34 
35 
36 #include "pm_periodic_boundary.h"
37 
38 namespace libMesh
39 {
40 
41 /*
42  * This class is used to build the spring network
43  * for a given (surface or volume) mesh
44  *
45  * This is only for one finite-sized particle, because
46  * particles usually use the same surface/volume mesh,
47  * but they may have different centers and diameters (or shapes).
48  * In these cases, the spring network can be reused for the purpose
49  * of saving memory and operation time, and it is not necessary
50  * to build all the springs for each particle.
51  *
52  */
53 
54 
55 class MeshSpringNetwork : public ReferenceCountedObject<MeshSpringNetwork>,
56  public ParallelObject
57 {
58 public:
59 
60  // Type to store the neighboring ids and the equilibrium distance(for spring)
61  // For each node, there are typically more than one neighboring nodes.
62  typedef std::vector< std::pair<std::size_t, Real> > neighbor_connection;
63 
64 
65  // Constructor
66  MeshSpringNetwork(MeshBase& surface_mesh,
67  PMPeriodicBoundary& pbc);
68 
69 
70  // ~ Destructor
72 
73 
74 
75  /*
76  * Build the spring network for all the nodes of the mesh.
77  * This also include the spring connection between the nodes and its center,
78  * which constrains the movement along the radial directions.
79  *
80  * This function typically is called only once at the beginning. It initializes:
81  * - _nodes_neighbors
82  * - _node_center_equilibrium_dist
83  */
84  void build_spring_network(const Point& center);
85 
86 
87 
88  /*
89  * Return the i-th node neighbors
90  */
91  const neighbor_connection& nodes_neighbors(const std::size_t i) const
92  { return _nodes_neighbors[i]; }
93 
94 
95  /*
96  * Return the (i-th) node-center equilibrium distance
97  */
98  const Real& node_center_equilibrium_dist(const std::size_t i) const
99  { return _node_center_equilibrium_dist[i]; }
100 
101 
102 
103  /*
104  * Return pointer to the Periodic boundary condition
105  */
106  PMPeriodicBoundary* periodic_boundary() { return _periodic_boundary; };
107 
108 
109  /*
110  * print the MeshSpringNetwork info
111  */
112  void print_info();
113 
114 
115 private:
116 
117  /*
118  * Find the nodal neighbors.
119  * This function requires nodes_to_elem_map, which can be pre-computed by
120  * MeshTools::build_nodes_to_elem_map ( mesh, nodes_to_elem_map );
121  */
122  void find_nodal_neighbors(const Node & node,
123  const std::vector<std::vector< const Elem * > >& nodes_to_elem_map,
124  std::vector<const Node*> & neighbors ) const;
125 
126 
127 
128  // Mesh base of the particle
129  MeshBase& _p_mesh;
130 
131  // Pointer to the Periodic boundary condition
132  PMPeriodicBoundary* _periodic_boundary;
133 
134  // node neighbors: neighbor id and equilibrium distance
135  std::vector< neighbor_connection > _nodes_neighbors;
136 
137  // node-center equilibrium distance
138  std::vector<Real> _node_center_equilibrium_dist;
139 
140  // nodal force vector of _p_mesh
141 // std::vector<Point> _nodal_force;
142 };
143 
144 
145 }
MeshSpringNetwork(MeshBase &surface_mesh, PMPeriodicBoundary &pbc)
Definition: mesh_spring_network.C:35
void build_spring_network(const Point &center)
Definition: mesh_spring_network.C:54
Definition: brownian_system.h:58
Definition: pm_periodic_boundary.h:46
Definition: mesh_spring_network.h:55
PMPeriodicBoundary * periodic_boundary()
Definition: mesh_spring_network.h:106
const neighbor_connection & nodes_neighbors(const std::size_t i) const
Definition: mesh_spring_network.h:91
const Real & node_center_equilibrium_dist(const std::size_t i) const
Definition: mesh_spring_network.h:98
void print_info()
Definition: mesh_spring_network.C:100
~MeshSpringNetwork()
Definition: mesh_spring_network.C:46
std::vector< std::pair< std::size_t, Real > > neighbor_connection
Definition: mesh_spring_network.h:62