OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
schur_example.m
Go to the documentation of this file.
1%Example of using MUMPS in matlab with schur option
2
3% initialization of a matlab MUMPS structure
4id = initmumps;
5id = dmumps(id);
6load lhr01;
7mat = Problem.A;
8themax = max(max(abs(mat)));
9n = size(mat,1);
10mat = mat+sparse(1:n,1:n,3*themax*ones(n,1));
11
12% initialization of Schur option
13id.VAR_SCHUR = [n-9:n];
14
15% JOB = 6 means analysis+facto+solve
16id.JOB = 6;
17id.RHS = ones(size(mat,1),1);
18%call to mumps
19id = dmumps(id,mat);
20disp('*** check solution restricted to mat(1:n-10,1:n-10)');
21if(norm(mat(1:n-10,1:n-10)*id.SOL(1:n-10) - ones(n-10,1),'inf') > sqrt(eps))
22 disp('WARNING : precision may not be OK');
23else
24 disp('SCHUR SOLUTION CHECK1 OK');
25end
26norm(mat(1:n-10,1:n-10)*id.SOL(1:n-10) - ones(n-10,1),'inf')
27
28
29% we want to use Schur complement to solve
30% A * sol = rhs
31% with sol = x and rhs = rhs1
32% y rhs2
33%
34% check that the complete solution verify
35% y = S^(-1) * (rhs2 - A_{2,1} * A_{1,1}^(-1) * rhs1)
36% and
37% x = A_{1,1}^(-1) * rhs1) - A_{1,2} * y
38%
39sol1 = id.SOL(1:n-10);
40rhsy = ones(10,1)-mat(n-9:n,1:n-10)*sol1;
41
42%%%%%%%%%%%%%%%%%%%
43% TO CHANGE :
44% usually the resolution below is replaced by an iterative scheme
45y = id.SCHUR \ rhsy;
46%%%%%%%%%%%%%%%%%%%%
47
48rhsx = mat(1:n-10,n-9:n)*y;
49id.JOB = 3;
50id.RHS(1:n-10) = rhsx;
51id = dmumps(id,mat);
52rhsx = id.SOL(1:n-10);
53x = sol1-rhsx;
54sol = [x;y];
55r = mat*sol - ones(n,1);
56disp('*** check complete solution');
57if( norm(r,'inf') > sqrt(eps))
58 disp('WARNING : precision may not be OK');
59else
60 disp('SCHUR SOLUTION CHECK2 OK');
61end
62norm(r,'inf')
63
64
65
66%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67% NOW TRY REDUCED RHS FUNCTIONALITY
68% (easier to use than previous
69% computations)
70%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
72id.JOB=3;
73% Do forward solution step to obtain a reduced RHS
74id.ICNTL(26)=1;
75RHS=mat*ones(n,1);
76id.RHS=RHS;
77id = dmumps(id,mat);
78% Solve the problem on the interface
79id.REDRHS = id.SCHUR \ id.REDRHS;
80
81% Do backward solution stage to expand the solution
82id.ICNTL(26)=2;
83id = dmumps(id,mat);
84r = mat*id.SOL-RHS;
85disp('*** check solution when REDRHS is used');
86if( norm(r,'inf') > sqrt(eps))
87 disp('WARNING : precision may not be OK');
88else
89 disp('SCHUR SOLUTION CHECK3 OK');
90end
91norm(r,'inf')
92
!This file is part of MUMPS
Definition cmumps_root.h:2
end load lhr01
end diagonal values have been computed in the(sparse) matrix id.SOL
end[inform, rinform, sol, inst, schur, redrhs, pivnul_list, sym_perm, uns_perm, icntl, cntl, colsca_out, rowsca_out, keep_out, dkeep_out]
Definition dmumps.m:40
id SOL
Definition dmumps.m:43
#define max(a, b)
Definition macros.h:21
initmumps id
we set the rigth hand side id RHS
if(norm(mat *id.SOL - id.RHS, 'inf') > sqrt(eps)) disp('WARNING els disp)('SOLUTION OK')
****************************************This help menu gives details about the use of dmumps
Definition mumps_help.m:2
#define JOB
Definition mumpsmex.c:33
mat
rhsy
sol
end norm(mat(1:n-10, 1:n-10) *id.SOL(1:n-10) - ones(n-10, 1), 'inf') % we want to use Schur complement to solve % A *sol
themax
TO CHANGE
rhsx
n