diff --git a/lib/storage/@LevelData/LevelData.m b/lib/storage/@LevelData/LevelData.m index a41af48b65e135af4824ae642e611c5eafa65dec..28d0b9a03a6594b5237ef8422aee4ef6228077db 100644 --- a/lib/storage/@LevelData/LevelData.m +++ b/lib/storage/@LevelData/LevelData.m @@ -85,14 +85,8 @@ classdef LevelData < handle "domain", "domain", ... "method", "method", ... "identifier", "main", ... - "hostname", string(getHostname())); - - % Save time of creation - if isOctave() - obj.metaData("timestamp") = datestr(now, 'yyyy-MM-dd_HH:mm:ss'); %#ok<TNOW1,DATST> - else - obj.metaData("timestamp") = char(datetime('now', 'Format', 'yyyy-MM-dd_HH:mm:ss')); - end + "hostname", string(getHostname()), ... + "timestamp", string(datetime('now', 'Format', 'yyyy-MM-dd_HH:mm:ss'))); obj.category = dictionary(); @@ -298,4 +292,4 @@ end function spec = assembleSpecifier(width, format) spec = ['%', num2str(width), format]; -end \ No newline at end of file +end diff --git a/lib/storage/@LevelData/plotLevel.m b/lib/storage/@LevelData/plotLevel.m index a52dc28a8efdfb8d64d17d75af799f44ec618b4a..5db71169cc8b31672f1c0a17603e4cdc1c707730 100644 --- a/lib/storage/@LevelData/plotLevel.m +++ b/lib/storage/@LevelData/plotLevel.m @@ -49,8 +49,8 @@ function ax = plotLevel(obj, category, xVariable, yVariable) yValue = obj.get(1:obj.nLevel, yVariable{j}); % Extract label for legend from dictionary - if isfield(obj.dictionary, yVariable{j}) - variableLabel = obj.dictionary.(yVariable{j}); + if obj.dictionary.isKey(yVariable{j}) + variableLabel = obj.dictionary(yVariable{j}); else variableLabel = yVariable{j}; end diff --git a/lib/storage/@LevelData/saveToFile.m b/lib/storage/@LevelData/saveToFile.m index 19125149b34e76360d69218817de8c03e3b45e3c..d18503ed503331bff2e8355fb61604c082f80370 100644 --- a/lib/storage/@LevelData/saveToFile.m +++ b/lib/storage/@LevelData/saveToFile.m @@ -31,9 +31,5 @@ function saveToFile(obj, folder, file) ensureFolderExists(folder); % Save this object to file pathToMat = folder + '/' + file + '.mat'; - if isOctave() - save(pathToMat, 'obj', '-v7'); - else - save(pathToMat, 'obj', '-v7.3'); - end + save(pathToMat, 'obj', '-v7.3'); end diff --git a/lib/storage/@LevelDataCollection/LevelDataCollection.m b/lib/storage/@LevelDataCollection/LevelDataCollection.m index cfb332bf08806e4ec6f85cd7a03ef5619e3b7f1a..623d50f2b01665dccd4e3c96f05b117b24165be5 100644 --- a/lib/storage/@LevelDataCollection/LevelDataCollection.m +++ b/lib/storage/@LevelDataCollection/LevelDataCollection.m @@ -73,14 +73,8 @@ classdef LevelDataCollection < handle "domain", "domain", ... "method", "method", ... "identifier", "main", ... - "hostname", string(getHostname())); - - % Save time of creation - if isOctave() - obj.metaData("timestamp") = datestr(now, 'yyyy-MM-dd_HH:mm:ss'); %#ok<TNOW1,DATST> - else - obj.metaData("timestamp") = char(datetime('now', 'Format', 'yyyy-MM-dd_HH:mm:ss')); - end + "hostname", string(getHostname()), ... + "timestamp", string(datetime('now', 'Format', 'yyyy-MM-dd_HH:mm:ss'))); % Set identifier if nargin >= 2 diff --git a/lib/storage/@LevelDataCollection/plotStatistics.m b/lib/storage/@LevelDataCollection/plotStatistics.m index 14e9ed43eb3a8554a67aae5d60d4b3f12deaf729..20ce3721b7852299fe9e74949aa5b01867539730 100644 --- a/lib/storage/@LevelDataCollection/plotStatistics.m +++ b/lib/storage/@LevelDataCollection/plotStatistics.m @@ -72,20 +72,14 @@ function ax = plotData(xData, variableName, data) % Extract label for legend from dictionary variableLabel = variableName{j}; % Create plot - if isOctave() - fmt = [MARKER{j}, ';', variableLabel, ';']; - errorbar(ax, xData, yMean, ... - yMean - yMin, yMax - yMean, fmt); - else - errorbar(ax, xData, yMean, ... - yMean - yMin, yMax - yMean, ... - 'LineStyle', '-', 'Marker', '.', ... - 'Color', COLOURORDER(j,:), ... - 'DisplayName', variableLabel); - end + errorbar(ax, xData, yMean, ... + yMean - yMin, yMax - yMean, ... + 'LineStyle', '-', 'Marker', '.', ... + 'Color', COLOURORDER(j,:), ... + 'DisplayName', variableLabel); % Use double-logarithmic scales set(ax, 'XScale', 'log', 'YScale', 'log'); % Add new line into the current figure when calling plotConvergence again hold(ax, 'on'); end -end \ No newline at end of file +end diff --git a/lib/storage/@LevelDataCollection/saveToFile.m b/lib/storage/@LevelDataCollection/saveToFile.m index b43d1e777ceb3e66ec4f7f5bb9a855eb4ce22b9e..f8236c234247977caa6bd049832f7bad8f3e0714 100644 --- a/lib/storage/@LevelDataCollection/saveToFile.m +++ b/lib/storage/@LevelDataCollection/saveToFile.m @@ -34,10 +34,5 @@ function saveToFile(obj, folder, file) ensureFolderExists(folder); % Save this object to file - if isOctave() - warning(['LevelData not stored. Octave cannot save classdef objects. ', ... - 'See GNU Octave Bug: #45833']); - else - save(folder + '/' + file + '.mat', 'obj', '-v7.3'); - end + save(folder + '/' + file + '.mat', 'obj', '-v7.3'); end diff --git a/lib/storage/TimeIt.m b/lib/storage/TimeIt.m index c8b533494d47518a527f3242fcb7e4bd36d2c819..60df8118bde4a877f69010acd338228afb682ea5 100644 --- a/lib/storage/TimeIt.m +++ b/lib/storage/TimeIt.m @@ -61,11 +61,7 @@ function output = fevalc(functionName, varargin) %#ok<INUSD> % Create function call functioncall = 'feval(functionName, varargin{:})'; % Call function - if isOctave() - evalc(['output = ' functioncall]); - else - [~, output] = evalc(functioncall); - end + [~, output] = evalc(functioncall); % Store output in cell variable if ~iscell(output) output = {output}; diff --git a/lib/storage/configureLegend.m b/lib/storage/configureLegend.m index fa55cc376993c12ed596d4846baea86ff4b5a3d4..fe1a7c95992effeec2425a89aab902fb2315572b 100644 --- a/lib/storage/configureLegend.m +++ b/lib/storage/configureLegend.m @@ -26,10 +26,6 @@ function configureLegend(ax, location) % Specify location set(leg, 'Location', location); - % Set interpreter to latex in Matlab - if isOctave() - set(leg, 'Interpreter', 'tex'); - else - set(leg, 'Interpreter', 'latex'); - end + % Set interpreter to latex + set(leg, 'Interpreter', 'latex'); end diff --git a/lib/storage/getDefaultDictionary.m b/lib/storage/getDefaultDictionary.m index 851c27718a757025199523aaccf2342c5beb0f0f..61e7218ea3474c8c7fdefc169f9d03edb7cc3745 100644 --- a/lib/storage/getDefaultDictionary.m +++ b/lib/storage/getDefaultDictionary.m @@ -1,7 +1,7 @@ -function DICTIONARY = getDefaultDictionary() +function dict = getDefaultDictionary() %%GETDEFAULTDICTIONARY allows to specify default structure arrays for %dictionaries for legend labels in plots -% DICTIONARY = GETDEFAULTDICTIONARY() +% dict = GETDEFAULTDICTIONARY() % Copyright 2023 Philipp Bringmann % @@ -22,66 +22,31 @@ function DICTIONARY = getDefaultDictionary() % Dictionary for the latex description of data in the % convergence history plot - DICTIONARY_MATLAB =... - struct('eta' , '$\eta_\ell$',... - 'etaVol' , '$\eta_{\textrm{vol}}$',... - 'etaJump' , '$\eta_{\textrm{jump}}$',... - 'oscDb' , '$\textrm{osc}(\textrm{D} u_{\textrm{D}}, \mathcal{F}_\ell(\Gamma_{\textrm{D}})$',... - 'oscNb' , '$\textrm{osc}(t_{\textrm{N}}, \mathcal{F}_\ell(\Gamma_{\textrm{N}})$',... - 'oscF' , '$\textrm{osc}(f, \mathcal{T}_\ell)$',... - 'mu' , '$|| f - \Pi_0 f ||_{L^2(\Omega)}$',... - 'est' , 'built-in',... - 'res' , '$LS(f; \sigma_\ell, u_\ell)$',... - 'resRed' , '$LS(\Pi_0 f; \sigma_\ell, u_\ell)$',... - 'resDiv' , '$|| f + \textrm{div} \sigma_\ell ||_{L^2(\Omega)}$',... - 'resL2' , '$|| \sigma_\ell - \nabla u_\ell ||_{L^2(\Omega)}$',... - 'resDev' , '$|| \textrm{dev} \sigma_\ell - \textrm{D} u_\ell ||_{L^2(\Omega)}$',... - 'resMat' , '$|| C^{-1} \sigma_\ell - \varepsilon u_\ell ||_{L^2(\Omega)}$',... - 'errU' , '$|| u - u_\ell ||_{H^1(\Omega)}$',... - 'errL2U' , '$|| u - u_\ell ||_{L^2(\Omega)}$',... - 'errGradU' , '$||| u - u_\ell |||$',... - 'errSigma' , '$|| \sigma - \sigma_\ell ||_{H(\textrm{div},\Omega)}$',... - 'errL2Sigma' , '$|| \sigma - \sigma_\ell ||_{L^2(\Omega)}$',... - 'errDivSigma' , '$|| \textrm{div} (\sigma - \sigma_\ell) ||_{L^2(\Omega)}$',... - 'runtime' , 'runtime',... - 'setupTime' , 'setuptime',... - 'solutionTime' , 'solutiontime',... - 'estimatorTime' , 'estimatortime',... - 'refinementTime', 'refinementtime',... - 'condition' , 'condition'); - % Dictionary for the latex description of data in the convergence - % history plot for octave - DICTIONARY_OCTAVE =... - struct('eta' , '\eta_{l}',... - 'etaVol' , '\eta_{{vol,l}}',... - 'etaJump' , '\eta_{{jump,l}}',... - 'oscDb' , '{osc}({D} u_{{D}}, F_l(\Gamma_{{D}}))',... - 'oscNb' , '{osc}(t_{{N}}, F_l(\Gamma_{{N}}))',... - 'oscF' , '{osc}(f, T_\ell)',... - 'mu' , '|| f - \Pi_0 f ||_{L^2(\Omega)',... - 'est' , 'built-in',... - 'res' , 'LS(f; \sigma_l, u_l)',... - 'resRed' , 'LS(\Pi_0 f; \sigma_l, u_l)',... - 'resDiv' , '|| f + {div} \sigma_l ||_{L^2(\Omega)}',... - 'resL2' , '|| \sigma_l - \nabla u_l ||_{L^2(\Omega)}',... - 'resDev' , '|| {dev} \sigma_l - {D} u_l ||_{L^2(\Omega)}',... - 'resMat' , '|| C^{-1} \sigma_l - \epsilon u_l ||_{L^2(\Omega)}',... - 'errU' , '|| u - u_l ||_{H^1(\Omega)}',... - 'errL2U' , '|| u - u_\ell ||_{L^2(\Omega)}',... - 'errGradU' , '||| u - u_\ell |||',... - 'errSigma' , '|| \sigma - \sigma_l ||_{H({div},\Omega)}',... - 'errL2Sigma' , '|| \sigma - \sigma_\ell ||_{L^2(\Omega)}',... - 'errDivSigma' , '|| {div} (\sigma - \sigma_\ell) ||_{L^2(\Omega)}',... - 'runtime' , 'runtime',... - 'setupTime' , 'setuptime',... - 'solutionTime' , 'solutiontime',... - 'estimatorTime' , 'estimatortime',... - 'refinementTime', 'refinementtime',... - 'condition' , 'condition'); - % Choose dictionary according to running program - if isOctave() - DICTIONARY = DICTIONARY_OCTAVE; - else - DICTIONARY = DICTIONARY_MATLAB; - end -end \ No newline at end of file + dict =... + dictionary('eta' , '$\eta_\ell$',... + 'etaVol' , '$\eta_{\textrm{vol}}$',... + 'etaJump' , '$\eta_{\textrm{jump}}$',... + 'oscDb' , '$\textrm{osc}(\textrm{D} u_{\textrm{D}}, \mathcal{F}_\ell(\Gamma_{\textrm{D}})$',... + 'oscNb' , '$\textrm{osc}(t_{\textrm{N}}, \mathcal{F}_\ell(\Gamma_{\textrm{N}})$',... + 'oscF' , '$\textrm{osc}(f, \mathcal{T}_\ell)$',... + 'mu' , '$|| f - \Pi_0 f ||_{L^2(\Omega)}$',... + 'est' , 'built-in',... + 'res' , '$LS(f; \sigma_\ell, u_\ell)$',... + 'resRed' , '$LS(\Pi_0 f; \sigma_\ell, u_\ell)$',... + 'resDiv' , '$|| f + \textrm{div} \sigma_\ell ||_{L^2(\Omega)}$',... + 'resL2' , '$|| \sigma_\ell - \nabla u_\ell ||_{L^2(\Omega)}$',... + 'resDev' , '$|| \textrm{dev} \sigma_\ell - \textrm{D} u_\ell ||_{L^2(\Omega)}$',... + 'resMat' , '$|| C^{-1} \sigma_\ell - \varepsilon u_\ell ||_{L^2(\Omega)}$',... + 'errU' , '$|| u - u_\ell ||_{H^1(\Omega)}$',... + 'errL2U' , '$|| u - u_\ell ||_{L^2(\Omega)}$',... + 'errGradU' , '$||| u - u_\ell |||$',... + 'errSigma' , '$|| \sigma - \sigma_\ell ||_{H(\textrm{div},\Omega)}$',... + 'errL2Sigma' , '$|| \sigma - \sigma_\ell ||_{L^2(\Omega)}$',... + 'errDivSigma' , '$|| \textrm{div} (\sigma - \sigma_\ell) ||_{L^2(\Omega)}$',... + 'runtime' , 'runtime',... + 'setupTime' , 'setuptime',... + 'solutionTime' , 'solutiontime',... + 'estimatorTime' , 'estimatortime',... + 'refinementTime', 'refinementtime',... + 'condition' , 'condition'); +end diff --git a/lib/storage/getPlotStyle.m b/lib/storage/getPlotStyle.m index 1f814be44ea49ca3394ec42e7deefaf74251a68f..46e0482e8e2e05ac0cee5f42d9cab397e829b3be 100644 --- a/lib/storage/getPlotStyle.m +++ b/lib/storage/getPlotStyle.m @@ -1,6 +1,6 @@ -function [COLOURORDER, MARKER] = getPlotStyle() +function [colorOrder, marker] = getPlotStyle() %%GETPLOTSTYLE creates lists of default colours and markers for plotting -% [COLOURORDER, MARKER] = GETPLOTSTYLE() +% [colorOrder, marker] = GETPLOTSTYLE() % Copyright 2023 Philipp Bringmann % @@ -21,40 +21,32 @@ function [COLOURORDER, MARKER] = getPlotStyle() % Generate a sequence of colours for the graphs % Matlab default - COLOURORDER = [0 0.4470 0.7410; - 0.8500 0.3250 0.0980; - 0.9290 0.6940 0.1250; - 0.4940 0.1840 0.5560; - 0.4660 0.6740 0.1880; - 0.3010 0.7450 0.9330; - 0.6350 0.0780 0.1840]; + colorOrder = [0 0.4470 0.7410; + 0.8500 0.3250 0.0980; + 0.9290 0.6940 0.1250; + 0.4940 0.1840 0.5560; + 0.4660 0.6740 0.1880; + 0.3010 0.7450 0.9330; + 0.6350 0.0780 0.1840]; % ALTERNATIVE: TU corporate design colours - % COLOURORDER = [0 0.4 0.6; - % 0.3922 0.3882 0.3882; - % 0 0.4941 0.4431; - % 0.7294 0.2745 0.5098; - % 0.8824 0.5373 0.1333]; + % colorOrder = [0 0.4 0.6; + % 0.3922 0.3882 0.3882; + % 0 0.4941 0.4431; + % 0.7294 0.2745 0.5098; + % 0.8824 0.5373 0.1333]; % ALTERNATIVE: variable length colour sequence - % nColour = max(ceil(nVariable^(1/3)), 2); - nColour = 3; - [red, green, blue] = meshgrid(linspace(0, 1, nColour)); - % COLOURORDER = [red(:), green(:), blue(:)]; + % nColor = max(ceil(nVariable^(1/3)), 2); + nColor = 3; + [red, green, blue] = meshgrid(linspace(0, 1, nColor)); + % colorOrder = [red(:), green(:), blue(:)]; % Append - COLOURORDER = [COLOURORDER; red(:), green(:), blue(:)]; + colorOrder = [colorOrder; red(:), green(:), blue(:)]; % Remove white as line colour - COLOURORDER = COLOURORDER(1:end-1,:); + colorOrder = colorOrder(1:end-1,:); % Define sequence of markers - MATLAB_MARKER = {'o', '+', 'x', 'square', 'diamond', '*', '^', 'v', ... + marker = {'o', '+', 'x', 'square', 'diamond', '*', '^', 'v', ... 'pentagram', 'hexagram', '<', '>', '.', '_', '|'}; - OCTAVE_MARKER = {'~o-k', '~x-r', '~s-g', '~d-b', '~p-c', '~^-m', '~v-y'}; - - % Choose sequence of markers - if isOctave() - MARKER = OCTAVE_MARKER; - else - MARKER = MATLAB_MARKER; - end end diff --git a/lib/storage/isOctave.m b/lib/storage/isOctave.m deleted file mode 100644 index 0bf8d4b25358965590e6e42a809f0ae5f4cce2c5..0000000000000000000000000000000000000000 --- a/lib/storage/isOctave.m +++ /dev/null @@ -1,15 +0,0 @@ -function retval = isOctave() -%%ISOCTAVE checks whether this function is called from Octave -% -% Source: -% -% https://octave.org/doc/v5.1.0/How-to-Distinguish-Between-Octave-and-Matlab.html - - persistent cacheval; % speeds up repeated calls - - if isempty (cacheval) - cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); - end - - retval = cacheval; -end