view +blockmatrix/toMatrix.m @ 1329:7df63b17e078 feature/D2_boundary_opt

Add support for boundary optimized grids in DefCurvilinear, and add boundaryOptimizedCurvilinear for constructing a curvilinear grid with boundary optimized grid point placement.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 14 Feb 2022 14:55:29 +0100
parents 2501067f2fc7
children
line wrap: on
line source

function A = toMatrix(bm)
    if ~blockmatrix.isBlockmatrix(bm)
        error('blockmatrix:toMatrix:NotABlockmatrix', 'Input is not a blockmatrix');
    end

    div = blockmatrix.getDivision(bm);
    n = div{1};
    m = div{2};

    N = sum(n);
    M = sum(m);

    A = sparse(N,M);

    for i = 1:size(bm,1)
        for j = 1:size(bm,2)
            if isempty(bm{i,j})
                bm{i,j} = sparse(n(i),m(j));
            end
        end
    end
    A = cell2mat(bm);
end