view +blockmatrix/zeroTest.m @ 958:72cd29107a9a feature/poroelastic

Temporary changes in multiblock.DiffOp. Change traction operators in Elastic2dvariable to be true boundary operators. But adjoint FD conv test fails for dirichlet BC so need to debug!
author Martin Almquist <malmquist@stanford.edu>
date Wed, 05 Dec 2018 18:58:10 -0800
parents a5f1b0267dba
children
line wrap: on
line source

function tests = zeroTest()
    tests = functiontests(localfunctions);
end

function testZero(testCase)
    cases = {
        {
            {[],[]},
            {},
        },
        {
            {0,0},
            {[]};
        },
        {
            {1,1},
            {0};
        },
        {
            {2,1},
            {[0; 0]};
        },
        {
            {1,2},
            {[0 0]};
        },
        {
            {[1 2],2},
            {[0 0];[0 0; 0 0]};
        },
        {
            {[1 2],[2 1]},
            {[0 0],[0];[0 0; 0 0],[0; 0]};
        },
        {
            {[3],[0]},
            {zeros(3,0)},
        },

        {
            {[0],[3]},
            {zeros(0,3)},
        },
        {
            {[0 2],[0 3]},
            {
                zeros(0,0), zeros(0,3);
                zeros(2,0), zeros(2,3);
            },
        },
    };

    for i = 1:length(cases)
        out = convertToFull(blockmatrix.zero(cases{i}{1}));
        expected = cases{i}{2};
        testCase.verifyEqual(out,expected);
    end
end


function C = convertToFull(C)
    [N,M] = size(C);
    for i = 1:N
        for j = 1:M
            C{i,j} = full(C{i,j});
        end
    end
end