Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

UmfPackSolver.h 3.15 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.
       */
Thomas Witkowski's avatar
Thomas Witkowski committed
54 55
      OEMSolver* create() 
      { 
Thomas Witkowski's avatar
Thomas Witkowski committed
56
	return new UmfPackSolver(this->name); 
Thomas Witkowski's avatar
Thomas Witkowski committed
57
      }
58 59
    };

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

    /// 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);	
89
    }
90

91 92
    
  private:
93
    mtl::matrix::umfpack::solver<matrix_type> *solver;
Thomas Witkowski's avatar
Thomas Witkowski committed
94

95
    int                                       store_symbolic;
96 97 98 99 100 101 102
  };
  
}

#endif // HAVE_UMFPACK

#endif // AMDIS_UMFPACKSOLVER_H