9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
12 #include "../../shared/Numerics/types.h"
13 #include "../../shared/MemOps/MemOps.h"
14 #include "../../shared/Exceptions/exceptions.h"
15 #include "../../shared/io/Comm/IssmComm.h"
16 #include "../../classes/Params/GenericParam.h"
17 #include "../../classes/Params/Parameters.h"
18 #include "../mpi/issmmpi.h"
19 #include "../adolc/adolcincludes.h"
26 theMumpsStruc.par = 1;
27 theMumpsStruc.sym = 0;
29 theMumpsStruc.job = -1;
30 dmumps_c(&theMumpsStruc);
36 theMumpsStruc.icntl[1-1] = 6;
37 theMumpsStruc.icntl[2-1] = 0;
38 theMumpsStruc.icntl[3-1] = 0;
39 theMumpsStruc.icntl[4-1] = 0;
40 theMumpsStruc.icntl[5-1] = 0;
41 theMumpsStruc.icntl[18-1] = 3;
43 theMumpsStruc.icntl[20-1] = 0;
44 theMumpsStruc.icntl[21-1] = 0;
45 theMumpsStruc.icntl[30-1] = 0;
51 theMumpsStruc.job = 1;
52 dmumps_c(&theMumpsStruc);
57 theMumpsStruc.job = 2;
58 dmumps_c(&theMumpsStruc);
63 theMumpsStruc.job = 3;
64 dmumps_c(&theMumpsStruc);
69 theMumpsStruc.job = -2;
70 dmumps_c(&theMumpsStruc);
75 DMUMPS_STRUC_C theMumpsStruc;
82 theMumpsStruc.nz_loc=local_nnz;
83 theMumpsStruc.irn_loc=irn_loc;
84 theMumpsStruc.jcn_loc=jcn_loc;
85 theMumpsStruc.a_loc=a_loc;
86 theMumpsStruc.rhs=rhs;
109 void MpiDenseMumpsSolve(
IssmDouble* uf,
int uf_M,
int uf_m,
IssmDouble* Kff,
int Kff_M,
int Kff_N,
int Kff_m,
IssmDouble* pf,
int pf_M,
int pf_m,
Parameters* parameters){
123 int *recvcounts = NULL;
131 if (Kff_M!=Kff_N)
_error_(
"stiffness matrix Kff should be square");
132 if (uf_M!=Kff_M || uf_M!=pf_M)
_error_(
"solution vector should be the same size as stiffness matrix Kff and load vector pf");
133 if (uf_m!=Kff_m || uf_m!=pf_m)
_error_(
"solution vector should be locally the same size as stiffness matrix Kff and load vector pf");
138 for(i=0;i<Kff_m;i++){
139 for(j=0;j<Kff_N;j++){
140 if (Kff[i*Kff_N+j]!=0)local_nnz++;
149 irn_loc=xNew<int>(local_nnz);
150 jcn_loc=xNew<int>(local_nnz);
151 a_loc=xNew<IssmDouble>(local_nnz);
157 for(i=0;i<Kff_m;i++){
158 for(j=0;j<Kff_N;j++){
159 if (Kff[i*Kff_N+j]!=0){
160 irn_loc[count]=lower_row+i+1;
162 a_loc[count]=Kff[i*Kff_N+j];
168 rhs=xNew<IssmDouble>(pf_M);
170 recvcounts=xNew<int>(num_procs);
171 displs=xNew<int>(num_procs);
182 MumpsSolve(Kff_M,nnz,local_nnz,irn_loc,jcn_loc,a_loc,rhs,parameters);
188 xDelete<int>(irn_loc);
189 xDelete<int>(jcn_loc);
190 xDelete<IssmDouble>(a_loc);
191 xDelete<IssmDouble>(rhs);
192 xDelete<int>(recvcounts);
193 xDelete<int>(displs);
202 int local_nnz=iArr[2];
203 int *local_irn=xNew<int>(local_nnz);
204 int *local_jcn=xNew<int>(local_nnz);
206 for (
int i=0;i<local_nnz;++i) {
207 local_irn[i]=iArr[3+i];
208 local_jcn[i]=iArr[3+local_nnz+i];
212 for (
int i=0;i<n;++i) {
213 rhs_sol[i]=dp_x[local_nnz+i];
215 MumpsSolve(n,nnz,local_nnz,local_irn,local_jcn,A,rhs_sol);
216 for (
int i=0;i<n;++i) {
227 int packedDimsSparseArrLength=1+1+1+local_nnz+local_nnz;
228 int *packedDimsSparseArr=xNew<int>(packedDimsSparseArrLength);
229 packedDimsSparseArr[0]=n;
230 packedDimsSparseArr[1]=nnz;
231 packedDimsSparseArr[2]=local_nnz;
232 for (
int i=0;i<local_nnz;++i) {
233 packedDimsSparseArr[3+i]=irn_loc[i];
234 packedDimsSparseArr[3+local_nnz+i]=jcn_loc[i];
236 IssmDouble *pack_A_rhs=xNew<IssmDouble>(local_nnz+n);
237 for (
int i=0;i<local_nnz;++i) {
238 pack_A_rhs[i]=a_loc[i];
240 for (
int i=0;i<n;++i) {
241 pack_A_rhs[local_nnz+i]=rhs[i];
243 IssmPDouble *passivePack_A_rhs=xNew<IssmPDouble>(local_nnz+n);
247 packedDimsSparseArrLength, packedDimsSparseArr,
248 local_nnz+n, passivePack_A_rhs, pack_A_rhs,
250 for (
int i=0;i<n;++i) {
260 int fos_reverse_mumpsSolveEDF(
int iArrLength,
int* iArr,
267 int local_nnz=iArr[2];
268 int *local_irn=xNew<int>(local_nnz);
269 int *local_jcn=xNew<int>(local_nnz);
271 for (
int i=0;i<local_nnz;++i) {
272 local_irn[i]=iArr[3+i];
273 local_jcn[i]=iArr[3+local_nnz+i];
277 for (
int i=0;i<n;++i) {
280 DMUMPS_STRUC_C theMumpsStruc;
284 theMumpsStruc.nz=nnz;
285 theMumpsStruc.nz_loc=local_nnz;
286 theMumpsStruc.irn_loc=local_irn;
287 theMumpsStruc.jcn_loc=local_jcn;
288 theMumpsStruc.a_loc=a_loc;
289 theMumpsStruc.rhs=rhs_sol;
290 theMumpsStruc.nrhs=1;
291 theMumpsStruc.lrhs=1;
292 theMumpsStruc.icntl[9-1] = 0;
298 for (
int i=0;i<n;++i) {
299 dp_Z[local_nnz+i]+=rhs_sol[i];
306 for (
int i=0;i<local_nnz;++i) {
307 dp_Z[i]-=rhs_sol[iArr[3+i]-1]*dp_y[iArr[3+local_nnz+i]-1];