Hermes2D  2.0
picard_solver.h
1 // This file is part of Hermes2D
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __H2D_SOLVER_PICARD_H_
23 #define __H2D_SOLVER_PICARD_H_
24 
25 #include "global.h"
26 #include "projections/ogprojection.h"
27 #include "discrete_problem.h"
28 #include "views/scalar_view.h"
29 
30 namespace Hermes
31 {
32  namespace Hermes2D
33  {
73  template<typename Scalar>
74  class HERMES_API PicardSolver : public NonlinearSolver<Scalar>, public Hermes::Hermes2D::Mixins::SettableSpaces<Scalar>, public Hermes::Mixins::OutputAttachable, public Hermes::Hermes2D::Mixins::MatrixRhsOutput<Scalar>, public Hermes::Hermes2D::Mixins::StateQueryable
75  {
76  public:
77  PicardSolver();
79  PicardSolver(const WeakForm<Scalar>* wf, const Space<Scalar>* space);
80  PicardSolver(const WeakForm<Scalar>* wf, Hermes::vector<const Space<Scalar>*> spaces);
81  ~PicardSolver();
82 
84  virtual bool isOkay() const;
85  inline std::string getClassName() const { return "PicardSolver"; }
86 
88  void set_verbose_output_linear_solver(bool verbose_output_to_set);
89 
92  void solve(Scalar* coeff_vec = NULL);
93 
96  void solve(Solution<Scalar>* initial_guess);
97 
100  void solve(Hermes::vector<Solution<Scalar>*> initial_guess);
101 
103  virtual void set_time(double time);
104  virtual void set_time_step(double time_step);
105 
107  virtual void set_spaces(Hermes::vector<const Space<Scalar>*> spaces);
108  virtual void set_space(const Space<Scalar>* space);
109  virtual Hermes::vector<const Space<Scalar>*> get_spaces() const;
110 
112  void use_Anderson_acceleration(bool to_set);
113 
115  void set_picard_tol(double tol);
117  void set_picard_max_iter(int max_iter);
120  void set_num_last_vector_used(int num);
123  void set_anderson_beta(double beta);
124 
126  void set_weak_formulation(const WeakForm<Scalar>* wf);
127  private:
128  void init();
129  bool verbose_output_linear_solver;
130 
132  SparseMatrix<Scalar>* matrix;
133 
135  Vector<Scalar>* rhs;
136 
138  LinearMatrixSolver<Scalar>* linear_solver;
139 
141  const bool own_dp;
142 
143  double tol;
144  int max_iter;
145  int num_last_vectors_used;
146  bool anderson_is_on;
147  double anderson_beta;
148  };
149  }
150 }
151 #endif