getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] [getfem-commits] branch master updated: small fix on gm


From: Yves Renard
Subject: [Getfem-commits] [getfem-commits] branch master updated: small fix on gmsh import of N-2 dimensional elements
Date: Sun, 15 Nov 2020 08:05:41 -0500

This is an automated email from the git hooks/post-receive script.

renard pushed a commit to branch master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
     new fe24d85  small fix on gmsh import of N-2 dimensional elements
fe24d85 is described below

commit fe24d85399dbbd253ac76902bb771eed035fb815
Author: Yves Renard <Yves.Renard@insa-lyon.fr>
AuthorDate: Sun Nov 15 14:05:30 2020 +0100

    small fix on gmsh import of N-2 dimensional elements
---
 src/getfem_import.cc | 67 ++++++++++++++++++++++++++--------------------------
 1 file changed, 33 insertions(+), 34 deletions(-)

diff --git a/src/getfem_import.cc b/src/getfem_import.cc
index ce0b377..4ee7fb4 100644
--- a/src/getfem_import.cc
+++ b/src/getfem_import.cc
@@ -220,14 +220,14 @@ namespace getfem {
      for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh
      if remove_last_dimension == true the z-component of nodes will be removed
   */
-  static void import_gmsh_mesh_file(std::istream& f, mesh& m, int deprecate=0,
-                                    std::map<std::string, size_type> 
*region_map=NULL,
-                                    std::set<size_type> 
*lower_dim_convex_rg=NULL,
-                                    bool add_all_element_type = false,
-                                    bool remove_last_dimension = true,
-                                    std::map<size_type, std::set<size_type>> 
*nodal_map = NULL,
-                                    bool remove_duplicated_nodes = true)
-  {
+  static void import_gmsh_mesh_file
+  (std::istream& f, mesh& m, int deprecate=0,
+   std::map<std::string, size_type> *region_map=NULL,
+   std::set<size_type> *lower_dim_convex_rg=NULL,
+   bool add_all_element_type = false,
+   bool remove_last_dimension = true,
+   std::map<size_type, std::set<size_type>> *nodal_map = NULL,
+   bool remove_duplicated_nodes = true) {
     gmm::stream_standard_locale sl(f);
     // /* print general warning */
     // GMM_WARNING3("  All regions must have different number!");
@@ -545,7 +545,7 @@ namespace getfem {
     nb_cv = cvlst.size();
     if (cvlst.size()) {
       std::sort(cvlst.begin(), cvlst.end());
-      if (cvlst.front().type == 15){
+      if (cvlst.front().type == 15) {
         GMM_WARNING2("Only nodes defined in the mesh! No elements are added.");
         return;
       }
@@ -556,8 +556,8 @@ namespace getfem {
         gmsh_cv_info &ci = cvlst[cv];
         bool is_node = (ci.type == 15);
         unsigned ci_dim = (is_node) ? 0 : ci.pgt->dim();
-        //cout << "importing cv dim=" << int(ci.pgt->dim()) << " N=" << N
-        //     << " region: " << ci.region << "\n";
+        //  cout << "importing cv dim=" << ci_dim << " N=" << N
+        //       << " region: " << ci.region << " type: " << ci.type << "\n";
 
         //main convex import
         if (ci_dim == N) {
@@ -571,49 +571,48 @@ namespace getfem {
           //convex that lies within the regions of lower_dim_convex_rg
           //is imported explicitly as a convex.
           if (lower_dim_convex_rg != NULL &&
-              lower_dim_convex_rg->find(ci.region) != 
lower_dim_convex_rg->end() &&
-              !is_node){
-              size_type ic = m.add_convex(ci.pgt, ci.nodes.begin()); cvok = 
true;
-              m.region(ci.region).add(ic);
+              lower_dim_convex_rg->find(ci.region) != 
lower_dim_convex_rg->end()
+              && !is_node) {
+              size_type ic = m.add_convex(ci.pgt, ci.nodes.begin());
+              cvok = true; m.region(ci.region).add(ic);
           }
           //find if the convex is part of a face of higher dimension convex
           else{
-            bgeot::mesh_structure::ind_cv_ct ct = 
m.convex_to_point(ci.nodes[0]);
+            bgeot::mesh_structure::ind_cv_ct ct=m.convex_to_point(ci.nodes[0]);
             for (bgeot::mesh_structure::ind_cv_ct::const_iterator
                    it = ct.begin(); it != ct.end(); ++it) {
-              for (short_type face=0;
-                   face < m.structure_of_convex(*it)->nb_faces(); ++face) {
-                if (m.is_convex_face_having_points(*it,face,
-                                                   short_type(ci.nodes.size()),
-                                                   ci.nodes.begin())) {
-                  m.region(ci.region).add(*it,face);
-                  cvok = true;
+              if (m.structure_of_convex(*it)->dim() == ci_dim + 1) {
+                for (short_type face=0;
+                     face < m.structure_of_convex(*it)->nb_faces(); ++face) {
+                  if (m.is_convex_face_having_points(*it, face,
+                                                    
short_type(ci.nodes.size()),
+                                                    ci.nodes.begin())) {
+                    m.region(ci.region).add(*it,face);
+                    cvok = true;
+                  }
                 }
               }
             }
-            if (is_node && (nodal_map != NULL))
-            {
+            if (is_node && (nodal_map != NULL)) {
               for (auto i : ci.nodes) (*nodal_map)[ci.region].insert(i);
             }
-            //if the convex is not part of the face of others
-            if (!cvok)
-            {
-              if (is_node)
-              {
+            // if the convex is not part of the face of others
+            if (!cvok) {
+              if (is_node) {
                 if (nodal_map == NULL){
                   GMM_WARNING2("gmsh import ignored a node id: "
                                << ci.id << " region :" << ci.region <<
                                " point is not added explicitly as an 
element.");
                 }
               }
-              else if (add_all_element_type){
+              else if (add_all_element_type) {
                 size_type ic = m.add_convex(ci.pgt, ci.nodes.begin());
                 m.region(ci.region).add(ic);
                 cvok = true;
-              } else{
+              } else {
                 GMM_WARNING2("gmsh import ignored an element of type "
-                  << bgeot::name_of_geometric_trans(ci.pgt) <<
-                  " as it does not belong to the face of another element");
+                             << bgeot::name_of_geometric_trans(ci.pgt) <<
+                    " as it does not belong to the face of another element");
               }
             }
           }



reply via email to

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