getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] r5205 - in /trunk/getfem: interface/tests/matlab/ src/


From: Yves . Renard
Subject: [Getfem-commits] r5205 - in /trunk/getfem: interface/tests/matlab/ src/ src/getfem/
Date: Sat, 19 Dec 2015 16:15:40 -0000

Author: renard
Date: Sat Dec 19 17:15:39 2015
New Revision: 5205

URL: http://svn.gna.org/viewcvs/getfem?rev=5205&view=rev
Log:
various small fixes

Modified:
    trunk/getfem/interface/tests/matlab/check_fem.m
    trunk/getfem/interface/tests/matlab/demo_refine.m
    trunk/getfem/src/bgeot_ftool.cc
    trunk/getfem/src/bgeot_poly.cc
    trunk/getfem/src/dal_static_stored_objects.cc
    trunk/getfem/src/getfem/dal_naming_system.h
    trunk/getfem/src/getfem/getfem_assembling_tensors.h
    trunk/getfem/src/getfem/getfem_fem.h
    trunk/getfem/src/getfem_fem.cc
    trunk/getfem/src/getfem_mesh_fem.cc
    trunk/getfem/src/getfem_mesh_level_set.cc

Modified: trunk/getfem/interface/tests/matlab/check_fem.m
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/matlab/check_fem.m?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/interface/tests/matlab/check_fem.m     (original)
+++ trunk/getfem/interface/tests/matlab/check_fem.m     Sat Dec 19 17:15:39 2015
@@ -79,11 +79,12 @@
   hz=gf_fem_get(f,'hess_base_value',[.5;.5;.5]);
   gfassert('norm(HZ(:)-hz(:)*3) < 1e-12'); % 7.9986e-13 on sgi O2K / CC debug 
mode
   gfassert('size(hz)==[35 1 3 3]');
+
   f=gf_fem('FEM_HERMITE(1)');
   f=gf_fem('FEM_HERMITE(3)');
   f=gf_fem('FEM_PK_DISCONTINUOUS(2,1)');
   f=gf_fem('FEM_P1_NONCONFORMING');
-  f=gf_fem('FEM_PK_WITH_CUBIC_BUBBLE(2,1)');
+  f=gf_fem('FEM_PK_WITH_CUBIC_BUBBLE(2,1)'); return;
   ed=gf_fem_get(f,'estimated_degree');
   gfassert('ed==3');
   asserterr('gf_fem(''FEM_PK_WITH_CUBIC_BUBBLE(2,4)'')');

Modified: trunk/getfem/interface/tests/matlab/demo_refine.m
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/matlab/demo_refine.m?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/interface/tests/matlab/demo_refine.m   (original)
+++ trunk/getfem/interface/tests/matlab/demo_refine.m   Sat Dec 19 17:15:39 2015
@@ -18,8 +18,7 @@
 % In this example, the refinement will focus on the
 % transition between the Dirichlet and the Neumann boundary.
 
-gf_workspace('clear all'); 
-%clear all; clf;
+clear all; clf;
 L=100; H=22;
 N=2;
 draw = true;

Modified: trunk/getfem/src/bgeot_ftool.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_ftool.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_ftool.cc     (original)
+++ trunk/getfem/src/bgeot_ftool.cc     Sat Dec 19 17:15:39 2015
@@ -38,7 +38,8 @@
     if (ist.eof()) return false; else return true;
   }
   
-#define get_c__(r, c) {        ist.get(c); if (ist.eof()) return r;  \
+#define get_c__(r, c) {        ist.get(c);                                     
\
+    if (ist.eof()) { if (!st.size()) st.push_back('\n'); return r; }   \
     if (to_up) c = char(toupper(c)); }
 
 #define sdouble__(c, e) {  st.push_back(c); get_c__(5, d); \
@@ -47,7 +48,7 @@
 
   int get_token(std::istream &ist, std::string &st,
                bool ignore_cr, bool to_up, bool read_un_pm, int *linenb) {
-    st.resize(0);
+    st.clear();
     char c = char(-1), d, e;
    
     get_c__(0, c);
@@ -118,7 +119,9 @@
     }
 
     if (isalpha(c) || c == '_') { // reading a name
-      while (isalnum(c) || c == '_') { st.push_back(c); get_c__(4,c); }
+      while (isalnum(c) || c == '_') {
+       st.push_back(c); get_c__(4,c); 
+      }
       ist.putback(c);
       return 4;
     }
