From 0e079c4cb3b5a99e80b07fb53906683410552abf Mon Sep 17 00:00:00 2001
From: lakue103 <laura.kuehle@uni-duesseldorf.de>
Date: Sun, 11 Oct 2020 21:07:03 +0200
Subject: [PATCH] Improved access to class names.

---
 Initial_Condition.py      | 22 +---------------------
 Limiter.py                | 15 ++++++---------
 Quadrature.py             |  7 +++----
 Troubled_Cell_Detector.py | 12 +-----------
 Update_Scheme.py          |  8 +-------
 5 files changed, 12 insertions(+), 52 deletions(-)

diff --git a/Initial_Condition.py b/Initial_Condition.py
index 834f8fe..a559f4c 100644
--- a/Initial_Condition.py
+++ b/Initial_Condition.py
@@ -12,10 +12,8 @@ class InitialCondition(object):
         self._right_bound = right_bound
         self._interval_len = self._right_bound-self._left_bound
 
-        self.function_name = 'None'
-
     def get_name(self):
-        return self.function_name
+        return self.__class__.__name__
 
     def calculate(self, x):
         while x < self._left_bound:
@@ -32,9 +30,6 @@ class Sine(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'Sine'
-
         # Unpack necessary configurations
         self._factor = config.pop('factor', 2)
 
@@ -46,9 +41,6 @@ class Box(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'Box'
-
     def _get_point(self, x):
         if x < -1:
             x = x + 2
@@ -64,9 +56,6 @@ class FourPeakWave(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'FourPeakWave'
-
         # Set additional necessary parameter
         self._alpha = 10
         self._delta = 0.005
@@ -96,9 +85,6 @@ class Linear(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'Linear'
-
         # Unpack necessary configurations
         self._factor = config.pop('factor', 1)
 
@@ -110,9 +96,6 @@ class LinearAbsolut(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'LinearAbsolut'
-
         # Unpack necessary configurations
         self._factor = config.pop('factor', 1)
 
@@ -124,9 +107,6 @@ class DiscontinuousConstant(InitialCondition):
     def __init__(self, left_bound, right_bound, config):
         super().__init__(left_bound, right_bound, config)
 
-        # Set name of function
-        self.function_name = 'DiscontinuousConstant'
-
         # Unpack necessary configurations
         self._x0 = config.pop('x0', 0)
         self._left_factor = config.pop('left_factor', 1)
diff --git a/Limiter.py b/Limiter.py
index 3b05aa9..f2e69da 100644
--- a/Limiter.py
+++ b/Limiter.py
@@ -7,10 +7,10 @@
 
 class Limiter(object):
     def __init__(self, config):
-        self.function_name = 'None'
+        pass
 
     def get_name(self):
-        return self.function_name
+        return self.__class__.__name__
 
     def apply(self, projection, cell):
         pass
@@ -20,9 +20,6 @@ class NoLimiter(Limiter):
     def __init__(self, config):
         super().__init__(config)
 
-        # Set name of function
-        self.function_name = 'NoLimiter'
-
     def apply(self, projection, cell):
         return projection[:, cell]
 
@@ -34,8 +31,8 @@ class MinMod(Limiter):
         # Unpack necessary configurations
         self._erase_degree = config.pop('erase_degree', 0)
 
-        # Set name of function
-        self.function_name = 'MinMod' + str(self._erase_degree)
+    def get_name(self):
+        return self.__class__.__name__ + str(self._erase_degree)
 
     def apply(self, projection, cell):
         cell_slope = self._set_cell_slope(projection, cell)
@@ -75,8 +72,8 @@ class ModifiedMinMod(MinMod):
         self._cell_len = config.pop('cell_len')
         self._mod_factor = config.pop('mod_factor', 0)
 
-        # Set name of function
-        self.function_name = 'ModifiedMinMod' + str(self._erase_degree)
+    def get_name(self):
+        return self.__class__.__name__ + str(self._erase_degree)
 
     def _determine_modification(self, projection, cell, cell_slope):
         if abs(cell_slope) <= self._mod_factor*self._cell_len**2:
diff --git a/Quadrature.py b/Quadrature.py
index 9cf793e..bc68aa8 100644
--- a/Quadrature.py
+++ b/Quadrature.py
@@ -8,13 +8,12 @@ import numpy.polynomial.legendre as leg
 
 class Quadrature(object):
     def __init__(self, config):
-        self.function_name = 'None'
         self._eval_points = None
         self._weights = None
         self._num_eval_points = None
 
     def get_name(self):
-        return self.function_name
+        return self.__class__.__name__
 
     def get_eval_points(self):
         return self._eval_points
@@ -35,5 +34,5 @@ class Gauss(Quadrature):
 
         self._eval_points, self._weights = leg.leggauss(self._num_eval_points)
 
-        # Set name of function
-        self.function_name = 'Gauss' + str(self._num_eval_points)
+    def get_name(self):
+        return self.__class__.__name__ + str(self._num_eval_points)
diff --git a/Troubled_Cell_Detector.py b/Troubled_Cell_Detector.py
index cd2232e..328428c 100644
--- a/Troubled_Cell_Detector.py
+++ b/Troubled_Cell_Detector.py
@@ -31,10 +31,9 @@ class TroubledCellDetector(object):
         self._basis = basis
         self._init_cond = init_cond
         self._quadrature = quadrature
-        self.function_name = 'None'
 
     def get_name(self):
-        return self.function_name
+        return self.__class__.__name__
 
     def get_cells(self, projection):
         pass
@@ -139,9 +138,6 @@ class NoDetection(TroubledCellDetector):
         super().__init__(config, mesh, wave_speed, polynom_degree, num_grid_cells, final_time, left_bound, right_bound,
                          basis, init_cond, quadrature)
 
-        # Set name of function
-        self.function_name = 'NoDetection'
-
     def get_cells(self, projection):
         return []
 
@@ -315,9 +311,6 @@ class Boxplot(WaveletDetector):
         super().__init__(config, mesh, wave_speed, polynom_degree, num_grid_cells, final_time, left_bound, right_bound,
                          basis, init_cond, quadrature)
 
-        # Set name of function
-        self.function_name = 'Boxplot'
-
         # Unpack necessary configurations
         self._fold_len = config.pop('fold_len', 16)
         self._whisker_len = config.pop('whisker_len', 3)
@@ -368,9 +361,6 @@ class Theoretical(WaveletDetector):
         super().__init__(config, mesh, wave_speed, polynom_degree, num_grid_cells, final_time, left_bound, right_bound,
                          basis, init_cond, quadrature)
 
-        # Set name of function
-        self.function_name = 'Theoretical'
-
         # Unpack necessary configurations
         self._cutoff_factor = config.pop('cutoff_factor', np.sqrt(2) * self._cell_len)
         # comment to line above: or 2 or 3
diff --git a/Update_Scheme.py b/Update_Scheme.py
index 89249f1..d1ed685 100644
--- a/Update_Scheme.py
+++ b/Update_Scheme.py
@@ -27,7 +27,7 @@ class UpdateScheme(object):
         self._reset()
 
     def get_name(self):
-        return self.name
+        return self.__class__.__name__
 
     def step(self, projection, cfl_number):
         current_projection, troubled_cells = self._apply_stability_method(projection, cfl_number)
@@ -38,9 +38,6 @@ class UpdateScheme(object):
         return projection, []
 
     def _reset(self):
-        # Set additional necessary fixed instance variables
-        self.name = 'None'
-
         # Set matrix A
         matrix = []
         for i in range(self._polynom_degree+1):
@@ -82,9 +79,6 @@ class SSPRK3(UpdateScheme):
     def __init__(self, polynom_degree, num_grid_cells, detector, limiter):
         super().__init__(polynom_degree, num_grid_cells, detector, limiter)
 
-        # Set name of update scheme
-        self.name = 'SSPRK3'
-
     # Override method of superclass
     def _apply_stability_method(self, projection, cfl_number):
         original_projection = projection
-- 
GitLab