Am Montag, 13. Mai 2022, finden Wartungsarbeiten am Gitlab-Server (Update auf neue Version statt). Der Dienst wird daher am Montag für einige Zeit nicht verfügbar sein.
On Monday, May 13th 2022, the Gitlab server will be updated. The service will therefore not be accessible for some time on Monday.

UmfPackSolver.h 3.12 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file UmfPackSolver.h */

#ifndef AMDIS_UMFPACKSOLVER_H
#define AMDIS_UMFPACKSOLVER_H

25
#if defined HAVE_UMFPACK && defined MTL_HAS_UMFPACK
26

27
#include <boost/numeric/mtl/interface/umfpack_solve.hpp>
Thomas Witkowski's avatar
Thomas Witkowski committed
28
#include "OEMSolver.h"
29

30
31
32
33
34
35
36
37
38
39
40
namespace AMDiS {

  /**
   * \ingroup Solver
   * 
   * \brief
   * Wrapper for the external UMFPACK solver:
   *   http://www.cise.ufl.edu/research/sparse/umfpack/
   *
   * This is a direct solver for large sparse matrices.
   */
41
42

  class UmfPackSolver : public OEMSolver
43
44
  {
  public:
45
46
    /// Creator class used in the OEMSolverMap.
    class Creator : public OEMSolverCreator
47
48
    {
    public:
Thomas Witkowski's avatar
Thomas Witkowski committed
49
      virtual ~Creator() {}
50
51
52
53
      
      /** \brief
       * Returns a new UmfPackSolver object.
       */
54
55
      OEMSolver* create() { 
	return NEW UmfPackSolver(this->name); 
Thomas Witkowski's avatar
Thomas Witkowski committed
56
      }
57
58
    };

59
60
61
    /// Constructor
    UmfPackSolver(::std::string name) 
      : OEMSolver(name), 
Thomas Witkowski's avatar
Thomas Witkowski committed
62
63
	solver(0),
	store_symbolic(0)
64
65
66
    {
	GET_PARAMETER(0, name + "->store symbolic", "%d", &store_symbolic);
	// GET_PARAMETER(0, name + "->multiple rhs", "%d", &multipleRhs);
67
    }
68
    
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    /// Destructor
    ~UmfPackSolver() { if (solver) delete solver;}

    /// Solves the system directly
    int solveSystem(const DOFMatrix::base_matrix_type&      A,
		    mtl::dense_vector<value_type>&          x,
		    const mtl::dense_vector<value_type>&    b)
    {
	if (!solver)
	    solver= new mtl::matrix::umfpack::solver<matrix_type>(A);
	else if (store_symbolic)
	    solver->update_numeric();
	else
	    solver->update();
	return (*solver)(x, b);	
84
    }
85

86
87
    
  private:
88
    mtl::matrix::umfpack::solver<matrix_type> *solver;
Thomas Witkowski's avatar
Thomas Witkowski committed
89

90
    int                                       store_symbolic;
91
92
93
94
95
96
97
  };
  
}

#endif // HAVE_UMFPACK

#endif // AMDIS_UMFPACKSOLVER_H