Newton.h 3.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file Newton.h */

#ifndef AMDIS_NEWTON_H
#define AMDIS_NEWTON_H

#include "MemoryManager.h"
#include "CreatorInterface.h"
#include "NonLinSolver.h"

namespace AMDiS {

  class FiniteElemSpace;

  template<typename VectorType> class OEMSolver;
 
  // ============================================================================
  // ===== class Newton =========================================================
  // ============================================================================

  /**
   * \ingroup Solver
   * 
   * \brief
   * Implements the newton method for solving a non linear system. Sub class of
   * NonLinSolver.
   */
  template<typename VectorType>
  class Newton : public NonLinSolver<VectorType>
  {
  public:
    MEMORY_MANAGED(Newton<VectorType>);

    /** \brief
     * Creator class used in the NonLinSolverMap.
     */
    class Creator : public NonLinSolverCreator<VectorType> 
    {
    public:
      MEMORY_MANAGED(Creator);

      virtual ~Creator() {};

      /** \brief
       * Returns a new Newton object.
       */
      NonLinSolver<VectorType>* create() { 
	return NEW Newton(this->name, this->linearSolver, this->nonLinUpdater); 
      };
    };

    /** \brief
     * Calls constructor of base class NonLinSolver
     */
    Newton(const ::std::string& name_, 
	   OEMSolver<VectorType> *linSolver_,
	   NonLinUpdater<VectorType> *updater)
      : NonLinSolver<VectorType>(name_, linSolver_, updater)
    {};

  private:
    /** \brief
     * realisation of NonLinSolver::init
     */
    void init();

    /** \brief
     * realisation of NonLinSolver::nlsolve
     */
    int  nlsolve(MatVecMultiplier<VectorType> *matVec,
		 VectorType *x, VectorType *rhs,
		 Preconditioner<VectorType> *lPrecon = NULL,
		 Preconditioner<VectorType> *rPrecon = NULL);

    /** \brief
     * realisation of NonLinSolver::exit
     */
    void exit();

  private:
    /** \brief
     * internal used data
     */
    VectorType *b;
  };

}

#include "Newton.hh"

#endif // AMDIS_NEWTON_H