renumbering_P1P1BP2.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of NS2DDV. %
% %
% Copyright(C) 2011-2018 C. Calgaro (caterina.calgaro@math.univ-lille1.fr) %
% E. Creusé (emmanuel.creuse@math.univ-lille1.fr) %
% T. Goudon (thierry.goudon@inria.fr) %
% A. Mouton (alexandre.mouton@math.univ-lille1.fr) %
% %
% NS2DDV is free software: you can redistribute it and/or modify it under the terms %
% of the GNU General Public License as published by the Free Software Foundation, %
% either version 3 of the License, or (at your option) any later version. %
% %
% NS2DDV is distributed in the hope that it will be useful, but WITHOUT ANY %
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A %
% PARTICULAR PURPOSE. See the GNU General Public License for more details. %
% %
% You should have received a copy of the GNU General Public License along with %
% NS2DDV. If not, see <http://www.gnu.org/licenses/>. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[RENUMBERING] = renumbering_P1P1BP2(MESH, PARAMETERS)
% INPUT
% MESH An incomplete mesh metadata
% PARAMETERS List of simulation parameters
%
% OUTPUT
% RENUMBERING List of renumbering permutation matrices
% Assembling P1 mass matrix with P1 dof and P1B (resp. P2) mass matrix with P1B dof (resp P2 dof)
% WARNING : we must provide a P1 discretization of rho = 1 to the mass assembling routine
rho_Id = ones(MESH.np1,1);
M_p1 = assembling_mass(MESH, 'P1', rho_Id, 'P1', PARAMETERS);
M_p1b = assembling_mass(MESH, 'P1B', rho_Id, 'P1', PARAMETERS);
M_p2 = assembling_mass(MESH, 'P2', rho_Id, 'P1', PARAMETERS);
% Permutation using M_p1, M_p1b and M_p2 matrices (resp. with P1, P1B and P2 dof)
switch PARAMETERS.MESH.RENUMBERING
case {'AMD'}
RENUMBERING.perm_p1 = amd(M_p1);
RENUMBERING.perm_p1b = amd(M_p1b);
RENUMBERING.perm_p2 = amd(M_p2);
case {'CMK'}
RENUMBERING.perm_p1 = symrcm(M_p1);
RENUMBERING.perm_p1b = symrcm(M_p1b);
RENUMBERING.perm_p2 = symrcm(M_p2);
otherwise
error(sprintf('Unknown renumbering technique.\n'));
end
end