diff --git a/scripts/compute_1d_error.m b/scripts/compute_1d_error.m new file mode 100644 index 0000000000000000000000000000000000000000..ec13cac0145a8add54f4b02beec6cb5d0da69a47 --- /dev/null +++ b/scripts/compute_1d_error.m @@ -0,0 +1,28 @@ +function [totalRelativeFractureError] = compute_1d_error( coarseFile,referenceFile ) +%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') +load(coarseFile,'fracXAndPCell') + +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); +end + +totalRelativeFractureError = sqrt(sum(fractureErrorSquared)/sum(normalizationSquared)); +end +