4 % lexicographic unit cube
24 % linear transformation
27 X = T*X0+rand(3,1)*ones(1,8);
30 [K, F, Jg] = hexa(A,X,u);
31 eig(K) % one eigenvalue zero
34 % for linear field mu with values V at nodes V*F should be -integral (grad mu) * u
38 exact = - gradmu*u*vol;
41 if exist('vrrotvec2mat')
42 % invariariant to random isometry
43 S=vrrotvec2mat(vrrotvec(randn(3,1),randn(3,1)))*diag(sign(randn(3,1)));
44 [K0, ~, ~] = hexa(A,X,u);
45 [K1, ~, ~] = hexa(A,S*X,u);
46 err_iso=norm(K0-K1,'fro')
48 warning('No vrrotvec2mat, cannot test rotation invariance. Install Simulink 3D Animation.')
52 X3 = diag([1 1 2])*X0;
53 [K3, ~, ~] = hexa(A,X3,u);
55 % test same results from matlab and fortran
56 if exist('fortran/hexa_test.exe')
57 disp('testing if same result in fortran')
58 err=hexa_fortran(A,X3,u)
60 fprintf('error %g OK\n',err)
62 error(sprintf('error %g too large',err))
65 warning('fortran/hexa_test.exe not available')