| 1 |
function varargout = muelu(varargin) |
| 2 |
% |
| 3 |
% Call Syntax: |
| 4 |
% (1) [h,oc] = muelu('setup', A, [Coordinates], [, 'parameter', value,...]) - setup |
| 5 |
% Input: |
| 6 |
% A - Matrix to be solved with (must be sparse) |
| 7 |
% Coordinates - User-defined coordinates array (optional, dense array) |
| 8 |
% parameter - Teuchos parameter key (string) |
| 9 |
% value - Value for Teuchos parameter |
| 10 |
% Output: |
| 11 |
% h - The MueMex handle for the system |
| 12 |
% oc - The operator complexity of MueLu hierarchy |
| 13 |
% |
| 14 |
% Muemex has a parameter to control APIs used: "Linear Algebra" |
| 15 |
% Can be "epetra unprec", "epetra", "tpetra" |
| 16 |
% Note: "tpetra" supports real and complex scalar matrices |
| 17 |
% All but "epetra unprec" use MueLu as a right preconditioner |
| 18 |
% All use a Belos solver (PseudoBlockGmres is default) |
| 19 |
% |
| 20 |
% (2) [x,its] = muelu(h, A, b[, 'parameter', value,...]) |
| 21 |
% Input: |
| 22 |
% h - The MueMex handle for the system to solve (int) |
| 23 |
% A - Matrix to be solved with |
| 24 |
% b - The RHS to solve with (vector or multivector) |
| 25 |
% parameter - Teuchos parameter key (string) |
| 26 |
% value - Value for Teuchos parameter |
| 27 |
% Output: |
| 28 |
% x - Solution (vector or multivector) |
| 29 |
% its - Number of iterations taken by Belos |
| 30 |
% |
| 31 |
% (3) [x,its] = muelu(h, b[, 'parameter', value,...]) |
| 32 |
% Input: |
| 33 |
% h - The MueMex handle for the system to solve (int) |
| 34 |
% b - The RHS to solve with (vector or multivector) |
| 35 |
% parameter - Teuchos parameter key (string) |
| 36 |
% value - Value for Teuchos parameter |
| 37 |
% Output: |
| 38 |
% x - Solution (vector or multivector) |
| 39 |
% its - Number of iterations taken by Belos |
| 40 |
% |
| 41 |
% In this case the original 'A' matrix with which this was |
| 42 |
% constructed is now the iteration matrix. |
| 43 |
% |
| 44 |
% (4) x = muelu('apply', h, r) |
| 45 |
% Input: |
| 46 |
% h - The MueMex handle for the system to solve (int) |
| 47 |
% r - The residual/RHS vector to solve with (vector or multivector) |
| 48 |
% Output: |
| 49 |
% x - M*r, where M is the preconditioner operator |
| 50 |
% |
| 51 |
% (5) muelu('cleanup'[, h]) - frees allocated memory |
| 52 |
% Input: |
| 53 |
% h - The MueMex handle for the system to clean up. |
| 54 |
% Calling 'cleanup' with no handle cleans up all |
| 55 |
% the systems. |
| 56 |
% |
| 57 |
% (6) muelu('status'[, h]) - prints out status information |
| 58 |
% Input: |
| 59 |
% h - The MueMex handle for the system to print status for. |
| 60 |
% Calling 'status' with no handle prints status |
| 61 |
% for all the systems. |
| 62 |
% |
| 63 |
% (7) data = muelu('get', h, levelID, dataName[, typeHint]) |
| 64 |
% - get hierarchy data |
| 65 |
% Input: |
| 66 |
% h - MueMex handle for problem with the hierarchy |
| 67 |
% levelID - ID of level to get data from (0, 1, etc.) |
| 68 |
% dataName - Name of data field to fetch ('Nullspace', 'P', etc.) |
| 69 |
% typeHint - (Optional) Type of data expected ('matrix', 'scalar', 'lovector', etc). |
| 70 |
% If not given, will attempt to infer from dataName. |
| 71 |
% Output: |
| 72 |
% data - The data from the hierarchy. |
| 73 |
% |
| 74 |
% by: Brian Kelley <[email protected]> |
| 75 |
|
| 76 |
if(nargin >= 2 && strcmp(varargin{1},'setup')), |
| 77 |
% Setup mode = 0 |
| 78 |
[out, oc] = muemex(0, varargin{2:nargin}); |
| 79 |
varargout{1} = out; |
| 80 |
if(nargout == 2), |
| 81 |
varargout{2} = oc; |
| 82 |
end |
| 83 |
elseif(nargin >= 2 && isnumeric(varargin{1}) && isnumeric(varargin{2})), |
| 84 |
% Solve mode = 1 |
| 85 |
[sol, its] = muemex(1, varargin{:}); |
| 86 |
varargout{1} = sol; |
| 87 |
if(nargout == 2), |
| 88 |
varargout{2} = its; |
| 89 |
end |
| 90 |
elseif(nargin >= 1 && strcmp(varargin{1}, 'cleanup')), |
| 91 |
% Cleanup mode = 2 |
| 92 |
varargout{1} = muemex(2, varargin{2:nargin}); |
| 93 |
elseif(nargin>=1 && strcmp(varargin{1}, 'status')), |
| 94 |
% Status mode = 3 |
| 95 |
varargout{1} = muemex(3, varargin{2:nargin}); |
| 96 |
elseif(strcmp(varargin{1}, 'get')), |
| 97 |
% Get mode = 5 |
| 98 |
varargout{1} = muemex(5, varargin{2:nargin}); |
| 99 |
elseif(strcmp(varargin{1}, 'apply')), |
| 100 |
% Apply mode = 8 |
| 101 |
varargout{1} = muemex(8, varargin{2:nargin}); |
| 102 |
else |
| 103 |
fprintf('\nUsage:\n'); |
| 104 |
fprintf('[h, oc] = muelu(''setup'', A) to setup a problem\n'); |
| 105 |
fprintf('muelu(''status''[, probID]) to get status of all problems, or a specific problem.\n'); |
| 106 |
fprintf('[x, its] = muelu(h, A, b[, paramName, paramValue, ...]) to solve problem #h\n'); |
| 107 |
fprintf('[x, its] = muelu(h, b[, paramName, paramValue, ...]) to solve problem #h with loaded matrix\n'); |
| 108 |
fprintf('x = muelu(''apply'', h, r) to apply preconditioner of problem #h to vector r\n'); |
| 109 |
fprintf('muelu(''cleanup''[, id]) to free memory associated with all problems, or a specific one.\n'); |
| 110 |
fprintf('muelu(''get'', h, levelID, dataName[, typeHint]) to get data from a level of problem #h.\n'); |
| 111 |
end |
| 112 |
end |