/usr/share/doc/freefem++/examples/examples++-mpi/testsolver_MUMPS.edp is in freefem++-doc 3.19.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | load "MUMPS_FreeFem" // load the library dynamic correspond to MUMPS interface
verbosity = 0;
int[int] ICNTL(40); // declaration of ICNTL parameter for MUMPS
// get value of ICNTL from file
if(mpirank == 0)
{
ifstream ff("ffmumps_fileparam.txt");
string line;
getline(ff,line);
getline(ff,line);
for(int iii=0; iii<40;iii++){
ff >> ICNTL[iii];
getline(ff,line);
}
}
broadcast(processor(0),ICNTL);
// Given data of MUMPS solver in array lparams(SYM,PAR,ICNTL)
// There is no symmetric storage for a matrix associated with a sparse solver.
// Therefore, the matrix will be considered unsymmetric for parallel sparse solver even if symmetric.
// This fact will be change in new version of FreeFem++
{
int SYM = 0;
int PAR = 1;
matrix A =
[[ 40, 0, 45, 0, 0],
[ 0, 12, 0, 0 , 0],
[ 0, 0, 40, 0, 0],
[ 12, 0, 0, 22, 0],
[ 0, 0, 20, 0., 22]];
// construction of integer parameter for MUMPS
int[int] MumpsLParams(42);
MumpsLParams[0] = SYM;
MumpsLParams[1] = PAR;
for(int ii=0; ii< 40; ii++) MumpsLParams[ii+2] = ICNTL[ii]; // ICNTL begin with index 0 here
real[int] xx = [ 1,32,45,7,2], x(5), b(5), di(5);
b=A*xx;
if(mpirank ==0) cout << "xx=" << xx << endl;
set(A,solver=sparsesolver,lparams=MumpsLParams); // We take the default value for CNTL MUMPS parameter
if(mpirank ==0) cout << "solving solution" << endl;
x = A^-1*b;
if(mpirank ==0) cout << "b=" << b << endl;
if(mpirank ==0) cout << "x=" << endl; cout << x << endl;
di = xx-x;
if(mpirank==0){
cout << "x-xx="<< endl; cout << "Linf "<< di.linfty << " L2 " << di.l2 << endl;
}
}
// Read parameter of MUMPS solver in file ffmumps_fileparam.txt
{
matrix A =
[[ 40, 0, 45, 0, 0],
[ 0, 12, 0, 0 , 0],
[ 0, 0, 40, 0, 0],
[ 12, 0, 0, 22, 0],
[ 0, 0, 20, 0., 22]];
real[int] xx = [ 1,32,45,7000,2], x(5), b(5), di(5); // xb(4),bbb(4);
b=A*xx;
cout << "b=" << b << endl;
cout << "xx=" << xx << endl;
set(A,solver=sparsesolver,datafilename="ffmumps_fileparam.txt");
cout << "solving solution" << endl;
x = A^-1*b;
cout << "b=" << b << endl;
cout << "x=" << endl; cout << x << endl;
di = xx-x;
if(mpirank==0){
cout << "x-xx="<< endl; cout << "Linf "<< di.linfty << " L2 " << di.l2 << endl;
}
}
|