Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.5new_solver
      Class Index
      File List
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
epot_mgsubsolver.hpp
1 
5 /* Copyright (c) 2011-2013 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef EPOT_MGSUBSOLVER_HPP
44 #define EPOT_MGSUBSOLVER_HPP 1
45 
46 
47 #include "epot_solver.hpp"
48 
49 
55 class EpotMGSubSolver : public EpotSolver {
56 
57  MeshScalarField *_defect;
58  MeshScalarField *_epot;
59  const MeshScalarField *_rhs;
60 
61  double _Ulim;
62  uint32_t _imax;
63  double _eps;
64 
65  virtual void reset_problem( void ) {}
66  virtual void subsolve( MeshScalarField &epot, const MeshScalarField &scharge ) {}
67 
68  double solve_nsimp_potential( double epf, double cof, double rhs, double p ) const;
69  double solve_pexp_potential( double epf, double cof, double rhs, double p ) const;
70 
71  // 1D
72  double rbgs_loop_1d( void ) const;
73  double sor_loop_1d( double w ) const;
74  double gs_process_near_solid_1d( const uint8_t *nearsolid_ptr,
75  uint32_t i, uint8_t bindex ) const;
76  double gs_process_pure_vacuum_1d( uint32_t i ) const;
77  double gs_process_neumann_1d( uint32_t i, uint8_t bindex ) const;
78 
79  void defect_1d( void ) const;
80  double defect_near_solid_1d( const uint8_t *nearsolid_ptr, uint32_t i, uint8_t bindex ) const;
81  double defect_pure_vacuum_1d( uint32_t i ) const;
82  double defect_neumann_1d( uint32_t i, uint8_t bindex ) const;
83 
84  // 2D
85  double rbgs_loop_2d( void ) const;
86  double sor_loop_2d( double w ) const;
87  double gs_process_near_solid_2d( const uint8_t *nearsolid_ptr,
88  uint32_t a, uint32_t dj, uint8_t bindex ) const;
89  double gs_process_pure_vacuum_2d( uint32_t a, uint32_t dj ) const;
90  double gs_process_neumann_2d( uint32_t a, uint32_t dj, uint8_t bindex ) const;
91 
92  void defect_2d( void ) const;
93  double defect_near_solid_2d( const uint8_t *nearsolid_ptr,
94  uint32_t a, uint32_t dj, uint8_t bindex ) const;
95  double defect_pure_vacuum_2d( uint32_t a, uint32_t dj ) const;
96  double defect_neumann_2d( uint32_t a, uint32_t dj, uint8_t bindex ) const;
97 
98  // CYL
99  double rbgs_loop_cyl( void ) const;
100  double sor_loop_cyl( double w ) const;
101  double gs_process_near_solid_cyl( const uint8_t *nearsolid_ptr,
102  uint32_t i, uint32_t j, uint8_t bindex ) const;
103  double gs_process_pure_vacuum_cyl( uint32_t i, uint32_t j ) const;
104  double gs_process_neumann_cyl( uint32_t i, uint32_t j, uint8_t bindex ) const;
105 
106  void defect_cyl( void ) const;
107  double defect_near_solid_cyl( const uint8_t *nearsolid_ptr,
108  uint32_t i, uint32_t j, uint8_t bindex ) const;
109  double defect_pure_vacuum_cyl( uint32_t i, uint32_t j ) const;
110  double defect_neumann_cyl( uint32_t i, uint32_t j, uint8_t bindex ) const;
111 
112  // 3D
113  double rbgs_loop_3d( void ) const;
114  double sor_loop_3d( double w ) const;
115  double gs_process_near_solid_3d( const uint8_t *nearsolid_ptr,
116  uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
117  double gs_process_pure_vacuum_3d( uint32_t a, uint32_t dj, uint32_t dk ) const;
118  double gs_process_neumann_3d( uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
119 
120  void defect_3d( bool after_smooth ) const;
121  double defect_near_solid_3d( const uint8_t *nearsolid_ptr,
122  uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
123  double defect_pure_vacuum_3d( uint32_t a, uint32_t dj, uint32_t dk ) const;
124  double defect_neumann_3d( uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
125 
126 public:
127 
133  EpotMGSubSolver( const EpotSolver &epsolver, Geometry &geom,
134  double Ulim, uint32_t imax, double eps );
135 
138  virtual ~EpotMGSubSolver() {}
139 
145  void defect( MeshScalarField *defect, MeshScalarField *epot, const MeshScalarField *rhs,
146  bool after_smooth );
147 
150  double mg_smooth( MeshScalarField *epot, const MeshScalarField *rhs );
151 
154  double mg_solve( MeshScalarField *epot, const MeshScalarField *rhs, double w );
155 
158  double error_scale( double w ) const;
159 
162  double error_scale_mg( void ) const;
163 
166  void preprocess( MeshScalarField &epot );
167 
170  void postprocess( void );
171 
174  virtual void debug_print( std::ostream &os ) const {}
175 
178  virtual void save( std::ostream &s ) const {}
179 };
180 
181 
182 #endif
Subroutine class for EpotMGSolver.
Definition: epot_mgsubsolver.hpp:55
virtual ~EpotMGSubSolver()
Destructor.
Definition: epot_mgsubsolver.hpp:138
void preprocess(MeshScalarField &epot)
Preprocess.
Definition: epot_mgsubsolver.cpp:186
Scalar field class.
Definition: meshscalarfield.hpp:70
double mg_solve(MeshScalarField *epot, const MeshScalarField *rhs, double w)
Do a solve round with SOR using over-relaxation factor w.
Definition: epot_mgsubsolver.cpp:134
EpotMGSubSolver(const EpotSolver &epsolver, Geometry &geom, double Ulim, uint32_t imax, double eps)
Constructor.
Definition: epot_mgsubsolver.cpp:58
Geometry defining class.
Definition: geometry.hpp:179
Class for constructing the linear/nonlinear problem for the solver.
Definition: epot_solver.hpp:207
void postprocess(void)
Postprocess.
Definition: epot_mgsubsolver.cpp:192
double error_scale_mg(void) const
Return error scaling factor for MG smoother.
Definition: epot_mgsubsolver.cpp:66
Poisson equation problem for solving electric potential.
void defect(MeshScalarField *defect, MeshScalarField *epot, const MeshScalarField *rhs, bool after_smooth)
Calculate defect.
Definition: epot_mgsubsolver.cpp:160
double error_scale(double w) const
Return error scaling factor for SOR solver with over-relaxation factor w.
Definition: epot_mgsubsolver.cpp:85
virtual void save(std::ostream &s) const
Saves problem data to stream.
Definition: epot_mgsubsolver.hpp:178
virtual void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: epot_mgsubsolver.hpp:174
double mg_smooth(MeshScalarField *epot, const MeshScalarField *rhs)
Do a smoothing round with Red-Black Gauss-Seidel.
Definition: epot_mgsubsolver.cpp:108


Reference manual for Ion Beam Simulator 1.0.5new_solver
Generated by Doxygen 1.8.5 on Tue May 19 2015 09:15:42.