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

logari81 pushed a commit to branch master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
     new e895f1ff Coding style and documentation improvements
e895f1ff is described below

commit e895f1ffa9ab92c4ff305f9469b5687c7f386ac6
Author: Konstantinos Poulios <logar...@gmail.com>
AuthorDate: Sun Sep 17 00:55:39 2023 +0200

    Coding style and documentation improvements
---
 interface/src/gf_spmat.cc                       |  4 +-
 src/getfem/getfem_continuation.h                | 76 +++++++++++++------------
 src/getfem/getfem_models.h                      | 41 ++++++++++++-
 src/getfem/getfem_omp.h                         |  2 +-
 src/getfem_generic_assembly_compile_and_exec.cc |  5 +-
 src/getfem_generic_assembly_semantic.cc         | 11 +++-
 src/getfem_plasticity.cc                        |  2 +-
 src/gmm/gmm_sub_vector.h                        | 27 ++++-----
 8 files changed, 107 insertions(+), 61 deletions(-)

diff --git a/interface/src/gf_spmat.cc b/interface/src/gf_spmat.cc
index f0e8f601..be62254a 100644
--- a/interface/src/gf_spmat.cc
+++ b/interface/src/gf_spmat.cc
@@ -189,8 +189,8 @@ void gf_spmat(getfemint::mexargs_in& m_in,
        gsp->allocate(m, n, gsparse::WSCMAT, gsparse::REAL);
        );
 
