Skip to content
Snippets Groups Projects
compute_1d_error.m 1.24 KiB
Newer Older
function [totalRelativeFractureError] = compute_1d_error( coarseFile, referenceFile, kmat )
Ivar Stefansson's avatar
Ivar Stefansson committed
%compute1dError Evaluates the norm in each of the fractures
% 
% The coarse file must contain a nFractures x 1 cell array with fracXAndP for
% each of the fractures, see the Description for details on how each
% fracXAndP should be constructed.
% The reference file should contain a triangulation t, point list x and
% solution vector p.

load(referenceFile,'p','t','x','k')
Ivar Stefansson's avatar
Ivar Stefansson committed
load(coarseFile,'fracXAndPCell')
if nargin == 2
    kmat = 1;
end
matrixIndices = find(k == kmat);
t(matrixIndices) = [];
p(matrixIndices) = [];
Ivar Stefansson's avatar
Ivar Stefansson committed

nFractures                      = length(fracXAndPCell);
idividualRelativeFractureError  = zeros(nFractures,1); %Included for comparison
% between the fractures
fractureErrorSquared            = zeros(nFractures,1);
normalizationSquared            = zeros(nFractures,1);
frac = true;

for i = 1:nFractures
    fracXAndP                   = fracXAndPCell{i};
    [idividualRelativeFractureError(i),fractureErrorSquared(i),normalizationSquared(i)] = ...
                                  line_norm(fracXAndP,p,t,x,frac,maxp,minp);
Ivar Stefansson's avatar
Ivar Stefansson committed
end

totalRelativeFractureError = sqrt(sum(fractureErrorSquared)/sum(normalizationSquared));
end