Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
elasticity_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 #pragma once
23 
24 // libmesh Includes -----------------------------------
25 #include "libmesh/libmesh_config.h"
26 #include "libmesh/petsc_macro.h"
27 #include "libmesh/linear_implicit_system.h"
28 
29 
30 // Local Includes -----------------------------------
31 //#include "point_mesh.h"
32 #include "particle_mesh.h"
33 #include "mesh_spring_network.h"
34 
35 
36 // include PETSc KSP solver
37 EXTERN_C_FOR_PETSC_BEGIN
38 # include <petscksp.h>
39 EXTERN_C_FOR_PETSC_END
40 
41 
42 // C++ Includes -------------------------------------
43 #include <stdio.h>
44 #include <cstddef>
45 
46 
47 namespace libMesh
48 {
49 
50 
51  /*
52  * The ElasticitySystem is designed to solve the elasticity
53  * equation associated with immersed solid bodies using FEM.
54  */
55 
56 
57 class ElasticitySystem : public LinearImplicitSystem
58 {
59 public:
60 
64  ElasticitySystem (EquationSystems& es,
65  const std::string& name,
66  const unsigned int number); // number of systems
67 
71  virtual ~ElasticitySystem ();
72 
73 
74 
79 
80 
84  typedef LinearImplicitSystem Parent;
85 
86 
90  sys_type & system () { return *this; }
91 
92 
96  virtual void clear ();
97 
98 
102  void init_ksp_solver();
103 
104 
108  void destroy_ksp_solver();
109 
110 
114  KSP& ksp_solver() { return _ksp; }
115 
116 
123  void build_nodal_force_gravity(const std::vector<Real>& f);
124 
125 
129  std::vector<Real> nodal_force() const { return _nodal_force; };
130 
131 
132  /*
133  * Attach ParticleMesh
134  */
135  void attach_particle_mesh(ParticleMesh<3>* pm){ _particle_mesh = pm; };
136 
137 
138  /*
139  * return editable ParticleMesh ptr and const ParticleMesh ptr
140  */
141  ParticleMesh<3>* particle_mesh(){ return _particle_mesh; };
142  ParticleMesh<3>* particle_mesh() const { return _particle_mesh; };
143 
144 
145  /*
146  * Attach MeshSpringNetwork
147  */
148  void attach_mesh_spring_network(MeshSpringNetwork* msn){ _mesh_spring_network = msn; };
149 
150 
151  /*
152  * return editable MeshSpringNetwork ptr and const MeshSpringNetwork ptr
153  */
154  MeshSpringNetwork* mesh_spring_network() { return _mesh_spring_network; };
155  MeshSpringNetwork* mesh_spring_network() const { return _mesh_spring_network; };
156 
157 
158  /*
159  * Compute the min and max mesh size:
160  */
161  std::vector<Real> mesh_size() const;
162 
163 
164 private:
165 
166  // particle mesh pointer
167  ParticleMesh<3>* _particle_mesh;
168 
169 
170  // (surface or volume) mesh spring network pointer
171  MeshSpringNetwork* _mesh_spring_network;
172 
173 
174  // label whether the system matrix is assembled
175  // if is assembled, there is no need to assemble it every time step
176  bool _matrix_assembled;
177 
178 
179  // Krylov Subspace
180  KSP _ksp;
181 
182 
183  // nodal force vector, which has a copy on each processor
184  std::vector<Real> _nodal_force;
185 }; // end of class
186 
187 
188 } // end of namespace
ParticleMesh< 3 > * particle_mesh()
Definition: elasticity_system.h:141
ParticleMesh< 3 > * particle_mesh() const
Definition: elasticity_system.h:142
MeshSpringNetwork * mesh_spring_network() const
Definition: elasticity_system.h:155
std::vector< Real > mesh_size() const
Definition: elasticity_system.C:230
LinearImplicitSystem Parent
Definition: elasticity_system.h:84
Definition: brownian_system.h:58
void init_ksp_solver()
Definition: elasticity_system.C:90
sys_type & system()
Definition: elasticity_system.h:90
Definition: mesh_spring_network.h:55
void attach_mesh_spring_network(MeshSpringNetwork *msn)
Definition: elasticity_system.h:148
ElasticitySystem sys_type
Definition: elasticity_system.h:78
std::vector< Real > nodal_force() const
Definition: elasticity_system.h:129
ElasticitySystem(EquationSystems &es, const std::string &name, const unsigned int number)
Definition: elasticity_system.C:58
virtual ~ElasticitySystem()
Definition: elasticity_system.C:71
void attach_particle_mesh(ParticleMesh< 3 > *pm)
Definition: elasticity_system.h:135
virtual void clear()
Definition: elasticity_system.C:80
void build_nodal_force_gravity(const std::vector< Real > &f)
Definition: elasticity_system.C:106
KSP & ksp_solver()
Definition: elasticity_system.h:114
Definition: elasticity_system.h:57
MeshSpringNetwork * mesh_spring_network()
Definition: elasticity_system.h:154
void destroy_ksp_solver()
Definition: elasticity_system.C:98