Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   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,2021 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_shield_potential( double epf, double cof, double rhs, double p ) const;
69  double solve_nsimp_potential( double epf, double cof, double rhs, double p ) const;
70  double solve_pexp_potential( double epf, double cof, double rhs, double p ) const;
71 
72  // 1D
73  double rbgs_loop_1d( void ) const;
74  double sor_loop_1d( double w ) const;
75  double gs_process_near_solid_1d( const uint8_t *nearsolid_ptr,
76  uint32_t i, uint8_t bindex ) const;
77  double gs_process_pure_vacuum_1d( uint32_t i ) const;
78  double gs_process_neumann_1d( uint32_t i, uint8_t bindex ) const;
79 
80  void defect_1d( void ) const;
81  double defect_near_solid_1d( const uint8_t *nearsolid_ptr, uint32_t i, uint8_t bindex ) const;
82  double defect_pure_vacuum_1d( uint32_t i ) const;
83  double defect_neumann_1d( uint32_t i, uint8_t bindex ) const;
84 
85  // 2D
86  double rbgs_loop_2d( void ) const;
87  double sor_loop_2d( double w ) const;
88  double gs_process_near_solid_2d( const uint8_t *nearsolid_ptr,
89  uint32_t a, uint32_t dj, uint8_t bindex ) const;
90  double gs_process_pure_vacuum_2d( uint32_t a, uint32_t dj ) const;
91  double gs_process_neumann_2d( uint32_t a, uint32_t dj, uint8_t bindex ) const;
92 
93  void defect_2d( void ) const;
94  double defect_near_solid_2d( const uint8_t *nearsolid_ptr,
95  uint32_t a, uint32_t dj, uint8_t bindex ) const;
96  double defect_pure_vacuum_2d( uint32_t a, uint32_t dj ) const;
97  double defect_neumann_2d( uint32_t a, uint32_t dj, uint8_t bindex ) const;
98 
99  // CYL
100  double rbgs_loop_cyl( void ) const;
101  double sor_loop_cyl( double w ) const;
102  double gs_process_near_solid_cyl( const uint8_t *nearsolid_ptr,
103  uint32_t i, uint32_t j, uint8_t bindex ) const;
104  double gs_process_pure_vacuum_cyl( uint32_t i, uint32_t j ) const;
105  double gs_process_neumann_cyl( uint32_t i, uint32_t j, uint8_t bindex ) const;
106 
107  void defect_cyl( void ) const;
108  double defect_near_solid_cyl( const uint8_t *nearsolid_ptr,
109  uint32_t i, uint32_t j, uint8_t bindex ) const;
110  double defect_pure_vacuum_cyl( uint32_t i, uint32_t j ) const;
111  double defect_neumann_cyl( uint32_t i, uint32_t j, uint8_t bindex ) const;
112 
113  // 3D
114  double rbgs_loop_3d( void ) const;
115  double sor_loop_3d( double w ) const;
116  double gs_process_near_solid_3d( const uint8_t *nearsolid_ptr,
117  uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
118  double gs_process_pure_vacuum_3d( uint32_t a, uint32_t dj, uint32_t dk ) const;
119  double gs_process_neumann_3d( uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
120 
121  void defect_3d( bool after_smooth ) const;
122  double defect_near_solid_3d( const uint8_t *nearsolid_ptr,
123  uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
124  double defect_pure_vacuum_3d( uint32_t a, uint32_t dj, uint32_t dk ) const;
125  double defect_neumann_3d( uint32_t a, uint32_t dj, uint32_t dk, uint8_t bindex ) const;
126 
127 public:
128 
134  EpotMGSubSolver( const EpotSolver &epsolver, Geometry &geom,
135  double Ulim, uint32_t imax, double eps );
136 
139  virtual ~EpotMGSubSolver() {}
140 
146  void defect( MeshScalarField *defect, MeshScalarField *epot, const MeshScalarField *rhs,
147  bool after_smooth );
148 
151  double mg_smooth( MeshScalarField *epot, const MeshScalarField *rhs );
152 
155  double mg_solve( MeshScalarField *epot, const MeshScalarField *rhs, double w );
156 
159  double error_scale( double w ) const;
160 
163  double error_scale_mg( void ) const;
164 
167  void preprocess( MeshScalarField &epot );
168 
171  void postprocess( void );
172 
175  virtual void debug_print( std::ostream &os ) const {}
176 
179  virtual void save( std::ostream &s ) const {}
180 };
181 
182 
183 #endif
Subroutine class for EpotMGSolver.
Definition: epot_mgsubsolver.hpp:55
double error_scale_mg(void) const
Return error scaling factor for MG smoother.
Definition: epot_mgsubsolver.cpp:66
void preprocess(MeshScalarField &epot)
Preprocess.
Definition: epot_mgsubsolver.cpp:186
virtual ~EpotMGSubSolver()
Destructor.
Definition: epot_mgsubsolver.hpp:139
void postprocess(void)
Postprocess.
Definition: epot_mgsubsolver.cpp:192
void defect(MeshScalarField *defect, MeshScalarField *epot, const MeshScalarField *rhs, bool after_smooth)
Calculate defect.
Definition: epot_mgsubsolver.cpp:160
virtual void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: epot_mgsubsolver.hpp:175
EpotMGSubSolver(const EpotSolver &epsolver, Geometry &geom, double Ulim, uint32_t imax, double eps)
Constructor.
Definition: epot_mgsubsolver.cpp:58
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:179
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
double mg_smooth(MeshScalarField *epot, const MeshScalarField *rhs)
Do a smoothing round with Red-Black Gauss-Seidel.
Definition: epot_mgsubsolver.cpp:108
Class for constructing the linear/nonlinear problem for the solver.
Definition: epot_solver.hpp:210
Geometry defining class.
Definition: geometry.hpp:180
Scalar field class.
Definition: meshscalarfield.hpp:70
Poisson equation problem for solving electric potential.


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.