getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] (no subject)


From: Konstantinos Poulios
Subject: [Getfem-commits] (no subject)
Date: Sat, 10 Nov 2018 07:07:42 -0500 (EST)

branch: fix-project-into-element
commit f054185836bce485b191ca6ec56f171f05f9ff0c
Author: Konstantinos Poulios <address@hidden>
Date:   Sat Nov 10 13:07:30 2018 +0100

    Let the tolerance sign determine if added points to a mesh are merged with 
existing ones or not
---
 src/bgeot_node_tab.cc       | 26 ++++++++++++--------------
 src/getfem/bgeot_mesh.h     | 14 +++++++++-----
 src/getfem/bgeot_node_tab.h |  9 ++++++---
 src/getfem_import.cc        |  5 +++--
 4 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/src/bgeot_node_tab.cc b/src/bgeot_node_tab.cc
index 6f85a72..28ef581 100644
--- a/src/bgeot_node_tab.cc
+++ b/src/bgeot_node_tab.cc
@@ -55,7 +55,8 @@ namespace bgeot {
 
   size_type node_tab::search_node(const base_node &pt,
                                   const scalar_type radius) const {
-    if (card() == 0) return size_type(-1);
+    if (card() == 0 || radius < 0.)
+      return size_type(-1);
 
     scalar_type eps_radius = std::max(eps, radius);
     for (size_type is = 0; is < 5; ++is) {
@@ -99,21 +100,18 @@ namespace bgeot {
     max_radius = std::max(max_radius, npt);
     eps = max_radius * prec_factor;
 
-    size_type id;
-    if (this->card() == 0) {
+    if (this->card() == 0)
       dim_ = pt.size();
-      id = dal::dynamic_tas<base_node>::add(pt);
-      for (size_type i = 0; i < sorters.size(); ++i) sorters[i].insert(id);
-    }
-    else {
+    else
       GMM_ASSERT1(dim_ == pt.size(), "Nodes should have the same dimension");
-      id = remove_duplicated_nodes ? search_node(pt, radius) : size_type(-1);
-      if (id == size_type(-1)) {
-        id = dal::dynamic_tas<base_node>::add(pt);
-        for (size_type i = 0; i < sorters.size(); ++i) {
-          sorters[i].insert(id);
-          GMM_ASSERT3(sorters[i].size() == card(), "internal error");
-        }
+    size_type id(-1);
+    if (remove_duplicated_nodes && radius >= 0.)
+      id = search_node(pt, radius);
+    if (id == size_type(-1)) {
+      id = dal::dynamic_tas<base_node>::add(pt);
+      for (size_type i = 0; i < sorters.size(); ++i) {
+        sorters[i].insert(id);
+        GMM_ASSERT3(sorters[i].size() == card(), "internal error");
       }
     }
     return id;
diff --git a/src/getfem/bgeot_mesh.h b/src/getfem/bgeot_mesh.h
index bdc4720..10b9119 100644
--- a/src/getfem/bgeot_mesh.h
+++ b/src/getfem/bgeot_mesh.h
@@ -106,15 +106,19 @@ namespace bgeot {
     /** Add the point pt to the mesh and return the index of the
         point.
 
-        If the point is too close to an existing point and 
remove_duplicated_nodes = true,
-        the function does not create a new point, and returns the index of the
-        already existing point.
-        @param pt the point coordinates.
+        If the point is within a radius tol from an existing point the
+        function does not create a new point, and returns the index of
+         the already existing point.
+        If tol is negative the check for nearby points is deactivated.
+        The same effect can be achieved by setting the deprecated
+        argument remove_duplicated_nodes to false.
+
+        @param pt holds the point coordinates.
     */
     size_type add_point(const base_node &pt,
                         const scalar_type tol=scalar_type(0),
                         bool remove_duplicated_nodes = true) {
-      return pts.add_node(pt, tol, remove_duplicated_nodes);
+      return pts.add_node(pt, remove_duplicated_nodes ? tol : -1.);
     }
 
     template<class ITER>
diff --git a/src/getfem/bgeot_node_tab.h b/src/getfem/bgeot_node_tab.h
index 66a924c..d78c488 100644
--- a/src/getfem/bgeot_node_tab.h
+++ b/src/getfem/bgeot_node_tab.h
@@ -80,9 +80,12 @@ namespace bgeot {
        or size_type(-1) otherwise.
     */
     size_type search_node(const base_node &pt, const scalar_type radius=0) 
const;
-    /** Add a point to the array or identify it with a very close existing
-       point. If remove_duplicated_nodes = false, the identification of close 
existing points will be
-    omitted and the point simply added to the array.
+    /** Add a point to the array or use an existing point, located within
+        a distance smaller than radius. If radius is negative, the detection
+        of proximate existing points will be skipped and the point will simply
+        be added to the array.
+        The optional argument remove_duplicated_nodes is deprecated. Setting it
+        to false has the same effect as passing a negative value to radius.
     */
     size_type add_node(const base_node &pt, const scalar_type radius=0,
                        bool remove_duplicated_nodes = true);
diff --git a/src/getfem_import.cc b/src/getfem_import.cc
index bdfc853..12800a9 100644
--- a/src/getfem_import.cc
+++ b/src/getfem_import.cc
@@ -274,7 +274,8 @@ namespace getfem {
       size_type node_id;
       base_node n(3); n[0]=n[1]=n[2]=0.0;
       f >> node_id >> n[0] >> n[1] >> n[2];
-      msh_node_2_getfem_node[node_id] = m.add_point(n, 0.0, 
remove_duplicated_nodes);
+      msh_node_2_getfem_node[node_id]
+        = m.add_point(n, remove_duplicated_nodes ? 0. : -1.);
     }
 
     if (version == 2)
@@ -849,7 +850,7 @@ namespace getfem {
       for (size_type j=0; j < 3; ++j, pos += fieldwidth2)
         pt[j] = std::stod(line.substr(pos, fieldwidth2));
 
-      cdb_node_2_getfem_node[nodeid] = m.add_point(pt, 0., false);
+      cdb_node_2_getfem_node[nodeid] = m.add_point(pt, -1.);
     }
 
     while (bgeot::casecmp(line.substr(0,6),"EBLOCK") != 0) {



reply via email to

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