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 #include <MumpsParallelSolver.h>
00031 #include <MumpsParallelSOE.h>
00032 #include <Channel.h>
00033 #include <FEM_ObjectBroker.h>
00034 #include <OPS_Globals.h>
00035
00036 #define ICNTL(I) icntl[(I)-1]
00037
00038 extern "C" {
00039 #include <mpi.h>
00040 }
00041
00042 MumpsParallelSolver::MumpsParallelSolver()
00043 :LinearSOESolver(SOLVER_TAGS_MumpsParallelSolver),
00044 theMumpsSOE(0)
00045 {
00046 init = false;
00047 }
00048
00049 MumpsParallelSolver::MumpsParallelSolver(int mpi_comm, int ICNTL7)
00050 :LinearSOESolver(SOLVER_TAGS_MumpsParallelSolver),
00051 theMumpsSOE(0)
00052 {
00053 init = false;
00054 }
00055
00056
00057 MumpsParallelSolver::~MumpsParallelSolver()
00058 {
00059 id.job=-2;
00060 dmumps_c(&id);
00061 }
00062
00063 int
00064 MumpsParallelSolver::solve(void)
00065 {
00066 int n = theMumpsSOE->size;
00067 int nnz = theMumpsSOE->nnz;
00068 int *rowA = theMumpsSOE->rowA;
00069 int *colA = theMumpsSOE->colA;
00070 double *A = theMumpsSOE->A;
00071 double *X = theMumpsSOE->X;
00072 double *B = theMumpsSOE->B;
00073
00074
00075 id.ICNTL(5)=0; id.ICNTL(18)=3;
00076
00077
00078 id.ICNTL(1)=-1; id.ICNTL(2)=-1; id.ICNTL(3)=-1; id.ICNTL(4)=0;
00079
00080
00081 for (int i=0; i<nnz; i++) {
00082 rowA[i]++;
00083 colA[i]++;
00084 }
00085
00086 if (rank == 0) {
00087 id.n = n;
00088 for (int i=0; i<n; i++) {
00089 X[i] = B[i];
00090 }
00091 id.rhs = X;
00092 }
00093
00094
00095 id.nz_loc = nnz;
00096 id.irn_loc = rowA;
00097 id.jcn_loc = colA;
00098 id.a_loc = A;
00099
00100 if (theMumpsSOE->factored == false) {
00101
00102
00103 id.job = 5;
00104 dmumps_c(&id);
00105 theMumpsSOE->factored = true;
00106
00107 } else {
00108
00109
00110 id.job = 3;
00111 dmumps_c(&id);
00112 }
00113
00114 int info = id.infog[0];
00115 if (info != 0) {
00116 opserr << "WARNING MumpsParallelSolver::solve(void)- ";
00117 opserr << " Error " << info << " returned in substitution dmumps()\n";
00118 return info;
00119 }
00120
00121
00122 for (int i=0; i<nnz; i++) {
00123 rowA[i]--;
00124 colA[i]--;
00125 }
00126
00127 return 0;
00128 }
00129
00130
00131 int
00132 MumpsParallelSolver::setSize()
00133 {
00134 if (init == false) {
00135 id.job=-1;
00136 id.par=1;
00137 id.sym=theMumpsSOE->matType;
00138
00139 id.comm_fortran=MPI_COMM_WORLD;
00140 dmumps_c(&id);
00141
00142 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
00143 MPI_Comm_size(MPI_COMM_WORLD, &np);
00144 init = true;
00145 }
00146
00147
00148 id.ICNTL(5)=0; id.ICNTL(18)=3;
00149
00150
00151 id.ICNTL(1)=-1; id.ICNTL(2)=-1; id.ICNTL(3)=-1; id.ICNTL(4)=0;
00152
00153 int nnz = theMumpsSOE->nnz;
00154 int *rowA = theMumpsSOE->rowA;
00155 int *colA = theMumpsSOE->colA;
00156
00157
00158 for (int i=0; i<nnz; i++) {
00159 rowA[i]++;
00160 colA[i]++;
00161 }
00162
00163
00164 id.n = theMumpsSOE->size;
00165 id.nz_loc = theMumpsSOE->nnz;
00166 id.irn_loc = theMumpsSOE->rowA;
00167 id.jcn_loc = theMumpsSOE->colA;
00168 id.a_loc = theMumpsSOE->A;
00169
00170
00171 id.job = 1;
00172 dmumps_c(&id);
00173
00174
00175 for (int i=0; i<nnz; i++) {
00176 rowA[i]--;
00177 colA[i]--;
00178 }
00179
00180 int info = id.infog[0];
00181 if (info != 0) {
00182 opserr << "WARNING MumpsParallelSolver::setSize(void)- ";
00183 opserr << " Error " << info << " returned in substitution dmumps()\n";
00184 return info;
00185 }
00186
00187 return info;
00188 }
00189
00190 int
00191 MumpsParallelSolver::sendSelf(int cTag, Channel &theChannel)
00192 {
00193
00194 return 0;
00195 }
00196
00197 int
00198 MumpsParallelSolver::recvSelf(int ctag,
00199 Channel &theChannel,
00200 FEM_ObjectBroker &theBroker)
00201 {
00202
00203 return 0;
00204 }
00205
00206 int
00207 MumpsParallelSolver::setLinearSOE(MumpsParallelSOE &theSOE)
00208 {
00209 theMumpsSOE = &theSOE;
00210 return 0;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224