13 #include "mkl_pardiso.h" 22 TPZPardisoControl<TVar>::TPZPardisoControl() : fSystemType(ENonSymmetric),
23 fStructure(EStructureSymmetric), fProperty(EIndefinite), fPardisoControl(), fHandle(0),
24 fParam(64,0), fMax_num_factors(1), fMatrix_num(1), fMessageLevel(0), fError(0), fPermutation(), fMatrixType(0),
25 fNonSymmetricSystem(0), fSymmetricSystem(0)
28 fHandle = &fPardisoControl.operator->()->operator[](0);
34 TPZPardisoControl<TVar>::TPZPardisoControl(MSystemType systemtype, MProperty prop) : fSystemType(systemtype),
35 fStructure(EStructureSymmetric), fProperty(prop), fPardisoControl(), fHandle(0),
36 fParam(64,0), fMax_num_factors(1), fMatrix_num(1), fMessageLevel(0), fError(0), fPermutation(), fMatrixType(0),
37 fNonSymmetricSystem(0), fSymmetricSystem(0)
41 fHandle = &fPardisoControl.operator->()->operator[](0);
48 void TPZPardisoControl<TVar>::SetMatrixType(MSystemType systemtype, MProperty prop)
50 fSystemType = systemtype;
52 fMatrixType = MatrixType();
60 TPZPardisoControl<TVar>::TPZPardisoControl(
const TPZPardisoControl<TVar> ©) : fSystemType(copy.fSystemType),
61 fStructure(copy.fStructure), fProperty(copy.fProperty), fPardisoControl(copy.fPardisoControl), fHandle(copy.fHandle),
62 fParam(copy.fParam), fMax_num_factors(copy.fMax_num_factors), fMatrix_num(copy.fMatrix_num), fMessageLevel(copy.fMessageLevel),
63 fError(copy.fError), fPermutation(copy.fPermutation), fMatrixType(copy.fMatrixType),
64 fSymmetricSystem(copy.fSymmetricSystem), fNonSymmetricSystem(copy.fNonSymmetricSystem)
70 TPZPardisoControl<TVar> &TPZPardisoControl<TVar>::operator=(
const TPZPardisoControl ©)
72 fSystemType = copy.fSystemType;
73 fStructure = copy.fStructure;
74 fProperty = copy.fProperty;
75 fPardisoControl = copy.fPardisoControl;
76 fHandle = copy.fHandle;
78 fMax_num_factors = copy.fMax_num_factors;
79 fMatrix_num = copy.fMatrix_num;
80 fMessageLevel = copy.fMessageLevel;
82 fPermutation = copy.fPermutation;
83 fMatrixType = copy.fMatrixType;
84 fSymmetricSystem = copy.fSymmetricSystem;
85 fNonSymmetricSystem = copy.fNonSymmetricSystem;
105 int DataType(
double a)
111 int DataType(
float a)
118 long long TPZPardisoControl<TVar>::MatrixType()
121 if (fStructure == EStructureNonSymmetric) {
124 if (fSystemType == ESymmetric && fProperty == EIndefinite) {
125 if(fMatrixType != 0 && fMatrixType != -2)
129 else if(fMatrixType == -2)
135 if (fSystemType == ESymmetric && fProperty == EPositiveDefinite) {
136 if(fMatrixType != 0 && fMatrixType != 2)
140 else if(fMatrixType == 2)
146 if (fSystemType == ENonSymmetric && fStructure == EStructureSymmetric) {
149 if (fSystemType == ENonSymmetric && fProperty == EPositiveDefinite) {
161 int matrixtype = fMatrixType;
162 pardisoinit(fHandle,&matrixtype,param);
163 for (
int i=0; i<64; i++) {
164 fParam[i] = param[i];
173 void TPZPardisoControl<TVar>::Decompose()
176 TVar bval = 0., xval = 0.;
177 TVar *a,*b = &bval, *x = &xval;
179 if (fSymmetricSystem) {
180 if (fSymmetricSystem->Rows()==0) {
183 a = &(fSymmetricSystem->fA[0]);
184 ia = (
long long *) &(fSymmetricSystem->fIA[0]);
185 ja = (
long long *) &(fSymmetricSystem->fJA[0]);
186 n = fSymmetricSystem->Rows();
188 if (fNonSymmetricSystem) {
189 a = &(fNonSymmetricSystem->fA[0]);
190 ia = (
long long *) &(fNonSymmetricSystem->fIA[0]);
191 ja = (
long long *) &(fNonSymmetricSystem->fJA[0]);
192 n = fNonSymmetricSystem->Rows();
196 long long *perm = 0,nrhs = 0;
199 fPermutation.resize(n);
200 perm = &fPermutation[0];
205 long long phase = 12;
206 fPermutation.resize(n);
207 for (
long long i=0; i<n; i++) {
210 perm = &fPermutation[0];
214 if (fProperty == EIndefinite) {
216 if(fSystemType == ESymmetric){
225 if(fSystemType == ESymmetric){
234 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, ia, ja, perm,
235 &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
237 Error_check(
int(Error));
238 std::cout << __PRETTY_FUNCTION__ <<
" error code " << Error << std::endl;
242 std::cout <<
"Pardiso:: decomposition complete. \n";
253 if (fSymmetricSystem) {
254 if(fSymmetricSystem->Rows() == 0)
258 a = &(fSymmetricSystem->fA[0]);
259 ia = (
long long *) &(fSymmetricSystem->fIA[0]);
260 ja = (
long long *) &(fSymmetricSystem->fJA[0]);
261 n = fSymmetricSystem->Rows();
263 if (fNonSymmetricSystem) {
264 a = &(fNonSymmetricSystem->fA[0]);
265 ia = (
long long *) &(fNonSymmetricSystem->fIA[0]);
266 ja = (
long long *) &(fNonSymmetricSystem->fJA[0]);
267 n = fNonSymmetricSystem->Rows();
270 long long *perm,nrhs;
276 perm = &fPermutation[0];
278 long long phase = 33;
280 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, ia, ja, perm,
281 &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
284 std::cout <<
"Pardiso:: Number of iterations " << fParam[19] <<
" > 150, calling numerical factorization... " << std::endl;
286 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, ia, ja, perm,
287 &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
290 int rest =
abs(fParam[19]%10);
294 std::cout <<
"Pardiso:: fluctuations of the residuum are too large. " << std::endl;
299 std::cout <<
"Pardiso:: Slow convergence - Main matrix and matrix for preconditioner differ a lot. " << std::endl;
304 std::cout <<
"Pardiso:: perturbed pivots caused iterative refinement. " << std::endl;
309 std::cout <<
"Pardiso:: factorization is too fast for this matrix. It is better to use the factorization method with iparm[3] = 0 " << std::endl;
314 std::cout <<
"Pardiso:: There is not a diagnostig. " << std::endl;
325 Error_check(
int(Error));
326 std::cout <<
"Pardiso:: Calling a numerical factorization. \n";
328 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, ia, ja, perm,
329 &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
333 Error_check(
int(Error));
338 std::cout <<
"Pardiso:: linear solve complete. \n";
341 #ifdef Release_Memory_Q 343 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, ia, ja, perm, &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
344 if (fSymmetricSystem) {
345 fSymmetricSystem->SetIsDecomposed(0);
347 if (fNonSymmetricSystem) {
348 fNonSymmetricSystem->SetIsDecomposed(0);
351 std::cout <<
"Pardiso:: release memory complete. \n";
357 TPZPardisoControl<TVar>::~TPZPardisoControl()
359 long long phase = -1;
362 void *a= &
av,*b = &bv, *x = &xv;
363 long long ia,ja,perm,nrhs = 1;
366 pardiso_64 (fHandle, &fMax_num_factors, &fMatrix_num, &fMatrixType, &phase, &n, a, &ia, &ja, &perm,
367 &nrhs, &fParam[0], &fMessageLevel, b, x, &Error);
376 void TPZPardisoControl<TVar>::Error_check(
int error)
const {
380 std::cout <<
"Pardiso:: Input inconsistent." << std::endl;
383 std::cout <<
"Pardiso:: Not enough memory." << std::endl;
386 std::cout <<
"Pardiso:: Reordering problem." << std::endl;
389 std::cout <<
"Pardiso:: Zero pivot, numerical fact. or iterative refinement problem. " << std::endl;
392 std::cout <<
"Pardiso:: Unclassified (internal) error. " << std::endl;
395 std::cout <<
"Pardiso:: Preordering failed (matrix types 11, 13 only). " << std::endl;
398 std::cout <<
"Pardiso:: Diagonal matrix problem. " << std::endl;
401 std::cout <<
"Pardiso:: 32-bit integer overflow problem. " << std::endl;
404 std::cout <<
"Pardiso:: There is not a explanation. " << std::endl;
411 template class TPZPardisoControl<double>;
412 template class TPZPardisoControl<long double>;
413 template class TPZPardisoControl<float>;
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Implements a vector class which allows to use external storage provided by the user. Utility.
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
#define DebugStop()
Returns a message to user put a breakpoint in.
int64_t Rows() const
Returns number of rows.
Contains the TPZFYsmpMatrix class which implements a non symmetric sparse matrix. ...
Full matrix class. Matrix.
int64_t Cols() const
Returns number of cols.
Contains TPZSYsmpMatrix class which implements a symmetric sparse matrix. Purpose: Defines operation...