00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <UmfpackGenLinSOE.h>
00039 #include <UmfpackGenLinSolver.h>
00040 #include <f2c.h>
00041 #include <math.h>
00042 #include <Channel.h>
00043 #include <FEM_ObjectBroker.h>
00044
00045 #ifdef _WIN32
00046 extern "C" int UMD21I(int *keep, double *cntl, int *icntl);
00047 #else
00048 extern "C" int umd21i_(int *keep, double *cntl, int *icntl);
00049 #endif
00050
00051
00052 UmfpackGenLinSolver::
00053 UmfpackGenLinSolver()
00054 :LinearSOESolver(SOLVER_TAGS_UmfpackGenLinSolver),
00055 copyIndex(0), lIndex(0), work(0), theSOE(0)
00056 {
00057
00058 #ifdef _WIN32
00059 UMD21I(keep, cntl, icntl);
00060 #else
00061 umd21i_(keep, cntl, icntl);
00062 #endif
00063 }
00064
00065
00066 UmfpackGenLinSolver::~UmfpackGenLinSolver()
00067 {
00068 if (copyIndex != 0)
00069 delete [] copyIndex;
00070
00071 if (work != 0)
00072 delete [] work;
00073 }
00074
00075 #ifdef _WIN32
00076 extern "C" int UMD2FA(int *n, int *ne, int *job, logical *transa,
00077 int *lvalue, int *lindex, double *value,
00078 int *index, int *keep, double *cntl, int *icntl,
00079 int *info, double *rinfo);
00080
00081
00082
00083
00084
00085
00086
00087 extern "C" int UMD2SO(int *n, int *job, logical *transa,
00088 int *lvalue, int *lindex, double *value,
00089 int *index, int *keep, double *b, double *x,
00090 double *w, double *cntl, int *icntl,
00091 int *info, double *rinfo);
00092 #else
00093 extern "C" int umd2fa_(int *n, int *ne, int *job, logical *transa,
00094 int *lvalue, int *lindex, double *value,
00095 int *index, int *keep, double *cntl, int *icntl,
00096 int *info, double *rinfo);
00097
00098 extern "C" int umd2so_(int *n, int *job, logical *transa,
00099 int *lvalue, int *lindex, double *value,
00100 int *index, int *keep, double *b, double *x,
00101 double *w, double *cntl, int *icntl,
00102 int *info, double *rinfo);
00103 #endif
00104
00105 int
00106 UmfpackGenLinSolver::solve(void)
00107 {
00108 if (theSOE == 0) {
00109 opserr << "WARNING UmfpackGenLinSolver::solve(void)- ";
00110 opserr << " No LinearSOE object has been set\n";
00111 return -1;
00112 }
00113
00114 int n = theSOE->size;
00115 int ne = theSOE->nnz;
00116 int lValue = theSOE->lValue;
00117
00118
00119 if (n == 0)
00120 return 0;
00121
00122
00123 double *Xptr = theSOE->X;
00124 double *Bptr = theSOE->B;
00125 double *Aptr = theSOE->A;
00126
00127 int job =0;
00128 logical trans = FALSE_;
00129
00130 if (theSOE->factored == false) {
00131
00132
00133 for (int i=0; i<2*ne; i++) {
00134 copyIndex[i] = theSOE->index[i];
00135 }
00136
00137
00138 #ifdef _WIN32
00139 UMD2FA(&n, &ne, &job, &trans, &lValue, &lIndex, Aptr,
00140 copyIndex, keep, cntl, icntl, info, rinfo);
00141 #else
00142 umd2fa_(&n, &ne, &job, &trans, &lValue, &lIndex, Aptr,
00143 copyIndex, keep, cntl, icntl, info, rinfo);
00144 #endif
00145
00146 if (info[0] != 0) {
00147 opserr << "WARNING UmfpackGenLinSolver::solve(void)- ";
00148 opserr << info[0] << " returned in factorization UMD2FA()\n";
00149 return -info[0];
00150 }
00151 theSOE->factored = true;
00152 }
00153
00154
00155 #ifdef _WIN32
00156 UMD2SO(&n, &job, &trans, &lValue, &lIndex, Aptr, copyIndex,
00157 keep, Bptr, Xptr, work, cntl, icntl, info, rinfo);
00158 #else
00159 umd2so_(&n, &job, &trans, &lValue, &lIndex, Aptr, copyIndex,
00160 keep, Bptr, Xptr, work, cntl, icntl, info, rinfo);
00161 #endif
00162
00163 if (info[0] != 0) {
00164 opserr << "WARNING UmfpackGenLinSolver::solve(void)- ";
00165 opserr << info[0] << " returned in substitution dgstrs()\n";
00166 return -info[0];
00167 }
00168
00169 return 0;
00170 }
00171
00172
00173 int
00174 UmfpackGenLinSolver::setSize()
00175 {
00176 int n = theSOE->size;
00177 int ne = theSOE->nnz;
00178 if (n > 0) {
00179 if (work != 0)
00180 delete [] work;
00181
00182 work = new double[4*n];
00183
00184 lIndex = 37*n + 4*ne + 10;
00185 if (copyIndex != 0)
00186 delete [] copyIndex;
00187
00188 copyIndex = new int[lIndex];
00189 }
00190 return 0;
00191 }
00192
00193 int
00194 UmfpackGenLinSolver::setLinearSOE(UmfpackGenLinSOE &theLinearSOE)
00195 {
00196 theSOE = &theLinearSOE;
00197 return 0;
00198 }
00199
00200 int
00201 UmfpackGenLinSolver::sendSelf(int cTag, Channel &theChannel)
00202 {
00203
00204 return 0;
00205 }
00206
00207 int
00208 UmfpackGenLinSolver::recvSelf(int ctag,
00209 Channel &theChannel,
00210 FEM_ObjectBroker &theBroker)
00211 {
00212
00213 return 0;
00214 }
00215