-    /*@INIT SM = ('copy', @mat K [, @PYTHON{@list} I [, @PYTHON{@list} J]])
-      Duplicate a matrix `K` (which might be a @tsp@MATLAB{ or a native matlab
+    /*@INIT SM = ('copy', @mat K [, @PYTHON{@list} I [, @PYTHON{@list} J=I]])
+      Duplicate a matrix `K` (which might be an @tsp@MATLAB{ or a native matlab
       sparse matrix}). If index `I` and/or `J` are given, the matrix will
       be a submatrix of `K`. For example::
 
diff --git a/src/getfem/getfem_continuation.h b/src/getfem/getfem_continuation.h
index 6b4da63f..5d69add2 100644
--- a/src/getfem/getfem_continuation.h
+++ b/src/getfem/getfem_continuation.h
@@ -232,7 +232,8 @@ namespace getfem {
 
     double test_function_bp(const MAT &A, const VECT &g,
                             const VECT &tx, double tgamma) {
-      VECT v_x(g); double v_gamma;
+      VECT v_x(g);
+      double v_gamma;
       return test_function_bp(A, g, tx, tgamma, v_x, v_gamma);
     }
 
@@ -249,7 +250,8 @@ namespace getfem {
 
     double test_function_bp(const VECT &x, double gamma,
                             const VECT &tx, double tgamma) {
-      VECT v_x(x); double v_gamma;
+      VECT v_x(x);
+      double v_gamma;
       return test_function_bp(x, gamma, tx, tgamma, v_x, v_gamma);
     }
 
@@ -801,39 +803,39 @@ namespace getfem {
   public:
 
     // Misc. for accessing private data
-    int noisy(void) const { return noisy_; }
-    double h_init(void) const { return h_init_; }
-    double h_min(void) const { return h_min_; }
-    double h_max(void) const { return h_max_; }
-    double h_dec(void) const { return h_dec_; }
-    double h_inc(void) const { return h_inc_; }
-    size_type maxit(void) const { return maxit_; }
-    size_type thrit(void) const { return thrit_; }
-    double maxres(void) const { return maxres_; }
-    double maxdiff(void) const { return maxdiff_; }
-    double mincos(void) const { return mincos_; }
-    double delta_max(void) const { return delta_max_; }
-    double delta_min(void) const { return delta_min_; }
-    double thrvar(void) const { return thrvar_; }
-    size_type nbdir(void) const { return nbdir_; }
-    size_type nbspan(void) const { return nbspan_; }
+    int noisy() const { return noisy_; }
+    double h_init() const { return h_init_; }
+    double h_min() const { return h_min_; }
+    double h_max() const { return h_max_; }
+    double h_dec() const { return h_dec_; }
+    double h_inc() const { return h_inc_; }
+    size_type maxit() const { return maxit_; }
+    size_type thrit() const { return thrit_; }
+    double maxres() const { return maxres_; }
+    double maxdiff() const { return maxdiff_; }
+    double mincos() const { return mincos_; }
+    double delta_max() const { return delta_max_; }
+    double delta_min() const { return delta_min_; }
+    double thrvar() const { return thrvar_; }
+    size_type nbdir() const { return nbdir_; }
+    size_type nbspan() const { return nbspan_; }
 
     void set_tau_lp(double tau) { tau_lp = tau; }
-    double get_tau_lp(void) const { return tau_lp; }
+    double get_tau_lp() const { return tau_lp; }
     void set_tau_bp_1(double tau) { tau_bp_1 = tau; }
-    double get_tau_bp_1(void) const { return tau_bp_1; }
+    double get_tau_bp_1() const { return tau_bp_1; }
     void set_tau_bp_2(double tau) { tau_bp_2 = tau; }
-    double get_tau_bp_2(void) const { return tau_bp_2; }
-    void clear_tau_bp_currentstep(void) {
+    double get_tau_bp_2() const { return tau_bp_2; }
+    void clear_tau_bp_currentstep() {
       tau_bp_graph.clear();
     }
-    void init_tau_bp_graph(void) { tau_bp_graph[0.] = tau_bp_2; }
+    void init_tau_bp_graph() { tau_bp_graph[0.] = tau_bp_2; }
     void insert_tau_bp_graph(double alpha, double tau) {
       tau_bp_graph[alpha] = tau;
       gmm::resize(alpha_hist, 0);
       gmm::resize(tau_bp_hist, 0);
     }
-    const VECT &get_alpha_hist(void) {
+    const VECT &get_alpha_hist() {
       size_type i = 0;
       gmm::resize(alpha_hist, tau_bp_graph.size());
       for (std::map<double, double>::iterator it = tau_bp_graph.begin();
@@ -842,7 +844,7 @@ namespace getfem {
       }
       return alpha_hist;
     }
-    const VECT &get_tau_bp_hist(void) {
+    const VECT &get_tau_bp_hist() {
       size_type i = 0;
       gmm::resize(tau_bp_hist, tau_bp_graph.size());
       for (std::map<double, double>::iterator it = tau_bp_graph.begin();
@@ -852,7 +854,7 @@ namespace getfem {
       return tau_bp_hist;
     }
 
-    void clear_sing_data(void) {
+    void clear_sing_data() {
       sing_label = "";
       gmm::resize(x_sing, 0);
       gmm::resize(x_next, 0);
@@ -862,14 +864,14 @@ namespace getfem {
       tgamma_predict.clear();
     }
     void set_sing_label(std::string label) { sing_label = label; }
-    const std::string get_sing_label(void) const { return sing_label; }
+    const std::string get_sing_label() const { return sing_label; }
     void set_sing_point(const VECT &x, double gamma) {
       gmm::resize(x_sing, gmm::vect_size(x));
       copy(x, gamma, x_sing, gamma_sing);
     }
-    const VECT &get_x_sing(void) const { return x_sing; }
-    double get_gamma_sing(void) const { return gamma_sing; }
-    size_type nb_tangent_sing(void) const { return tx_sing.size(); }
+    const VECT &get_x_sing() const { return x_sing; }
+    double get_gamma_sing() const { return gamma_sing; }
+    size_type nb_tangent_sing() const { return tx_sing.size(); }
     bool insert_tangent_sing(const VECT &tx, double tgamma){
       bool is_included = false;
       for (size_type i = 0; (i < tx_sing.size()) && (!is_included); ++i) {
@@ -884,8 +886,8 @@ namespace getfem {
     }
     const VECT &get_tx_sing(size_type i) const { return tx_sing[i]; }
     double get_tgamma_sing(size_type i) const { return tgamma_sing[i]; }
-    const std::vector<VECT> &get_tx_sing(void) const { return tx_sing; }
-    const std::vector<double> &get_tgamma_sing(void) const { return 
tgamma_sing; }
+    const std::vector<VECT> &get_tx_sing() const { return tx_sing; }
+    const std::vector<double> &get_tgamma_sing() const { return tgamma_sing; }
 
     void set_next_point(const VECT &x, double gamma) {
       if (gmm::vect_size(x_next) == 0) {
@@ -893,8 +895,8 @@ namespace getfem {
         copy(x, gamma, x_next, gamma_next);
       }
     }
-    const VECT &get_x_next(void) const { return x_next; }
-    double get_gamma_next(void) const { return gamma_next; }
+    const VECT &get_x_next() const { return x_next; }
+    double get_gamma_next() const { return gamma_next; }
 
     bool insert_tangent_predict(const VECT &tx, double tgamma) {
       bool is_included = false;
@@ -927,7 +929,7 @@ namespace getfem {
     const VECT &cc_x(size_type nbdof)
     { if (gmm::vect_size(cc_x_) != nbdof) init_border(nbdof); return cc_x_; }
 
-    size_type estimated_memsize(void) {
+    size_type estimated_memsize() {
       size_type szd = sizeof(double);
       return (this->singularities == 0) ? 0
              : (2 * gmm::vect_size(bb_x_) * szd
@@ -1045,8 +1047,8 @@ namespace getfem {
                    const base_vector &w, base_vector &y) const;
 
   public:
-    size_type estimated_memsize(void);
-    const model &linked_model(void) { return *md; }
+    size_type estimated_memsize();
+    const model &linked_model() { return *md; }
 
     void set_parametrised_data_names
     (const std::string &in, const std::string &fn, const std::string &cn) {
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 9707404e..1c06b424 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -1189,8 +1189,45 @@ namespace getfem {
     const std::string &dataname_of_brick(size_type ind_brick,
                                          size_type ind_data);
 
-    /** Assembly of the tangent system taking into account the terms
-        from all bricks. */
+    /** Assembly of the tangent system taking into account all enabled
+        terms in the model.
+
+      version = BUILD_RHS
+        assembles the rhs only for the primary variables, accessible with
+        ::real_rhs() = ::real_rhs(false)
+
+      version = BUILD_MATRIX
+        assembles the tangent matrix only for the primary variables,
+        accessible with ::real_tangent_matrix() = ::real_tangent_matrix(false)
+
+      version = BUILD_ALL
+        assembles the rhs and the tangent matrix only for primary variables
+
+      version = BUILD_RHS_WITH_LIN
+        assembles the rhs, including linear terms
+
+      version = BUILD_RHS_WITH_INTERNAL
+        assembles the rhs of both primary and internal variables, accessible
+        with ::real_rhs(true), no condensation is performed
+        the part of the rhs for primary variables is still accessible with
+        ::real_rhs() = ::real_rhs(false)
+
+      version = BUILD_MATRIX_CONDENSED
+        assembles the condensed tangent system for the primary system,
+        accessible with ::real_tangent_matrix() = ::real_tangent_matrix(false)
+        as well as the coupling tangent matrix between internal and
+        primary variables accessible with ::real_tangent_matrix(true)
+
+        Moreover, the condensed rhs for primary variables will be computed
+        based on whatever is currently contained in the full rhs. The
+        condensed rhs is accessible with ::real_rhs() = ::real_rhs(false)
+        the unmodified content of the full rhs is still accessible with
+        ::real_rhs(true)
+
+      version = BUILD_ALL_CONDENSED
+        assembles the full rhs first and then it assembles the condensed
+        tangent matrix and the condensed rhs
+    */
     virtual void assembly(build_version version);
 
     /** Gives the assembly string corresponding to the Neumann term of
diff --git a/src/getfem/getfem_omp.h b/src/getfem/getfem_omp.h
index f224ffe6..76a4e26e 100644
--- a/src/getfem/getfem_omp.h
+++ b/src/getfem/getfem_omp.h
@@ -340,7 +340,7 @@ namespace getfem
   /* Use these macros only in function local context to achieve
   the effect of thread local storage for any type of objects
   and their initialization (it's more general and portable
-  then using __declspec(thread))*/
+  than using __declspec(thread))*/
   #ifdef GETFEM_HAS_OPENMP
     #define THREAD_SAFE_STATIC thread_local
   #else
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index e5517f49..e09d46ff 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1289,7 +1289,8 @@ namespace getfem {
       GA_DEBUG_INFO("Instruction: copy small vector");
       GMM_ASSERT1(!(inin.has_ctx) || inin.ctx.is_convex_num_valid(),
                   "Invalid element, probably transformation failed");
-      GMM_ASSERT1(t.size() == vec.size(), "Invalid vector size.");
+      GMM_ASSERT1(t.size() == vec.size(),
+                  "Invalid vector size: " << t.size() << "!=" << vec.size());
       gmm::copy(vec, t.as_vector());
       return 0;
     }
