getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] (no subject)


From: Yves Renard
Subject: [Getfem-commits] (no subject)
Date: Fri, 26 May 2017 04:31:17 -0400 (EDT)

branch: devel-yves
commit 90375bac19595ba8a290a6d91b2a7d9d7f0282e8
Author: Yves Renard <address@hidden>
Date:   Fri May 26 10:08:12 2017 +0200

    Introducing gmm::vref(const std::vector<T> &) for cout std::vector in 
replacement of the overload of << operator which induces some conflicts
---
 src/bgeot_sparse_tensors.cc      |  6 +--
 src/getfem/bgeot_config.h        |  3 +-
 src/getfem/bgeot_tensor.h        |  2 +-
 src/getfem/getfem_config.h       |  3 +-
 src/getfem_assembling_tensors.cc |  9 ++--
 src/getfem_integration.cc        | 99 ++++++++++++++++++++++++----------------
 src/gmm/gmm_interface.h          | 11 +++--
 7 files changed, 77 insertions(+), 56 deletions(-)

diff --git a/src/bgeot_sparse_tensors.cc b/src/bgeot_sparse_tensors.cc
index 0651668..0ac040b 100644
--- a/src/bgeot_sparse_tensors.cc
+++ b/src/bgeot_sparse_tensors.cc
@@ -628,9 +628,9 @@ namespace bgeot {
       cout << "  pri[" << int(i) << "]: n=" << int(pri[i].n) 
            << ", range=" << pri[i].range << ", mean_increm=" 
            << pri[i].mean_increm << ", regular = " << 
pri[i].have_regular_strides 
-           << ", inc=" << pri[i].inc << "\n";
-    cout << "bloc_rank: " << bloc_rank << ", bloc_nelt: " << bloc_nelt << 
"\n";    
-    cout << "vectorized_size : " << vectorized_size_ << ", strides = " << 
vectorized_strides_ << ", pr_dim=" << vectorized_pr_dim << "\n";
+           << ", inc=" << vref(pri[i].inc) << "\n";
+    cout << "bloc_rank: " << vref(bloc_rank) << ", bloc_nelt: " << 
vref(bloc_nelt) << "\n";    
+    cout << "vectorized_size : " << vectorized_size_ << ", strides = " << 
vref(vectorized_strides_) << ", pr_dim=" << vectorized_pr_dim << "\n";
   }
 
   void tensor_reduction::insert(const tensor_ref& tr_, const std::string& s) {
diff --git a/src/getfem/bgeot_config.h b/src/getfem/bgeot_config.h
index 8ff645e..66a367b 100644
--- a/src/getfem/bgeot_config.h
+++ b/src/getfem/bgeot_config.h
@@ -72,8 +72,7 @@ namespace bgeot {
 
   using std::endl; using std::cout; using std::cerr;
   using std::ends; using std::cin;
-  template <typename T> std::ostream &operator <<
-  (std::ostream &o, const std::vector<T>& m) { gmm::write(o,m); return o; }
+  using gmm::vref;
 
   static const size_t ST_NIL = size_t(-1);
   typedef gmm::uint16_type dim_type;
diff --git a/src/getfem/bgeot_tensor.h b/src/getfem/bgeot_tensor.h
index d21b5ec..85cc71c 100644
--- a/src/getfem/bgeot_tensor.h
+++ b/src/getfem/bgeot_tensor.h
@@ -544,7 +544,7 @@ namespace bgeot {
 
   template<class T> std::ostream &operator <<
     (std::ostream &o, const tensor<T>& t) {
-    o << "sizes " << t.sizes() << " " << t.as_vector();
+    o << "sizes " << t.sizes() << " " << vref(t.as_vector());
     return o;
   }
 
diff --git a/src/getfem/getfem_config.h b/src/getfem/getfem_config.h
index 666930b..978c100 100644
--- a/src/getfem/getfem_config.h
+++ b/src/getfem/getfem_config.h
@@ -218,8 +218,7 @@ namespace getfem {
 
   using std::endl; using std::cout; using std::cerr;
   using std::ends; using std::cin;
-  template <typename T> std::ostream &operator <<
-  (std::ostream &o, const std::vector<T>& m) { gmm::write(o,m); return o; }
+  using gmm::vref;
 
 #if GETFEM_PARA_LEVEL > 1
   template <typename T> inline T MPI_SUM_SCALAR(T a) {
diff --git a/src/getfem_assembling_tensors.cc b/src/getfem_assembling_tensors.cc
index ed51942..b7c4bc8 100644
--- a/src/getfem_assembling_tensors.cc
+++ b/src/getfem_assembling_tensors.cc
@@ -280,9 +280,8 @@ namespace getfem {
       if ((shape_updated_ = child(0).is_shape_updated())) {
         if (reorder.size() != child(0).ranges().size())
           ASM_THROW_TENSOR_ERROR("can't reorder tensor '" << name()
-          << "' of dimensions " 
-          << child(0).ranges() << 
-          " with this permutation: " << reorder);
+                                << "' of dimensions " << child(0).ranges() << 
+                                " with this permutation: " << vref(reorder));
         r_.resize(reorder.size());
         std::fill(r_.begin(), r_.end(), dim_type(-1));
 
@@ -1462,9 +1461,9 @@ namespace getfem {
       }
       if (check_permut.first_false() != reorder.size()) {
         cerr << check_permut << endl;
-        cerr << reorder << endl;
+        cerr << vref(reorder) << endl;
         ASM_THROW_PARSE_ERROR("you did not give a real permutation:"
-          << reorder);
+                             << vref(reorder));
       }
       t = tnode(record(std::make_unique<ATN_permuted_tensor>(*t.tensor(), 
reorder)));
     }
diff --git a/src/getfem_integration.cc b/src/getfem_integration.cc
index 0921369..475ad31 100644
--- a/src/getfem_integration.cc
+++ b/src/getfem_integration.cc
@@ -830,57 +830,75 @@ namespace getfem {
   struct quasi_polar_integration : public approx_integration {
     quasi_polar_integration(papprox_integration base_im, 
                            size_type ip1, size_type ip2=size_type(-1)) : 
-      approx_integration(bgeot::simplex_of_reference(base_im->dim()))  {
+      approx_integration
+      ((base_im->structure() == bgeot::parallelepiped_structure(3)) ?
+       bgeot::pyramidal_element_of_reference(base_im->dim())
+       : bgeot::simplex_of_reference(base_im->dim()))  {
       size_type N = base_im->dim();
 
-      enum { SQUARE, PRISM, PYRAMID, PRISM2 } what;
+      enum { SQUARE, PRISM, TETRA_CYL, PRISM2, PYRAMID } what;
       if (N == 2) what = SQUARE;
       else if (base_im->structure() == bgeot::prism_structure(3))
        what = (ip2 == size_type(-1) || ip1 == ip2) ? PRISM2 : PRISM;
       else if (base_im->structure() == bgeot::simplex_structure(3))
+       what = TETRA_CYL;
+      else if (base_im->structure() == bgeot::parallelepiped_structure(3))
        what = PYRAMID;
       else GMM_ASSERT1(false, "Incoherent integration method");
 
       // The first geometric transformation collapse a face of
-      // a parallelepiped.
+      // a parallelepiped or collapse a parrallelepiped on a pyramid.
       // The second geometric transformation chooses the orientation.
-      // The third is used for the PYRAMID case only.
+      // The third is used for the TETRA_CYL case only.
       bgeot::pgeometric_trans pgt1 = bgeot::parallelepiped_geotrans(N,1);
+      std::vector<base_node> nodes1 = pgt1->convex_ref()->points();
       bgeot::pgeometric_trans pgt2 = bgeot::simplex_geotrans(N, 1);
+      std::vector<base_node> nodes2(N+1);
+      std::vector<size_type> other_nodes; // for the construction of node2
       bgeot::pgeometric_trans pgt3 = bgeot::simplex_geotrans(N, 1);
-      std::vector<base_node> nodes1 = pgt1->convex_ref()->points();
-      std::vector<base_node> nodes2(N+1), nodes3(N+1);
-      std::vector<size_type> other_nodes;
+      std::vector<base_node> nodes3(N+1);
 
       switch (what) {
-       case SQUARE :
-         nodes1[3] = nodes1[1];
-         nodes2[ip1] = nodes1[1]; ip2 = ip1;
-         other_nodes.push_back(0);
-         other_nodes.push_back(2);
-         break;
-       case PRISM :
-         nodes1[4] = nodes1[0]; nodes1[5] = nodes1[1];
-         nodes2[ip1] = nodes1[0];
-         nodes2[ip2] = nodes1[1];
-         other_nodes.push_back(2);
-         other_nodes.push_back(6);
-         break;
-       case PYRAMID :
-         nodes3[0] = nodes1[0]; nodes3[1] = nodes1[1];
-         nodes3[2] = nodes1[2]; nodes3[3] = nodes1[4];
-         // nodes1[4] = nodes1[0]; nodes1[7] = base_node(1.0, 1.0, 2.0);
-         nodes2[ip1] = nodes1[1]; ip2 = ip1;
-         other_nodes.push_back(0);
-         other_nodes.push_back(2);
-         other_nodes.push_back(4);
-         break;
-       case PRISM2 :
-         nodes2[ip1] = nodes1[4];
-         other_nodes.push_back(0);
-         other_nodes.push_back(1);
-         other_nodes.push_back(2);
-         break;
+      case SQUARE :
+       nodes1[3] = nodes1[1];
+       nodes2[ip1] = nodes1[1]; ip2 = ip1;
+       other_nodes.push_back(0);
+       other_nodes.push_back(2);
+       break;
+      case PRISM :
+       nodes1[4] = nodes1[0]; nodes1[5] = nodes1[1];
+       nodes2[ip1] = nodes1[0];
+       nodes2[ip2] = nodes1[1];
+       other_nodes.push_back(2);
+       other_nodes.push_back(6);
+       break;
+      case TETRA_CYL :
+       nodes3[0] = nodes1[0]; nodes3[1] = nodes1[1];
+       nodes3[2] = nodes1[2]; nodes3[3] = nodes1[4];
+       // nodes1[4] = nodes1[0]; nodes1[7] = base_node(1.0, 1.0, 2.0);
+       nodes2[ip1] = nodes1[1]; ip2 = ip1;
+       other_nodes.push_back(0);
+       other_nodes.push_back(2);
+       other_nodes.push_back(4);
+       break;
+      case PRISM2 :
+       nodes2[ip1] = nodes1[4];
+       other_nodes.push_back(0);
+       other_nodes.push_back(1);
+       other_nodes.push_back(2);
+       break;
+      case PYRAMID :
+       ip2 = ip1 = 0; // ?
+       nodes2[ip1] = nodes1[4];  // ?
+       other_nodes.push_back(0); // ?
+       other_nodes.push_back(1); // ?
+       other_nodes.push_back(2); // ?
+       nodes1[0] =  base_node(-1.,-1., 0.);
+       nodes1[1] =  base_node( 1.,-1., 0.);
+       nodes1[2] =  base_node(-1., 1., 0.);
+       nodes1[3] =  base_node( 1., 1., 0.);
+       nodes1[4] =  base_node( 0., 0., 1.);
+       nodes1[5] =  nodes1[6] = nodes1[7] =  nodes1[4];
       }
 
       for (size_type i = 0; i <= N; ++i)
@@ -890,7 +908,8 @@ namespace getfem {
          other_nodes.pop_back();
        }
 
-      //cout << "nodes2 = " << nodes2 << endl;
+      cout << "nodes1 = " << vref(nodes1) << endl;
+      cout << "nodes2 = " << vref(nodes2) << endl;
 
       base_matrix G1, G2, G3; 
       base_matrix K(N, N), grad(N, N), K3(N, N), K4(N, N);
@@ -903,7 +922,7 @@ namespace getfem {
 
       for (size_type nc = 0; nc < 2; ++nc) {
        
-       if (what == PYRAMID) {
+       if (what == TETRA_CYL) {
          if (nc == 1) nodes3[0] = nodes1[3];
          bgeot::vectors_to_base_matrix(G3, nodes3);
          pgt3->poly_vector_grad(nodes1[0], grad);
@@ -926,7 +945,7 @@ namespace getfem {
          }
 
          base_node P = base_im->point(i);
-         if (what == PYRAMID) { 
+         if (what == TETRA_CYL) { 
            P = pgt3->transform(P, nodes3);
            scalar_type x = P[0], y = P[1], one_minus_z = 1.0 - P[2];
            K4(0, 1) = - y / one_minus_z;
@@ -950,7 +969,7 @@ namespace getfem {
          J1 = gmm::abs(gmm::lu_det(K)) * J3 * J4;
 
          if (fp != size_type(-1) && J1 > 1E-10 && J4 > 1E-10) {
-           if (what == PYRAMID) {
+           if (what == TETRA_CYL) {
              gmm::mult(K3, normal1, normal2);
              normal1 = normal2;
            }
@@ -988,7 +1007,7 @@ namespace getfem {
            // else { cout << "Point " << P2 << " eliminated" << endl; }
          }  
        }
-       if (what != PYRAMID) break;
+       if (what != TETRA_CYL) break;
       }
       valid_method();
     }
diff --git a/src/gmm/gmm_interface.h b/src/gmm/gmm_interface.h
index c89ff57..a3c66cd 100644
--- a/src/gmm/gmm_interface.h
+++ b/src/gmm/gmm_interface.h
@@ -194,6 +194,12 @@ namespace gmm {
   std::ostream &operator << (std::ostream &o, const simple_vector_ref<PT>& v)
   { gmm::write(o,v); return o; }
 
+  template <typename T, typename alloc>
+  simple_vector_ref<const std::vector<T,alloc> *>
+    vref(const std::vector<T, alloc> &vv)
+  { return simple_vector_ref<const std::vector<T,alloc> *>(vv); }
+  
+
   /* ********************************************************************* */
   /*                                                                      */
   /*           Traits for S.T.L. object                                   */
@@ -231,9 +237,8 @@ namespace gmm {
     static void resize(this_type &v, size_type n) { v.resize(n); }
   };
 
-  template <typename T> std::ostream &operator <<
-  (std::ostream &o, const std::vector<T>& m) { gmm::write(o,m); return o; }
-
+  
+  
   template <typename T>
   inline size_type nnz(const std::vector<T>& l) { return l.size(); }
 



reply via email to

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