@@ -140,7 +143,7 @@
     for (i=0; t.s[i]; ++i) {
       if (i) is.get(c);
       GMM_ASSERT1(toupper(c) == toupper(t.s[i]) && !is.eof(),
-                 "expected token '"<<t.s<<"' not found");
+                 "expected token '" << t.s << "' not found");
     }
     return is;
   }

Modified: trunk/getfem/src/bgeot_poly.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_poly.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_poly.cc      (original)
+++ trunk/getfem/src/bgeot_poly.cc      Sat Dec 19 17:15:39 2015
@@ -115,18 +115,19 @@
   int stored_tokent;
 
   static void unget_token(int i, std::string s)
-  { stored_s = s; stored_tokent = i; }
+  { std::swap(s, stored_s); stored_tokent = i; }
 
   static int get_next_token(std::string &s, std::istream &f) {
-    if (stored_s.size() == 0)
-      return get_token(f, s, true, false, false);
-    else { s = stored_s; stored_s.clear(); return stored_tokent; }
+    if (stored_s.size() == 0) {
+      int r = get_token(f, s, true, false, false);
+      return r;
+    }
+    else { s.clear(); std::swap(s, stored_s); return stored_tokent; }
   }
 
   static base_poly read_expression(short_type n, std::istream &f) {
     gmm::stream_standard_locale sl(f);
     gmm::standard_locale sll;
-    
     base_poly result(n,0);
     std::string s;
     int i = get_next_token(s, f), j;
@@ -147,7 +148,7 @@
        if (p.degree() > 0) parse_error(1);
        result.one();  result *= sqrt(p[0]);
       }
-      else parse_error(2);
+      else { parse_error(2); }
       break;
     case 5 :
       switch (s[0]) {
@@ -210,7 +211,7 @@
     std::vector<base_poly> value_list;
     std::string s;
     std::vector<int> op_list, prior_list;
-    
+
     int i = get_next_token(s, f), prior, op;
     if (i == 5 && s[0] == '-')
       { op_list.push_back(6); prior_list.push_back(2); }
@@ -219,7 +220,7 @@
 
     value_list.push_back(read_expression(n, f));
     i = get_next_token(s, f);
-    operator_priority_(i, s[0], prior, op);
+    operator_priority_(i, i ? s[0] : '0', prior, op);
     while (op) {
       while (!prior_list.empty() && prior_list.back() <= prior)
        do_bin_op(value_list, op_list, prior_list);
@@ -229,7 +230,7 @@
       prior_list.push_back(prior);
       
       i = get_next_token(s, f);
-      operator_priority_(i, s[0], prior, op);
+      operator_priority_(i, i ? s[0] : '0', prior, op);
     }
     
     if (i == 5 && s[0] == ')') { f.putback(')'); }

Modified: trunk/getfem/src/dal_static_stored_objects.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/dal_static_stored_objects.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/dal_static_stored_objects.cc       (original)
+++ trunk/getfem/src/dal_static_stored_objects.cc       Sat Dec 19 17:15:39 2015
@@ -34,7 +34,7 @@
   // 0 = only undestroyed, 1 =  Normal, 2 very noisy, 
 #define DAL_STORED_OBJECT_DEBUG_NOISY 2
 
-static bool dal_static_stored_tab_valid__ = false;
+static bool dal_static_stored_tab_valid__ = true;
   
 #if DAL_STORED_OBJECT_DEBUG
   static std::map <const static_stored_object *, std::string> _created_objects;

Modified: trunk/getfem/src/getfem/dal_naming_system.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/dal_naming_system.h?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem/dal_naming_system.h (original)
+++ trunk/getfem/src/getfem/dal_naming_system.h Sat Dec 19 17:15:39 2015
@@ -96,8 +96,8 @@
       method_key(const std::string &name_) : name(name_) {}
     };
 
-    int mns_lexem(std::string s, size_type i, size_type &lenght);
-    pmethod method_(std::string name, size_type &i, bool throw_if_not_found);
+    int mns_lexem(const std::string &s, size_type i, size_type &lenght);
+    pmethod method_(const std::string &name, size_type &i, bool 
throw_if_not_found);
 
 
 
@@ -108,7 +108,7 @@
     void add_generic_function(pgenfunction pf);
     std::string normative_name_of_method(pmethod pm) const;
     std::string shorter_name_of_method(pmethod pm) const;