@@ -2991,7 +2992,7 @@ namespace getfem {
         return std::make_shared<ga_instruction_contraction_opt0_1_unrolled<5>>
           (t, tc1, tc2);
       default:
-        return std::make_shared<ga_instruction_contraction_opt0_1>(t,tc1,tc2, 
n);
+        return 
std::make_shared<ga_instruction_contraction_opt0_1>(t,tc1,tc2,n);
       }
     }
     if (tc2_.sparsity() == 2) {
diff --git a/src/getfem_generic_assembly_semantic.cc 
b/src/getfem_generic_assembly_semantic.cc
index 8e75e3a7..302f7688 100644
--- a/src/getfem_generic_assembly_semantic.cc
+++ b/src/getfem_generic_assembly_semantic.cc
@@ -4047,7 +4047,9 @@ namespace getfem {
       if (m.dim() > 1) mi.push_back(m.dim());
       pnode->t.adjust_sizes(mi);
       tree.duplicate_with_operation(pnode, GA_COLON);
-      child0 = pnode; pnode = pnode->parent; child1 = pnode->children[1];
+      child0 = pnode;
+      pnode = pnode->parent;
+      child1 = pnode->children[1];
       child1->init_matrix_tensor(meshdim, meshdim);
       gmm::clear(pnode->tensor().as_vector());
       for (size_type i = 0; i < meshdim; ++i)
@@ -4129,7 +4131,9 @@ namespace getfem {
             if (trans_dim > 1) mi.push_back(trans_dim);
             pnode->t.adjust_sizes(mi);
             tree.duplicate_with_operation(pnode, GA_COLON);
-            child0 = pnode; pnode = pnode->parent; child1 = pnode->children[1];
+            child0 = pnode;
+            pnode = pnode->parent;
+            child1 = pnode->children[1];
             child1->init_matrix_tensor(trans_dim, trans_dim);
             gmm::clear(pnode->tensor().as_vector());
             for (size_type i = 0; i < trans_dim; ++i)
@@ -4155,7 +4159,8 @@ namespace getfem {
                          pnode->parent->children[1]);
         } else {
           pnode->node_type = GA_NODE_ZERO;
-          mi = pnode->tensor().sizes(); mi.push_back(m.dim());
+          mi = pnode->tensor().sizes();
+          mi.push_back(m.dim());
           gmm::clear(pnode->tensor().as_vector());
         }
       }
diff --git a/src/getfem_plasticity.cc b/src/getfem_plasticity.cc
index 447438f9..cb90dff4 100644
--- a/src/getfem_plasticity.cc
+++ b/src/getfem_plasticity.cc
@@ -153,7 +153,7 @@ namespace getfem {
   }
 
   // numerical differantiation of logm
-  // not used becaused it caused some issues and was slower than
+  // not used because it caused some issues and was slower than
   // simply inverting the derivative of expm
   bool logm_deriv(const base_matrix &a, base_tensor &dalog,
                   base_matrix *palog=NULL) {
diff --git a/src/gmm/gmm_sub_vector.h b/src/gmm/gmm_sub_vector.h
index 92369098..8e99eb80 100644
--- a/src/gmm/gmm_sub_vector.h
+++ b/src/gmm/gmm_sub_vector.h
@@ -62,9 +62,9 @@ namespace gmm {
     typedef size_t                                  size_type;
     typedef sparse_sub_vector_iterator<IT, MIT, SUBI>    iterator;
 
-    size_type index(void) const { return si.rindex(itb.index()); }
-    void forward(void);
-    void backward(void);
+    size_type index() const { return si.rindex(itb.index()); }
+    void forward();
+    void backward();
     iterator &operator ++()
     { ++itb; forward(); return *this; }
     iterator operator ++(int) { iterator tmp = *this; ++(*this); return tmp; }
@@ -76,7 +76,7 @@ namespace gmm {
     bool operator ==(const iterator &i) const { return itb == i.itb; }
     bool operator !=(const iterator &i) const { return !(i == *this); }
 
-    sparse_sub_vector_iterator(void) {}
+    sparse_sub_vector_iterator() {}
     sparse_sub_vector_iterator(const IT &it, const IT &ite, const SUBI &s)
       : itb(it), itbe(ite), si(s) { forward(); }
     sparse_sub_vector_iterator
@@ -89,11 +89,11 @@ namespace gmm {
   };
 
   template <typename IT, typename MIT, typename SUBI>
-  void  sparse_sub_vector_iterator<IT, MIT, SUBI>::forward(void)
+  void  sparse_sub_vector_iterator<IT, MIT, SUBI>::forward()
   { while(itb!=itbe && index()==size_type(-1)) { ++itb; } }
 
   template <typename IT, typename MIT, typename SUBI>
-  void  sparse_sub_vector_iterator<IT, MIT, SUBI>::backward(void)
+  void  sparse_sub_vector_iterator<IT, MIT, SUBI>::backward()
   { while(itb!=itbe && index()==size_type(-1)) --itb; }
 
   template <typename PT, typename SUBI> struct sparse_sub_vector {
@@ -109,7 +109,7 @@ namespace gmm {
     porigin_type origin;
     SUBI si;
 
-    size_type size(void) const { return si.size(); }
+    size_type size() const { return si.size(); }
    
     reference operator[](size_type i) const
     { return linalg_traits<V>::access(origin, begin_, end_, si.index(i)); }
@@ -283,9 +283,9 @@ namespace gmm {
     typedef size_t                                  size_type;
     typedef skyline_sub_vector_iterator<IT, MIT, SUBI>    iterator;
 
-    size_type index(void) const
+    size_type index() const
     { return (itb.index() - si.min + si.step() - 1) / si.step(); }
-    void backward(void);
+    void backward();
     iterator &operator ++()
     { itb += si.step(); return *this; }
     iterator operator ++(int) { iterator tmp = *this; ++(*this); return tmp; }
@@ -311,11 +311,12 @@ namespace gmm {
     bool operator !=(const iterator &i) const { return !(i == *this); }
     bool operator < (const iterator &i) const { return index()  < i.index();}
 
-    skyline_sub_vector_iterator(void) {}
+    skyline_sub_vector_iterator() {}
     skyline_sub_vector_iterator(const IT &it, const SUBI &s)
       : itb(it), si(s) {}
-    skyline_sub_vector_iterator(const skyline_sub_vector_iterator<MIT, MIT,
-         SUBI> &it) : itb(it.itb), si(it.si) {}
+    skyline_sub_vector_iterator
+      (const skyline_sub_vector_iterator<MIT, MIT, SUBI> &it)
+      : itb(it.itb), si(it.si) {}
   };
 
   template <typename IT, typename SUBI>
@@ -339,7 +340,7 @@ namespace gmm {
     porigin_type origin;
     SUBI si;
 
-    size_type size(void) const { return si.size(); }
+    size_type size() const { return si.size(); }
    
     reference operator[](size_type i) const
     { return linalg_traits<V>::access(origin, begin_, end_, si.index(i)); }

Reply via email to