Hermes2D  2.0
linear_solver.h
1 // This file is part of HermesCommon
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 __HERMES_COMMON_LINEAR_SOLVER_H_
23 #define __HERMES_COMMON_LINEAR_SOLVER_H_
24 
25 #include "discrete_problem_linear.h"
26 
27 namespace Hermes
28 {
29  namespace Hermes2D
30  {
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66  template <typename Scalar>
67  class LinearSolver : public Hermes::Mixins::Loggable, public Hermes::Mixins::TimeMeasurable, public Hermes::Mixins::SettableComputationTime, public Hermes::Hermes2D::Mixins::SettableSpaces<Scalar>, public Hermes::Mixins::OutputAttachable, public Hermes::Hermes2D::Mixins::MatrixRhsOutput<Scalar>, public Hermes::Hermes2D::Mixins::StateQueryable
68  {
69  public:
70  LinearSolver();
72  LinearSolver(const WeakForm<Scalar>* wf, const Space<Scalar>* space);
73  LinearSolver(const WeakForm<Scalar>* wf, Hermes::vector<const Space<Scalar>*> spaces);
74  void init();
75 
76  ~LinearSolver();
77 
79  virtual bool isOkay() const;
80  inline std::string getClassName() const { return "LinearSolver"; }
81 
83  virtual void solve();
84 
85  Scalar *get_sln_vector();
86 
88  virtual void set_time(double time);
89  virtual void set_time_step(double time_step);
90 
91  virtual void set_spaces(Hermes::vector<const Space<Scalar>*> spaces);
92  virtual void set_space(const Space<Scalar>* space);
93  virtual Hermes::vector<const Space<Scalar>*> get_spaces() const;
94 
96  void set_weak_formulation(const WeakForm<Scalar>* wf);
97 
99  SparseMatrix<Scalar>* get_jacobian();
100 
102  Vector<Scalar>* get_residual();
103  protected:
105 
107  Scalar* sln_vector;
108 
110  SparseMatrix<Scalar>* jacobian;
111 
113  Vector<Scalar>* residual;
114 
116  LinearMatrixSolver<Scalar>* matrix_solver;
117 
119  const bool own_dp;
120  };
121  }
122 }
123 #endif