Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
pm_system_stokes.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 "assemble_stokes.h"
26 #include "stokes_solver.h"
28 
29 namespace libMesh
30 {
31 
32 /*
33  * The PMSystemStokes is designed to solve the Stokes
34  * equation with regularized Gaussian point forces
35  * due to particles using mixed FEM.
36  */
37 
38 //class Fix;
39 
41 {
42 public:
43 
47  PMSystemStokes (EquationSystems& es,
48  const std::string& name,
49  const unsigned int number); // number of systems
50 
51 
55  virtual ~PMSystemStokes ();
56 
57 
62 
63 
67  sys_type & system () { return *this; }
68 
69 
70  /*
71  * Re-init particle mesh, including:
72  * (1) reinit() reinit point particles
73  * build_particle_neighbor_list()
74  * build_elem_neighbor_list()
75  * (2) update the mesh of each finite sized particle if there are;
76  * (3) compute particle force (by force field)
77  * modify the force field according to the vel_last_step.
78  */
79  void reinit_hi_system(bool& neighbor_list_update_flag);
80 
81 
82  /*
83  * Re-init free-draining system, including:
84  * (1) reinit() reinit point particles
85  * build_particle_neighbor_list()
86  * (2) compute particle force (by force field)
87  * modify the force field according to the vel_last_step.
88  */
89  void reinit_fd_system(bool& neighbor_list_update_flag);
90 
91 
95  void clear ();
96 
97 
103  void assemble_matrix (const std::string& system_name,
104  const std::string& option);
105 
106 
110  void assemble_rhs (const std::string& system_name,
111  const std::string& option);
112 
113 
114  /*
115  * Solve the Stokes system.
116  * option = "undisturbed", compute the undisturbed field of flow without particles
117  * option = "disturbed", compute the disturbed field of flow with particles
118  * re_init = true => re-assemble the matrix and reinit the KSP solver.
119  */
120  void solve (const std::string& option,
121  const bool& re_init);
122 
123 
124  /*
125  * Add the local solution to the global solution
126  */
127  void add_local_solution();
128 
129 
130  /*
131  * Compute the L2-error in an unbounded domain
132  * This function will change the system solution vector by add local solution.
133  */
134  void test_l2_norm(bool& neighbor_list_update_flag);
135 
136 
137  /*
138  * Write out equation systems of Stokes. This requires combining the
139  * local and global solution, and update the solution vectors.
140  * output_format=="EXODUS" ; "VTK"; "GMV"
141  */
142  void write_equation_systems(const std::size_t time_step,
143  const std::string& output_filename,
144  const std::string& output_format);
145 
146 
147  /*
148  * Return the StokesSolver
149  */
150  StokesSolver& stokes_solver() { return _stokes_solver; }
151 
152 
164  void compute_point_velocity(const std::string& option, std::vector<Real>& pv);
165 
166 
170  std::vector<Real> compute_unperturbed_point_velocity();
171 
172 
173  /*
174  * Obtain the velocity vector on the i-th point
175  */
176  std::vector<Real> point_velocity(const std::vector<Real>& vel_beads,
177  const std::size_t i) const;
178 
179 
185  std::vector<Real> local_velocity_fluid(const Point &p,
186  const std::string& force_type) const;
187 
188 
194  std::vector<Real> local_velocity_fluid(const Elem* elem,
195  const Point &p,
196  const std::string& force_type) const;
197 
198 
204  Point local_velocity_bead(const std::size_t& bead_id,
205  const std::string& force_type) const;
206 
207 
208  /*
209  * Self-exclusion term for the velocity at the i-th bead
210  */
211  Point global_self_exclusion(const std::size_t p_id) const;
212 
213 
214  /*
215  * Test function. output velocity profile along x-y-z direction
216  */
217  void test_velocity_profile(bool& neighbor_list_update_flag);
218 
219 
220  /*
221  * Return the exact solution of Stokes eqn for any given
222  * point \pt0 in an unbounded domain.
223  */
224  //const std::vector<Real> exact_solution(const Point& pt0) const;
225 
226 
227  /*
228  * Write nodal coordinates (x, y, z) and velocities (vx, vy, vz)
229  * from system's solution vector to raw data file for step i.
230  * If you want to write the total velocites, this function MUST ONLY
231  * be called after you *add_local_solution* and *unperturbed* velocities
232  * to the solution vector.
233  */
234  void write_fluid_velocity_data(const std::string& filename);
235 
236 
237 
238 private:
239 
240  // Stokes solver
241  StokesSolver _stokes_solver;
242 
243  // Assemble Stokes system
244  AssembleStokes* _assemble_stokes;
245 
246 };
247 
248 } // end namespace libMesh
sys_type & system()
Definition: pm_system_stokes.h:67
void assemble_rhs(const std::string &system_name, const std::string &option)
Definition: pm_system_stokes.C:196
std::vector< Real > compute_unperturbed_point_velocity()
Definition: pm_system_stokes.C:638
void assemble_matrix(const std::string &system_name, const std::string &option)
Definition: pm_system_stokes.C:165
Point local_velocity_bead(const std::size_t &bead_id, const std::string &force_type) const
Definition: pm_system_stokes.C:755
void test_l2_norm(bool &neighbor_list_update_flag)
Definition: pm_system_stokes.C:350
void clear()
Definition: pm_system_stokes.C:69
void reinit_fd_system(bool &neighbor_list_update_flag)
Definition: pm_system_stokes.C:125
Point global_self_exclusion(const std::size_t p_id) const
Definition: pm_system_stokes.C:794
std::vector< Real > local_velocity_fluid(const Point &p, const std::string &force_type) const
Definition: pm_system_stokes.C:676
Definition: brownian_system.h:58
void test_velocity_profile(bool &neighbor_list_update_flag)
Definition: pm_system_stokes.C:814
void compute_point_velocity(const std::string &option, std::vector< Real > &pv)
Definition: pm_system_stokes.C:518
PMSystemStokes(EquationSystems &es, const std::string &name, const unsigned int number)
Definition: pm_system_stokes.C:47
PMSystemStokes sys_type
Definition: pm_system_stokes.h:61
void solve(const std::string &option, const bool &re_init)
Definition: pm_system_stokes.C:222
void write_fluid_velocity_data(const std::string &filename)
Definition: pm_system_stokes.C:999
void reinit_hi_system(bool &neighbor_list_update_flag)
Definition: pm_system_stokes.C:80
void write_equation_systems(const std::size_t time_step, const std::string &output_filename, const std::string &output_format)
Definition: pm_system_stokes.C:421
This class provides the basic components for assembling the matrix and vector when solving Stokes equ...
Definition: assemble_stokes.h:35
Definition: pm_system_stokes.h:40
Definition: pm_linear_implicit_system.h:52
virtual ~PMSystemStokes()
Definition: pm_system_stokes.C:60
void add_local_solution()
Definition: pm_system_stokes.C:270
std::vector< Real > point_velocity(const std::vector< Real > &vel_beads, const std::size_t i) const
Definition: pm_system_stokes.C:658
StokesSolver & stokes_solver()
Definition: pm_system_stokes.h:150