File: schur_example.sce

package info (click to toggle)
mumps 5.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,624 kB
  • sloc: fortran: 455,982; ansic: 14,533; makefile: 684; xml: 527; f90: 181; sh: 130
file content (68 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (8)
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
//A simple demo for the MUMPS interface, with the return of the schur complement
//to run it, You just have to execute  the instruction within Scilab
//		exec sparse_example.sce; 


//*********************** MATRIX INITIALISATION ***********************//
	n=10;
	mat=sprand(n,n,.5)+speye(n,n);
        size_schur=3;

// Right Hand side setting
	RHS = ones(n,1);

	
//****************** Initialisation of the Scilab MUMPS structure ******************//
timer();
[id]=initmumps();

//Here Job=-1, the next call will only initialise the C and Fortran structure
[id]=dmumps(id);

id.RHS=RHS;
id.VAR_SCHUR = [n-size_schur+1:n];

//******************** CALL TO MUMPS FOR RESOLUTION ON INTERNAL PROBLEM ************//
job=6;
id.JOB=job;

[id]=dmumps(id,mat);

// verification of the solution
solution=id.SOL;
norm1=norm(mat(1:n-size_schur,1:n-size_schur)*solution(1:n-size_schur) - ones(n-size_schur,1),'inf');
if norm1> 10^(-9) then
	write(%io(2),'WARNING: solution on internal problem may not be OK');
else
	write(%io(2),'SOLUTION on internal problem ok');
end


//******************* TRY REDUCED RHS FUNCTIONALITY **************//
id.JOB=3;
id.ICNTL(26)=1;

// Forward
[id]=dmumps(id,mat);

// Solve the problem on the Schur complement
id.REDRHS=id.SCHUR \ id.REDRHS;

// and reinject it to MUMPS
id.ICNTL(26)=2;
[id]=dmumps(id,mat);
solution=id.SOL;
norm1=norm(mat*solution-RHS,'inf')
if norm1> 10^(-9) then
	write(%io(2),'WARNING: solution on complete problem may not be OK');
else
	write(%io(2),'SOLUTION on complete problem ok');
end



//****************** DESTRUCTION OF THE MUMPS INSTANCE ******************//
job=-2;
id.JOB=job;
[id]=dmumps(id);
t=timer()