Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
pm_linear_implicit_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 // Local Includes -----------------------------------
30 #include "point_mesh.h"
31 #include "particle_mesh.h"
32 
33 // C++ Includes -------------------------------------
34 #include <stdio.h>
35 #include <cstddef>
36 
37 
38 namespace libMesh
39 {
40 
41 
42 /*
43  * The PMLinearImplicitSystem is designed to provide
44  * a basic class for solving partial different equations
45  * with regularized Gaussian point forces due to particles
46  * using mixed FEM.
47  */
48 
49 class Fix;
50 
51 
52 class PMLinearImplicitSystem : public LinearImplicitSystem
53 {
54 public:
55 
59  PMLinearImplicitSystem (EquationSystems& es,
60  const std::string& name,
61  const unsigned int number); // number of systems
62 
63 
67  virtual ~PMLinearImplicitSystem ();
68 
69 
74 
75 
79  sys_type & system () { return *this; }
80 
81 
85  virtual void clear () = 0;
86 
87 
91  virtual void assemble_matrix (const std::string& system_name,
92  const std::string& option) = 0;
93 
94 
98  virtual void assemble_rhs (const std::string& system_name,
99  const std::string& option) = 0;
100 
101 
105  virtual void solve (const std::string& option,
106  const bool& re_init) = 0;
107 
108 
109  /*
110  * Add the local solution to the global solution
111  */
112  virtual void add_local_solution() = 0;
113 
114 
115  /*
116  * Compute the L2-error by comparing numerical and analytical solutions
117  */
118  virtual void test_l2_norm(bool& neighbor_list_update_flag) = 0;
119 
120 
121  /*
122  * Write out equation systems. This requires combining the
123  * local and global solution, and update the solution vectors.
124  * output_format=="EXODUS" ; "VTK"; "GMV"
125  */
126  virtual void write_equation_systems(const std::size_t time_step,
127  const std::string& output_filename,
128  const std::string& output_format) = 0;
129 
130 
131  /*
132  * Attach PointMesh
133  */
135 
136 
137  /*
138  * return editable PointMesh ptr and const PointMesh ptr
139  */
141  PointMesh<3>* point_mesh() const { return _point_mesh; };
142 
143 
144  /*
145  * Attach ParticleMesh
146  */
148 
149 
150  /*
151  * return editable ParticleMesh ptr and const ParticleMesh ptr
152  */
155 
156 
157  /*
158  * Attach the ForceField
159  */
160  void attach_fixes(std::vector<Fix*> fixes){ _fixes = fixes; };
161  std::vector<Fix*> fixes() { return _fixes; };
162  std::vector<Fix*> fixes() const { return _fixes; };
163 
164 
165  /*
166  * write out single particle(point particle) info, including:
167  * timestep, time, particle_xyz, particle_velocity
168  */
169  void write_out_single_particle(const Point& coords,
170  const std::vector<Real>& vel,
171  const int i_step,
172  const Real time) const;
173 
174 
175  /*
176  * Write out particle(point) coordinates represented by a PETSc vector
177  */
178  void write_out_point_coordinate(Vec* ROUT,
179  const std::size_t istep,
180  const Real& time,
181  const std::string& f_name,
182  const std::string& openmode) const;
183 
184 
185  /*
186  * Write out particle(point) coordinates
187  * The output format is Comma Separated Variable(CSV) for ParaView.
188  */
189  void write_point_csv(const std::string& filename,
190  const std::vector<Real>& pv,
191  const bool write_velocity) const;
192 
193  PetscErrorCode write_point_csv(const std::string& filename,
194  Vec * petsc_vector,
195  const bool write_velocity) const;
196 
197 
198 
199 protected:
200 
201  // particle mesh pointer
203 
204  // particle mesh pointer
206 
207  // force field for particle/points
208  std::vector<Fix*> _fixes;
209 
210 };
211 
212 } // end namespace libMesh
virtual void solve(const std::string &option, const bool &re_init)=0
void write_out_single_particle(const Point &coords, const std::vector< Real > &vel, const int i_step, const Real time) const
Definition: pm_linear_implicit_system.C:67
virtual void write_equation_systems(const std::size_t time_step, const std::string &output_filename, const std::string &output_format)=0
virtual void add_local_solution()=0
std::vector< Fix * > _fixes
Definition: pm_linear_implicit_system.h:208
PMLinearImplicitSystem sys_type
Definition: pm_linear_implicit_system.h:73
sys_type & system()
Definition: pm_linear_implicit_system.h:79
Definition: brownian_system.h:58
virtual ~PMLinearImplicitSystem()
Definition: pm_linear_implicit_system.C:58
PointMesh< 3 > * _point_mesh
Definition: pm_linear_implicit_system.h:202
Definition: fix.h:55
void attach_particle_mesh(ParticleMesh< 3 > *pm)
Definition: pm_linear_implicit_system.h:147
PMLinearImplicitSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Definition: pm_linear_implicit_system.C:46
ParticleMesh< 3 > * particle_mesh() const
Definition: pm_linear_implicit_system.h:154
std::vector< Fix * > fixes() const
Definition: pm_linear_implicit_system.h:162
void write_out_point_coordinate(Vec *ROUT, const std::size_t istep, const Real &time, const std::string &f_name, const std::string &openmode) const
Definition: pm_linear_implicit_system.C:137
void write_point_csv(const std::string &filename, const std::vector< Real > &pv, const bool write_velocity) const
Definition: pm_linear_implicit_system.C:211
ParticleMesh< 3 > * particle_mesh()
Definition: pm_linear_implicit_system.h:153
Definition: pm_linear_implicit_system.h:52
void attach_point_mesh(PointMesh< 3 > *pm)
Definition: pm_linear_implicit_system.h:134
virtual void assemble_matrix(const std::string &system_name, const std::string &option)=0
ParticleMesh< 3 > * _particle_mesh
Definition: pm_linear_implicit_system.h:205
PointMesh< 3 > * point_mesh()
Definition: pm_linear_implicit_system.h:140
std::vector< Fix * > fixes()
Definition: pm_linear_implicit_system.h:161
PointMesh< 3 > * point_mesh() const
Definition: pm_linear_implicit_system.h:141
void attach_fixes(std::vector< Fix * > fixes)
Definition: pm_linear_implicit_system.h:160
virtual void test_l2_norm(bool &neighbor_list_update_flag)=0
virtual void assemble_rhs(const std::string &system_name, const std::string &option)=0