getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5277 - in /trunk/getfem: contrib/icare/ src/ src/getfe


From: logari81
Subject: [Getfem-commits] r5277 - in /trunk/getfem: contrib/icare/ src/ src/getfem/
Date: Sat, 02 Apr 2016 06:26:43 -0000

Author: logari81
Date: Sat Apr  2 08:26:42 2016
New Revision: 5277

URL: http://svn.gna.org/viewcvs/getfem?rev=5277&view=rev
Log:
some optimizations

Modified:
    trunk/getfem/contrib/icare/icare.cc
    trunk/getfem/src/bgeot_convex_structure.cc
    trunk/getfem/src/bgeot_mesh_structure.cc
    trunk/getfem/src/getfem/bgeot_convex_structure.h
    trunk/getfem/src/getfem/bgeot_geometric_trans.h
    trunk/getfem/src/getfem_mesh_fem.cc

Modified: trunk/getfem/contrib/icare/icare.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/contrib/icare/icare.cc?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/contrib/icare/icare.cc (original)
+++ trunk/getfem/contrib/icare/icare.cc Sat Apr  2 08:26:42 2016
@@ -1032,7 +1032,7 @@
   scalar_type BoxXmax =  PARAM.real_value("BOXXmax", "Particular Point xMax");
   scalar_type BoxYmin =  PARAM.real_value("BOXYmin", "Particular Point yMin");
   scalar_type BoxYmax =  PARAM.real_value("BOXYmax", "Particular Point yMax");
