From d3490bbd7856609d4f74fc284eed221a3ade1185 Mon Sep 17 00:00:00 2001
From: Ivar Stefansson <ist050@uib.no>
Date: Wed, 21 Dec 2016 18:29:08 +0100
Subject: [PATCH] Upload new file

---
 scripts/compute_1d_error.m | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 scripts/compute_1d_error.m

diff --git a/scripts/compute_1d_error.m b/scripts/compute_1d_error.m
new file mode 100644
index 0000000..ec13cac
--- /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
+
-- 
GitLab