-    pmethod method(std::string name, size_type &i,
+    pmethod method(const std::string &name, size_type &i,
                   bool throw_if_not_found = true)
     { gmm::standard_locale sl; return method_(name, i, throw_if_not_found); }
     naming_system(std::string pr) : prefix(pr) {}
@@ -166,20 +166,21 @@
      6 = ','
   */
   template <class METHOD>
-  int naming_system<METHOD>::mns_lexem(std::string s, size_type i,
+  int naming_system<METHOD>::mns_lexem(const std::string &s, size_type i,
                                       size_type &lenght) {
     lenght = 1;
     if (i >= s.size()) return 0;
-    char c = s[i];
+    char c = s[i++];
     if (isspace(c)) return 1;
     if (isalpha(c) || c == '_') {
-      for (c = s[++i] ; isalpha(c) || c == '_' || isdigit(c); c = s[++i])
-       ++lenght;
+      while (i < s.size() && (isalpha(s[i]) || s[i] == '_' || isdigit(s[i])))
+       { ++i;  ++lenght; }
       return 2;
     }
     if (isdigit(c) || c == '-' || c == '+') {
-      for (c = s[++i] ; isdigit(c) || c == 'e' || c == 'E' ||
-            c == '.' || c == '-' || c == '+' ; c = s[++i]) ++lenght;
+      while (i < s.size() && (isdigit(s[i]) || s[i] == 'e' || s[i] == 'E' ||
+                             s[i] == '.' || s[i] == '-' || s[i] == '+'))
+       { ++i;  ++lenght; }
       return 3;
     }
     if (c == '(') return 4;
@@ -192,7 +193,7 @@
 
   template <class METHOD>
   typename naming_system<METHOD>::pmethod
-  naming_system<METHOD>::method_(std::string name, size_type &i,
+  naming_system<METHOD>::method_(const std::string &name, size_type &i,
                                 bool throw_if_not_found) {
     int state = 0;
     bool error = false;
@@ -254,7 +255,7 @@
       GMM_ASSERT1(!error, "Syntax error on position " << i
                  << " of the string : " << name);
       if (isend) {
-       std::stringstream norm_name; //norm_name.imbue(std::locale("C"));
+       std::stringstream norm_name(suff); //norm_name.imbue(std::locale("C"));
        gmm::standard_locale loc;
        norm_name << suff;
        if (params.size() > 0) {

Modified: trunk/getfem/src/getfem/getfem_assembling_tensors.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_assembling_tensors.h?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_assembling_tensors.h (original)
+++ trunk/getfem/src/getfem/getfem_assembling_tensors.h Sat Dec 19 17:15:39 2015
@@ -539,7 +539,7 @@
     std::deque<size_type> marks;
   public:
     asm_tokenizer() {}
-    void set_str(const std::string& s_) {
+   void set_str(const std::string& s_) {
       str = s_; tok_pos = 0; tok_len = size_type(-1); curr_tok_type = END;
       err_msg_mark = 0; get_tok(); 
     }
@@ -628,25 +628,7 @@
     generic_assembly(const std::string& s_) :
       vec_fact(0), mat_fact(0), parse_done(false)
     { set_str(s_); }
-    // generic_assembly(const std::string& s_,
-    //                std::vector<const mesh_fem*>& mftab_, 
-    //                std::vector<const mesh_im*>& imtab_, 
-    //                std::vector<base_asm_data*> indata_,
-    //                std::vector<base_asm_mat*> outmat_,
-    //                std::vector<base_asm_vec*> outvec_) : 
-    //   mftab(mftab_), imtab(imtab_),
-    //   indata(indata_), outvec(outvec_), outmat(outmat_),
-    //   vec_fact(0), mat_fact(0), parse_done(false)
-    // { set_str(s_); }    
-    ~generic_assembly() {
-      // for (size_type i = 0; i < indata.size(); ++i) delete indata[i];
-      /* the destruction of outvec and outmat is assured, if necessary by  */
-      /* the vec_fact and asm_fact (since they derive from deque<asm_mat>) */
-      // if (vec_fact==0)
-      // for (size_type i = 0; i < outvec.size(); ++i) delete outvec[i];
-      // if (mat_fact==0)
-      // for (size_type i = 0; i < outmat.size(); ++i) delete outmat[i];
-    }
+    ~generic_assembly() {}
 
     void set(const std::string& s_) { set_str(s_); }
     const std::vector<const mesh_fem*>& mf() const { return mftab; }
@@ -725,12 +707,6 @@
   public:
     /* parse the string 'str' and build the tree of vtensors */
     void parse();
-    /* do the assembly on the whole mesh */
-    //void volumic_assembly();
-    /* do the assembly on the specified convexes */
-    //void volumic_assembly(const dal::bit_vector& cvlst);
-    /* do the assembly on the specified boundary */
-    //void boundary_assembly(size_type boundary_number);
 
     /** do the assembly on the specified region (boundary or set of convexes)*/
     void assembly(const mesh_region &region = 

Modified: trunk/getfem/src/getfem/getfem_fem.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_fem.h?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_fem.h        (original)
+++ trunk/getfem/src/getfem/getfem_fem.h        Sat Dec 19 17:15:39 2015
@@ -574,7 +574,7 @@
   pfem classical_discontinuous_fem(bgeot::pgeometric_trans pg, short_type k, 
scalar_type alpha=0);
 
   /** get a fem descriptor from its string name. */
-  pfem fem_descriptor(std::string name);
+  pfem fem_descriptor(const std::string &name);
 
   /** get the string name of a fem descriptor. */
   std::string name_of_fem(pfem p);

Modified: trunk/getfem/src/getfem_fem.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_fem.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem_fem.cc      (original)
+++ trunk/getfem/src/getfem_fem.cc      Sat Dec 19 17:15:39 2015
@@ -2679,7 +2679,7 @@
   // Hermite element on the segment. when the real element lies in
   // a 2 or 3 dimensional domain, the element should still work if
   // the tangent coincides.
-  hermite_segment__::hermite_segment__(void) { 
+  hermite_segment__::hermite_segment__(void) {
     base_node pt(1);
     cvr = bgeot::simplex_of_reference(1);
     dim_ = cvr->structure()->dim();
@@ -2688,7 +2688,7 @@
     is_pol = true;
     is_lag = is_equiv = false;
     base_.resize(4);
-    
+
     pt[0] = 0.0; add_node(lagrange_dof(1), pt);
     read_poly(base_[0], 1, "(1 - x)^2*(2*x + 1)");
 
@@ -3369,7 +3369,7 @@
   };
   
   // get a fem descriptor from a string name of a fem.
-  pfem fem_descriptor(std::string name) {
+  pfem fem_descriptor(const std::string &name) {
     size_type i = 0;
     pfem  pf = dal::singleton<fem_naming_system>::instance().method(name, i);
     const_cast<virtual_fem &>(*pf).debug_name()

Modified: trunk/getfem/src/getfem_mesh_fem.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh_fem.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh_fem.cc (original)
+++ trunk/getfem/src/getfem_mesh_fem.cc Sat Dec 19 17:15:39 2015
@@ -455,7 +455,7 @@
     gmm::stream_standard_locale sl(ist);
     dal::bit_vector npt;
     dal::dynamic_array<double> tmpv;
-    std::string tmp, tmp2;
+    std::string tmp("nop"), tmp2("nop"); tmp.clear(); tmp2.clear();
     bool dof_read = false;
     gmm::col_matrix< gmm::wsvector<scalar_type> > RR, EE;
     ist.precision(16);

Modified: trunk/getfem/src/getfem_mesh_level_set.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh_level_set.cc?rev=5205&r1=5204&r2=5205&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh_level_set.cc   (original)
+++ trunk/getfem/src/getfem_mesh_level_set.cc   Sat Dec 19 17:15:39 2015
@@ -129,7 +129,10 @@
     for (size_type i=0; i < ipts.size(); ++i) {
       // cout << "ipts[i] = " << ipts[i] << endl;
       if (ipts[i] < nb_vertices) {
-       if (noisy) cout << "point " << i << " coordinates " << 
m.points()[ipts[i]]<< " constraints[ipts[i]] = " << constraints[ipts[i]] << 
endl;
+       if (noisy)
+         cout << "point " << i << " coordinates "
+              << m.points()[ipts[i]] << " constraints[ipts[i]] = "
+              << constraints[ipts[i]] << endl;
        if (cnt == 0) cts = constraints[ipts[i]];
        else cts &= constraints[ipts[i]];
        ++cnt;
@@ -150,9 +153,10 @@
                         "Original point " << m.points()[ipts[i]]
                         << " projection " << P);
          } else {
-           if (noisy && pgt->convex_ref()->is_in(P) > 1E-8)
-             cout << "The projected point is outside the reference convex !" 
<< P << endl;
-           m.points()[ipts[i]] = P;
+           if (pgt->convex_ref()->is_in(P) > 1E-8) {
+             GMM_WARNING1("Projected point outside the reference convex ! "
+                          "Projection canceled. P = " << P);
+           } else m.points()[ipts[i]] = P;
          }
          ptdone[ipts[i]] = true;
          // dist(P, new_cts);




reply via email to

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