1 //#**************************************************************
2 //#
3 //# filename:             pardiso.h
4 //#
5 //# author:               Astrid Pechstein
6 //#
7 //# generated:
8 //# description:
9 //# remarks:
10 //#
11 //# Copyright (c) 2003-2013 Johannes Gerstmayr, Linz Center of Mechatronics GmbH, Austrian
12 //# Center of Competence in Mechatronics GmbH, Institute of Technical Mechanics at the
13 //# Johannes Kepler Universitaet Linz, Austria. All rights reserved.
14 //#
15 //# This file is part of HotInt.
16 //# HotInt is free software: you can redistribute it and/or modify it under the terms of
17 //# the HOTINT license. See folder 'licenses' for more details.
18 //#
19 //# bug reports are welcome!!!
20 //# WWW:		www.hotint.org
21 //# email:	bug_reports@hotint.org or support@hotint.org
22 //#**************************************************************
23 
24 #ifndef PARDISO_INCLUDES_H
25 #define PARIDSO_INCLUDES_H
26 
27 #include "mkl_includes.h"
28 
29 class PardisoInverse
30 {
31 public:
PardisoInverse()32 	PardisoInverse() : sparseA(0), size(0), mtype(11), solver(0), error(0), perm(0), isFirstStep(1), isFactorized(0)
33 	{
34 	}
35 
PardisoInverse(const SparseMatrix & matA)36 	PardisoInverse:: PardisoInverse(const SparseMatrix & matA) : sparseA(&matA), size(0), mtype(11), solver(0), error(0), perm(0), isFirstStep(1), isFactorized(0)
37 	{
38 		sparseA =&matA;
39 		size = matA.Getcols();
40 		SetDefaultIParm();
41 
42 		perm = new _INTEGER_t[size];
43 	}
44 
45 
46 	~PardisoInverse();
47 
48 	void SetDefaultIParm();
49 
SetSparseMatrix(const SparseMatrix & matA)50 	void SetSparseMatrix(const SparseMatrix& matA)
51 	{
52 		sparseA =&matA;
53 		size = matA.Getcols();
54 
55 		SetDefaultIParm();
56 		delete [] perm;
57 
58 		perm = new _INTEGER_t[size];
59 	}
60 
61 	int Solve(Vector& q);
62 	int Factorize();
63 	int Apply(Vector& q);
64 
IsFirstStep()65 	int& IsFirstStep() {return isFirstStep; }
IsFirstStep()66 	const int& IsFirstStep() const {return isFirstStep; }
67 
68 
69 private:
70 	// pointer to original sparsematrix
71 	const SparseMatrix* sparseA;
72 
73 	// size, has to be quadratic
74 	_INTEGER_t size;
75 	// Pardiso-Data
76 	_MKL_DSS_HANDLE_t pt[64];
77 
78 	_INTEGER_t mtype;
79 	int solver;
80 	_INTEGER_t iparm[64];
81 
82 	double dparm[64];
83 
84 	_INTEGER_t error;
85 
86 	_INTEGER_t* perm;
87 
88 	int isFirstStep;
89 	int isFactorized;
90 
91 };
92 
93 
94 #endif