branch: devel-logari81
commit a1a0185f9207a91d526f9835810d00930c3a2c55
Author: Konstantinos Poulios <logar...@gmail.com>
Date:   Mon Aug 7 14:07:34 2017 +0200

    code refactoring and simplifications
---
 src/bgeot_convex_ref.cc                |  6 ++---
 src/getfem/dal_static_stored_objects.h |  2 +-
 src/getfem_fem.cc                      | 43 +++++++++++++++++-----------------
 3 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/src/bgeot_convex_ref.cc b/src/bgeot_convex_ref.cc
index 8fe7002..402a60d 100644
--- a/src/bgeot_convex_ref.cc
+++ b/src/bgeot_convex_ref.cc
@@ -214,16 +214,14 @@ namespace bgeot {
   /* By Yao Koutsawa  <yao.kouts...@tudor.lu> 2012-12-10                  */
 
   class Q2_incomplete_of_ref_ : public convex_of_reference {
-    pconvex_ref pllref;
   public :
     scalar_type is_in(const base_node& pt) const
-    { return pllref->is_in(pt); }
+    { return basic_convex_ref_->is_in(pt); }
     scalar_type is_in_face(short_type f, const base_node& pt) const
-    { return pllref->is_in_face(f, pt); }
+    { return basic_convex_ref_->is_in_face(f, pt); }
 
     Q2_incomplete_of_ref_(dim_type nc) {
       GMM_ASSERT1(nc == 2 || nc == 3, "Sorry exist only in dimension 2 or 3");
-      pllref = parallelepiped_of_reference(nc);
       cvs = Q2_incomplete_structure(nc);
       convex<base_node>::points().resize(cvs->nb_points());
       normals_.resize(nc == 2 ? 4: 6);
diff --git a/src/getfem/dal_static_stored_objects.h 
b/src/getfem/dal_static_stored_objects.h
index 7269ddb..f8acb95 100644
--- a/src/getfem/dal_static_stored_objects.h
+++ b/src/getfem/dal_static_stored_objects.h
@@ -150,7 +150,7 @@ namespace dal {
   public :
     virtual bool compare(const static_stored_object_key &oo) const {
       const simple_key &o = dynamic_cast<const simple_key &>(oo);
-      if (a < o.a) return true; else return false;
+      return (a < o.a);
     }
     simple_key(var_type aa) : a(aa) {}
   };
diff --git a/src/getfem_fem.cc b/src/getfem_fem.cc
index dfcd9e1..fe53627 100644
--- a/src/getfem_fem.cc
+++ b/src/getfem_fem.cc
@@ -3544,15 +3544,15 @@ namespace getfem {
     DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(short_type, k_last, short_type(-1));
     DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, fm_last, 0);
     DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(char, isuffix_last, 0);
-    bool found = false, isuffix = suffix[0], spec_dim = true;
+    bool found = false, isuffix = suffix[0];
 
     if (pgt_last == pgt && k_last == k && isuffix == isuffix_last)
       return fm_last;
 
     isuffix_last = isuffix;
 
-    size_type n = pgt->structure()->dim();
-    size_type nbp = pgt->basic_structure()->nb_points();
+    dim_type n = pgt->structure()->dim();
+    dim_type nbp = dim_type(pgt->basic_structure()->nb_points());
     std::stringstream name;
 
     // Identifying if it is a torus structure
@@ -3560,38 +3560,39 @@ namespace getfem {
 
     /* Identifying P1-simplexes.                                          */
     if (nbp == n+1)
-      if (pgt->basic_structure() == bgeot::simplex_structure(dim_type(n)))
-        { name << "FEM_PK" << suffix << "("; found = true; }
+      if (pgt->basic_structure() == bgeot::simplex_structure(n)) {
+        name << "FEM_PK" << suffix << "(" << n << ',' << k << arg << ')';
+        found = true;
+      }
 
     /* Identifying Q1-parallelepiped.                                     */
     if (!found && nbp == (size_type(1) << n))
-      if (pgt->basic_structure()==bgeot::parallelepiped_structure(dim_type(n)))
-        { name << "FEM_QK" << suffix << "("; found = true; }
+      if (pgt->basic_structure() == bgeot::parallelepiped_structure(n)) {
+        name << "FEM_QK" << suffix << "(" << n << ',' << k << arg << ')';
+        found = true;
+      }
 
     /* Identifying Q1-prisms.                                             */
     if (!found && nbp == 2 * n)
-      if (pgt->basic_structure() == bgeot::prism_structure(dim_type(n)))
-        { name << "FEM_PK_PRISM" << suffix << "("; found = true; }
+      if (pgt->basic_structure() == bgeot::prism_structure(n)) {
+        name << "FEM_PK_PRISM" << suffix << "(" << n << ',' << k << arg << ')';
+        found = true;
+      }
 
     /* Identifying pyramids.                                              */
     if (!found && nbp == 5)
       if (pgt->basic_structure() == bgeot::pyramid_structure(1)) {
-        name << "FEM_PYRAMID" << suffix << "_LAGRANGE(";
-        found = true; spec_dim = false;
+        name << "FEM_PYRAMID" << suffix << "_LAGRANGE(" << k << arg << ')';
+        found = true;;
       }
 
     // To be completed
 
-    if (found) {
-      if (spec_dim) name << int(n) << ',';
-      name << int(k) << arg << ')';
-      fm_last = fem_descriptor(name.str());
-      pgt_last = pgt;
-      k_last = k;
-      return fm_last;
-    }
-
-    GMM_ASSERT1(false, "This element is not taken into account. Contact us");
+    GMM_ASSERT1(found, "This element is not taken into account. Contact us");
+    fm_last = fem_descriptor(name.str());
+    pgt_last = pgt;
+    k_last = k;
+    return fm_last;
   }
 
   pfem classical_fem(bgeot::pgeometric_trans pgt, short_type k) {

Reply via email to