00001 #include "pardiso.h"
00002 #include <stdio.h>
00003
00004
00005
00006
00007 extern "C" { int PARDISO (void *, int *, int *, int *, int *, int *,
00008 double *, int *, int *, int *, int *, int *,
00009 int *, double *, double *, int *);
00010 }
00011
00012
00013 pardiso::pardiso ()
00014 {
00015 nRows=0; nCols=0;
00016 nNonZeros=0;
00017 nrhs=1;
00018
00019 mtype=11;
00020
00021 }
00022
00023 pardiso::~pardiso ()
00024 {
00025
00026 }
00027
00028
00029
00030
00031 void pardiso::symbfact (double *a,long *ci,long*adr,long ndof)
00032 {
00033 long i;
00034
00035 nRows=ndof;
00036 nCols=ndof;
00037 nNonZeros=adr[ndof];
00038
00039 for (i = 0; i < 64; i++) {
00040 iparm[i] = 0;
00041 }
00042
00043 iparm[0] = 1;
00044 iparm[1] = 2;
00045
00046
00047 iparm[2] = 1;
00048 iparm[3] = 0;
00049 iparm[4] = 0;
00050 iparm[5] = 0;
00051 iparm[6] = 16;
00052 iparm[7] = 2;
00053 iparm[8] = 0;
00054 iparm[9] = 13;
00055 iparm[10] = 1;
00056 iparm[11] = 0;
00057 iparm[12] = 0;
00058 iparm[13] = 0;
00059 iparm[14] = 0;
00060 iparm[15] = 0;
00061 iparm[16] = 0;
00062 iparm[17] = -1;
00063 iparm[18] = -1;
00064 iparm[19] = 0;
00065 maxfct = 1;
00066 mnum = 1;
00067 msglvl = 0;
00068 error = 0;
00069
00070
00071
00072
00073 for (i = 0; i < 64; i++) {
00074 pt[i] = 0;
00075 }
00076
00077
00078
00079
00080
00081 phase = 11;
00082 iparm[3] = 31;
00083
00084
00085
00086
00087
00088 PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
00089 (int *)&ndof, a, (int *)adr, (int *)ci, &idum, &nrhs,
00090 iparm, &msglvl, &ddum, &ddum, &error);
00091
00092
00093 if (error != 0) {
00094 fprintf(stderr,"\nERROR during symbolic factorization: %d\n.", error);
00095
00096 }
00097
00098 fprintf(stdout,"\nReordering completed ... ");
00099 fprintf(stdout,"\nPeak memory in KB = %d", iparm[14]);
00100 fprintf(stdout,"\nPermament memory in KB = %d", iparm[15]);
00101 fprintf(stdout,"\nMemory for solve in KB = %d", iparm[16]);
00102 fprintf(stdout,"\nNumber of nonzeros in factors = %d", iparm[17]);
00103 fprintf(stdout,"\nNumber of factorization MFLOPS = %d", iparm[18]);
00104
00105 fflush(stdout);
00106 }
00107
00108
00109
00110
00111 void pardiso::numfact (double *a,long *ci,long*adr,long ndof)
00112 {
00113 phase = 22;
00114
00115 PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
00116 (int *)&ndof, a, (int *)adr, (int *)ci, &idum, &nrhs,
00117 iparm, &msglvl, &ddum, &ddum, &error);
00118
00119 if (error != 0) {
00120 printf("\nERROR during numerical factorization: %d", error);
00121
00122 printf("\nFactorization completed ... ");
00123 fflush(stdout);
00124 }
00125
00126 }
00127
00128
00129
00130
00131 void pardiso::backsubst (double *a,long *ci,long*adr,long ndof,double *x,double *y)
00132 {
00133 phase = 33;
00134 iparm[7] = 2;
00135
00136 PARDISO (pt, &maxfct, &mnum, &mtype, &phase,
00137 (int *)&ndof, a, (int *)adr, (int *)ci, &idum, &nrhs,
00138 iparm, &msglvl, x, y, &error);
00139
00140
00141 if (error != 0) {
00142 printf("\nERROR during solution: %d", error);
00143
00144 }
00145 printf("\nSolve completed ... ");
00146 printf("\nThe solution of the system is: ");
00147 fflush(stdout);
00148
00149 }
00150