From bd6c21b5653aa35833066c1fa8e8dc4cec46d4b9 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Wed, 20 Sep 2023 10:56:18 +0200
Subject: [PATCH] refact(result): improve result tables

---
 src/classes/@Result/Result.m | 47 +++++++++++++++++-------------------
 src/configs/templatecoax.m   |  3 ++-
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/classes/@Result/Result.m b/src/classes/@Result/Result.m
index e37170a..91d79f5 100644
--- a/src/classes/@Result/Result.m
+++ b/src/classes/@Result/Result.m
@@ -5,7 +5,7 @@ classdef Result < handle
     %
     % Notes:
     %   - Almost all properties are private to prevent accidental overwriting.
-    %
+    %   - Most properties are structured as [nRotor, nOperPoint]
     % -----
     %
     % Result properties:
@@ -14,11 +14,16 @@ classdef Result < handle
     %   indvel   - Results obtained with the indVel solver
     %   stahlhut - Results obtained with the stalhlut solver
     %   operPts  - Table with the operating points for each individual result
-    %   ModExt   - Modelling enstension options (losses, etc)
-    %
+    %   ModExt   - Modelling extension options (losses, etc)
+    %   cT       - Table with all Thrust coefficients
+    %   cP       - Table with all Power coefficients
+    %   cQ       - Table with all Torque coefficients
     %
     % Result methods:
-    %   save - Save the Result object to file
+    %   save      - Save the Result object to file
+    %   summarize - Output a summary table with the operating points and the performance
+    %   filter    - Filter for a specific operating point
+    %   plotperf  - Plot and compare rotor performances
     %
     % Result constructor:
     %   Result = Result() creates an empty object.
@@ -73,8 +78,8 @@ classdef Result < handle
         % ---------------------------------------------
         % Set methods
         function set.operPts(self, val)
-            % Note: A bug in Matlab prevents the user of variable names when  size checks are added
-            % in the property definition. https://stackoverflow.com/q/48423003
+            % Note: A bug in Matlab prevents the use of variable names when size checks are added
+            % in the property definition. See: https://stackoverflow.com/q/48423003
             self.operPts = val;
             self.operPts.Properties.VariableNames = {'altitude', 'speed', 'rpm', 'collective'};
 
@@ -105,29 +110,21 @@ end
 function resTable = maketable(self, prop)
     % MAKETABLE Gather properties from all solvers and all operating points in a table
 
-    resTable = table('Size', [size(self.operPts, 1), 4], ...
-                     'VariableTypes', {'double', 'double', 'double', 'double'});
-
-    propName = cell(1, 4);
-    for i = 1:length(self.SOLVERS)
-        propName{i} = [prop, '_', self.SOLVERS{i}];
-    end
-
-    resTable.Properties.VariableNames = propName;
-
-    for iRotor = 1:size(self.indvel, 2)
-        for iSolv = 1:length(self.SOLVERS)
-            for iOp = 1:size(self.operPts, 1)
+    resTable = table('Size', [size(self.operPts, 1), 0]);
 
-                solver = self.SOLVERS{iSolv};
+    for iSolv = 1:length(self.SOLVERS)
+        thissolver = self.SOLVERS{iSolv};
+        tmpTable = [];
 
-                if ~isempty(self.(solver))
-                    resTable.(iSolv)(iOp, iRotor) = self.(solver)(iOp, iRotor).(prop);
-                else
-                    resTable.(iSolv)(iOp, iRotor) = NaN;
-                end
+        for iRotor = size(self.(thissolver), 2):-1:1
+            for iOp = size(self.operPts, 1):-1:1
+                tmpTable(iOp, iRotor) = self.(thissolver)(iOp, iRotor).(prop);
             end
         end
+
+        if ~isempty(tmpTable)
+            resTable = addvars(resTable, tmpTable, 'NewVariableNames', [prop, '_', thissolver]);
+        end
     end
 
 end
diff --git a/src/configs/templatecoax.m b/src/configs/templatecoax.m
index 004aa0a..fe60dd4 100644
--- a/src/configs/templatecoax.m
+++ b/src/configs/templatecoax.m
@@ -22,8 +22,9 @@
 % Just load exisiting template
 template;
 
+Sim.Out.show3D    = false;  % Show the 3D view of the whole rotor
 % Currently only indvel is supported fro coaxial
-Mod.solvers = 'indvel';  % BEMT Solver ('leishman', 'indfact', 'indvel', 'stahlhut', 'all')
+% Mod.solvers = 'indvel';  % BEMT Solver ('leishman', 'indfact', 'indvel', 'stahlhut', 'all')
 
 % ==================================================================================================
 % ================================= Blade and rotor geometry =======================================
-- 
GitLab