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_mgsolver.hpp
Go to the documentation of this file.
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_MGSOLVER_HPP
44 #define EPOT_MGSOLVER_HPP 1
45 
46 
47 #include "epot_solver.hpp"
48 #include "epot_mgsubsolver.hpp"
49 
50 
53 class EpotMGSolver : public EpotSolver {
54 
55  std::vector<MeshScalarField *> _epotv;
56  std::vector<Geometry *> _geomv;
57  std::vector<EpotMGSubSolver *> _epotsolverv;
58  std::vector<MeshScalarField *> _rhsv;
59  std::vector<MeshScalarField *> _workv;
60  std::vector<MeshScalarField *> _work2v;
61 
62  bool _geom_prepared;
63  uint32_t _levels;
64  uint32_t _npre;
65  uint32_t _npost;
66  uint32_t _mgcycmax;
67  uint32_t _mgcyc;
68  double _mgeps;
69  double _mgerr;
70  uint32_t _gamma;
71  double _step;
72  double _coarse_eps;
73  double _coarse_err;
74  double _w;
75  uint32_t _imax;
76  uint32_t _coarse_steps;
77  double _local_Ulim;
78  uint32_t _local_imax;
79  double _local_eps;
81  void prepare_local_gnewton_settings( void );
82  void print_field( const MeshScalarField *F );
83 
84  void prepare_mg_geom( void );
85 
86  double near_solid_neumann_rhs_contribution( uint32_t i, uint32_t j, uint32_t k,
87  uint8_t bindex, const Vec3D &x ) const;
88  void preprocess( MeshScalarField &epot, const MeshScalarField &scharge );
89  void postprocess( void );
90 
91  void prolong_add_3d( MeshScalarField *out, int32_t i, int32_t j, int32_t k, double C );
92  void prolong_add_cyl( MeshScalarField *out, int32_t i, int32_t j, double C );
93  void prolong_add_2d( MeshScalarField *out, int32_t i, int32_t j, double C );
94  void prolong_add_1d( MeshScalarField *out, int32_t i, double C );
95 
96  void correct( const Geometry *geom, MeshScalarField *sol, const MeshScalarField *corr );
97 
98  void restrict_3d( MeshScalarField *out, const MeshScalarField *in, bool defect );
99  void restrict_cyl( MeshScalarField *out, const MeshScalarField *in, bool defect );
100  void restrict_2d( MeshScalarField *out, const MeshScalarField *in, bool defect );
101  void restrict_1d( MeshScalarField *out, const MeshScalarField *in, bool defect );
102 
107  void restrict( MeshScalarField *out, const MeshScalarField *in, bool defect );
108 
109  void prolong_3d( MeshScalarField *out, const MeshScalarField *in );
110  void prolong_cyl( MeshScalarField *out, const MeshScalarField *in );
111  void prolong_2d( MeshScalarField *out, const MeshScalarField *in );
112  void prolong_1d( MeshScalarField *out, const MeshScalarField *in );
113  void prolong( MeshScalarField *out, const MeshScalarField *in );
114 
115  void mg_recurse( uint32_t level );
116 
119  virtual void reset_problem( void );
120 
123  virtual void subsolve( MeshScalarField &epot, const MeshScalarField &scharge );
124 
125 public:
126 
129  EpotMGSolver( Geometry &geom );
130 
133  EpotMGSolver( Geometry &geom, std::istream &s );
134 
137  virtual ~EpotMGSolver();
138 
143  void set_eps( double eps );
144 
149  void set_w( double w );
150 
155  void set_imax( uint32_t imax );
156 
161  void set_local_imax( uint32_t local_imax );
162 
167  void set_levels( uint32_t levels );
168 
175  void set_mgcycmax( uint32_t mgcyc );
176 
183  void set_mgeps( double mgeps );
184 
189  void set_gamma( uint32_t gamma );
190 
195  void set_npre( uint32_t npre );
196 
201  void set_npost( uint32_t npost );
202 
207  double get_potential_change_norm( void ) const;
208 
215  double get_error_estimate( void ) const;
216 
219  uint32_t get_mgcyc( void ) const;
220 
223  virtual void debug_print( std::ostream &os ) const;
224 
227  virtual void save( std::ostream &s ) const;
228 };
229 
230 #endif
Multigrid solver for Electric potential problem.
Definition: epot_mgsolver.hpp:53
EpotMGSolver(Geometry &geom)
Constructor.
Definition: epot_mgsolver.cpp:59
virtual void save(std::ostream &s) const
Saves problem data to stream.
Definition: epot_mgsolver.cpp:1606
void set_local_imax(uint32_t local_imax)
Sets maximum number of local iterations to take for nonlinear problems.
Definition: epot_mgsolver.cpp:137
void set_npost(uint32_t npost)
Sets number of post cycle smoother rounds.
Definition: epot_mgsolver.cpp:198
void set_imax(uint32_t imax)
Sets maximum number of iteration rounds for coarsest level SOR solver.
Definition: epot_mgsolver.cpp:131
virtual ~EpotMGSolver()
Destructor.
Definition: epot_mgsolver.cpp:77
double get_potential_change_norm(void) const
Get potential change norm.
Definition: epot_mgsolver.cpp:143
void set_mgcycmax(uint32_t mgcyc)
Sets maximum number of multigrid cycles to take.
Definition: epot_mgsolver.cpp:170
void set_npre(uint32_t npre)
Sets number of pre cycle smoother rounds.
Definition: epot_mgsolver.cpp:190
void set_mgeps(double mgeps)
Sets the accuracy request for finest level.
Definition: epot_mgsolver.cpp:176
void set_eps(double eps)
Sets the accuracy request for coarsest level SOR solver.
Definition: epot_mgsolver.cpp:119
virtual void debug_print(std::ostream &os) const
Print debugging information to os.
Definition: epot_mgsolver.cpp:1614
void set_levels(uint32_t levels)
Sets multigrid levels.
Definition: epot_mgsolver.cpp:161
void set_w(double w)
Sets the over-relaxation factor for coarsest level SOR solver.
Definition: epot_mgsolver.cpp:125
double get_error_estimate(void) const
Get estimate of relative solution error.
Definition: epot_mgsolver.cpp:149
uint32_t get_mgcyc(void) const
Get number of multigrid cycles done.
Definition: epot_mgsolver.cpp:155
void set_gamma(uint32_t gamma)
Sets multigrid cycle coefficient.
Definition: epot_mgsolver.cpp:182
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
Three dimensional vector.
Definition: vec3d.hpp:58
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.