HermesCommon  2.0
nonlinear_solver.cpp
Go to the documentation of this file.
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 #include "nonlinear_solver.h"
23 #include "api.h"
24 
25 using namespace Hermes::Algebra;
26 
27 namespace Hermes
28 {
29  namespace Solvers
30  {
31  template<typename Scalar>
32  NonlinearSolver<Scalar>::NonlinearSolver(DiscreteProblemInterface<Scalar>* dp) : Hermes::Mixins::Loggable(true, NULL), dp(dp), sln_vector(NULL)
33  {
34  }
35 
36  template<typename Scalar>
37  NonlinearSolver<Scalar>::~NonlinearSolver()
38  {
39  if(sln_vector != NULL)
40  delete [] sln_vector;
41  }
42 
43  template<typename Scalar>
44  void NonlinearSolver<Scalar>::solve(Scalar* coeff_vec)
45  {
46  throw Hermes::Exceptions::MethodNotOverridenException("NonlinearSolver<Scalar>::solve");
47  return;
48  }
49 
50  template<typename Scalar>
52  {
53  return sln_vector;
54  }
55 
56  template<typename Scalar>
57  void NonlinearSolver<Scalar>::set_iterative_method(const char* iterative_method_name)
58  {
59  if(Hermes::HermesCommonApi.get_integral_param_value(Hermes::matrixSolverType) != SOLVER_AZTECOO)
60  {
61  this->warn("Trying to set iterative method for a different solver than AztecOO.");
62  return;
63  }
64  else
65  {
66  this->iterative_method = (char*)iterative_method_name;
67  }
68  }
69 
70  template<typename Scalar>
71  void NonlinearSolver<Scalar>::set_preconditioner(const char* preconditioner_name)
72  {
73  if(Hermes::HermesCommonApi.get_integral_param_value(Hermes::matrixSolverType) != SOLVER_AZTECOO)
74  {
75  this->warn("Trying to set iterative method for a different solver than AztecOO.");
76  return;
77  }
78  else
79  {
80  this->preconditioner = (char*)preconditioner_name;
81  }
82  }
83 
84  template class HERMES_API NonlinearSolver<double>;
85  template class HERMES_API NonlinearSolver<std::complex<double> >;
86  }
87 }