-  scalar_type BoxZmin, BoxZmax;
+  scalar_type BoxZmin(0), BoxZmax(0);
 
   if (N==3) {
     BoxZmin =  PARAM.real_value("BOXZmin", "Particular Point zMin");

Modified: trunk/getfem/src/bgeot_convex_structure.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_convex_structure.cc?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_convex_structure.cc  (original)
+++ trunk/getfem/src/bgeot_convex_structure.cc  Sat Apr  2 08:26:42 2016
@@ -50,6 +50,22 @@
     std::fill(faces.begin(),faces.end(), convex_ind_ct());
      dir_points_ = convex_ind_ct();
     nbpt = 0;
+  }
+
+  const convex_ind_ct &convex_structure::ind_common_points_of_faces
+  (const std::vector<short_type> &ftab) const {
+    auto it = intersection_points.find(ftab);
+    if (it == intersection_points.end()) {
+      std::vector<size_type> cpt(nb_points(), ftab.size());
+      for (short_type iff : ftab)
+        for (short_type i : ind_points_of_face(iff))
+          cpt[i]--;
+      convex_ind_ct ind;
+      for (size_type i = 0; i < nb_points(); ++i)
+        if (cpt[i] == 0) ind.push_back(i);
+      it = intersection_points.emplace(ftab, ind).first;
+    }
+    return it->second;
   }
 
   std::ostream &operator <<(std::ostream &o, const convex_structure &cv) {

Modified: trunk/getfem/src/bgeot_mesh_structure.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_mesh_structure.cc?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_mesh_structure.cc    (original)
+++ trunk/getfem/src/bgeot_mesh_structure.cc    Sat Apr  2 08:26:42 2016
@@ -230,23 +230,21 @@
 
 
   void mesh_structure::neighbours_of_convex(size_type ic,
-                                           const std::vector<short_type> &ftab,
-                                           ind_set &s) const {
+                                            const std::vector<short_type> 
&ftab,
+                                            ind_set &s) const {
     s.resize(0);
-    size_type nb = nb_points_of_convex(ic);
     const mesh_convex_structure &q = convex_tab[ic];
-    std::vector<size_type> cpt(nb, size_type(0)), ipt(nb);
-    for (short_type iff : ftab)
-      for (short_type i : q.cstruct->ind_points_of_face(iff))
-       cpt[i]++;
-    ipt.resize(0);
-    for (size_type i = 0; i < nb; ++i)
-      if (cpt[i] == ftab.size()) ipt.push_back(q.pts[i]);
-
-    for (size_type i = 0; i < points_tab[ipt[0]].size(); ++i) {
-      size_type icv = points_tab[ipt[0]][i];
-      if (icv != ic && is_convex_having_points(icv, short_type(ipt.size()),
-                                               ipt.begin())
+    const convex_ind_ct &ind = q.cstruct->ind_common_points_of_faces(ftab);
+    std::vector<size_type> ipts(ind.size());
+    auto it = ind.cbegin();
+    for (size_type &ipt : ipts) ipt = q.pts[*it++];
+
+    auto ipt0 = ipts.cbegin();
+    auto ipt1 = ipt0 + 1;
+    short_type nbpts(ipts.size()-1);
+    for (size_type icv : points_tab[*ipt0]) {
+      if (icv != ic &&
+          (nbpts == 0 || is_convex_having_points(icv, nbpts, ipt1))
           && (convex_tab[ic].cstruct->dim()==convex_tab[icv].cstruct->dim()))
         s.push_back(icv);
     }
@@ -292,7 +290,7 @@
     for (short_type iff = 0; iff < nNeighbourElementFaces; ++iff) {
       auto nPointsOnFace = pcs->nb_points_of_face(iff);
       if (is_convex_face_having_points(neighbour_element, iff,
-                                      nPointsOnFace, face_points.begin()))
+                                       nPointsOnFace, face_points.begin()))
         return {neighbour_element, iff};
     }
     GMM_ASSERT2(false, "failed to determine neighbouring face");

Modified: trunk/getfem/src/getfem/bgeot_convex_structure.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_convex_structure.h?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_convex_structure.h    (original)
+++ trunk/getfem/src/getfem/bgeot_convex_structure.h    Sat Apr  2 08:26:42 2016
@@ -82,14 +82,17 @@
 
     pconvex_structure prod_a, prod_b; /* only filled for convex structures */
                                       /* product.                          */
-    public :
-
-      /// Number of faces.
-      inline short_type nb_faces(void)  const { return nbf;  }
-      /// Dimension of the convex.
-      inline dim_type  dim(void)        const { return Nc;   }
-      /// Number of vertices.
-      inline short_type nb_points(void) const { return nbpt; }
+
+    mutable std::map<std::vector<short_type>, convex_ind_ct> 
intersection_points;
+
+  public :
+
+    /// Number of faces.
+    inline short_type nb_faces()  const { return nbf;  }
+    /// Dimension of the convex.
+    inline dim_type  dim()        const { return Nc;   }
+    /// Number of vertices.
+    inline short_type nb_points() const { return nbpt; }
     /** Number of vertices of a face.
      *  @param i the face number.
      */
@@ -101,6 +104,12 @@
      */
     inline const convex_ind_ct &ind_points_of_face(short_type i) const
     { return faces[i]; }
+    /** Give an array of the indexes of the vertices at the intersection
+     *  of a set of faces. The indexes are "local" to the convex.
+     *  @param i the face number.
+     */
+    const convex_ind_ct &
+    ind_common_points_of_faces(const std::vector<short_type> &ftab) const;
     /** Return "direct" points indexes. These are the subset of points that
      *  can be used to build a direct vector basis. (rarely used)
      */

Modified: trunk/getfem/src/getfem/bgeot_geometric_trans.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_geometric_trans.h?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_geometric_trans.h     (original)
+++ trunk/getfem/src/getfem/bgeot_geometric_trans.h     Sat Apr  2 08:26:42 2016
@@ -44,8 +44,6 @@
 #include "getfem/dal_naming_system.h"
 
 namespace bgeot {
-
-  typedef std::vector<short_type> convex_ind_ct;
 
   /**  Description of a geometric transformation between a
    * reference element and a real element.

Modified: trunk/getfem/src/getfem_mesh_fem.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh_fem.cc?rev=5277&r1=5276&r2=5277&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh_fem.cc (original)
+++ trunk/getfem/src/getfem_mesh_fem.cc Sat Apr  2 08:26:42 2016
@@ -341,8 +341,8 @@
       ftab.resize(nbd);
       for (size_type i = 0; i < nbd; ++i) ftab[i].resize(0);
       for (short_type f = 0; f < pf->structure(cv)->nb_faces(); ++f) {
-       for (short_type i : pf->structure(cv)->ind_points_of_face(f))
-         ftab[i].push_back(f);
+        for (short_type i : pf->structure(cv)->ind_points_of_face(f))
+          ftab[i].push_back(f);
       }
 
       for (size_type i = 0; i < nbd; i++) { // Loop on dofs
@@ -362,23 +362,23 @@
           nbdof += Qdim / pf->target_dim();
         } else {                            // For a standard linkable dof
           pgp->transform(linked_mesh().points_of_convex(cv), i, P);
-         size_type idof = nbdof;
-         if (ftab[i].size()) {
-           linked_mesh().neighbours_of_convex(cv, ftab[i], s);
-         
-           for (size_type ncv : s) { // For each neighbour
-                                     // control if the dof already exists.
-             fd.ind_node = dof_nodes[ncv].search_node(P);
-             if (fd.ind_node != size_type(-1)) {
-               auto it = dof_sorts[ncv].find(fd);
-               if (it != dof_sorts[ncv].end()) { idof = it->second; break; }
-             }
-           }
-         }
-         if (idof == nbdof) nbdof += Qdim / pf->target_dim();
-         itab[i] = idof;
-         fd.ind_node = dof_nodes[cv].add_node(P);
-         dof_sorts[cv][fd] = idof;
+          size_type idof = nbdof;
+          if (ftab[i].size()) {
+            linked_mesh().neighbours_of_convex(cv, ftab[i], s);
+          
+            for (size_type ncv : s) { // For each neighbour
+                                      // control if the dof already exists.
+              fd.ind_node = dof_nodes[ncv].search_node(P);
+              if (fd.ind_node != size_type(-1)) {
+                auto it = dof_sorts[ncv].find(fd);
+                if (it != dof_sorts[ncv].end()) { idof = it->second; break; }
+              }
+            }
+          }
+          if (idof == nbdof) nbdof += Qdim / pf->target_dim();
+          itab[i] = idof;
+          fd.ind_node = dof_nodes[cv].add_node(P);
+          dof_sorts[cv][fd] = idof;
         }
       }
       dof_structure.add_convex_noverif(pf->structure(cv), itab.begin(), cv);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]