From e28e517415f895800877e78ff518148ea3f2df47 Mon Sep 17 00:00:00 2001
From: acrovato <a.crovato@uliege.be>
Date: Thu, 6 Jun 2024 17:37:19 +0200
Subject: [PATCH] Refactor default value in API.

---
 sdpm/api/core.py               | 10 +++++-----
 sdpm/src/sdpmSolver.cpp        |  2 +-
 sdpm/src/sdpmSolver.h          |  2 +-
 sdpm/src/sdpmSolverTransonic.h |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sdpm/api/core.py b/sdpm/api/core.py
index f0bbb3c..10a355e 100644
--- a/sdpm/api/core.py
+++ b/sdpm/api/core.py
@@ -58,14 +58,14 @@ def init_sdpm(cfg, use_ad=False):
         raise RuntimeError('Symmetric (half) geometric model cannot be used with nonzero angle of sideslip (AoS)!\n')
 
     # Mesh
-    pars = {} if 'Pars' not in cfg else cfg['Pars']
+    pars = cfg.get('Pars', {})
     _msh = MeshLoader(cfg['File']).run(pars)
     _wrt = sdpm.GmshExport(_msh)
 
     # Problem
-    aoa = 0 if 'AoA' not in cfg else cfg['AoA'] * math.pi / 180
-    aos = 0 if 'AoS' not in cfg else cfg['AoS'] * math.pi / 180
-    minf = 0 if 'Mach' not in cfg else cfg['Mach']
+    aoa = cfg.get('AoA', 0.) * math.pi / 180
+    aos = cfg.get('AoS', 0.) * math.pi / 180
+    minf = cfg.get('Mach', 0.)
     _pbl = sdpm.Problem(_msh)
     _pbl.setGeometry(cfg['s_ref'], cfg['c_ref'], cfg['x_ref'], cfg['y_ref'], cfg['z_ref'], cfg['Symmetry'])
     _pbl.setFreestream(aoa, aos, minf)
@@ -85,7 +85,7 @@ def init_sdpm(cfg, use_ad=False):
     _pbl.addBody(_bdy)
 
     # Solver
-    vrb = cfg['Verb_lvl'] if 'Verb_lvl' in cfg else 1
+    vrb = cfg.get('Verb_lvl', 1)
     _sol = sdpm.Solver(_pbl, vrb) if 'Transonic_pressure_grad' not in cfg else sdpm.SolverTransonic(_pbl, vrb)
     _adj = sdpm.Adjoint(_sol) if use_ad else None
 
diff --git a/sdpm/src/sdpmSolver.cpp b/sdpm/src/sdpmSolver.cpp
index 17cd2dd..4953c5b 100644
--- a/sdpm/src/sdpmSolver.cpp
+++ b/sdpm/src/sdpmSolver.cpp
@@ -34,7 +34,7 @@ Solver::Solver(Problem &pbl, int vrb) : _pbl(pbl), _vrb(vrb), _cl(0), _cd(0), _c
     // Say hi
     std::cout << std::endl;
     std::cout << "*******************************************************************************" << std::endl;
-    std::cout << "** Hi! My name is SDPM v1.1-2401                                             **" << std::endl;
+    std::cout << "** Hi! My name is SDPM v1.2-2412                                             **" << std::endl;
     std::cout << "** ULiege 2023-2024                                                          **" << std::endl;
     std::cout << "*******************************************************************************" << std::endl;
 
diff --git a/sdpm/src/sdpmSolver.h b/sdpm/src/sdpmSolver.h
index ee6d564..ab5cc32 100644
--- a/sdpm/src/sdpmSolver.h
+++ b/sdpm/src/sdpmSolver.h
@@ -39,7 +39,7 @@ protected:
     int _vrb;      ///< verbosity level
     // AICs
     size_t _nP;                     ///< number of body panels
-    std::map<Element *, int> _rows; ///< map linking an element to a matrix cell
+    std::map<Element *, int> _rows; ///< map linking an element to a matrix entry
     sdpmMatrixXd _A0;               ///< zero-frequency body-body doublet matrix
     sdpmMatrixXd _B0;               ///< zero-frequency body-body source matrix
     std::vector<sdpmMatrixXcd> _A;  ///< unsteady body-body doublet matrix
diff --git a/sdpm/src/sdpmSolverTransonic.h b/sdpm/src/sdpmSolverTransonic.h
index f69da67..e803db7 100644
--- a/sdpm/src/sdpmSolverTransonic.h
+++ b/sdpm/src/sdpmSolverTransonic.h
@@ -31,7 +31,7 @@ namespace sdpm
  */
 class SDPM_API SolverTransonic : public Solver
 {
-    std::map<Node *, int> _rowsN; ///< map linking a node to a matrix cell
+    std::map<Node *, int> _rowsN; ///< map linking a node to a matrix entry
     sdpmVectorXd _dCorr;          ///< transonic correction terms
 
 public:
-- 
GitLab