[Getfem-commits] [getfem-commits] master updated (76d9cbf -> 9b03efd)

2019-10-16 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

  from  76d9cbf   Create .codecov.yml
   new  9b03efd   Allow to detect lapack contained in the available BLAS 
library


Summary of changes:
 configure.ac | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)



[Getfem-commits] (no subject)

2019-10-16 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 9b03efd9854e865e195005436a7fbacf0e925361
Author: Konstantinos Poulios 
Date:   Wed Oct 16 17:43:04 2019 +0200

Allow to detect lapack contained in the available BLAS library
---
 configure.ac | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2509644..9789db2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -351,13 +351,18 @@ fi
 dnl --LAPACK TEST
 
 if test x"$acx_blas_ok" = xyes; then
-  if test x"$FC" = "x"; then
-dgetrf=dgetrf_
-  else
-AC_FC_FUNC(dgetrf)
-  fi;
-
-  AC_CHECK_LIB(lapack, dgetrf_, [acx_lapack_ok=yes; LAPACK_LIBS="-llapack "])
+#This name mangling detection is currently not in use
+#  if test x"$FC" = "x"; then
+#dgetrf=dgetrf_
+#  else
+#AC_FC_FUNC(dgetrf)
+#  fi;
+
+  # LAPACK linked to by default?  (is sometimes included in BLAS lib)
+  AC_CHECK_FUNC(dgetrf_, [acx_lapack_ok=yes; LAPACK_LIBS=""])
+  if test "x$acx_lapack_ok" != xyes; then
+AC_CHECK_LIB(lapack, dgetrf_, [acx_lapack_ok=yes; LAPACK_LIBS="-llapack"])
+  fi
 
   if test x"$acx_lapack_ok" = xyes; then
  CPPFLAGS="$CPPFLAGS -DGMM_USES_LAPACK"



[Getfem-commits] (no subject)

2019-10-24 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 29539bc33c527893aaf820f582466d1819b62103
Author: Konstantinos Poulios 
Date:   Thu Oct 24 14:31:49 2019 +0200

Deep copy of mesh regions when copying a mesh
---
 src/getfem_mesh.cc | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/getfem_mesh.cc b/src/getfem_mesh.cc
index 13ea483..8f86983 100644
--- a/src/getfem_mesh.cc
+++ b/src/getfem_mesh.cc
@@ -488,11 +488,12 @@ namespace getfem {
 clear();
 set_name(m.name_);
 bgeot::basic_mesh::operator=(m);
-cvf_sets = m.cvf_sets;
+for (const auto  : m.cvf_sets) {
+  if (kv.second.get_parent_mesh() != 0)
+cvf_sets[kv.first].set_parent_mesh(this);
+  cvf_sets[kv.first] = kv.second;
+}
 valid_cvf_sets = m.valid_cvf_sets;
-for (std::map::iterator it = cvf_sets.begin();
- it != cvf_sets.end(); ++it)
-  if (it->second.get_parent_mesh() != 0) it->second.set_parent_mesh(this);
 cvs_v_num.clear();
 gmm::uint64_type d = act_counter();
 for (dal::bv_visitor i(convex_index()); !i.finished(); ++i)



[Getfem-commits] (no subject)

2020-01-29 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit ff5eb9c9271cb82fd96b6044728bae6173203c81
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 08:57:05 2020 +0100

Fix wrong scaling of coupling matrix in internal variable condensation
---
 src/getfem_generic_assembly_compile_and_exec.cc | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 890b1b5..5c301ba 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4534,6 +4534,7 @@ namespace getfem {
   protected:
 const bool false_=false;
 const size_type zero_=0;
+const scalar_type one_=1;
   };
 
 
@@ -4714,6 +4715,18 @@ namespace getfem {
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
 imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
+
+ga_instruction_matrix_assembly_imd_mf // constructor without coeff (== 1)
+(const base_tensor _, model_real_sparse_matrix _,
+ const fem_interpolation_context _,
+ const fem_interpolation_context _,
+ const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
+ const gmm::sub_interval _, const mesh_fem _, const scalar_type ,
+ const size_type _)
+  : ga_instruction_matrix_assembly_base
+(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
+Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
+imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
   };
 
   struct ga_instruction_matrix_assembly_mf_imd
@@ -4816,6 +4829,17 @@ namespace getfem {
   : ga_instruction_matrix_assembly_base
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
+
+ga_instruction_matrix_assembly_imd_imd // constructor without coeff (== 1)
+(const base_tensor _, model_real_sparse_matrix _,
+ const fem_interpolation_context _,
+ const fem_interpolation_context _,
+ const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
+ const gmm::sub_interval _, const im_data *imd2_, const scalar_type ,
+ const size_type _)
+  : ga_instruction_matrix_assembly_base
+(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
+K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
   };
 
 
@@ -7980,12 +8004,13 @@ namespace getfem {
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, *mf2, alpha2, gis.coeff, gis.ipt); 
// TODO: name_test2 variable group
+ I1, imd1, alpha1, I2, *mf2, alpha2, gis.ipt); // 
constructor without gis.coeff
+// TODO: name_test2 variable group
 else // for global variable imd2 == 0
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, imd2, alpha2, gis.coeff, gis.ipt);
+ I1, imd1, alpha1, I2, imd2, alpha2, gis.ipt); // 
constructor without gis.coeff
 rmi.instructions.push_back(std::move(pgai));
   }
   const bool initialize = true;



[Getfem-commits] (no subject)

2020-01-29 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit 50ebaab6f372cc9435066732a13a9cb14498caa5
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 16:49:18 2020 +0100

Add support for internal variable condensation to the model object
---
 src/getfem/getfem_accumulated_distro.h   |   6 +-
 src/getfem/getfem_models.h   |  42 ++--
 src/getfem_generic_assembly_workspace.cc |   4 +-
 src/getfem_model_solvers.cc  |  90 +++-
 src/getfem_models.cc | 178 +++
 5 files changed, 261 insertions(+), 59 deletions(-)

diff --git a/src/getfem/getfem_accumulated_distro.h 
b/src/getfem/getfem_accumulated_distro.h
index ebf8226..a428202 100644
--- a/src/getfem/getfem_accumulated_distro.h
+++ b/src/getfem/getfem_accumulated_distro.h
@@ -173,12 +173,16 @@ namespace detail {
   }
 }
 
-operator T&(){
+T& get(){
   if (distributed.num_threads() == 1 ||
   distributed.this_thread() == 0) return original;
   else return distributed;
 }
 
+operator T&(){ // implicit conversion
+  return get();
+}
+
 T& operator = (const T ){
   return distributed = x;
 }
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 62ec9ee..813bb69 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -121,9 +121,14 @@ namespace getfem {
 bool is_linear_;
 bool is_symmetric_;
 bool is_coercive_;
-mutable model_real_sparse_matrix rTM;// tangent matrix, real version
+mutable model_real_sparse_matrix
+  rTM,  // tangent matrix (only primary variables), real version
+  internal_rTM; // coupling matrix between internal and primary vars (no 
empty rows)
 mutable model_complex_sparse_matrix cTM; // tangent matrix, complex version
-mutable model_real_plain_vector rrhs;
+mutable model_real_plain_vector
+  rrhs, // residual vector of primary variables (after 
condensation)
+  full_rrhs,// residual vector of primary and internal variables 
(pre-condensation)
+  internal_sol; // partial solution for internal variables (after 
condensation)
 mutable model_complex_plain_vector crhs;
 mutable bool act_size_to_be_done;
 dim_type leading_dim;
@@ -278,6 +283,10 @@ namespace getfem {
   BUILD_ON_DATA_CHANGE = 4,
   BUILD_WITH_LIN = 8,   // forced calculation of linear terms
   BUILD_RHS_WITH_LIN = 9,   // = BUILD_RHS | BUILD_WITH_LIN_RHS
+  BUILD_WITH_INTERNAL = 16,
+  BUILD_RHS_WITH_INTERNAL = 17, // = BUILD_RHS | BUILD_WITH_INTERNAL
+  BUILD_MATRIX_CONDENSED = 18,  // = BUILD_MATRIX | BUILD_WITH_INTERNAL
+  BUILD_ALL_CONDENSED = 19, // = BUILD_ALL | BUILD_WITH_INTERNAL
 };
 
   protected:
@@ -571,7 +580,13 @@ namespace getfem {
 bool is_linear() const { return is_linear_; }
 
 /** Total number of degrees of freedom in the model. */
-size_type nb_dof() const;
+size_type nb_dof(bool with_internal=false) const;
+
+/** Number of internal degrees of freedom in the model. */
+size_type nb_internal_dof() const { return nb_dof(true)-nb_dof(); }
+
+/** Number of primary degrees of freedom in the model. */
+size_type nb_primary_dof() const { return nb_dof(); }
 
 /** Leading dimension of the meshes used in the model. */
 dim_type leading_dimension() const { return leading_dim; }
@@ -898,10 +913,11 @@ namespace getfem {
 size_type qdim_of_variable(const std::string ) const;
 
 /** Gives the access to the tangent matrix. For the real version. */
-const model_real_sparse_matrix _tangent_matrix() const {
+const model_real_sparse_matrix &
+real_tangent_matrix(bool internal=false) const {
   GMM_ASSERT1(!complex_version, "This model is a complex one");
   context_check(); if (act_size_to_be_done) actualize_sizes();
-  return rTM;
+  return internal ? internal_rTM : rTM;
 }
 
 /** Gives the access to the tangent matrix. For the complex version. */
@@ -913,19 +929,27 @@ namespace getfem {
 
 /** Gives access to the right hand side of the tangent linear system.
 For the real version. An assembly of the rhs has to be done first. */
-const model_real_plain_vector _rhs() const {
+const model_real_plain_vector _rhs(bool with_internal=false) const {
   GMM_ASSERT1(!complex_version, "This model is a complex one");
   context_check(); if (act_size_to_be_done) actualize_sizes();
-  return rrhs;
+  return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
 }
 
 /** Gives write access to the right hand side of the tangent linear system.
 Some solvers need to manipulate the model rhs directly so that for
 example internal condensed variables can be treated properly. */
-model_real_plain_vector _real_rhs() const {
+model_real_plain_vector _real_rhs(bool with_internal=false) const {
+  GMM_ASSERT1(!complex_version, 

[Getfem-commits] (no subject)

2020-01-29 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit 232385db09a7ff588cb8144fd1e8aa79ce6a32b6
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 09:47:03 2020 +0100

Fix size of internal variable condensation matrix

  - Including empty rows for keeping the implementation simpler
---
 src/getfem/getfem_generic_assembly.h| 4 +++-
 src/getfem_generic_assembly_compile_and_exec.cc | 7 +++
 src/getfem_generic_assembly_workspace.cc| 6 ++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 16b77b6..367d227 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -413,7 +413,9 @@ namespace getfem {
   KQJpr = std::shared_ptr
   (std::shared_ptr(), _); // alias
 }
-// getter functions for condensation matrix/vectors
+/** getter function for condensation matrix
+Its size is (nb_primary_dof()+nb_internal_dof()) x nb_primary_dof()
+but its first nb_primary_dof() rows are empty */
 const model_real_sparse_matrix _coupling_matrix() const
 { return *KQJpr; }
 model_real_sparse_matrix _coupling_matrix() { return *KQJpr; }
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 5c301ba..11c2a72 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -8000,6 +8000,13 @@ namespace getfem {
 const base_tensor  = *(CC.KQJpr(q1,j2)); // <- input
 model_real_sparse_matrix
= workspace.internal_coupling_matrix(); // <- output
+GMM_ASSERT1(
+  gmm::mat_nrows(KQJpr) == workspace.nb_primary_dof()
+  +workspace.nb_internal_dof() &&
+  gmm::mat_ncols(KQJpr) == workspace.nb_primary_dof(),
+  "The internal coupling matrix needs to be allocated with "
+  "nb_primary_dof()+nb_internal_dof() number of rows, even if "
+  "only the last nb_internal_dof() rows are filled in.");
 if (mf2)
   pgai =
 std::make_shared
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 50c0db1..4b7517f 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -789,9 +789,9 @@ namespace getfem {
   //  gmm::mat_ncols(*K) == nb_prim_dof, "Wrong sizes");
   if (KQJpr.use_count()) {
 gmm::clear(*KQJpr);
-gmm::resize(*KQJpr, nb_intern_dof, nb_prim_dof); // redundant if 
condensation == false
+gmm::resize(*KQJpr, nb_prim_dof+nb_intern_dof, nb_prim_dof); // 
redundant if condensation == false
   } else if (condensation)
-GMM_ASSERT1(gmm::mat_nrows(*KQJpr) == nb_intern_dof &&
+GMM_ASSERT1(gmm::mat_nrows(*KQJpr) == nb_prim_dof+nb_intern_dof &&
 gmm::mat_ncols(*KQJpr) == nb_prim_dof, "Wrong sizes");
   gmm::clear(col_unreduced_K);
   gmm::clear(row_unreduced_K);
@@ -894,8 +894,6 @@ namespace getfem {
   GMM_ASSERT1(I1.last() <= nb_prim_dof, "Internal error");
   gmm::add(M, gmm::sub_matrix(*K, I1, I2)); // -> *K
 } else { // vname1 is an internal variable
-  I1.min -= first_internal_dof();
-  I1.max -= first_internal_dof();
   gmm::add(M, gmm::sub_matrix(*KQJpr, I1, I2)); // -> 
*KQJpr
 }
   }



[Getfem-commits] (no subject)

2020-01-29 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit 78b191f942d27d95da95d6dec284c0f051531cb1
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 16:47:37 2020 +0100

Minor changes
---
 src/getfem/getfem_models.h  | 16 +---
 src/getfem_generic_assembly_compile_and_exec.cc | 12 +++-
 src/getfem_models.cc| 16 
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 3e0657d..62ec9ee 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -271,12 +271,14 @@ namespace getfem {
 
 typedef std::vector termlist;
 
-enum build_version { BUILD_RHS = 1,
- BUILD_MATRIX = 2,
- BUILD_ALL = 3,
- BUILD_ON_DATA_CHANGE = 4,
- BUILD_WITH_COMPLETE_RHS = 8,
- BUILD_COMPLETE_RHS = 9, };
+enum build_version {
+  BUILD_RHS = 1,
+  BUILD_MATRIX = 2,
+  BUILD_ALL = 3,
+  BUILD_ON_DATA_CHANGE = 4,
+  BUILD_WITH_LIN = 8,   // forced calculation of linear terms
+  BUILD_RHS_WITH_LIN = 9,   // = BUILD_RHS | BUILD_WITH_LIN_RHS
+};
 
   protected:
 
@@ -356,7 +358,7 @@ namespace getfem {
   std::string secondary_domain;
   gen_expr(const std::string _, const mesh_im _,
size_type region_, const std::string )
-   : expr(expr_), mim(mim_), region(region_), secondary_domain(secdom)  {}
+: expr(expr_), mim(mim_), region(region_), secondary_domain(secdom) {}
 };
 
 // Structure for assignment in assembly
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 11c2a72..fe64993 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5445,9 +5445,11 @@ namespace getfem {
 }
 cout << "sub_tree_are_equal = " << int(sub_tree_are_equal(pnode, 
pnode1, workspace, 1)) << endl;
 std::stringstream ss;
-ss << "Detected wrong equivalent nodes: \n";
-ga_print_node(pnode, ss); ss << "\n and \n"; ga_print_node(pnode1, ss);
-ss << "\nNo problem, but hash values could be adapted." << endl;
+ss << "Detected wrong equivalent nodes:" << endl;
+ga_print_node(pnode, ss);
+ss << endl << " and " << endl;
+ga_print_node(pnode1, ss);
+ss << endl << "No problem, but hash values could be adapted." << endl;
 GMM_TRACE2(ss.str());
   }
 }
@@ -8019,13 +8021,13 @@ namespace getfem {
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
  I1, imd1, alpha1, I2, imd2, alpha2, gis.ipt); // 
constructor without gis.coeff
 rmi.instructions.push_back(std::move(pgai));
-  }
+  } // for j2
   const bool initialize = true;
   pgai = std::make_shared
 (*(CC.RQpr[q1]), workspace.assembled_vector(), // <- 
overwriting internal variables residual with internal solution
  gis.ctx, I1, *imd1, gis.coeff, gis.ipt, initialize);
   rmi.instructions.push_back(std::move(pgai));
-}
+} // for q1
   }
 
   // Add superdiagonal condensation instructions
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 25e67c1..c8a5f1a 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2391,7 +2391,7 @@ namespace getfem {
   }
 }
 if (term.is_matrix_term && brick.pbr->is_linear()
-&& (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+&& (!is_linear() || (version & BUILD_WITH_LIN))) {
   if (!(var1->is_disabled))
 gmm::mult_add(brick.cmatlist[j],
   gmm::scaled(var2->complex_value[0],
@@ -2411,7 +2411,7 @@ namespace getfem {
  gmm::sub_vector(crhs, I2));
   }
if (brick.pbr->is_linear()
-   && (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+   && (!is_linear() || (version & BUILD_WITH_LIN))) {
  gmm::mult_add(gmm::conjugated(brick.cmatlist[j]),
 gmm::scaled(var1->complex_value[0],
 complex_type(-alpha2)),
@@ -2459,7 +2459,7 @@ namespace getfem {
   }
 }
 if (term.is_matrix_term && brick.pbr->is_linear()
-&& (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+&& (!is_linear() || (version & BUILD_WITH_LIN))) {
   if (!(var1->is_disabled))
 gmm::mult_add(brick.rmatlist[j],
   gmm::scaled(var2->complex_value[0],
@@ -2479,7 +2479,7 @@ namespace getfem {
  

[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables updated: Fix in proccessing of multiple coupled internal variables

2020-01-29 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-internal-variables
in repository getfem.

The following commit(s) were added to 
refs/heads/devel-logari81-internal-variables by this push:
 new 19ccc74  Fix in proccessing of multiple coupled internal variables
19ccc74 is described below

commit 19ccc748b9dd0dbc50391074d1e3eeceb8f93d53
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 22:08:50 2020 +0100

Fix in proccessing of multiple coupled internal variables
---
 src/getfem_generic_assembly_compile_and_exec.cc | 134 +---
 1 file changed, 73 insertions(+), 61 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index fe64993..f033698 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5055,17 +5055,16 @@ namespace getfem {
 std::vector RQloc;
 base_tensor invK, Kqqjj;
 base_vector Rqq;
-std::vector partQ, partJ;
-size_type Qsize, Jsize;
+std::vector> partQ, partJ;
 virtual int exec() { // implementation can be optimized
   GA_DEBUG_INFO("Instruction: variable cluster subdiagonal condensation");
   // copy from KQQ to invK
-  for (size_type q1=0; q1 < Qsize; ++q1) {
-size_type qq1start = partQ[q1], qq1end = partQ[q1+1];
-for (size_type q2=0; q2 < Qsize; ++q2) {
+  for (const auto  : partQ) {
+size_type q1 = qqq1[0], qq1start = qqq1[1], qq1end = qqq1[2];
+for (const auto  : partQ) {
+  size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
   if (KQQloc(q1,q2)) {
 auto itr = KQQloc(q1,q2)->cbegin();
-size_type qq2start = partQ[q2], qq2end = partQ[q2+1];
 GMM_ASSERT1(KQQloc(q1,q2)->size()
 == (qq1end-qq1start)*(qq2end-qq2start),
 "Internal error");
@@ -5079,40 +5078,44 @@ namespace getfem {
   bgeot::lu_inverse(&(invK[0]), invK.size(0));
 
   // Resize Kqqjj as primary variable sizes may change dynamically
-  partJ.clear();
-  partJ.resize(Jsize,0);
-  for (size_type j=0; j < Jsize; ++j)
-for (size_type q=0; q < Qsize; ++q)
+  size_type prev_j(0);
+  for (auto & : partJ) {
+size_type j=jjj[0];
+size_type new_j(0);
+for (const auto  : partQ) {
+  size_type q=qqq[0];
   if (KQJloc(q,j)) {
-if (partJ[j] == 0)
-  partJ[j] = KQJloc(q,j)->size(1);
-else
-  GMM_ASSERT1(partJ[j] == KQJloc(q,j)->size(1), "Internal error");
+if (new_j) {
+  GMM_ASSERT1(new_j == KQJloc(q,j)->size(1), "Internal error");
+} else
+  new_j = KQJloc(q,j)->size(1);
   }
-  for (size_type jj=1; jj < partJ.size(); ++jj)
-partJ[jj] += partJ[jj-1];
-  partJ.insert(partJ.begin(), 0);
+}
+// Resize KQJprime submatrices to match KQJloc sizes
+for (const auto  : partQ) {
+  size_type q=qqq[0];
+  KQJprime(q,j)->adjust_sizes(qqq[2]-qqq[1], new_j);
+}
+jjj[1] = prev_j;
+prev_j += new_j;
+jjj[2] = prev_j;
+  }
 
-  Kqqjj.adjust_sizes(partQ.back(), partJ.back());
+  Kqqjj.adjust_sizes(partQ.back()[2], partJ.back()[2]);
   gmm::clear(Kqqjj.as_vector());
   gmm::clear(Rqq);
 
-  // Resize KQJprime submatrices to match KQJloc sizes
-  for (size_type j=0; j < Jsize; ++j)
-for (size_type q=0; q < Qsize; ++q)
-  KQJprime(q,j)->adjust_sizes(partQ[q+1]-partQ[q], 
partJ[j+1]-partJ[j]);
-
   // multiply invK with all submatrices in KQJloc and RQloc and store
   // the results in Kqqjj and Rqq
-  for (size_type j=0; j < Jsize; ++j) {
-size_type jjstart = partJ[j], jjend = partJ[j+1];
-for (size_type q2=0; q2 < Qsize; ++q2) {
+  for (const auto  : partJ) {
+size_type j = jjj[0], jjstart = jjj[1], jjend = jjj[2];
+for (const auto  : partQ) {
+  size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
   if (KQJloc(q2,j)) {
 auto itr = KQJloc(q2,j)->begin(); // auto  = KQJloc(q2,j);
-size_type qqstart = partQ[q2], qqend = partQ[q2+1];
 for (size_type jj=jjstart; jj < jjend; ++jj) {
-  for (size_type qq2=qqstart; qq2 < qqend; ++qq2, ++itr) {
-for (size_type qq1=0; qq1 < partQ.back(); ++qq1) {
+  for (size_type qq2=qq2start; qq2 < qq2end; ++qq2, ++itr) {
+for (size_type qq1=0; qq1 < partQ.back()[2]; ++qq1) {
   Kqqjj(qq1,jj) += invK(qq1,qq2)*(*itr);
   // Kqqjj(qq1,jj) += 
invKqq(qq1,qq2)*mat(qq2-qqstart,jj-jjstart);
 } // for qq1
@@ -5120,30 +5123,31 @@ namespace getfem {
 } // for jj
 

[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables updated: Refactoring of model solvers

2020-01-28 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-internal-variables
in repository getfem.

The following commit(s) were added to 
refs/heads/devel-logari81-internal-variables by this push:
 new f85112c  Refactoring of model solvers
f85112c is described below

commit f85112cc3c7947eab82ed34cac44b751474852ed
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 06:41:07 2020 +0100

Refactoring of model solvers

 - make the model_pb object responsible for the solution of the linearized 
system
---
 src/getfem/getfem_model_solvers.h | 181 ++--
 src/getfem/getfem_models.h|  18 
 src/getfem_model_solvers.cc   | 213 +-
 3 files changed, 236 insertions(+), 176 deletions(-)

diff --git a/src/getfem/getfem_model_solvers.h 
b/src/getfem/getfem_model_solvers.h
index 517b3d3..b286116 100644
--- a/src/getfem/getfem_model_solvers.h
+++ b/src/getfem/getfem_model_solvers.h
@@ -79,8 +79,10 @@ namespace getfem {
 
   template 
   struct abstract_linear_solver {
+typedef MAT MATRIX;
+typedef VECT VECTOR;
 virtual void operator ()(const MAT &, VECT &, const VECT &,
- gmm::iteration &) const  = 0;
+ gmm::iteration &) const = 0;
 virtual ~abstract_linear_solver() {}
   };
 
@@ -386,7 +388,7 @@ namespace getfem {
   /* * */
   /* Newton(-Raphson) algorithm with step control. */
   /* * */
-  /* Still solves a problem F(X) = 0 sarting at X0 but setting */
+  /* Still solves a problem F(X) = 0 starting at X0 but setting*/
   /* B0 = F(X0) and solving*/
   /* F(X) = (1-alpha)B0   (1)  */
   /* with alpha growing from 0 to 1.   */
@@ -403,15 +405,12 @@ namespace getfem {
   /*  else alpha0 <- alpha,*/
   /*  alpha <- min(1,alpha0+2*(alpha-alpha0)), */
   /*  Go to step 1 with Xi+1   */
-  /*  being the result of Newton iteraitons of step1.  */
+  /*  being the result of Newton iterations of step1.  */
   /*   */
   /*/
 
   template 
-  void Newton_with_step_control
-  (PB , gmm::iteration ,
-   const abstract_linear_solver _solver)
+  void Newton_with_step_control(PB , gmm::iteration )
   {
 typedef typename gmm::linalg_traits::value_type T;
 typedef typename gmm::number_traits::magnitude_type R;
@@ -430,7 +429,6 @@ namespace getfem {
 gmm::copy(pb.state_vector(), Xi);
 
 typename PB::VECTOR dr(gmm::vect_size(pb.residual()));
-typename PB::VECTOR b(gmm::vect_size(pb.residual()));
 
 R alpha0(0), alpha(1), res0(gmm::vect_norm1(b0)), minres(res0);
 // const newton_search_with_step_control *ls
@@ -447,18 +445,18 @@ namespace getfem {
 / approx_eln;
   if (!iter.converged(crit)) {
 gmm::iteration iter_linsolv = iter_linsolv0;
-if (iter.get_noisy() > 1)
-  cout << "starting tangent matrix computation" << endl;
 
 int is_singular = 1;
 while (is_singular) { // Linear system solve
-  pb.compute_tangent_matrix();
   gmm::clear(dr);
-  gmm::copy(pb.residual(), b);
-  gmm::add(gmm::scaled(b0,alpha-R(1)), b);
-  if (iter.get_noisy() > 1) cout << "starting linear solver" << endl;
+  pb.add_to_residual(b0, alpha-R(1)); // canceled at next 
compute_residual
   iter_linsolv.init();
-  linear_solver(pb.tangent_matrix(), dr, b, iter_linsolv);
+  if (iter.get_noisy() > 1)
+cout << "starting tangent matrix computation" << endl;
+  pb.compute_tangent_matrix();
+  if (iter.get_noisy() > 1)
+cout << "starting linear solver" << endl;
+  pb.linear_solve(dr, iter_linsolv);
   if (!iter_linsolv.converged()) {
 is_singular++;
 if (is_singular <= 4) {
@@ -466,7 +464,7 @@ namespace getfem {
 cout << "Singular tangent matrix:"
   " perturbation of the state vector." << endl;
   pb.perturbation();
-  pb.compute_residual();
+  pb.compute_residual(); // cancels add_to_residual
 } else {
   if (iter.get_noisy())
 cout << "Singular tangent matrix: perturbation failed, "
@@ -478,9 +476,8 @@ namespace getfem {
 }
 if (iter.get_noisy() > 1) cout << "linear solver done" << endl;
 
-
 gmm::add(dr, pb.state_vector());
-

[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables updated: Fix model class for internal variable condensation

2020-02-01 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-internal-variables
in repository getfem.

The following commit(s) were added to 
refs/heads/devel-logari81-internal-variables by this push:
 new d7d1e07  Fix model class for internal variable condensation
d7d1e07 is described below

commit d7d1e07384e555389d3c1e7cdf46bc970cf5a4de
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 11:23:55 2020 +0100

Fix model class for internal variable condensation
---
 src/getfem_models.cc | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index d509046..14e2673 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2597,8 +2597,11 @@ namespace getfem {
   if (version & BUILD_RHS) approx_external_load_ += brick.external_load;
 }
 
-if (gmm::vect_size(full_rrhs)) { // i.e. if has_internal_variables()
+if (version & BUILD_RHS && version & BUILD_WITH_INTERNAL) {
+  GMM_ASSERT1(gmm::vect_size(full_rrhs) > 0 && has_internal_variables(),
+  "Internal error");
   gmm::sub_interval IP(0,gmm::vect_size(rrhs));
+  gmm::fill(full_rrhs, 0.);
   gmm::copy(rrhs, gmm::sub_vector(full_rrhs, IP)); // TICTIC
 }
 
@@ -2656,14 +2659,12 @@ namespace getfem {
 if (with_internal) { // Condensation reads from/writes to rhs
   gmm::copy(res0_distro.get(), res1_distro.get());
   gmm::add(gmm::scaled(full_rrhs, scalar_type(-1)),
-   res1_distro.get()); // TIC: initial value residual=-rhs
+   res1_distro.get()); // initial value residual=-rhs 
(actually only the internal variables residual is needed)
   workspace.set_assembled_vector(res1_distro);
   workspace.set_internal_coupling_matrix(intern_mat_distro);
 }
 workspace.set_assembled_matrix(tangent_matrix_distro);
 workspace.assembly(2, with_internal);
-if (with_internal) // TOC: diff from initial value, hack to make 
OMP work
-  gmm::add(full_rrhs, res1_distro.get());
   ) // end GETFEM_OMP_PARALLEL
 } // end of res0_distro scope
 else { // only BUILD_MATRIX
@@ -2672,14 +2673,12 @@ namespace getfem {
 add_assignments_and_expressions_to_workspace(workspace);
 if (with_internal) { // Condensation reads from/writes to rhs
   gmm::copy(gmm::scaled(full_rrhs, scalar_type(-1)),
-res1_distro.get()); // TIC: initial value residual=-rhs
+res1_distro.get()); // initial value residual=-rhs 
(actually only the internal variables residual is needed)
   workspace.set_assembled_vector(res1_distro);
   workspace.set_internal_coupling_matrix(intern_mat_distro);
 }
 workspace.set_assembled_matrix(tangent_matrix_distro);
 workspace.assembly(2, with_internal);
-if (with_internal) // TOC: diff from initial value, hack to make 
OMP work
-  gmm::add(full_rrhs, res1_distro.get());
   ) // end GETFEM_OMP_PARALLEL
 }
   } // end of tangent_matrix_distro, intern_mat_distro, res1_distro scope



[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables updated: Add unit test for internal variable condensation

2020-02-01 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-internal-variables
in repository getfem.

The following commit(s) were added to 
refs/heads/devel-logari81-internal-variables by this push:
 new 9d1c444  Add unit test for internal variable condensation
9d1c444 is described below

commit 9d1c4449796fe7b3c3adabeed57977c5d6ac7507
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 11:28:19 2020 +0100

Add unit test for internal variable condensation
---
 tests/Makefile.am  |   4 +
 tests/test_condensation.cc | 184 +
 tests/test_condensation.pl | 105 ++
 3 files changed, 293 insertions(+)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba8b7a3..296934f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@ check_PROGRAMS =   \
test_assembly_assignment   \
test_interpolated_fem  \
test_internal_variables\
+   test_condensation  \
test_range_basis   \
laplacian  \
laplacian_with_bricks  \
@@ -100,6 +101,7 @@ geo_trans_inv_SOURCES = geo_trans_inv.cc
 test_int_set_SOURCES = test_int_set.cc
 test_interpolated_fem_SOURCES = test_interpolated_fem.cc
 test_internal_variables_SOURCES = test_internal_variables.cc
+test_condensation_SOURCES = test_condensation.cc
 test_tree_sorted_SOURCES = test_tree_sorted.cc
 test_mat_elem_SOURCES = test_mat_elem.cc
 test_slice_SOURCES = test_slice.cc
@@ -141,6 +143,7 @@ TESTS = \
test_assembly_assignment.pl   \
test_interpolated_fem.pl  \
test_internal_variables.pl\
+   test_condensation.pl  \
test_range_basis.pl   \
laplacian.pl  \
laplacian_with_bricks.pl  \
@@ -182,6 +185,7 @@ EXTRA_DIST =
\
test_int_set.pl \
test_interpolated_fem.pl\
test_internal_variables.pl  \
+   test_condensation.pl\
test_slice.pl   \
test_mesh_im_level_set.pl   \
thermo_elasticity_electrical_coupling.pl\
diff --git a/tests/test_condensation.cc b/tests/test_condensation.cc
new file mode 100644
index 000..2a3ec22
--- /dev/null
+++ b/tests/test_condensation.cc
@@ -0,0 +1,184 @@
+/*===
+
+ Copyright (C) 2019-2020 Konstantinos Poulios.
+
+ This file is a part of GetFEM++
+
+ GetFEM++  is  free software;  you  can  redistribute  it  and/or modify it
+ under  the  terms  of the  GNU  Lesser General Public License as published
+ by  the  Free Software Foundation;  either version 3 of the License,  or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program  is  distributed  in  the  hope  that it will be useful,  but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You  should  have received a copy of the GNU Lesser General Public License
+ along  with  this program;  if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+
+===*/
+#include "getfem/getfem_regular_meshes.h"
+#include "getfem/getfem_export.h"
+#include "getfem/getfem_model_solvers.h"
+
+using bgeot::dim_type;
+using bgeot::size_type;
+using bgeot::scalar_type;
+using bgeot::base_node;
+
+static bool debug=false;
+
+int main(int argc, char *argv[]) {
+
+  gmm::set_traces_level(1);
+
+  bgeot::md_param PARAM;
+  PARAM.add_int_param("NX", 1);
+  PARAM.add_int_param("NY", 1);
+  PARAM.add_int_param("FEM_ORDER", 1);
+  PARAM.add_int_param("IM_ORDER", 1);
+  PARAM.add_int_param("DIFFICULTY", 0);
+  PARAM.read_command_line(argc, argv);
+  size_type NX = PARAM.int_value("NX", "Number of elements in X direction");
+  size_type NY = PARAM.int_value("NY", "Number of elements in Y direction");
+  dim_type FEM_ORDER = dim_type(PARAM.int_value("FEM_ORDER", "Degree of finite 
element basis"));
+  dim_type IM_ORDER = dim_type(PARAM.int_value("IM_ORDER", "Degree of 
integration method"));
+  size_type DIFFICULTY = PARAM.int_value("DIFFICULTY", "Difficulty of test");
+
+  getfem::mesh m;
+  getfem::regular_unit_mesh(m, {NX, NY}, 
bgeot::geometric_trans_descriptor("GT_QK(2, 2)"));
+
+  getfem::mesh_region outer_faces;
+  getfem::outer_faces_of_mesh(m, outer_faces);
+  m.region(98) = 

Re: [Getfem-commits] Please merge devel-tetsuo-fix-type

2020-01-17 Thread Konstantinos Poulios via Getfem-commits
I would maybe leave this for after merging my internal-variables branch

On Fri, Jan 17, 2020 at 8:36 AM Tetsuo Koyama  wrote:

> Hi getfem project.
>
> I fixed one line of Newmark_beta_method object code.
> It is a explicit define of scalar_type.
> Could you merge devel-tetsuo-fix-type?
>
> Thank you for reading.
>
> Best regard Tetsuo
>
>


[Getfem-commits] (no subject)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit 79df5e1c2c7b53417298e9d2041d6d414cc049d5
Author: Konstantinos Poulios 
Date:   Thu Jan 2 18:43:14 2020 +0100

Clean variable inheritance model for ga_workspace

 - Now it is possible to create a ga_workspace linked
   to a model or another workspace without inheriting
   its variables at all ga_workspace::inherit::NONE

 - Temporary enabling disabled variables of the parent
   model is now done with ga_workspace::inherit::ALL
   instead of ga_workspace::inherit::ENABLED
---
 src/getfem/getfem_generic_assembly.h   |  9 --
 src/getfem_contact_and_friction_integral.cc|  2 +-
 ...fem_generic_assembly_functions_and_operators.cc |  3 +-
 src/getfem_generic_assembly_interpolation.cc   |  4 +--
 src/getfem_generic_assembly_workspace.cc   | 32 ---
 src/getfem_models.cc   | 37 --
 6 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 3f47eaa..ddd7266 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -264,6 +264,7 @@ namespace getfem {
 
 const model *md;
 const ga_workspace *parent_workspace;
+bool with_parent_variables;
 size_type nb_prim_dof, nb_tmp_dof;
 
 void init();
@@ -566,8 +567,12 @@ namespace getfem {
   return (it != tmp_var_intervals.end()) ? it->second : empty_interval;
 }
 
-ga_workspace(const getfem::model _, bool 
enable_disabled_variables=false);
-ga_workspace(bool, const ga_workspace );
+enum class inherit { NONE, ENABLED, ALL };
+
+ga_workspace(const getfem::model _,
+ const inherit var_inherit=inherit::ENABLED);
+ga_workspace(const ga_workspace ,// compulsory 2nd arg to avoid
+ const inherit var_inherit); // conflict with copy constructor
 ga_workspace();
 ~ga_workspace();
 
diff --git a/src/getfem_contact_and_friction_integral.cc 
b/src/getfem_contact_and_friction_integral.cc
index 58d2f65..9d838e5 100644
--- a/src/getfem_contact_and_friction_integral.cc
+++ b/src/getfem_contact_and_friction_integral.cc
@@ -2551,7 +2551,7 @@ namespace getfem {
size_type region) {
 
 std::string theta = std::to_string(theta_);
-ga_workspace workspace(md, true);
+ga_workspace workspace(md, ga_workspace::inherit::ALL); // reenables vars
 size_type order = workspace.add_expression(Neumannterm, mim, region, 1);
 GMM_ASSERT1(order == 0, "Wrong expression of the Neumann term");
 // model::varnamelist vl, vl_test1, vl_test2, dl;
diff --git a/src/getfem_generic_assembly_functions_and_operators.cc 
b/src/getfem_generic_assembly_functions_and_operators.cc
index d0cf80e..7e5a00b 100644
--- a/src/getfem_generic_assembly_functions_and_operators.cc
+++ b/src/getfem_generic_assembly_functions_and_operators.cc
@@ -678,7 +678,8 @@ namespace getfem {
 
   ga_function::ga_function(const ga_workspace _,
const std::string )
-: local_workspace(true, workspace_), expr(e), gis(0) {}
+: local_workspace(workspace_, ga_workspace::inherit::ALL),
+  expr(e), gis(0) {}
 
   ga_function::ga_function(const model , const std::string )
 : local_workspace(md), expr(e), gis(0) {}
diff --git a/src/getfem_generic_assembly_interpolation.cc 
b/src/getfem_generic_assembly_interpolation.cc
index 610921d..771105c 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -533,7 +533,7 @@ namespace getfem {
   used_vars.clear();
 else
   used_data.clear();
-ga_workspace aux_workspace(true, workspace);
+ga_workspace aux_workspace(workspace, ga_workspace::inherit::ALL);
 aux_workspace.clear_expressions();
 aux_workspace.add_interpolation_expression(expr, source_mesh);
 for (size_type i = 0; i < aux_workspace.nb_trees(); ++i)
@@ -556,7 +556,7 @@ namespace getfem {
   size_type N = target_mesh.dim();
 
   // Expression compilation
-  local_workspace = ga_workspace(true, workspace);
+  local_workspace = ga_workspace(workspace, ga_workspace::inherit::ALL);
   local_workspace.clear_expressions();
 
   local_workspace.add_interpolation_expression(expr, source_mesh);
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 330d1db..7b8ede8 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -171,9 +171,10 @@ namespace getfem {
 if (it != variables.end()) return it->second.I;
 const auto it2 = reenabled_var_intervals.find(name);
 if (it2 != reenabled_var_intervals.end()) return it2->second;
-if (md && md->variable_exists(name))
+if (with_parent_variables && md && md->variable_exists(name))
   return 

[Getfem-commits] [getfem-commits] devel-logari81-internal-variables updated (fb27f37 -> 79df5e1)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-internal-variables.

  from  fb27f37   Refactor inheritance of model disabled variables by 
ga_workspace
   new  79df5e1   Clean variable inheritance model for ga_workspace


Summary of changes:
 src/getfem/getfem_generic_assembly.h   |  9 --
 src/getfem_contact_and_friction_integral.cc|  2 +-
 ...fem_generic_assembly_functions_and_operators.cc |  3 +-
 src/getfem_generic_assembly_interpolation.cc   |  4 +--
 src/getfem_generic_assembly_workspace.cc   | 32 ---
 src/getfem_models.cc   | 37 --
 6 files changed, 52 insertions(+), 35 deletions(-)



[Getfem-commits] (no subject)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit e903249a77c10f310e61421aa6e237bd2bb86c08
Author: Konstantinos Poulios 
Date:   Fri Jan 3 02:26:06 2020 +0100

Refactor compilation and execution of global vector and matrix assembly

  - more specialized matrix assembly instruction classes for different
combinations of variable types (mesh_fem, mesh_im_data, global)

  - dispatching according to variable type at compilation rather than
run time
---
 .../getfem_generic_assembly_compile_and_exec.h |   12 +-
 src/getfem_generic_assembly_compile_and_exec.cc|  +---
 2 files changed, 748 insertions(+), 375 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index 6e72d99..e477024 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -108,12 +108,16 @@ namespace getfem {
 std::map really_extended_vars;
 
 struct variable_group_info {
+  const mesh *cached_mesh;
+  const std::string *varname;
   const mesh_fem *mf;
-  gmm::sub_interval Iu, Ir;
+  bool reduced_mf;
+  const gmm::sub_interval *I; // sub_interval in the assembled 
vector/matrix
+  // or in the unreduced vars indexing
   scalar_type alpha;
-  const base_vector *U;
-  const std::string *varname;
-  variable_group_info() : mf(0), U(0), varname(0) {}
+  const base_vector *U;   // Vector to read values from
+  variable_group_info()
+: cached_mesh(0), varname(0), mf(0), reduced_mf(false), I(0) {}
 };
 
 struct interpolate_info {
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index fc56d05..a6ac233 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1220,21 +1220,28 @@ namespace getfem {
 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: Update group info for "+gname);
-  if (vgi.varname &&
-  &(workspace.associated_mf(*(vgi.varname))->linked_mesh())==inin.m)
+  if (vgi.cached_mesh && vgi.cached_mesh == inin.m)
 return 0;
+
+  vgi.cached_mesh = inin.m;
   const std::string 
 = inin.m ? workspace.variable_in_group(gname, *(inin.m))
  : workspace.first_variable_of_group(gname);
+  vgi.varname = 
   vgi.mf = workspace.associated_mf(varname);
-  vgi.Iu = workspace.temporary_interval_of_variable(varname);
-  vgi.Ir = workspace.interval_of_variable(varname);
+  GA_DEBUG_ASSERT(vgi.mf, "Group variable should always have a mesh_fem");
+  vgi.reduced_mf = vgi.mf->is_reduced();
+  if (vgi.reduced_mf) {
+const auto it = gis.really_extended_vars.find(varname);
+GA_DEBUG_ASSERT(it != gis.really_extended_vars.end(),
+"Variable " << varname << " not in extended 
variables");
+vgi.U = &(it->second);
+vgi.I = &(workspace.temporary_interval_of_variable(varname));
+  } else {
+vgi.U = &(workspace.value(varname));
+vgi.I = &(workspace.interval_of_variable(varname));
+  }
   vgi.alpha = workspace.factor_of_variable(varname);
-  const auto it = gis.extended_vars.find(varname);
-  GA_DEBUG_ASSERT(it != gis.extended_vars.end(),
-  "Variable " << varname << " not in extended variables");
-  vgi.U = it->second;
-  vgi.varname = 
   return 0;
 }
 
@@ -4124,16 +4131,18 @@ namespace getfem {
   : t(t_), E(E_), coeff(coeff_) {}
   };
 
-  struct ga_instruction_fem_vector_assembly : public ga_instruction {
+  struct ga_instruction_vector_assembly_mf : public ga_instruction
+  {
 const base_tensor 
-base_vector , 
+base_vector , 
 const fem_interpolation_context 
-const gmm::sub_interval , 
-const mesh_fem *mfn, **mfg;
-scalar_type 
+const gmm::sub_interval *const, *const I__;
+const mesh_fem *const, *const mf__;
+const bool _mf;
+const scalar_type 
 const size_type , 
 base_vector elem;
-bool interpolate;
+const bool interpolate;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: vector term assembly for fem variable");
   bool empty_weight = (coeff == scalar_type(0));
@@ -4147,62 +4156,80 @@ namespace getfem {
 add_scaled_4(t, coeff, elem);
 
   if (ipt == nbpt-1 || interpolate) { // finalize
-GMM_ASSERT1(mfg ? *mfg : mfn, "Internal error");
-const mesh_fem  = *(mfg ? *mfg : mfn);
-const gmm::sub_interval  = mf.is_reduced() ? Iu : Ir;
-base_vector  = mf.is_reduced() ? Vr : Vn;
-if (!(ctx.is_convex_num_valid())) return 0;
+GA_DEBUG_ASSERT(mf, "Internal error");
+if (!ctx.is_convex_num_valid()) return 0;
 size_type cv_1 = ctx.convex_num();
-// size_type 

[Getfem-commits] [getfem-commits] devel-logari81-internal-variables updated (79df5e1 -> e903249)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-internal-variables.

  from  79df5e1   Clean variable inheritance model for ga_workspace
   new  e903249   Refactor compilation and execution of global vector and 
matrix assembly


Summary of changes:
 .../getfem_generic_assembly_compile_and_exec.h |   12 +-
 src/getfem_generic_assembly_compile_and_exec.cc|  +---
 2 files changed, 748 insertions(+), 375 deletions(-)



Re: [Getfem-commits] Happy New Year 2020

2020-01-03 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo,

Nice that you have found one more mistake.

Actually I don't think that we have a policy for updating headers. I think
Yves did it before making a new release, which is also a good option. If we
are to make a policy for this I would suggest:
- Update headers before a release
- Update only headers of files that where created by the getfem project
And the we have to decide for a policy on whether we update the header of
all files or of the files that where touched since the latest release.

BR
Kostas

On Fri, Jan 3, 2020 at 5:25 AM Tetsuo Koyama  wrote:

> Dear Kostas  and getfem project team
>
> I rechecked the commit and found a obvious mistake.
> I pushed branch devel-tetsuo-fix-header.
>
> Kostas
> Thank you for fix my mistake in your commit.
>
> Best regard Tetsuo.
>
> 2020年1月3日(金) 12:16 Tetsuo Koyama :
> >
> > Dear Kostas  and happy 2020
> >
> > Thank you very much for your comment.
> >
> > >  In general we shouldn't alter third-party license headers.
> > Sorry for my mistake. I didn't notice that. I'm rechecking the
> modification now.
> >
> > > Then the other question is if we really want to change the license
> headers of all files every year or only the license headers of the files
> that have been modified during the past year. This would also exclude many
> of the mistakes on third pary files that we never touch.
> > The OSS project which I know updates the copyright of all the sources
> > in the project. So I followed that way. But your way may be more
> > appropriate to maintain the source code. Either way, I will follow the
> > project policy and will recheck the changes. (Sorry I think I should
> > have checked the project policy before the modification.)
> >
> > Best regards Tetsuo
> >
> > 2020年1月2日(木) 20:16 Konstantinos Poulios :
> > >
> > > Hi Tetsuo and happy 2020,
> > >
> > > I have found and fixed quite a few mistakes in this commit. But I
> would like to ask you if you have time to recheck your changes in this
> commit manually to make sure that we haven't broken any more headers. In
> general we shouldn't alter third-party license headers.
> > >
> > > Then the other question is if we really want to change the license
> headers of all files every year or only the license headers of the files
> that have been modified during the past year. This would also exclude many
> of the mistakes on third pary files that we never touch.
> > >
> > > Best regards
> > > Kostas
> > >
> > > On Wed, Jan 1, 2020 at 11:55 PM Tetsuo Koyama 
> wrote:
> > >>
> > >> Dear Yves
> > >>
> > >> Thank you for your merge.
> > >>
> > >> Best regards,
> > >>
> > >> Tetsuo
> > >>
> > >> 2020年1月2日(木) 1:00 Yves Renard :
> > >>>
> > >>>
> > >>> Dear Tetsuo,
> > >>>
> > >>> Thank for that ! And Happy new year 2020 too !
> > >>>
> > >>> Best regards,
> > >>>
> > >>> Yves
> > >>>
> > >>> - Mail original -
> > >>> De: "Tetsuo Koyama" 
> > >>> À: "getfem-commits" 
> > >>> Envoyé: Mercredi 1 Janvier 2020 10:42:54
> > >>> Objet: [Getfem-commits] Happy New Year 2020
> > >>>
> > >>> Dear getfem project
> > >>>
> > >>> Happy new year 2020 !
> > >>> I updated the year of license.
> > >>> Could you merge devel-tetsuo-happy-new-year-2020?
> > >>>
> > >>> Have a nice year.
> > >>>
> > >>> Best regards Tetsuo
>


[Getfem-commits] (no subject)

2020-01-01 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit cac4df66312b3b6155eab78c794b820a5e25ff57
Author: Konstantinos Poulios 
Date:   Wed Jan 1 11:45:37 2020 +0100

Code readability and typo fixes
---
 src/getfem/getfem_generic_assembly.h|  14 +-
 src/getfem/getfem_models.h  |   4 +-
 src/getfem_generic_assembly_compile_and_exec.cc |   8 +-
 src/getfem_generic_assembly_workspace.cc|   5 +
 src/getfem_models.cc| 218 
 src/getfem_nonlinear_elasticity.cc  |   2 +-
 6 files changed, 131 insertions(+), 120 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 68ea575..8d1f8d4 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -288,10 +288,10 @@ namespace getfem {
   }
 
   var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_,
-  gmm::sub_interval I_, const model_real_plain_vector *v,
+  gmm::sub_interval I_, const model_real_plain_vector *V_,
   size_type Q)
 : is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_),
-  I(I_), V(v), qdims(1)
+  I(I_), V(V_), qdims(1)
   {
 GMM_ASSERT1(Q > 0, "Bad dimension");
 qdims[0] = Q;
@@ -340,10 +340,12 @@ namespace getfem {
 const mesh_region _region(const mesh , const mesh_region );
 
 // variables and variable groups
-mutable std::map int_disabled_variables;
-
 typedef std::map VAR_SET;
 VAR_SET variables;
+
+mutable std::map int_disabled_variables;
+std::map tmp_var_intervals;
+
 std::map transformations;
 std::map elem_transformations;
 std::map secondary_domains;
@@ -362,7 +364,6 @@ namespace getfem {
   bool scalar_expr, operation_type op_type=ASSEMBLY,
   const std::string varname_interpolation="");
 
-
 std::shared_ptr K;
 std::shared_ptr V;
 model_real_sparse_matrix col_unreduced_K,
@@ -372,8 +373,6 @@ namespace getfem {
 base_tensor assemb_t;
 bool include_empty_int_pts = false;
 
-std::map tmp_var_intervals;
-
   public:
 // setter functions
 void set_assembled_matrix(model_real_sparse_matrix _) {
@@ -460,6 +459,7 @@ namespace getfem {
 std::vector _test2,
 std::vector ,
 size_type order);
+bool is_linear(size_type order);
 
 bool variable_exists(const std::string ) const;
 
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 0d72462..54b62d7 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -2304,7 +2304,7 @@ namespace getfem {
 
   /**  Linear elasticity brick ( @f$ \int \sigma(u):\varepsilon(v) @f$ ).
   for isotropic material. Parametrized by Young modulus and Poisson ratio
-  For two-dimensional problems, corresponds to the plain strain
+  For two-dimensional problems, corresponds to the plane strain
   approximation
   ( @f$ \lambda = E\nu/((1+\nu)(1-2\nu)), \mu = E/(2(1+\nu)) @f$ ).
   Corresponds to the standard model for three-dimensional problems.
@@ -2317,7 +2317,7 @@ namespace getfem {
   /** 
   Linear elasticity brick ( @f$ \int \sigma(u):\varepsilon(v) @f$ ).
   for isotropic material. Parametrized by Young modulus and Poisson ratio.
-  For two-dimensional problems, corresponds to the plain stress
+  For two-dimensional problems, corresponds to the plane stress
   approximation
   ( @f$ \lambda^* = E\nu/(1-\nu^2), \mu = E/(2(1+\nu)) @f$ ).
   Corresponds to the standard model for three-dimensional problems.
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index dcf0921..f3d4ac9 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5174,7 +5174,7 @@ namespace getfem {
 (is_elementary ? pnode->elementary_target : 
pnode->name)
 << " has to be defined on the same mesh than the "
 << "integration method or interpolation used");
-
+
 // An instruction for extracting local dofs of the variable.
 if (rmi.local_dofs.count(pnode->name) == 0) {
   rmi.local_dofs[pnode->name] = base_vector(1);
@@ -5206,7 +5206,7 @@ namespace getfem {
 (*mf, rmi.pfps[mf], gis.ctx, gis.fp_pool);
   rmi.instructions.push_back(std::move(pgai));
 }
-
+
 // An instruction for the base value
 pgai = pga_instruction();
 switch (pnode->node_type) {
@@ -5289,7 +5289,7 @@ namespace getfem {
 (rmi.xfem_minus_hess[mf], gis.ctx, *mf, rmi.pfps[mf]);
 }
   break;
-  
+
 default : GMM_ASSERT1(false, 

[Getfem-commits] [getfem-commits] master updated (46ae0a7 -> cac4df6)

2020-01-01 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

  from  46ae0a7   :arrow_up: isort import for PEP8
   new  cac4df6   Code readability and typo fixes


Summary of changes:
 src/getfem/getfem_generic_assembly.h|  14 +-
 src/getfem/getfem_models.h  |   4 +-
 src/getfem_generic_assembly_compile_and_exec.cc |   8 +-
 src/getfem_generic_assembly_workspace.cc|   5 +
 src/getfem_models.cc| 218 
 src/getfem_nonlinear_elasticity.cc  |   2 +-
 6 files changed, 131 insertions(+), 120 deletions(-)



[Getfem-commits] (no subject)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit fb27f37675ffd7d6c8a0a12bd1c6cbaa255dacdd
Author: Konstantinos Poulios 
Date:   Thu Jan 2 11:05:11 2020 +0100

Refactor inheritance of model disabled variables by ga_workspace
---
 src/getfem/getfem_generic_assembly.h | 10 ++--
 src/getfem_generic_assembly_workspace.cc | 84 +---
 src/getfem_models.cc | 45 -
 3 files changed, 57 insertions(+), 82 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index e6d872e..3f47eaa 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -264,7 +264,6 @@ namespace getfem {
 
 const model *md;
 const ga_workspace *parent_workspace;
-bool enable_all_md_variables;
 size_type nb_prim_dof, nb_tmp_dof;
 
 void init();
@@ -343,8 +342,8 @@ namespace getfem {
 typedef std::map VAR_SET;
 VAR_SET variables;
 
-mutable std::map int_disabled_variables;
-std::map tmp_var_intervals;
+std::map reenabled_var_intervals,
+ tmp_var_intervals;
 
 std::map transformations;
 std::map elem_transformations;
@@ -486,9 +485,6 @@ namespace getfem {
 const scalar_type _of_variable(const std::string ) const;
 
 const gmm::sub_interval &
-interval_of_disabled_variable(const std::string ) const;
-
-const gmm::sub_interval &
 interval_of_variable(const std::string ) const;
 
 const mesh_fem *associated_mf(const std::string ) const;
@@ -570,7 +566,7 @@ namespace getfem {
   return (it != tmp_var_intervals.end()) ? it->second : empty_interval;
 }
 
-ga_workspace(const getfem::model _, bool enable_all_variables = false);
+ga_workspace(const getfem::model _, bool 
enable_disabled_variables=false);
 ga_workspace(bool, const ga_workspace );
 ga_workspace();
 ~ga_workspace();
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 756f1fe..330d1db 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -124,28 +124,30 @@ namespace getfem {
 
   bool ga_workspace::is_constant(const std::string ) const {
 VAR_SET::const_iterator it = variables.find(name);
-if (it != variables.end()) return !(it->second.is_variable);
-if (variable_group_exists(name))
+if (it != variables.end())
+  return !(it->second.is_variable);
+else if (variable_group_exists(name))
   return is_constant(first_variable_of_group(name));
-if (md && md->variable_exists(name)) {
-  if (enable_all_md_variables) return md->is_true_data(name);
+else if (reenabled_var_intervals.count(name))
+  return false;
+else if (md && md->variable_exists(name))
   return md->is_data(name);
-}
-if (parent_workspace && parent_workspace->variable_exists(name))
+else if (parent_workspace && parent_workspace->variable_exists(name))
   return parent_workspace->is_constant(name);
 GMM_ASSERT1(false, "Undefined variable " << name);
   }
 
   bool ga_workspace::is_disabled_variable(const std::string ) const {
 VAR_SET::const_iterator it = variables.find(name);
-if (it != variables.end()) return false;
-if (variable_group_exists(name))
+if (it != variables.end())
+  return false;
+else if (variable_group_exists(name))
   return is_disabled_variable(first_variable_of_group(name));
-if (md && md->variable_exists(name)) {
-  if (enable_all_md_variables) return false;
+else if (reenabled_var_intervals.count(name))
+  return false;
+else if (md && md->variable_exists(name))
   return md->is_disabled_variable(name);
-}
-if (parent_workspace && parent_workspace->variable_exists(name))
+else if (parent_workspace && parent_workspace->variable_exists(name))
   return parent_workspace->is_disabled_variable(name);
 GMM_ASSERT1(false, "Undefined variable " << name);
   }
@@ -164,33 +166,14 @@ namespace getfem {
   }
 
   const gmm::sub_interval &
-  ga_workspace::interval_of_disabled_variable(const std::string ) const {
-std::map::const_iterator
-  it1 = int_disabled_variables.find(name);
-if (it1 != int_disabled_variables.end()) return it1->second;
-if (md->is_affine_dependent_variable(name))
-  return interval_of_disabled_variable(md->org_variable(name));
-
-size_type first = md->nb_dof();
-for (const std::pair 
- : int_disabled_variables)
-  first = std::max(first, p.second.last());
-
-int_disabled_variables[name]
-  = gmm::sub_interval(first, gmm::vect_size(value(name)));
-return int_disabled_variables[name];
-  }
-
-  const gmm::sub_interval &
   ga_workspace::interval_of_variable(const std::string ) const {
 VAR_SET::const_iterator it = variables.find(name);
 if (it != variables.end()) return it->second.I;
-if (md && 

[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables created (now fb27f37)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-internal-variables.

at  fb27f37   Refactor inheritance of model disabled variables by 
ga_workspace

This branch includes the following new commits:

   new  fb27f37   Refactor inheritance of model disabled variables by 
ga_workspace




[Getfem-commits] (no subject)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit ab907910d9bafc8de6fc914a8d7d66e2bca1f152
Author: Konstantinos Poulios 
Date:   Thu Jan 2 11:03:03 2020 +0100

File header fixes
---
 src/getfem/getfem_fem_global_function.h  | 2 +-
 src/getfem/getfem_global_function.h  | 2 +-
 src/getfem/getfem_mesh_fem_global_function.h | 2 +-
 src/getfem/getfem_plasticity.h   | 9 +
 src/getfem_global_function.cc| 2 +-
 src/getfem_plasticity.cc | 3 ++-
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/getfem/getfem_fem_global_function.h 
b/src/getfem/getfem_fem_global_function.h
index 2be332e..b678914 100644
--- a/src/getfem/getfem_fem_global_function.h
+++ b/src/getfem/getfem_fem_global_function.h
@@ -2,7 +2,7 @@
 /*===
 
  Copyright (C) 2004-2020 Yves Renard
- Copyright (C) 2016  Konstantinos Poulios
+ Copyright (C) 2016-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 
diff --git a/src/getfem/getfem_global_function.h 
b/src/getfem/getfem_global_function.h
index bc62c74..95f955d 100644
--- a/src/getfem/getfem_global_function.h
+++ b/src/getfem/getfem_global_function.h
@@ -2,7 +2,7 @@
 /*===
 
  Copyright (C) 2004-2020 Yves Renard
- Copyright (C) 2016  Konstantinos Poulios
+ Copyright (C) 2016-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 
diff --git a/src/getfem/getfem_mesh_fem_global_function.h 
b/src/getfem/getfem_mesh_fem_global_function.h
index 74767e5..b66b124 100644
--- a/src/getfem/getfem_mesh_fem_global_function.h
+++ b/src/getfem/getfem_mesh_fem_global_function.h
@@ -2,7 +2,7 @@
 /*===
 
  Copyright (C) 2004-2020 Yves Renard
- Copyright (C) 2016  Konstantinos Poulios
+ Copyright (C) 2016-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 
diff --git a/src/getfem/getfem_plasticity.h b/src/getfem/getfem_plasticity.h
index 412fa6d..95d651e 100644
--- a/src/getfem/getfem_plasticity.h
+++ b/src/getfem/getfem_plasticity.h
@@ -1,7 +1,8 @@
 /* -*- c++ -*- (enables emacs c++ mode) */
 /*===
 
- Copyright (C) 2002-2020 Konstantinos Poulios, Amandine Cottaz, Yves Renard
+ Copyright (C) 2002-2020 Amandine Cottaz, Yves Renard
+ Copyright (C) 2014-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 
@@ -475,13 +476,13 @@ namespace getfem {
   Note that the constitutive lawtype of projection
   to be used is described by `ACP` which should not be
   freed while the model is used.
-  `datalambda` and `datamu` describe the Lam� coeffcients
+  `datalambda` and `datamu` describe the Lamé coeffcients
   of the studied material. Could be scalar or vector fields
   described on a finite element method.
   `datathreshold` represents the elasticity threshold
   of the material. It could be a scalar or a vector field
   described on the same finite element method as
-  the Lam� coefficients.
+  the Lamé coefficients.
   `datasigma` represents the stress constraints values
   supported by the material. It should be a vector field
   described on a finite element method.
@@ -508,7 +509,7 @@ namespace getfem {
   `previous_dep_name` represents the displacement at the previous time 
step,
   `ACP` is the type of projection to be used that could only be
   `Von Mises` for the moment,
-  `datalambda` and `datamu` are the Lam� coefficients
+  `datalambda` and `datamu` are the Lamé coefficients
   of the material,
   `datathreshold` is the elasticity threshold of the material,
   `datasigma` is the vector which will contains the new
diff --git a/src/getfem_global_function.cc b/src/getfem_global_function.cc
index e30d8fe..8f5df8f 100644
--- a/src/getfem_global_function.cc
+++ b/src/getfem_global_function.cc
@@ -1,7 +1,7 @@
 /*===
 
  Copyright (C) 2004-2020 Yves Renard
- Copyright (C) 2016  Konstantinos Poulios
+ Copyright (C) 2016-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 
diff --git a/src/getfem_plasticity.cc b/src/getfem_plasticity.cc
index f87bf91..453ba57 100644
--- a/src/getfem_plasticity.cc
+++ b/src/getfem_plasticity.cc
@@ -1,6 +1,7 @@
 /*===
 
- Copyright (C) 2002-2020 Konstantinos Poulios, Amandine Cottaz, Yves Renard
+ Copyright (C) 2002-2020 Amandine Cottaz, Yves Renard
+ Copyright (C) 2014-2020 Konstantinos Poulios
 
  This file is a part of GetFEM++
 



[Getfem-commits] [getfem-commits] master updated (f360290 -> ab90791)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

  from  f360290   Merge remote-tracking branch 
'origin/devel-tetsuo-happy-new-year-2020'
   new  ab90791   File header fixes


Summary of changes:
 src/getfem/getfem_fem_global_function.h  | 2 +-
 src/getfem/getfem_global_function.h  | 2 +-
 src/getfem/getfem_mesh_fem_global_function.h | 2 +-
 src/getfem/getfem_plasticity.h   | 9 +
 src/getfem_global_function.cc| 2 +-
 src/getfem_plasticity.cc | 3 ++-
 6 files changed, 11 insertions(+), 9 deletions(-)



[Getfem-commits] (no subject)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit cde202b2cfc85d2288ed1a2c7aa4452e7ec07a46
Author: Konstantinos Poulios 
Date:   Thu Jan 2 11:52:06 2020 +0100

File header fixes
---
 GNU_GPL_V3 | 2 +-
 INSTALL| 2 +-
 superlu/colamd.c   | 2 +-
 superlu/colamd.h   | 2 +-
 superlu/dlamch.c   | 6 +++---
 superlu/f2c_lite.c | 2 +-
 superlu/lsame.c| 6 +++---
 superlu/slamch.c   | 6 +++---
 superlu/xerbla.c   | 6 +++---
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/GNU_GPL_V3 b/GNU_GPL_V3
index 16bce6b..94a9ed0 100644
--- a/GNU_GPL_V3
+++ b/GNU_GPL_V3
@@ -74,7 +74,7 @@ modification follow.
 
   "This License" refers to version 3 of the GNU General Public License.
 
-  "Copyright" also means copyright-2020 laws that apply to other kinds of
+  "Copyright" also means copyright-like laws that apply to other kinds of
 works, such as semiconductor masks.
 
   "The Program" refers to any copyrightable work licensed under this
diff --git a/INSTALL b/INSTALL
index 33c6db6..b11ce69 100644
--- a/INSTALL
+++ b/INSTALL
@@ -15,7 +15,7 @@
 #  along  with  this program;  if not, write to the Free Software Foundation,
 #  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 =
-Copyright (C) 1994-1996, 1999-2002, 2004-2020 Free Software Foundation,
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
 Inc.
 
Copying and distribution of this file, with or without modification,
diff --git a/superlu/colamd.c b/superlu/colamd.c
index 3c6a483..dc531f0 100644
--- a/superlu/colamd.c
+++ b/superlu/colamd.c
@@ -49,7 +49,7 @@
 
 Copyright and License:
 
-   Copyright (c) 1998-2020 by the University of Florida.
+   Copyright (c) 1998-2003 by the University of Florida.
All Rights Reserved.
 
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
diff --git a/superlu/colamd.h b/superlu/colamd.h
index 440f7fd..6e30662 100644
--- a/superlu/colamd.h
+++ b/superlu/colamd.h
@@ -24,7 +24,7 @@
 
 Notice:
 
-   Copyright (c) 1998-2020 by the University of Florida.
+   Copyright (c) 1998-2003 by the University of Florida.
All Rights Reserved.
 
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
diff --git a/superlu/dlamch.c b/superlu/dlamch.c
index a510bd9..e01db46 100644
--- a/superlu/dlamch.c
+++ b/superlu/dlamch.c
@@ -10,12 +10,12 @@
 double dlamch_(char *cmach)
 {
 /*  -- LAPACK auxiliary routine (version 2.0) --   
-   Copyright (c) 1992-2020 The University of Tennessee and The University
+   Copyright (c) 1992-2013 The University of Tennessee and The University
 of Tennessee Research Foundation.  All rights
 reserved.
-   Copyright (c) 2000-2020 The University of California Berkeley. All
+   Copyright (c) 2000-2013 The University of California Berkeley. All
 rights reserved.
-   Copyright (c) 2006-2020 The University of Colorado Denver.  All rights
+   Copyright (c) 2006-2013 The University of Colorado Denver.  All rights
 reserved.
 
Redistribution and use in source and binary forms, with or without
diff --git a/superlu/f2c_lite.c b/superlu/f2c_lite.c
index 118ca5b..7dfb0d7 100644
--- a/superlu/f2c_lite.c
+++ b/superlu/f2c_lite.c
@@ -1,5 +1,5 @@
 /*
-  Copyright: 1992-2020 The University of Tennessee.  All rights reserved.
+  Copyright: 1992-2007 The University of Tennessee.  All rights reserved.
   License:
 LAPACK is a freely-available software package. It is available from
 netlib via anonymous ftp and the World Wide Web. Thus, it can be
diff --git a/superlu/lsame.c b/superlu/lsame.c
index e3777be..e235b88 100644
--- a/superlu/lsame.c
+++ b/superlu/lsame.c
@@ -3,12 +3,12 @@
 int lsame_(char *ca, char *cb)
 {
 /*  -- LAPACK auxiliary routine (version 2.0) --   
-   Copyright (c) 1992-2020 The University of Tennessee and The University
+   Copyright (c) 1992-2013 The University of Tennessee and The University
 of Tennessee Research Foundation.  All rights
 reserved.
-   Copyright (c) 2000-2020 The University of California Berkeley. All
+   Copyright (c) 2000-2013 The University of California Berkeley. All
 rights reserved.
-   Copyright (c) 2006-2020 The University of Colorado Denver.  All rights
+   Copyright (c) 2006-2013 The University of Colorado Denver.  All rights
 reserved.
 
Redistribution and use in source and binary forms, with or without
diff --git a/superlu/slamch.c b/superlu/slamch.c
index e8eecc2..08148e2 100644
--- a/superlu/slamch.c
+++ b/superlu/slamch.c
@@ -11,12 +11,12 @@
 double slamch_(char *cmach)
 {
 /*  -- LAPACK auxiliary routine (version 2.0) --   
-   Copyright (c) 1992-2020 The University of Tennessee and The University
+   Copyright (c) 1992-2013 The University of Tennessee and The University
 

[Getfem-commits] [getfem-commits] master updated (ab90791 -> cde202b)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

  from  ab90791   File header fixes
   new  cde202b   File header fixes


Summary of changes:
 GNU_GPL_V3 | 2 +-
 INSTALL| 2 +-
 superlu/colamd.c   | 2 +-
 superlu/colamd.h   | 2 +-
 superlu/dlamch.c   | 6 +++---
 superlu/f2c_lite.c | 2 +-
 superlu/lsame.c| 6 +++---
 superlu/slamch.c   | 6 +++---
 superlu/xerbla.c   | 6 +++---
 9 files changed, 17 insertions(+), 17 deletions(-)



[Getfem-commits] [getfem-commits] master updated (cde202b -> 45d95da)

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

  from  cde202b   File header fixes
   new  45d95da   File header fixes


Summary of changes:
 m4/ax_prog_cc_mpi.m4  | 2 +-
 m4/ax_prog_cxx_mpi.m4 | 2 +-
 m4/ax_prog_fc_mpi.m4  | 2 +-
 m4/matlab.m4  | 2 +-
 m4/matlabver.m4   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)



Re: [Getfem-commits] Happy New Year 2020

2020-01-02 Thread Konstantinos Poulios via Getfem-commits
Hi Tetsuo and happy 2020,

I have found and fixed quite a few mistakes in this commit. But I would
like to ask you if you have time to recheck your changes in this commit
manually to make sure that we haven't broken any more headers. In general
we shouldn't alter third-party license headers.

Then the other question is if we really want to change the license headers
of all files every year or only the license headers of the files that have
been modified during the past year. This would also exclude many of the
mistakes on third pary files that we never touch.

Best regards
Kostas

On Wed, Jan 1, 2020 at 11:55 PM Tetsuo Koyama  wrote:

> Dear Yves
>
> Thank you for your merge.
>
> Best regards,
>
> Tetsuo
>
> 2020年1月2日(木) 1:00 Yves Renard :
>
>>
>> Dear Tetsuo,
>>
>> Thank for that ! And Happy new year 2020 too !
>>
>> Best regards,
>>
>> Yves
>>
>> - Mail original -
>> De: "Tetsuo Koyama" 
>> À: "getfem-commits" 
>> Envoyé: Mercredi 1 Janvier 2020 10:42:54
>> Objet: [Getfem-commits] Happy New Year 2020
>>
>> Dear getfem project
>>
>> Happy new year 2020 !
>> I updated the year of license.
>> Could you merge devel-tetsuo-happy-new-year-2020?
>>
>> Have a nice year.
>>
>> Best regards Tetsuo
>>
>


[Getfem-commits] (no subject)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit d788e47a4897aee425275c7dbc1a16e9a4609a87
Author: Konstantinos Poulios 
AuthorDate: Mon Jan 6 12:40:35 2020 +0100

Remove replaced assembly instruction class
---
 src/getfem_generic_assembly_compile_and_exec.cc | 84 -
 1 file changed, 84 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 618f094..97b0446 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4509,90 +4509,6 @@ namespace getfem {
 const size_type zero_=0;
   };
 
-  struct ga_instruction_matrix_assembly
-: public ga_instruction_matrix_assembly_base
-  {
-model_real_sparse_matrix , 
-const gmm::sub_interval , , , 
-const mesh_fem *mfn1, *mfn2, **mfg1, **mfg2;
-const im_data *imd1, *imd2;
-virtual int exec() {
-  GA_DEBUG_INFO("Instruction: matrix term assembly");
-
-  bool initialize = (ipt == 0) || interpolate || imd1 || imd2;
-  bool empty_weight = (coeff == scalar_type(0));
-  add_tensor_to_element_matrix(initialize, empty_weight); // t --> elem
-
-  if (ipt == nbpt-1 || interpolate || imd1 || imd2) { // finalize
-const mesh_fem *pmf1 = mfg1 ? *mfg1 : mfn1;
-const mesh_fem *pmf2 = mfg2 ? *mfg2 : mfn2;
-bool reduced = (pmf1 && pmf1->is_reduced())
-  || (pmf2 && pmf2->is_reduced());
-model_real_sparse_matrix  = reduced ? Kr : Kn;
-const gmm::sub_interval  = reduced ? Ir1 : In1;
-const gmm::sub_interval  = reduced ? Ir2 : In2;
-GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
-
-scalar_type ninf = gmm::vect_norminf(elem);
-if (ninf == scalar_type(0)) return 0;
-
-size_type s1 = t.sizes()[0], s2 = t.sizes()[1];
-size_type cv1 = ctx1.convex_num(), cv2 = ctx2.convex_num();
-size_type N = 1;
-
-size_type ifirst1 = I1.first(), ifirst2 = I2.first();
-if (imd1) ifirst1 +=  s1*imd1->filtered_index_of_point(cv1, ipt);
-if (imd2) ifirst2 +=  s2*imd2->filtered_index_of_point(cv2, ipt);
-
-if (pmf1) {
-  if (!ctx1.is_convex_num_valid()) return 0;
-  N = ctx1.N();
-  size_type qmult1 = pmf1->get_qdim();
-  if (qmult1 > 1) qmult1 /= pmf1->fem_of_element(cv1)->target_dim();
-  populate_dofs_vector(dofs1, s1, ifirst1, qmult1,// --> dofs1
-   pmf1->ind_scalar_basic_dof_of_element(cv1));
-} else
-  populate_contiguous_dofs_vector(dofs1, s1, ifirst1); // --> dofs1
-
-if (pmf1 == pmf2 && (pmf1 ? (cv1 == cv2) : (s1 == s2))) {
-  if (ifirst1 == ifirst2) {
-add_elem_matrix(K, dofs1, dofs1, dofs1_sort, elem, ninf*1E-14, N);
-  } else {
-populate_dofs_vector(dofs2, dofs1.size(), ifirst2 - ifirst1, 
dofs1);
-add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-  }
-} else {
-  if (pmf2) {
-if (!ctx2.is_convex_num_valid()) return 0;
-N = std::max(N, ctx2.N());
-size_type qmult2 = pmf2->get_qdim();
-if (qmult2 > 1) qmult2 /= pmf2->fem_of_element(cv2)->target_dim();
-populate_dofs_vector(dofs2, s2, ifirst2, qmult2,// --> 
dofs2
- pmf2->ind_scalar_basic_dof_of_element(cv2));
-  } else
-populate_contiguous_dofs_vector(dofs2, s2, ifirst2); // --> dofs2
-  add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-}
-  }
-  return 0;
-}
-ga_instruction_matrix_assembly
-(const base_tensor _,
- model_real_sparse_matrix _, model_real_sparse_matrix _,
- const fem_interpolation_context _,
- const fem_interpolation_context _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const mesh_fem *mfn1_, const mesh_fem **mfg1_, const im_data *imd1_,
- const mesh_fem *mfn2_, const mesh_fem **mfg2_, const im_data *imd2_,
- const scalar_type , const scalar_type , const scalar_type _,
- const size_type _, const size_type _, bool interpolate_)
-  : ga_instruction_matrix_assembly_base
-(t_, ctx1_, ctx2_, a1, a2, coeff_, nbpt_, ipt_, interpolate_),
-Kr(Kr_), Kn(Kn_), Ir1(Ir1_), Ir2(Ir2_), In1(In1_), In2(In2_),
-mfn1(mfn1_), mfn2(mfn2_), mfg1(mfg1_), mfg2(mfg2_),
-imd1(imd1_), imd2(imd2_) {}
-  };
 
   struct ga_instruction_matrix_assembly_mf_mf
 : public ga_instruction_matrix_assembly_base



[Getfem-commits] [getfem-commits] devel-logari81-internal-variables updated (afe03f8 -> d788e47)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-internal-variables.

from afe03f8  adding a test
 new d56812c  Basic infrastructure for defining internal variables
 new d788e47  Remove replaced assembly instruction class


Summary of changes:
 src/getfem/getfem_generic_assembly.h| 14 +++-
 src/getfem/getfem_models.h  | 72 ---
 src/getfem_generic_assembly_compile_and_exec.cc | 96 ++---
 src/getfem_generic_assembly_workspace.cc| 36 +-
 src/getfem_models.cc| 39 ++
 5 files changed, 125 insertions(+), 132 deletions(-)



[Getfem-commits] (no subject)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit d56812c6dc2926e0978df1e15786ed07a687ecb7
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 3 23:45:46 2020 +0100

Basic infrastructure for defining internal variables

 - no condensation functionality yet
---
 src/getfem/getfem_generic_assembly.h| 14 +++--
 src/getfem/getfem_models.h  | 72 -
 src/getfem_generic_assembly_compile_and_exec.cc | 12 +++--
 src/getfem_generic_assembly_workspace.cc| 36 -
 src/getfem_models.cc| 39 +-
 5 files changed, 125 insertions(+), 48 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index ddd7266..3b7872b 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -265,7 +265,7 @@ namespace getfem {
 const model *md;
 const ga_workspace *parent_workspace;
 bool with_parent_variables;
-size_type nb_prim_dof, nb_tmp_dof;
+size_type nb_prim_dof, nb_intern_dof, first_intern_dof, nb_tmp_dof;
 
 void init();
 
@@ -280,6 +280,7 @@ namespace getfem {
   bgeot::multi_index qdims;  // For data having a qdim different than the
  // qdim of the fem or im_data (dim per dof for
  // dof data) and for constant variables.
+  const bool is_internal;
 
   size_type qdim() const {
 size_type q = 1;
@@ -289,9 +290,9 @@ namespace getfem {
 
   var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_,
   gmm::sub_interval I_, const model_real_plain_vector *V_,
-  size_type Q)
+  size_type Q, bool is_intern_=false)
 : is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_),
-  I(I_), V(V_), qdims(1)
+  I(I_), V(V_), qdims(1), is_internal(is_intern_)
   {
 GMM_ASSERT1(Q > 0, "Bad dimension");
 qdims[0] = Q;
@@ -444,6 +445,9 @@ namespace getfem {
 void add_im_variable(const std::string , const im_data ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
+void add_internal_im_variable(const std::string , const im_data ,
+  const gmm::sub_interval ,
+  const model_real_plain_vector );
 void add_fixed_size_variable(const std::string ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
@@ -463,6 +467,8 @@ namespace getfem {
 
 bool variable_exists(const std::string ) const;
 
+bool is_internal_variable(const std::string ) const;
+
 const std::string _in_group(const std::string _name,
  const mesh ) const;
 
@@ -551,6 +557,8 @@ namespace getfem {
 bool include_empty_int_points() const;
 
 size_type nb_primary_dof() const { return nb_prim_dof; }
+size_type nb_internal_dof() const { return nb_intern_dof; }
+size_type first_internal_dof() const { return first_intern_dof; }
 size_type nb_temporary_dof() const { return nb_tmp_dof; }
 
 void add_temporary_interval_for_unreduced_variable(const std::string 
);
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 175d337..8b8c7f2 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -151,6 +151,8 @@ namespace getfem {
   bool is_complex;  // The variable is complex numbers
   bool is_affine_dependent; // The variable depends in an affine way
 // to another variable.
+  bool is_internal; // An internal variable defined on integration
+// points, condensed out of the global system.
   bool is_fem_dofs; // The variable is the dofs of a fem
   size_type n_iter; // Number of versions of the variable stored.
   size_type n_temp_iter;// Number of additional temporary versions
@@ -198,7 +200,7 @@ namespace getfem {
   const std::string _var_ = std::string(""),
   mesh_im const *filter_mim_ = 0)
 : is_variable(is_var), is_disabled(false), is_complex(is_compl),
-  is_affine_dependent(false),
+  is_affine_dependent(false), is_internal(false),
   is_fem_dofs(mf_ != 0),
   n_iter(std::max(size_type(1), n_it)), n_temp_iter(0),
   default_iter(0), ptsc(0),
@@ -525,6 +527,9 @@ namespace getfem {
 /** States if a name corresponds to a declared data. */
 bool is_true_data(const std::string ) const;
 
+/** States if a variable is condensed out of the global system. */
+bool is_internal_variable(const std::string ) const;
+
 bool is_affine_dependent_variable(const std::string ) const;
 
 const std::string _variable(const 

[Getfem-commits] [getfem-commits] branch devel-logari81-internal-variables updated: Implementation of internal variable condensation in ga_workspace

2020-01-08 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-internal-variables
in repository getfem.

The following commit(s) were added to 
refs/heads/devel-logari81-internal-variables by this push:
 new ee1b344  Implementation of internal variable condensation in 
ga_workspace
ee1b344 is described below

commit ee1b344c1a0c0545d0255a217dbf3c849cae39e1
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 8 11:53:37 2020 +0100

Implementation of internal variable condensation in ga_workspace
---
 src/getfem/getfem_generic_assembly.h   |  18 +-
 .../getfem_generic_assembly_compile_and_exec.h |   5 +-
 src/getfem_generic_assembly_compile_and_exec.cc| 771 -
 src/getfem_generic_assembly_workspace.cc   |  68 +-
 4 files changed, 830 insertions(+), 32 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 3b7872b..16b77b6 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -365,8 +365,10 @@ namespace getfem {
   bool scalar_expr, operation_type op_type=ASSEMBLY,
   const std::string varname_interpolation="");
 
-std::shared_ptr K;
-std::shared_ptr V;
+std::shared_ptr K, KQJpr;
+std::shared_ptr V; // reduced residual vector (primary vars + 
internal vars)
+// after condensation it partially holds 
the condensed residual
+// and the internal solution
 model_real_sparse_matrix col_unreduced_K,
  row_unreduced_K,
  row_col_unreduced_K;
@@ -406,6 +408,15 @@ namespace getfem {
 model_real_sparse_matrix _col_unreduced_matrix()
 { return row_col_unreduced_K; }
 base_vector _vector() { return unreduced_V; }
+// setter function for condensation matrix
+void set_internal_coupling_matrix(model_real_sparse_matrix _) {
+  KQJpr = std::shared_ptr
+  (std::shared_ptr(), _); // alias
+}
+// getter functions for condensation matrix/vectors
+const model_real_sparse_matrix _coupling_matrix() const
+{ return *KQJpr; }
+model_real_sparse_matrix _coupling_matrix() { return *KQJpr; }
 
 /** Add an expression, perform the semantic analysis, split into
  *  terms in separated test functions, derive if necessary to obtain
@@ -550,8 +561,7 @@ namespace getfem {
 std::string extract_order0_term();
 std::string extract_Neumann_term(const std::string );
 
-
-void assembly(size_type order);
+void assembly(size_type order, bool condensation=false);
 
 void set_include_empty_int_points(bool include);
 bool include_empty_int_points() const;
diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index e477024..84d28ea 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -202,6 +202,9 @@ namespace getfem {
 
 std::map all_instructions;
 
+// storage of intermediary tensors for condensation of variables
+std::list> condensation_tensors;
+
 ga_instruction_set() : need_elt_size(false), nbpt(0), ipt(0) {}
   };
 
@@ -209,7 +212,7 @@ namespace getfem {
   void ga_exec(ga_instruction_set , ga_workspace );
   void ga_function_exec(ga_instruction_set );
   void ga_compile(ga_workspace , ga_instruction_set ,
-  size_type order);
+  size_type order, bool condensation=false);
   void ga_compile_function(ga_workspace ,
ga_instruction_set , bool scalar);
   void ga_compile_interpolation(ga_workspace ,
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 97b0446..890b1b5 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4207,7 +4207,7 @@ namespace getfem {
 const im_data 
 scalar_type 
 const size_type 
-const bool overwrite;
+const bool initialize;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: vector term assembly for im_data variable");
   size_type cv = ctx.convex_num();
@@ -4215,7 +4215,7 @@ namespace getfem {
   GMM_ASSERT1(i+t.size() <= I.size(),
   "Internal error "size()
+== (qq1end-qq1start)*(qq2end-qq2start),
+"Internal error");
+for (size_type qq2=qq2start; qq2 < qq2end; ++qq2)
+  for (size_type qq1=qq1start; qq1 < qq1end; ++qq1)
+invK(qq1,qq2) = *itr++;
+  }
+}
+  }
+  // calculate inverse matrix invK
+  

[Getfem-commits] [getfem-commits] branch master updated: Fix and simplify ga_local_projection for models with internal variables

2020-04-18 Thread Konstantinos Poulios via Getfem-commits
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 6ff98d3  Fix and simplify ga_local_projection for models with internal 
variables
6ff98d3 is described below

commit 6ff98d372828f5d48558f6610095e4d122edfa0f
Author: Konstantinos Poulios 
AuthorDate: Sat Apr 18 15:58:40 2020 +0200

Fix and simplify ga_local_projection for models with internal variables
---
 src/getfem_generic_assembly_interpolation.cc | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/getfem_generic_assembly_interpolation.cc 
b/src/getfem_generic_assembly_interpolation.cc
index d36f22e..2f45470 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -443,23 +443,22 @@ namespace getfem {
 
 // Could be improved by not performing the assembly of the global mass 
matrix
 // working locally. This means a specific assembly.
-model_real_sparse_matrix M(mf.nb_dof(), mf.nb_dof());
+size_type nbdof = mf.nb_dof();
+model_real_sparse_matrix M(nbdof, nbdof);
 asm_mass_matrix(M, mim, mf, region);
+// FIXME: M should be cached for performance
 
-ga_workspace workspace(md);
-size_type nbdof = md.nb_dof();
-gmm::sub_interval I(nbdof, mf.nb_dof());
+ga_workspace workspace(md, ga_workspace::inherit::NONE);
+gmm::sub_interval I(0,nbdof);
 workspace.add_fem_variable("c__dummy_var_95_", mf, I, base_vector(nbdof));
 if (mf.get_qdims().size() > 1)
   
workspace.add_expression("("+expr+"):Test_c__dummy_var_95_",mim,region,2);
 else
   
workspace.add_expression("("+expr+").Test_c__dummy_var_95_",mim,region,2);
-base_vector residual(nbdof+mf.nb_dof());
-workspace.set_assembled_vector(residual);
+getfem::base_vector F(nbdof);
+workspace.set_assembled_vector(F);
 workspace.assembly(1);
-getfem::base_vector F(mf.nb_dof());
-gmm::resize(result, mf.nb_dof());
-gmm::copy(gmm::sub_vector(residual, I), F);
+gmm::resize(result, nbdof);
 
 getfem::base_matrix loc_M;
 getfem::base_vector loc_U;



[Getfem-commits] [getfem-commits] branch master updated: Interface functions for the addition of internal variables to a model

2020-04-18 Thread Konstantinos Poulios via Getfem-commits
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 9de33b4  Interface functions for the addition of internal variables to 
a model
9de33b4 is described below

commit 9de33b40fb67be58b755716bf0b06f8cd5b32cd9
Author: Konstantinos Poulios 
AuthorDate: Sat Apr 18 15:56:38 2020 +0200

Interface functions for the addition of internal variables to a model
---
 interface/src/gf_model_set.cc | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc
index a093ca8..288572d 100644
--- a/interface/src/gf_model_set.cc
+++ b/interface/src/gf_model_set.cc
@@ -118,6 +118,29 @@ void gf_model_set(getfemint::mexargs_in& m_in,
);
 
 
+/*@SET ('add im variable', @str name, @tmimd mimd)
+  Add a variable to the model linked to a @tmimd. `name` is the variable
+  name. @*/
+sub_command
+  ("add im variable", 2, 2, 0, 0,
+   std::string name = in.pop().to_string();
+   getfem::im_data *mimd = to_meshimdata_object(in.pop());
+   md->add_im_variable(name, *mimd);
+   workspace().set_dependence(md, mimd);
+   );
+
+/*@SET ('add internal im variable', @str name, @tmimd mimd)
+  Add a variable to the model, which is linked to a @tmimd and will be
+  condensed out during the assemblage of the tangent matrix. `name` is
+  the variable name. @*/
+sub_command
+  ("add internal im variable", 2, 2, 0, 0,
+   std::string name = in.pop().to_string();
+   getfem::im_data *mimd = to_meshimdata_object(in.pop());
+   md->add_internal_im_variable(name, *mimd);
+   workspace().set_dependence(md, mimd);
+   );
+
 /*@SET ('add variable', @str name, sizes)
   Add a variable to the model of constant sizes. `sizes` is either a
   integer (for a scalar or vector variable) or a vector of dimensions



[Getfem-commits] [getfem-commits] branch master updated: Fix too strict assertion

2020-04-19 Thread Konstantinos Poulios via Getfem-commits
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 85d5e07  Fix too strict assertion
85d5e07 is described below

commit 85d5e07c867446a77bc8b15c9a107ef368f296f2
Author: Konstantinos Poulios 
AuthorDate: Sun Apr 19 20:54:36 2020 +0200

Fix too strict assertion
---
 src/getfem_generic_assembly_compile_and_exec.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 0ae8139..6eb3095 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1287,8 +1287,8 @@ namespace getfem {
 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: copy small vector");
-  GMM_ASSERT1(inin.ctx.is_convex_num_valid(), "Invalid element, "
-  "probably transformation failed");
+  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::copy(vec, t.as_vector());
   return 0;



Re: [Getfem-commits] Please merge devel-tetsuo-fix-type

2020-04-17 Thread Konstantinos Poulios via Getfem-commits
Has this been merged in the meanwhile?

On Fri, Jan 17, 2020 at 12:40 PM Tetsuo Koyama  wrote:

> OK. thanks.
>
> 2020年1月17日(金) 20:17 Konstantinos Poulios :
>
>> I would maybe leave this for after merging my internal-variables branch
>>
>> On Fri, Jan 17, 2020 at 8:36 AM Tetsuo Koyama 
>> wrote:
>>
>>> Hi getfem project.
>>>
>>> I fixed one line of Newmark_beta_method object code.
>>> It is a explicit define of scalar_type.
>>> Could you merge devel-tetsuo-fix-type?
>>>
>>> Thank you for reading.
>>>
>>> Best regard Tetsuo
>>>
>>>


[Getfem-commits] [getfem-commits] branch master updated: Fix deprecation warnings

2020-04-04 Thread Konstantinos Poulios via Getfem-commits
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 03b82cc  Fix deprecation warnings
03b82cc is described below

commit 03b82ccab94cbfdf262f000cfc31660d8b6955fd
Author: Konstantinos Poulios 
AuthorDate: Sat Apr 4 14:40:50 2020 +0200

Fix deprecation warnings
---
 contrib/aposteriori/aposteriori_laplacian.cc | 4 ++--
 contrib/xfem_contact/xfem_stokes.cc  | 2 +-
 src/getfem/bgeot_mesh_structure.h| 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/aposteriori/aposteriori_laplacian.cc 
b/contrib/aposteriori/aposteriori_laplacian.cc
index 5deb7c1..c7f78f7 100644
--- a/contrib/aposteriori/aposteriori_laplacian.cc
+++ b/contrib/aposteriori/aposteriori_laplacian.cc
@@ -352,12 +352,12 @@ void crack_problem::error_estimate(const plain_vector , 
plain_vector ) {
 
 scalar_type ee2 = ERR[cv] - ee1;
  
-// jump of the stress between the element ant its neighbours.
+// jump of the stress between the element ant its neighbors.
 for (short_type f1=0; f1 < mesh.structure_of_convex(cv)->nb_faces(); ++f1) 
{
 
   if 
(gmm::abs((*mmls)(mesh.trans_of_convex(cv)->convex_ref()->points_of_face(f1)[0]))
 < 1E-7 * radius) continue;
 
-  size_type cvn = mesh.neighbour_of_convex(cv, f1);
+  size_type cvn = mesh.neighbor_of_convex(cv, f1);
   if (cvn == size_type(-1)) continue;

   bgeot::pgeometric_trans pgt2 = mesh.trans_of_convex(cvn);
diff --git a/contrib/xfem_contact/xfem_stokes.cc 
b/contrib/xfem_contact/xfem_stokes.cc
index 8d69ecd..50400f5 100644
--- a/contrib/xfem_contact/xfem_stokes.cc
+++ b/contrib/xfem_contact/xfem_stokes.cc
@@ -680,7 +680,7 @@ int main(int argc, char *argv[]) {
   bgeot::mesh_structure::ind_set is;
   base_matrix Mloc;
   for (dal::bv_visitor i(elt_black_list); !i.finished(); ++i) {
-   mesh.neighbours_of_convex(i, is);
+   mesh.neighbors_of_convex(i, is);
size_type cv2 = size_type(-1);
scalar_type ratio = scalar_type(0);
for (size_type j = 0; j < is.size(); ++j) {
diff --git a/src/getfem/bgeot_mesh_structure.h 
b/src/getfem/bgeot_mesh_structure.h
index 1cadee6..69b5d65 100644
--- a/src/getfem/bgeot_mesh_structure.h
+++ b/src/getfem/bgeot_mesh_structure.h
@@ -209,8 +209,8 @@ namespace bgeot {
 @param s the resulting ind_set.
  */
 void neighbors_of_convex(size_type ic,
-  const std::vector ,
-  ind_set ) const;
+ const std::vector ,
+ ind_set ) const;
 void neighbours_of_convex(size_type ic,
   const std::vector ,
   ind_set ) const IS_DEPRECATED



[Getfem-commits] [getfem-commits] branch master updated: Support both installed and non-installed python3 module imports

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
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 fef17a6  Support both installed and non-installed python3 module 
imports
fef17a6 is described below

commit fef17a660a013637f777ab5846386084df65ac09
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 3 16:59:20 2020 +0200

Support both installed and non-installed python3 module imports
---
 bin/extract_doc  | 6 +-
 interface/src/python/__init__.py | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/extract_doc b/bin/extract_doc
index 3d5788c..78b1f25 100755
--- a/bin/extract_doc
+++ b/bin/extract_doc
@@ -1622,7 +1622,11 @@ except ImportError:
 
 from numpy import *
 
-from _getfem import *
+try:
+  from ._getfem import *
+except ImportError:
+  from _getfem import *
+
 obj_count = {}
 getfem('workspace', 'clear all')
 
diff --git a/interface/src/python/__init__.py b/interface/src/python/__init__.py
index 1971861..d0cb235 100644
--- a/interface/src/python/__init__.py
+++ b/interface/src/python/__init__.py
@@ -13,4 +13,4 @@ __LICENSE__ = """\
 GetFEM++ is free software; you can redistribute it and/or modify it under the 
terms of the GNU Lesser General Public License as published by the Free 
Software Foundation; either version 3 of the License, or (at your option) any 
later version along with the GCC Runtime Library Exception either version 3.1 
or (at your option) any later version. This program is distributed in the hope 
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
warranty of MERCHANTABILITY or F [...]
 """
 
-from getfem import *
+from .getfem import *



[Getfem-commits] [getfem-commits] branch master updated: Refactor inheritance of model disabled variables by ga_workspace

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
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 df4d3c4  Refactor inheritance of model disabled variables by 
ga_workspace
df4d3c4 is described below

commit df4d3c40d6fe7f5573ff79ee17b87f013e4ce1c1
Author: Konstantinos Poulios 
AuthorDate: Thu Jan 2 11:05:11 2020 +0100

Refactor inheritance of model disabled variables by ga_workspace
---
 src/getfem/getfem_generic_assembly.h | 10 ++--
 src/getfem_generic_assembly_workspace.cc | 84 +---
 src/getfem_models.cc | 45 -
 3 files changed, 57 insertions(+), 82 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 87c2f69..f3bd9a7 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -264,7 +264,6 @@ namespace getfem {
 
 const model *md;
 const ga_workspace *parent_workspace;
-bool enable_all_md_variables;
 size_type nb_prim_dof, nb_tmp_dof;
 
 void init();
@@ -343,8 +342,8 @@ namespace getfem {
 typedef std::map VAR_SET;
 VAR_SET variables;
 
-mutable std::map int_disabled_variables;
-std::map tmp_var_intervals;
+std::map reenabled_var_intervals,
+ tmp_var_intervals;
 
 std::map transformations;
 std::map elem_transformations;
@@ -486,9 +485,6 @@ namespace getfem {
 const scalar_type _of_variable(const std::string ) const;
 
 const gmm::sub_interval &
-interval_of_disabled_variable(const std::string ) const;
-
-const gmm::sub_interval &
 interval_of_variable(const std::string ) const;
 
 const mesh_fem *associated_mf(const std::string ) const;
@@ -570,7 +566,7 @@ namespace getfem {
   return (it != tmp_var_intervals.end()) ? it->second : empty_interval;
 }
 
-ga_workspace(const getfem::model _, bool enable_all_variables = false);
+ga_workspace(const getfem::model _, bool 
enable_disabled_variables=false);
 ga_workspace(bool, const ga_workspace );
 ga_workspace();
 ~ga_workspace();
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 7a82c8b..27583c2 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -151,28 +151,30 @@ namespace getfem {
 
   bool ga_workspace::is_constant(const std::string ) const {
 VAR_SET::const_iterator it = variables.find(name);
-if (it != variables.end()) return !(it->second.is_variable);
-if (variable_group_exists(name))
+if (it != variables.end())
+  return !(it->second.is_variable);
+else if (variable_group_exists(name))
   return is_constant(first_variable_of_group(name));
-if (md && md->variable_exists(name)) {
-  if (enable_all_md_variables) return md->is_true_data(name);
+else if (reenabled_var_intervals.count(name))
+  return false;
+else if (md && md->variable_exists(name))
   return md->is_data(name);
-}
-if (parent_workspace && parent_workspace->variable_exists(name))
+else if (parent_workspace && parent_workspace->variable_exists(name))
   return parent_workspace->is_constant(name);
 GMM_ASSERT1(false, "Undefined variable " << name);
   }
 
   bool ga_workspace::is_disabled_variable(const std::string ) const {
 VAR_SET::const_iterator it = variables.find(name);
-if (it != variables.end()) return false;
-if (variable_group_exists(name))
+if (it != variables.end())
+  return false;
+else if (variable_group_exists(name))
   return is_disabled_variable(first_variable_of_group(name));
-if (md && md->variable_exists(name)) {
-  if (enable_all_md_variables) return false;
+else if (reenabled_var_intervals.count(name))
+  return false;
+else if (md && md->variable_exists(name))
   return md->is_disabled_variable(name);
-}
-if (parent_workspace && parent_workspace->variable_exists(name))
+else if (parent_workspace && parent_workspace->variable_exists(name))
   return parent_workspace->is_disabled_variable(name);
 GMM_ASSERT1(false, "Undefined variable " << name);
   }
@@ -191,33 +193,14 @@ namespace getfem {
   }
 
   const gmm::sub_interval &
-  ga_workspace::interval_of_disabled_variable(const std::string ) const {
-std::map::const_iterator
-  it1 = int_disabled_variables.find(name);
-if (it1 != int_disabled_variables.end()) return it1->second;
-if (md->is_affine_dependent_variable(name))
-  return interval_of_disabled_variable(md->org_variable(name));
-
-size_type first = md->nb_dof();
-for (const std::pair 
- : int_disabled_variables)
-  first = std::max(first, p.second.last());
-
-int_disabled_variables[name]
-  = gmm::sub_interval(first, gmm::vect_size(value(name)));
-

[Getfem-commits] [getfem-commits] branch master updated: Clean variable inheritance model for ga_workspace

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
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 7afd1f5  Clean variable inheritance model for ga_workspace
7afd1f5 is described below

commit 7afd1f596b1e290d98c8f3de498c13835faece24
Author: Konstantinos Poulios 
AuthorDate: Thu Jan 2 18:43:14 2020 +0100

Clean variable inheritance model for ga_workspace

 - Now it is possible to create a ga_workspace linked
   to a model or another workspace without inheriting
   its variables at all ga_workspace::inherit::NONE

 - Temporary enabling disabled variables of the parent
   model is now done with ga_workspace::inherit::ALL
   instead of ga_workspace::inherit::ENABLED
---
 src/getfem/getfem_generic_assembly.h   |  9 --
 src/getfem_contact_and_friction_integral.cc|  2 +-
 ...fem_generic_assembly_functions_and_operators.cc |  3 +-
 src/getfem_generic_assembly_interpolation.cc   |  4 +--
 src/getfem_generic_assembly_workspace.cc   | 32 ---
 src/getfem_models.cc   | 37 --
 6 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index f3bd9a7..453e34e 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -264,6 +264,7 @@ namespace getfem {
 
 const model *md;
 const ga_workspace *parent_workspace;
+bool with_parent_variables;
 size_type nb_prim_dof, nb_tmp_dof;
 
 void init();
@@ -566,8 +567,12 @@ namespace getfem {
   return (it != tmp_var_intervals.end()) ? it->second : empty_interval;
 }
 
-ga_workspace(const getfem::model _, bool 
enable_disabled_variables=false);
-ga_workspace(bool, const ga_workspace );
+enum class inherit { NONE, ENABLED, ALL };
+
+ga_workspace(const getfem::model _,
+ const inherit var_inherit=inherit::ENABLED);
+ga_workspace(const ga_workspace ,// compulsory 2nd arg to avoid
+ const inherit var_inherit); // conflict with copy constructor
 ga_workspace();
 ~ga_workspace();
 
diff --git a/src/getfem_contact_and_friction_integral.cc 
b/src/getfem_contact_and_friction_integral.cc
index 58d2f65..9d838e5 100644
--- a/src/getfem_contact_and_friction_integral.cc
+++ b/src/getfem_contact_and_friction_integral.cc
@@ -2551,7 +2551,7 @@ namespace getfem {
size_type region) {
 
 std::string theta = std::to_string(theta_);
-ga_workspace workspace(md, true);
+ga_workspace workspace(md, ga_workspace::inherit::ALL); // reenables vars
 size_type order = workspace.add_expression(Neumannterm, mim, region, 1);
 GMM_ASSERT1(order == 0, "Wrong expression of the Neumann term");
 // model::varnamelist vl, vl_test1, vl_test2, dl;
diff --git a/src/getfem_generic_assembly_functions_and_operators.cc 
b/src/getfem_generic_assembly_functions_and_operators.cc
index d0cf80e..7e5a00b 100644
--- a/src/getfem_generic_assembly_functions_and_operators.cc
+++ b/src/getfem_generic_assembly_functions_and_operators.cc
@@ -678,7 +678,8 @@ namespace getfem {
 
   ga_function::ga_function(const ga_workspace _,
const std::string )
-: local_workspace(true, workspace_), expr(e), gis(0) {}
+: local_workspace(workspace_, ga_workspace::inherit::ALL),
+  expr(e), gis(0) {}
 
   ga_function::ga_function(const model , const std::string )
 : local_workspace(md), expr(e), gis(0) {}
diff --git a/src/getfem_generic_assembly_interpolation.cc 
b/src/getfem_generic_assembly_interpolation.cc
index 967f595..439dbd8 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -533,7 +533,7 @@ namespace getfem {
   used_vars.clear();
 else
   used_data.clear();
-ga_workspace aux_workspace(true, workspace);
+ga_workspace aux_workspace(workspace, ga_workspace::inherit::ALL);
 aux_workspace.clear_expressions();
 aux_workspace.add_interpolation_expression(expr, source_mesh);
 for (size_type i = 0; i < aux_workspace.nb_trees(); ++i)
@@ -556,7 +556,7 @@ namespace getfem {
   size_type N = target_mesh.dim();
 
   // Expression compilation
-  local_workspace = ga_workspace(true, workspace);
+  local_workspace = ga_workspace(workspace, ga_workspace::inherit::ALL);
   local_workspace.clear_expressions();
 
   local_workspace.add_interpolation_expression(expr, source_mesh);
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 27583c2..6cd17db 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -198,9 +198,10 @@ namespace getfem {
 if (it != variables.end()) return it->second.I;
 const 

[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit a8a51a7f4ba8e30e1b9fee73288705a7d7a55d9b
Author: Yves Renard 
AuthorDate: Sun Jan 5 16:11:55 2020 +0100

adding a test
---
 interface/tests/python/Makefile.am |  1 +
 .../demo_thermo_elasticity_electrical_coupling.py  | 26 +-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/interface/tests/python/Makefile.am 
b/interface/tests/python/Makefile.am
index e6bd548..40d7d4d 100644
--- a/interface/tests/python/Makefile.am
+++ b/interface/tests/python/Makefile.am
@@ -49,6 +49,7 @@ EXTRA_DIST=   \
demo_stokes_3D_tank_draw.py \
demo_finite_strain_plasticity.py\
demo_finite_strain_plasticity_3D.py \
+   demo_thermo_elasticity_electrical_coupling.py   \
demo_cracked_thermo_elastic_body.py \
demo_nonlinear_elasticity.py\
demo_elasticity_HHO.py  \
diff --git 
a/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py 
b/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
index 5d02c6e..0540e39 100644
--- a/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
+++ b/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
@@ -79,10 +79,11 @@ alpha = 0.0039 # Second resistance temperature 
coefficient.
 #
 # Numerical parameters
 #
-h = 2. # Approximate mesh size
-elements_degree = 2# Degree of the finite element methods
-export_mesh = True # Draw the mesh after mesh generation or not
-solve_in_two_steps = True  # Solve the elasticity problem separately or not
+h = 2.# Approximate mesh size
+elements_degree = 2   # Degree of the finite element methods
+export_mesh = True# Draw the mesh after mesh generation or not
+solve_in_two_steps = 2# Solve the elasticity problem separately (1)
+  # or in a coupled way (0) or both and compare (2)
 
 #
 # Mesh generation. Meshes can also been imported from several formats.
@@ -203,7 +204,8 @@ md.add_linear_term(mim, 
'beta*(T0-theta)*Trace(Grad_Test_u)')
 #
 # Model solve
 #
-if (solve_in_two_steps):
+
+if (solve_in_two_steps >= 1):
   md.disable_variable('u')
   print('First problem with', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
@@ -212,10 +214,22 @@ if (solve_in_two_steps):
   md.disable_variable('V')
   print('Second problem with ', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
-else:
+  md.enable_variable('theta')
+  md.enable_variable('V')
+  U1 = md.variable('u')
+  
+if (solve_in_two_steps == 0):
   print('Global problem with ', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
 
+if (solve_in_two_steps == 2):
+  print('Global problem with ', md.nbdof(), ' dofs')
+  md.set_variable('u', md.variable('u')*0.);
+  md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
+  U2 = md.variable('u')
+  print (np.linalg.norm(U2-U1));
+  if (np.linalg.norm(U2-U1) > 1E-10):
+  print("Too big difference between solve in one and two steps"); exit(1)
 
 #
 # Solution export



[Getfem-commits] [getfem-commits] master updated (7afd1f5 -> a8a51a7)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 7afd1f5  Clean variable inheritance model for ga_workspace
 new 2942d41  Refactor compilation and execution of global vector and 
matrix assembly
 new a8a51a7  adding a test


Summary of changes:
 interface/tests/python/Makefile.am |1 +
 .../demo_thermo_elasticity_electrical_coupling.py  |   26 +-
 .../getfem_generic_assembly_compile_and_exec.h |   12 +-
 src/getfem_generic_assembly_compile_and_exec.cc| 1117 +---
 4 files changed, 772 insertions(+), 384 deletions(-)



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 2942d419172f23fa7249db87a46136b0533c0992
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 3 02:26:06 2020 +0100

Refactor compilation and execution of global vector and matrix assembly

  - more specialized matrix assembly instruction classes for different
combinations of variable types (mesh_fem, mesh_im_data, global)

  - dispatching according to variable type at compilation rather than
run time

# Conflicts:
#   src/getfem_generic_assembly_compile_and_exec.cc
---
 .../getfem_generic_assembly_compile_and_exec.h |   12 +-
 src/getfem_generic_assembly_compile_and_exec.cc| 1117 +---
 2 files changed, 751 insertions(+), 378 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index 1484143..5e6e3b7 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -108,12 +108,16 @@ namespace getfem {
 std::map really_extended_vars;
 
 struct variable_group_info {
+  const mesh *cached_mesh;
+  const std::string *varname;
   const mesh_fem *mf;
-  gmm::sub_interval Iu, Ir;
+  bool reduced_mf;
+  const gmm::sub_interval *I; // sub_interval in the assembled 
vector/matrix
+  // or in the unreduced vars indexing
   scalar_type alpha;
-  const base_vector *U;
-  const std::string *varname;
-  variable_group_info() : mf(0), U(0), varname(0) {}
+  const base_vector *U;   // Vector to read values from
+  variable_group_info()
+: cached_mesh(0), varname(0), mf(0), reduced_mf(false), I(0) {}
 };
 
 struct interpolate_info {
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 52af5b0..9dda8b4 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1220,21 +1220,28 @@ namespace getfem {
 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: Update group info for "+gname);
-  if (vgi.varname &&
-  &(workspace.associated_mf(*(vgi.varname))->linked_mesh())==inin.m)
+  if (vgi.cached_mesh && vgi.cached_mesh == inin.m)
 return 0;
+
+  vgi.cached_mesh = inin.m;
   const std::string 
 = inin.m ? workspace.variable_in_group(gname, *(inin.m))
  : workspace.first_variable_of_group(gname);
+  vgi.varname = 
   vgi.mf = workspace.associated_mf(varname);
-  vgi.Iu = workspace.temporary_interval_of_variable(varname);
-  vgi.Ir = workspace.interval_of_variable(varname);
+  GA_DEBUG_ASSERT(vgi.mf, "Group variable should always have a mesh_fem");
+  vgi.reduced_mf = vgi.mf->is_reduced();
+  if (vgi.reduced_mf) {
+const auto it = gis.really_extended_vars.find(varname);
+GA_DEBUG_ASSERT(it != gis.really_extended_vars.end(),
+"Variable " << varname << " not in extended 
variables");
+vgi.U = &(it->second);
+vgi.I = &(workspace.temporary_interval_of_variable(varname));
+  } else {
+vgi.U = &(workspace.value(varname));
+vgi.I = &(workspace.interval_of_variable(varname));
+  }
   vgi.alpha = workspace.factor_of_variable(varname);
-  const auto it = gis.extended_vars.find(varname);
-  GA_DEBUG_ASSERT(it != gis.extended_vars.end(),
-  "Variable " << varname << " not in extended variables");
-  vgi.U = it->second;
-  vgi.varname = 
   return 0;
 }
 
@@ -4124,16 +4131,18 @@ namespace getfem {
   : t(t_), E(E_), coeff(coeff_) {}
   };
 
-  struct ga_instruction_fem_vector_assembly : public ga_instruction {
+  struct ga_instruction_vector_assembly_mf : public ga_instruction
+  {
 const base_tensor 
-base_vector , 
+base_vector , 
 const fem_interpolation_context 
-const gmm::sub_interval , 
-const mesh_fem *mfn, **mfg;
-scalar_type 
+const gmm::sub_interval *const, *const I__;
+const mesh_fem *const, *const mf__;
+const bool _mf;
+const scalar_type 
 const size_type , 
 base_vector elem;
-bool interpolate;
+const bool interpolate;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: vector term assembly for fem variable");
   bool empty_weight = (coeff == scalar_type(0));
@@ -4147,62 +4156,80 @@ namespace getfem {
 add_scaled_4(t, coeff, elem);
 
   if (ipt == nbpt-1 || interpolate) { // finalize
-GMM_ASSERT1(mfg ? *mfg : mfn, "Internal error");
-const mesh_fem  = *(mfg ? *mfg : mfn);
-const gmm::sub_interval  = mf.is_reduced() ? Iu : Ir;
-base_vector  = mf.is_reduced() ? Vr : Vn;
-if (!(ctx.is_convex_num_valid())) return 0;
+GA_DEBUG_ASSERT(mf, "Internal error");
+if (!ctx.is_convex_num_valid()) return 0;
 

[Getfem-commits] [getfem-commits] branch master updated: Implementation of internal variable condensation in ga_workspace

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
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 f74739a  Implementation of internal variable condensation in 
ga_workspace
f74739a is described below

commit f74739ad3b6576fd78f3babfbb818d9f00f8a44b
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 8 11:53:37 2020 +0100

Implementation of internal variable condensation in ga_workspace
---
 src/getfem/getfem_generic_assembly.h   |  18 +-
 .../getfem_generic_assembly_compile_and_exec.h |   5 +-
 src/getfem_generic_assembly_compile_and_exec.cc| 771 -
 src/getfem_generic_assembly_workspace.cc   |  68 +-
 4 files changed, 830 insertions(+), 32 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 9604225..8af5bf7 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -365,8 +365,10 @@ namespace getfem {
   bool scalar_expr, operation_type op_type=ASSEMBLY,
   const std::string varname_interpolation="");
 
-std::shared_ptr K;
-std::shared_ptr V;
+std::shared_ptr K, KQJpr;
+std::shared_ptr V; // reduced residual vector (primary vars + 
internal vars)
+// after condensation it partially holds 
the condensed residual
+// and the internal solution
 model_real_sparse_matrix col_unreduced_K,
  row_unreduced_K,
  row_col_unreduced_K;
@@ -406,6 +408,15 @@ namespace getfem {
 model_real_sparse_matrix _col_unreduced_matrix()
 { return row_col_unreduced_K; }
 base_vector _vector() { return unreduced_V; }
+// setter function for condensation matrix
+void set_internal_coupling_matrix(model_real_sparse_matrix _) {
+  KQJpr = std::shared_ptr
+  (std::shared_ptr(), _); // alias
+}
+// getter functions for condensation matrix/vectors
+const model_real_sparse_matrix _coupling_matrix() const
+{ return *KQJpr; }
+model_real_sparse_matrix _coupling_matrix() { return *KQJpr; }
 
 /** Add an expression, perform the semantic analysis, split into
  *  terms in separated test functions, derive if necessary to obtain
@@ -550,8 +561,7 @@ namespace getfem {
 std::string extract_order0_term();
 std::string extract_Neumann_term(const std::string );
 
-
-void assembly(size_type order);
+void assembly(size_type order, bool condensation=false);
 
 void set_include_empty_int_points(bool include);
 bool include_empty_int_points() const;
diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index 5e6e3b7..f8da58e 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -202,6 +202,9 @@ namespace getfem {
 
 std::map all_instructions;
 
+// storage of intermediary tensors for condensation of variables
+std::list> condensation_tensors;
+
 ga_instruction_set() : need_elt_size(false), nbpt(0), ipt(0) {}
   };
 
@@ -209,7 +212,7 @@ namespace getfem {
   void ga_exec(ga_instruction_set , ga_workspace );
   void ga_function_exec(ga_instruction_set );
   void ga_compile(ga_workspace , ga_instruction_set ,
-  size_type order);
+  size_type order, bool condensation=false);
   void ga_compile_function(ga_workspace ,
ga_instruction_set , bool scalar);
   void ga_compile_interpolation(ga_workspace ,
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 35b8af0..2b67876 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4207,7 +4207,7 @@ namespace getfem {
 const im_data 
 scalar_type 
 const size_type 
-const bool overwrite;
+const bool initialize;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: vector term assembly for im_data variable");
   size_type cv = ctx.convex_num();
@@ -4215,7 +4215,7 @@ namespace getfem {
   GMM_ASSERT1(i+t.size() <= I.size(),
   "Internal error "size()
+== (qq1end-qq1start)*(qq2end-qq2start),
+"Internal error");
+for (size_type qq2=qq2start; qq2 < qq2end; ++qq2)
+  for (size_type qq1=qq1start; qq1 < qq1end; ++qq1)
+invK(qq1,qq2) = *itr++;
+  }
+}
+  }
+  // calculate inverse matrix invK
+  bgeot::lu_inverse(&(invK[0]), invK.size(0));
+
+  // Resize Kqqjj as 

[Getfem-commits] [getfem-commits] branch master updated: Refactoring of model solvers

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
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 86ae3b6  Refactoring of model solvers
86ae3b6 is described below

commit 86ae3b6bbc4b43dea16e6bd69a486a668d8653d7
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 06:41:07 2020 +0100

Refactoring of model solvers

 - make the model_pb object responsible for the solution of the linearized 
system
---
 src/getfem/getfem_model_solvers.h | 181 ++--
 src/getfem/getfem_models.h|  18 
 src/getfem_model_solvers.cc   | 213 +-
 3 files changed, 236 insertions(+), 176 deletions(-)

diff --git a/src/getfem/getfem_model_solvers.h 
b/src/getfem/getfem_model_solvers.h
index 517b3d3..b286116 100644
--- a/src/getfem/getfem_model_solvers.h
+++ b/src/getfem/getfem_model_solvers.h
@@ -79,8 +79,10 @@ namespace getfem {
 
   template 
   struct abstract_linear_solver {
+typedef MAT MATRIX;
+typedef VECT VECTOR;
 virtual void operator ()(const MAT &, VECT &, const VECT &,
- gmm::iteration &) const  = 0;
+ gmm::iteration &) const = 0;
 virtual ~abstract_linear_solver() {}
   };
 
@@ -386,7 +388,7 @@ namespace getfem {
   /* * */
   /* Newton(-Raphson) algorithm with step control. */
   /* * */
-  /* Still solves a problem F(X) = 0 sarting at X0 but setting */
+  /* Still solves a problem F(X) = 0 starting at X0 but setting*/
   /* B0 = F(X0) and solving*/
   /* F(X) = (1-alpha)B0   (1)  */
   /* with alpha growing from 0 to 1.   */
@@ -403,15 +405,12 @@ namespace getfem {
   /*  else alpha0 <- alpha,*/
   /*  alpha <- min(1,alpha0+2*(alpha-alpha0)), */
   /*  Go to step 1 with Xi+1   */
-  /*  being the result of Newton iteraitons of step1.  */
+  /*  being the result of Newton iterations of step1.  */
   /*   */
   /*/
 
   template 
-  void Newton_with_step_control
-  (PB , gmm::iteration ,
-   const abstract_linear_solver _solver)
+  void Newton_with_step_control(PB , gmm::iteration )
   {
 typedef typename gmm::linalg_traits::value_type T;
 typedef typename gmm::number_traits::magnitude_type R;
@@ -430,7 +429,6 @@ namespace getfem {
 gmm::copy(pb.state_vector(), Xi);
 
 typename PB::VECTOR dr(gmm::vect_size(pb.residual()));
-typename PB::VECTOR b(gmm::vect_size(pb.residual()));
 
 R alpha0(0), alpha(1), res0(gmm::vect_norm1(b0)), minres(res0);
 // const newton_search_with_step_control *ls
@@ -447,18 +445,18 @@ namespace getfem {
 / approx_eln;
   if (!iter.converged(crit)) {
 gmm::iteration iter_linsolv = iter_linsolv0;
-if (iter.get_noisy() > 1)
-  cout << "starting tangent matrix computation" << endl;
 
 int is_singular = 1;
 while (is_singular) { // Linear system solve
-  pb.compute_tangent_matrix();
   gmm::clear(dr);
-  gmm::copy(pb.residual(), b);
-  gmm::add(gmm::scaled(b0,alpha-R(1)), b);
-  if (iter.get_noisy() > 1) cout << "starting linear solver" << endl;
+  pb.add_to_residual(b0, alpha-R(1)); // canceled at next 
compute_residual
   iter_linsolv.init();
-  linear_solver(pb.tangent_matrix(), dr, b, iter_linsolv);
+  if (iter.get_noisy() > 1)
+cout << "starting tangent matrix computation" << endl;
+  pb.compute_tangent_matrix();
+  if (iter.get_noisy() > 1)
+cout << "starting linear solver" << endl;
+  pb.linear_solve(dr, iter_linsolv);
   if (!iter_linsolv.converged()) {
 is_singular++;
 if (is_singular <= 4) {
@@ -466,7 +464,7 @@ namespace getfem {
 cout << "Singular tangent matrix:"
   " perturbation of the state vector." << endl;
   pb.perturbation();
-  pb.compute_residual();
+  pb.compute_residual(); // cancels add_to_residual
 } else {
   if (iter.get_noisy())
 cout << "Singular tangent matrix: perturbation failed, "
@@ -478,9 +476,8 @@ namespace getfem {
 }
 if (iter.get_noisy() > 1) cout << "linear solver done" << endl;
 
-
 gmm::add(dr, pb.state_vector());
-pb.compute_residual();
+pb.compute_residual(); // cancels 

[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 75ef42f0da2be172db2f884b0afa9301ba6a43e9
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 3 23:45:46 2020 +0100

Basic infrastructure for defining internal variables

 - no condensation functionality yet
---
 src/getfem/getfem_generic_assembly.h| 14 +++--
 src/getfem/getfem_models.h  | 72 -
 src/getfem_generic_assembly_compile_and_exec.cc | 12 +++--
 src/getfem_generic_assembly_workspace.cc| 36 -
 src/getfem_models.cc| 39 +-
 5 files changed, 125 insertions(+), 48 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 453e34e..9604225 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -265,7 +265,7 @@ namespace getfem {
 const model *md;
 const ga_workspace *parent_workspace;
 bool with_parent_variables;
-size_type nb_prim_dof, nb_tmp_dof;
+size_type nb_prim_dof, nb_intern_dof, first_intern_dof, nb_tmp_dof;
 
 void init();
 
@@ -280,6 +280,7 @@ namespace getfem {
   bgeot::multi_index qdims;  // For data having a qdim different than the
  // qdim of the fem or im_data (dim per dof for
  // dof data) and for constant variables.
+  const bool is_internal;
 
   size_type qdim() const {
 size_type q = 1;
@@ -289,9 +290,9 @@ namespace getfem {
 
   var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_,
   gmm::sub_interval I_, const model_real_plain_vector *V_,
-  size_type Q)
+  size_type Q, bool is_intern_=false)
 : is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_),
-  I(I_), V(V_), qdims(1)
+  I(I_), V(V_), qdims(1), is_internal(is_intern_)
   {
 GMM_ASSERT1(Q > 0, "Bad dimension");
 qdims[0] = Q;
@@ -444,6 +445,9 @@ namespace getfem {
 void add_im_variable(const std::string , const im_data ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
+void add_internal_im_variable(const std::string , const im_data ,
+  const gmm::sub_interval ,
+  const model_real_plain_vector );
 void add_fixed_size_variable(const std::string ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
@@ -463,6 +467,8 @@ namespace getfem {
 
 bool variable_exists(const std::string ) const;
 
+bool is_internal_variable(const std::string ) const;
+
 const std::string _in_group(const std::string _name,
  const mesh ) const;
 
@@ -551,6 +557,8 @@ namespace getfem {
 bool include_empty_int_points() const;
 
 size_type nb_primary_dof() const { return nb_prim_dof; }
+size_type nb_internal_dof() const { return nb_intern_dof; }
+size_type first_internal_dof() const { return first_intern_dof; }
 size_type nb_temporary_dof() const { return nb_tmp_dof; }
 
 void add_temporary_interval_for_unreduced_variable(const std::string 
);
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 14decdb..5da43c6 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -151,6 +151,8 @@ namespace getfem {
   bool is_complex;  // The variable is complex numbers
   bool is_affine_dependent; // The variable depends in an affine way
 // to another variable.
+  bool is_internal; // An internal variable defined on integration
+// points, condensed out of the global system.
   bool is_fem_dofs; // The variable is the dofs of a fem
   size_type n_iter; // Number of versions of the variable stored.
   size_type n_temp_iter;// Number of additional temporary versions
@@ -198,7 +200,7 @@ namespace getfem {
   const std::string _var_ = std::string(""),
   mesh_im const *filter_mim_ = 0)
 : is_variable(is_var), is_disabled(false), is_complex(is_compl),
-  is_affine_dependent(false),
+  is_affine_dependent(false), is_internal(false),
   is_fem_dofs(mf_ != 0),
   n_iter(std::max(size_type(1), n_it)), n_temp_iter(0),
   default_iter(0), ptsc(0),
@@ -525,6 +527,9 @@ namespace getfem {
 /** States if a name corresponds to a declared data. */
 bool is_true_data(const std::string ) const;
 
+/** States if a variable is condensed out of the global system. */
+bool is_internal_variable(const std::string ) const;
+
 bool is_affine_dependent_variable(const std::string ) const;
 
 const std::string _variable(const std::string ) const;
@@ -549,6 

[Getfem-commits] [getfem-commits] master updated (a8a51a7 -> f7d20be)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from a8a51a7  adding a test
 new 75ef42f  Basic infrastructure for defining internal variables
 new f7d20be  Remove replaced assembly instruction class


Summary of changes:
 src/getfem/getfem_generic_assembly.h|  14 +++-
 src/getfem/getfem_models.h  |  72 +++--
 src/getfem_generic_assembly_compile_and_exec.cc | 102 +++-
 src/getfem_generic_assembly_workspace.cc|  36 -
 src/getfem_models.cc|  39 ++---
 5 files changed, 128 insertions(+), 135 deletions(-)



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit f7d20be3b26b80094c08d54007703e6006c75ee2
Author: Konstantinos Poulios 
AuthorDate: Mon Jan 6 12:40:35 2020 +0100

Remove replaced assembly instruction class
---
 src/getfem_generic_assembly_compile_and_exec.cc | 90 +
 1 file changed, 3 insertions(+), 87 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 3bb6e25..35b8af0 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4509,90 +4509,6 @@ namespace getfem {
 const size_type zero_=0;
   };
 
-  struct ga_instruction_matrix_assembly
-: public ga_instruction_matrix_assembly_base
-  {
-model_real_sparse_matrix , 
-const gmm::sub_interval , , , 
-const mesh_fem *mfn1, *mfn2, **mfg1, **mfg2;
-const im_data *imd1, *imd2;
-virtual int exec() {
-  GA_DEBUG_INFO("Instruction: matrix term assembly");
-
-  bool initialize = (ipt == 0) || interpolate || imd1 || imd2;
-  bool empty_weight = (coeff == scalar_type(0));
-  add_tensor_to_element_matrix(initialize, empty_weight); // t --> elem
-
-  if (ipt == nbpt-1 || interpolate || imd1 || imd2) { // finalize
-const mesh_fem *pmf1 = mfg1 ? *mfg1 : mfn1;
-const mesh_fem *pmf2 = mfg2 ? *mfg2 : mfn2;
-bool reduced = (pmf1 && pmf1->is_reduced())
-  || (pmf2 && pmf2->is_reduced());
-model_real_sparse_matrix  = reduced ? Kr : Kn;
-const gmm::sub_interval  = reduced ? Ir1 : In1;
-const gmm::sub_interval  = reduced ? Ir2 : In2;
-GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
-
-scalar_type ninf = gmm::vect_norminf(elem);
-if (ninf == scalar_type(0)) return 0;
-
-size_type s1 = t.sizes()[0], s2 = t.sizes()[1];
-size_type cv1 = ctx1.convex_num(), cv2 = ctx2.convex_num();
-size_type N = 1;
-
-size_type ifirst1 = I1.first(), ifirst2 = I2.first();
-if (imd1) ifirst1 +=  s1*imd1->filtered_index_of_point(cv1, ipt);
-if (imd2) ifirst2 +=  s2*imd2->filtered_index_of_point(cv2, ipt);
-
-if (pmf1) {
-  if (!ctx1.is_convex_num_valid()) return 0;
-  N = ctx1.N();
-  size_type qmult1 = pmf1->get_qdim();
-  if (qmult1 > 1) qmult1 /= pmf1->fem_of_element(cv1)->target_dim();
-  populate_dofs_vector(dofs1, s1, ifirst1, qmult1,// --> dofs1
-   pmf1->ind_scalar_basic_dof_of_element(cv1));
-} else
-  populate_contiguous_dofs_vector(dofs1, s1, ifirst1); // --> dofs1
-
-if (pmf1 == pmf2 && (pmf1 ? (cv1 == cv2) : (s1 == s2))) {
-  if (ifirst1 == ifirst2) {
-add_elem_matrix(K, dofs1, dofs1, dofs1_sort, elem, ninf*1E-14, N);
-  } else {
-populate_dofs_vector(dofs2, dofs1.size(), ifirst2 - ifirst1, 
dofs1);
-add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-  }
-} else {
-  if (pmf2) {
-if (!ctx2.is_convex_num_valid()) return 0;
-N = std::max(N, ctx2.N());
-size_type qmult2 = pmf2->get_qdim();
-if (qmult2 > 1) qmult2 /= pmf2->fem_of_element(cv2)->target_dim();
-populate_dofs_vector(dofs2, s2, ifirst2, qmult2,// --> 
dofs2
- pmf2->ind_scalar_basic_dof_of_element(cv2));
-  } else
-populate_contiguous_dofs_vector(dofs2, s2, ifirst2); // --> dofs2
-  add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-}
-  }
-  return 0;
-}
-ga_instruction_matrix_assembly
-(const base_tensor _,
- model_real_sparse_matrix _, model_real_sparse_matrix _,
- const fem_interpolation_context _,
- const fem_interpolation_context _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const mesh_fem *mfn1_, const mesh_fem **mfg1_, const im_data *imd1_,
- const mesh_fem *mfn2_, const mesh_fem **mfg2_, const im_data *imd2_,
- const scalar_type , const scalar_type , const scalar_type _,
- const size_type _, const size_type _, bool interpolate_)
-  : ga_instruction_matrix_assembly_base
-(t_, ctx1_, ctx2_, a1, a2, coeff_, nbpt_, ipt_, interpolate_),
-Kr(Kr_), Kn(Kn_), Ir1(Ir1_), Ir2(Ir2_), In1(In1_), In2(In2_),
-mfn1(mfn1_), mfn2(mfn2_), mfg1(mfg1_), mfg2(mfg2_),
-imd1(imd1_), imd2(imd2_) {}
-  };
 
   struct ga_instruction_matrix_assembly_mf_mf
 : public ga_instruction_matrix_assembly_base
@@ -7224,7 +7140,7 @@ namespace getfem {
  : (secondary ? rmi.secondary_domain_infos.ctx
   : rmi.interpolate_infos[intn1].ctx);
   bool interpolate =
-!(intn1.empty() || intn1 == "neighbor_elt"
+

[Getfem-commits] [getfem-commits] master updated (86ae3b6 -> afffc20)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 86ae3b6  Refactoring of model solvers
 new 1765106  Fix wrong scaling of coupling matrix in internal variable 
condensation
 new 46ce1c6  Fix size of internal variable condensation matrix
 new afffc20  Minor changes


Summary of changes:
 src/getfem/getfem_generic_assembly.h|  4 ++-
 src/getfem/getfem_models.h  | 16 +
 src/getfem_generic_assembly_compile_and_exec.cc | 48 +
 src/getfem_generic_assembly_workspace.cc|  6 ++--
 src/getfem_models.cc| 16 -
 5 files changed, 63 insertions(+), 27 deletions(-)



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 46ce1c676124687e70d95299c9cf28cd10c4b76b
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 09:47:03 2020 +0100

Fix size of internal variable condensation matrix

  - Including empty rows for keeping the implementation simpler
---
 src/getfem/getfem_generic_assembly.h| 4 +++-
 src/getfem_generic_assembly_compile_and_exec.cc | 7 +++
 src/getfem_generic_assembly_workspace.cc| 6 ++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 8af5bf7..d52d463 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -413,7 +413,9 @@ namespace getfem {
   KQJpr = std::shared_ptr
   (std::shared_ptr(), _); // alias
 }
-// getter functions for condensation matrix/vectors
+/** getter function for condensation matrix
+Its size is (nb_primary_dof()+nb_internal_dof()) x nb_primary_dof()
+but its first nb_primary_dof() rows are empty */
 const model_real_sparse_matrix _coupling_matrix() const
 { return *KQJpr; }
 model_real_sparse_matrix _coupling_matrix() { return *KQJpr; }
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 6a21e28..48820ff 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -8004,6 +8004,13 @@ namespace getfem {
 const base_tensor  = *(CC.KQJpr(q1,j2)); // <- input
 model_real_sparse_matrix
= workspace.internal_coupling_matrix(); // <- output
+GMM_ASSERT1(
+  gmm::mat_nrows(KQJpr) == workspace.nb_primary_dof()
+  +workspace.nb_internal_dof() &&
+  gmm::mat_ncols(KQJpr) == workspace.nb_primary_dof(),
+  "The internal coupling matrix needs to be allocated with "
+  "nb_primary_dof()+nb_internal_dof() number of rows, even if "
+  "only the last nb_internal_dof() rows are filled in.");
 if (mf2)
   pgai =
 std::make_shared
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 8388110..64183e5 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -818,9 +818,9 @@ namespace getfem {
   //  gmm::mat_ncols(*K) == nb_prim_dof, "Wrong sizes");
   if (KQJpr.use_count()) {
 gmm::clear(*KQJpr);
-gmm::resize(*KQJpr, nb_intern_dof, nb_prim_dof); // redundant if 
condensation == false
+gmm::resize(*KQJpr, nb_prim_dof+nb_intern_dof, nb_prim_dof); // 
redundant if condensation == false
   } else if (condensation)
-GMM_ASSERT1(gmm::mat_nrows(*KQJpr) == nb_intern_dof &&
+GMM_ASSERT1(gmm::mat_nrows(*KQJpr) == nb_prim_dof+nb_intern_dof &&
 gmm::mat_ncols(*KQJpr) == nb_prim_dof, "Wrong sizes");
   gmm::clear(col_unreduced_K);
   gmm::clear(row_unreduced_K);
@@ -923,8 +923,6 @@ namespace getfem {
   GMM_ASSERT1(I1.last() <= nb_prim_dof, "Internal error");
   gmm::add(M, gmm::sub_matrix(*K, I1, I2)); // -> *K
 } else { // vname1 is an internal variable
-  I1.min -= first_internal_dof();
-  I1.max -= first_internal_dof();
   gmm::add(M, gmm::sub_matrix(*KQJpr, I1, I2)); // -> 
*KQJpr
 }
   }



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 1765106029a5aa40aa84435ebd151d460d294a6a
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 08:57:05 2020 +0100

Fix wrong scaling of coupling matrix in internal variable condensation
---
 src/getfem_generic_assembly_compile_and_exec.cc | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 2b67876..6a21e28 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4534,6 +4534,7 @@ namespace getfem {
   protected:
 const bool false_=false;
 const size_type zero_=0;
+const scalar_type one_=1;
   };
 
 
@@ -4714,6 +4715,18 @@ namespace getfem {
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
 imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
+
+ga_instruction_matrix_assembly_imd_mf // constructor without coeff (== 1)
+(const base_tensor _, model_real_sparse_matrix _,
+ const fem_interpolation_context _,
+ const fem_interpolation_context _,
+ const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
+ const gmm::sub_interval _, const mesh_fem _, const scalar_type ,
+ const size_type _)
+  : ga_instruction_matrix_assembly_base
+(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
+Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
+imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
   };
 
   struct ga_instruction_matrix_assembly_mf_imd
@@ -4816,6 +4829,17 @@ namespace getfem {
   : ga_instruction_matrix_assembly_base
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
+
+ga_instruction_matrix_assembly_imd_imd // constructor without coeff (== 1)
+(const base_tensor _, model_real_sparse_matrix _,
+ const fem_interpolation_context _,
+ const fem_interpolation_context _,
+ const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
+ const gmm::sub_interval _, const im_data *imd2_, const scalar_type ,
+ const size_type _)
+  : ga_instruction_matrix_assembly_base
+(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
+K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
   };
 
 
@@ -7984,12 +8008,13 @@ namespace getfem {
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, *mf2, alpha2, gis.coeff, gis.ipt); 
// TODO: name_test2 variable group
+ I1, imd1, alpha1, I2, *mf2, alpha2, gis.ipt); // 
constructor without gis.coeff
+// TODO: name_test2 variable group
 else // for global variable imd2 == 0
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, imd2, alpha2, gis.coeff, gis.ipt);
+ I1, imd1, alpha1, I2, imd2, alpha2, gis.ipt); // 
constructor without gis.coeff
 rmi.instructions.push_back(std::move(pgai));
   }
   const bool initialize = true;



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit afffc209a896ea5d7606aa86b227b7700c546631
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 16:47:37 2020 +0100

Minor changes
---
 src/getfem/getfem_models.h  | 16 +---
 src/getfem_generic_assembly_compile_and_exec.cc | 12 +++-
 src/getfem_models.cc| 16 
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index c25ddec..c28749f 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -271,12 +271,14 @@ namespace getfem {
 
 typedef std::vector termlist;
 
-enum build_version { BUILD_RHS = 1,
- BUILD_MATRIX = 2,
- BUILD_ALL = 3,
- BUILD_ON_DATA_CHANGE = 4,
- BUILD_WITH_COMPLETE_RHS = 8,
- BUILD_COMPLETE_RHS = 9, };
+enum build_version {
+  BUILD_RHS = 1,
+  BUILD_MATRIX = 2,
+  BUILD_ALL = 3,
+  BUILD_ON_DATA_CHANGE = 4,
+  BUILD_WITH_LIN = 8,   // forced calculation of linear terms
+  BUILD_RHS_WITH_LIN = 9,   // = BUILD_RHS | BUILD_WITH_LIN_RHS
+};
 
   protected:
 
@@ -356,7 +358,7 @@ namespace getfem {
   std::string secondary_domain;
   gen_expr(const std::string _, const mesh_im _,
size_type region_, const std::string )
-   : expr(expr_), mim(mim_), region(region_), secondary_domain(secdom)  {}
+: expr(expr_), mim(mim_), region(region_), secondary_domain(secdom) {}
 };
 
 // Structure for assignment in assembly
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 48820ff..ee141f4 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5445,9 +5445,11 @@ namespace getfem {
 }
 // cout << "sub_tree_are_equal = " << int(sub_tree_are_equal(pnode, 
pnode1, workspace, 1)) << endl;
 std::stringstream ss;
-ss << "Detected wrong equivalent nodes: \n";
-ga_print_node(pnode, ss); ss << "\n and \n"; ga_print_node(pnode1, ss);
-ss << "\nNo problem, but hash values could be adapted." << endl;
+ss << "Detected wrong equivalent nodes:" << endl;
+ga_print_node(pnode, ss);
+ss << endl << " and " << endl;
+ga_print_node(pnode1, ss);
+ss << endl << "No problem, but hash values could be adapted." << endl;
 GMM_TRACE2(ss.str());
   }
 }
@@ -8023,13 +8025,13 @@ namespace getfem {
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
  I1, imd1, alpha1, I2, imd2, alpha2, gis.ipt); // 
constructor without gis.coeff
 rmi.instructions.push_back(std::move(pgai));
-  }
+  } // for j2
   const bool initialize = true;
   pgai = std::make_shared
 (*(CC.RQpr[q1]), workspace.assembled_vector(), // <- 
overwriting internal variables residual with internal solution
  gis.ctx, I1, *imd1, gis.coeff, gis.ipt, initialize);
   rmi.instructions.push_back(std::move(pgai));
-}
+} // for q1
   }
 
   // Add superdiagonal condensation instructions
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index d0330eb..ee9ce16 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2419,7 +2419,7 @@ namespace getfem {
   }
 }
 if (term.is_matrix_term && brick.pbr->is_linear()
-&& (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+&& (!is_linear() || (version & BUILD_WITH_LIN))) {
   if (!(var1->is_disabled))
 gmm::mult_add(brick.cmatlist[j],
   gmm::scaled(var2->complex_value[0],
@@ -2439,7 +2439,7 @@ namespace getfem {
  gmm::sub_vector(crhs, I2));
   }
if (brick.pbr->is_linear()
-   && (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+   && (!is_linear() || (version & BUILD_WITH_LIN))) {
  gmm::mult_add(gmm::conjugated(brick.cmatlist[j]),
 gmm::scaled(var1->complex_value[0],
 complex_type(-alpha2)),
@@ -2487,7 +2487,7 @@ namespace getfem {
   }
 }
 if (term.is_matrix_term && brick.pbr->is_linear()
-&& (!is_linear() || (version & BUILD_WITH_COMPLETE_RHS))) {
+&& (!is_linear() || (version & BUILD_WITH_LIN))) {
   if (!(var1->is_disabled))
 gmm::mult_add(brick.rmatlist[j],
   gmm::scaled(var2->complex_value[0],
@@ -2507,7 +2507,7 @@ namespace getfem {
  gmm::sub_vector(crhs, I2));

[Getfem-commits] [getfem-commits] master updated (afffc20 -> 7262aa3)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from afffc20  Minor changes
 new 6ddb898  Add support for internal variable condensation to the model 
object
 new e32714c  Fix in proccessing of multiple coupled internal variables
 new 7262aa3  Fix bug in rhs computation of models with internal variables


Summary of changes:
 src/getfem/getfem_accumulated_distro.h  |   6 +-
 src/getfem/getfem_models.h  |  42 --
 src/getfem_generic_assembly_compile_and_exec.cc | 134 +
 src/getfem_generic_assembly_workspace.cc|   4 +-
 src/getfem_model_solvers.cc |  90 +++-
 src/getfem_models.cc| 183 ++--
 6 files changed, 339 insertions(+), 120 deletions(-)



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit e32714c433e96158d24b7f71915178d671b85c15
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 22:08:50 2020 +0100

Fix in proccessing of multiple coupled internal variables
---
 src/getfem_generic_assembly_compile_and_exec.cc | 134 +---
 1 file changed, 73 insertions(+), 61 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index ee141f4..e9671d9 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5055,17 +5055,16 @@ namespace getfem {
 std::vector RQloc;
 base_tensor invK, Kqqjj;
 base_vector Rqq;
-std::vector partQ, partJ;
-size_type Qsize, Jsize;
+std::vector> partQ, partJ;
 virtual int exec() { // implementation can be optimized
   GA_DEBUG_INFO("Instruction: variable cluster subdiagonal condensation");
   // copy from KQQ to invK
-  for (size_type q1=0; q1 < Qsize; ++q1) {
-size_type qq1start = partQ[q1], qq1end = partQ[q1+1];
-for (size_type q2=0; q2 < Qsize; ++q2) {
+  for (const auto  : partQ) {
+size_type q1 = qqq1[0], qq1start = qqq1[1], qq1end = qqq1[2];
+for (const auto  : partQ) {
+  size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
   if (KQQloc(q1,q2)) {
 auto itr = KQQloc(q1,q2)->cbegin();
-size_type qq2start = partQ[q2], qq2end = partQ[q2+1];
 GMM_ASSERT1(KQQloc(q1,q2)->size()
 == (qq1end-qq1start)*(qq2end-qq2start),
 "Internal error");
@@ -5079,40 +5078,44 @@ namespace getfem {
   bgeot::lu_inverse(&(invK[0]), invK.size(0));
 
   // Resize Kqqjj as primary variable sizes may change dynamically
-  partJ.clear();
-  partJ.resize(Jsize,0);
-  for (size_type j=0; j < Jsize; ++j)
-for (size_type q=0; q < Qsize; ++q)
+  size_type prev_j(0);
+  for (auto & : partJ) {
+size_type j=jjj[0];
+size_type new_j(0);
+for (const auto  : partQ) {
+  size_type q=qqq[0];
   if (KQJloc(q,j)) {
-if (partJ[j] == 0)
-  partJ[j] = KQJloc(q,j)->size(1);
-else
-  GMM_ASSERT1(partJ[j] == KQJloc(q,j)->size(1), "Internal error");
+if (new_j) {
+  GMM_ASSERT1(new_j == KQJloc(q,j)->size(1), "Internal error");
+} else
+  new_j = KQJloc(q,j)->size(1);
   }
-  for (size_type jj=1; jj < partJ.size(); ++jj)
-partJ[jj] += partJ[jj-1];
-  partJ.insert(partJ.begin(), 0);
+}
+// Resize KQJprime submatrices to match KQJloc sizes
+for (const auto  : partQ) {
+  size_type q=qqq[0];
+  KQJprime(q,j)->adjust_sizes(qqq[2]-qqq[1], new_j);
+}
+jjj[1] = prev_j;
+prev_j += new_j;
+jjj[2] = prev_j;
+  }
 
-  Kqqjj.adjust_sizes(partQ.back(), partJ.back());
+  Kqqjj.adjust_sizes(partQ.back()[2], partJ.back()[2]);
   gmm::clear(Kqqjj.as_vector());
   gmm::clear(Rqq);
 
-  // Resize KQJprime submatrices to match KQJloc sizes
-  for (size_type j=0; j < Jsize; ++j)
-for (size_type q=0; q < Qsize; ++q)
-  KQJprime(q,j)->adjust_sizes(partQ[q+1]-partQ[q], 
partJ[j+1]-partJ[j]);
-
   // multiply invK with all submatrices in KQJloc and RQloc and store
   // the results in Kqqjj and Rqq
-  for (size_type j=0; j < Jsize; ++j) {
-size_type jjstart = partJ[j], jjend = partJ[j+1];
-for (size_type q2=0; q2 < Qsize; ++q2) {
+  for (const auto  : partJ) {
+size_type j = jjj[0], jjstart = jjj[1], jjend = jjj[2];
+for (const auto  : partQ) {
+  size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
   if (KQJloc(q2,j)) {
 auto itr = KQJloc(q2,j)->begin(); // auto  = KQJloc(q2,j);
-size_type qqstart = partQ[q2], qqend = partQ[q2+1];
 for (size_type jj=jjstart; jj < jjend; ++jj) {
-  for (size_type qq2=qqstart; qq2 < qqend; ++qq2, ++itr) {
-for (size_type qq1=0; qq1 < partQ.back(); ++qq1) {
+  for (size_type qq2=qq2start; qq2 < qq2end; ++qq2, ++itr) {
+for (size_type qq1=0; qq1 < partQ.back()[2]; ++qq1) {
   Kqqjj(qq1,jj) += invK(qq1,qq2)*(*itr);
   // Kqqjj(qq1,jj) += 
invKqq(qq1,qq2)*mat(qq2-qqstart,jj-jjstart);
 } // for qq1
@@ -5120,30 +5123,31 @@ namespace getfem {
 } // for jj
 GMM_ASSERT1(itr == KQJloc(q2,j)->cend(), "Internal error");
   }
-} // for q2
-  } // for j
-  for (size_type q2=0; q2 < RQloc.size(); ++q2)
+} // in partQ
+  } // in partJ
+  for (const auto  : partQ) {
+size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
 if (RQloc[q2]) {
   

[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 6ddb89892316a0c6a0cb7eda9a6ab0db07c48ab4
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 29 16:49:18 2020 +0100

Add support for internal variable condensation to the model object
---
 src/getfem/getfem_accumulated_distro.h   |   6 +-
 src/getfem/getfem_models.h   |  42 ++--
 src/getfem_generic_assembly_workspace.cc |   4 +-
 src/getfem_model_solvers.cc  |  90 +++-
 src/getfem_models.cc | 178 +++
 5 files changed, 261 insertions(+), 59 deletions(-)

diff --git a/src/getfem/getfem_accumulated_distro.h 
b/src/getfem/getfem_accumulated_distro.h
index ebf8226..a428202 100644
--- a/src/getfem/getfem_accumulated_distro.h
+++ b/src/getfem/getfem_accumulated_distro.h
@@ -173,12 +173,16 @@ namespace detail {
   }
 }
 
-operator T&(){
+T& get(){
   if (distributed.num_threads() == 1 ||
   distributed.this_thread() == 0) return original;
   else return distributed;
 }
 
+operator T&(){ // implicit conversion
+  return get();
+}
+
 T& operator = (const T ){
   return distributed = x;
 }
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index c28749f..07f056c 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -121,9 +121,14 @@ namespace getfem {
 bool is_linear_;
 bool is_symmetric_;
 bool is_coercive_;
-mutable model_real_sparse_matrix rTM;// tangent matrix, real version
+mutable model_real_sparse_matrix
+  rTM,  // tangent matrix (only primary variables), real version
+  internal_rTM; // coupling matrix between internal and primary vars (no 
empty rows)
 mutable model_complex_sparse_matrix cTM; // tangent matrix, complex version
-mutable model_real_plain_vector rrhs;
+mutable model_real_plain_vector
+  rrhs, // residual vector of primary variables (after 
condensation)
+  full_rrhs,// residual vector of primary and internal variables 
(pre-condensation)
+  internal_sol; // partial solution for internal variables (after 
condensation)
 mutable model_complex_plain_vector crhs;
 mutable bool act_size_to_be_done;
 dim_type leading_dim;
@@ -278,6 +283,10 @@ namespace getfem {
   BUILD_ON_DATA_CHANGE = 4,
   BUILD_WITH_LIN = 8,   // forced calculation of linear terms
   BUILD_RHS_WITH_LIN = 9,   // = BUILD_RHS | BUILD_WITH_LIN_RHS
+  BUILD_WITH_INTERNAL = 16,
+  BUILD_RHS_WITH_INTERNAL = 17, // = BUILD_RHS | BUILD_WITH_INTERNAL
+  BUILD_MATRIX_CONDENSED = 18,  // = BUILD_MATRIX | BUILD_WITH_INTERNAL
+  BUILD_ALL_CONDENSED = 19, // = BUILD_ALL | BUILD_WITH_INTERNAL
 };
 
   protected:
@@ -571,7 +580,13 @@ namespace getfem {
 bool is_linear() const { return is_linear_; }
 
 /** Total number of degrees of freedom in the model. */
-size_type nb_dof() const;
+size_type nb_dof(bool with_internal=false) const;
+
+/** Number of internal degrees of freedom in the model. */
+size_type nb_internal_dof() const { return nb_dof(true)-nb_dof(); }
+
+/** Number of primary degrees of freedom in the model. */
+size_type nb_primary_dof() const { return nb_dof(); }
 
 /** Leading dimension of the meshes used in the model. */
 dim_type leading_dimension() const { return leading_dim; }
@@ -898,10 +913,11 @@ namespace getfem {
 size_type qdim_of_variable(const std::string ) const;
 
 /** Gives the access to the tangent matrix. For the real version. */
-const model_real_sparse_matrix _tangent_matrix() const {
+const model_real_sparse_matrix &
+real_tangent_matrix(bool internal=false) const {
   GMM_ASSERT1(!complex_version, "This model is a complex one");
   context_check(); if (act_size_to_be_done) actualize_sizes();
-  return rTM;
+  return internal ? internal_rTM : rTM;
 }
 
 /** Gives the access to the tangent matrix. For the complex version. */
@@ -913,19 +929,27 @@ namespace getfem {
 
 /** Gives access to the right hand side of the tangent linear system.
 For the real version. An assembly of the rhs has to be done first. */
-const model_real_plain_vector _rhs() const {
+const model_real_plain_vector _rhs(bool with_internal=false) const {
   GMM_ASSERT1(!complex_version, "This model is a complex one");
   context_check(); if (act_size_to_be_done) actualize_sizes();
-  return rrhs;
+  return (with_internal && gmm::vect_size(full_rrhs)) ? full_rrhs : rrhs;
 }
 
 /** Gives write access to the right hand side of the tangent linear system.
 Some solvers need to manipulate the model rhs directly so that for
 example internal condensed variables can be treated properly. */
-model_real_plain_vector _real_rhs() const {
+model_real_plain_vector _real_rhs(bool with_internal=false) const {
+  GMM_ASSERT1(!complex_version, "This model is a complex 

[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 4c176ff6596a7966bd55af715834ffec5d71190a
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 10:07:06 2020 +0100

Simplification
---
 .../getfem_generic_assembly_compile_and_exec.h |  2 ++
 src/getfem_generic_assembly_compile_and_exec.cc| 28 ++
 2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index 1a39731..e1e36e8 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -95,6 +95,8 @@ namespace getfem {
 std::map neighbor_corresp;
 std::set> unreduced_terms;
 
+scalar_type ONE=1;
+
 using region_mim_tuple = std::tuple;
 struct region_mim : public region_mim_tuple {
   const mesh_im* mim() const {return 
std::get<0>(static_cast(*this));}
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 5aa3205..42a74b0 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4534,7 +4534,6 @@ namespace getfem {
   protected:
 const bool false_=false;
 const size_type zero_=0;
-const scalar_type one_=1;
   };
 
 
@@ -4715,18 +4714,6 @@ namespace getfem {
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
 imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
-
-ga_instruction_matrix_assembly_imd_mf // constructor without coeff (== 1)
-(const base_tensor _, model_real_sparse_matrix _,
- const fem_interpolation_context _,
- const fem_interpolation_context _,
- const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
- const gmm::sub_interval _, const mesh_fem _, const scalar_type ,
- const size_type _)
-  : ga_instruction_matrix_assembly_base
-(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
-Kxr(K_), Kxu(K_), I1(_), I2__(_), I2(I2__),
-imd1(imd1_), mf2__(_), mf2(mf2__), reduced_mf2(false_) {}
   };
 
   struct ga_instruction_matrix_assembly_mf_imd
@@ -4829,17 +4816,6 @@ namespace getfem {
   : ga_instruction_matrix_assembly_base
 (t_, ctx1_, ctx2_, a1, a2, coeff_, zero_, ipt_, false),
 K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
-
-ga_instruction_matrix_assembly_imd_imd // constructor without coeff (== 1)
-(const base_tensor _, model_real_sparse_matrix _,
- const fem_interpolation_context _,
- const fem_interpolation_context _,
- const gmm::sub_interval _, const im_data *imd1_, const scalar_type ,
- const gmm::sub_interval _, const im_data *imd2_, const scalar_type ,
- const size_type _)
-  : ga_instruction_matrix_assembly_base
-(t_, ctx1_, ctx2_, a1, a2, one_, zero_, ipt_, false),
-K(K_), I1(I1_), I2(I2_), imd1(imd1_), imd2(imd2_) {}
   };
 
 
@@ -8041,7 +8017,7 @@ namespace getfem {
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, *mf2, alpha2, gis.ipt); // 
constructor without gis.coeff
+ I1, imd1, gis.ONE, I2, *mf2, gis.ONE, gis.ONE, gis.ipt); 
// without gis.coeff
 // TODO: name_test2 variable group
 if (mf2->is_reduced())
   gis.unreduced_terms.emplace(name_test1, name_test2);
@@ -8049,7 +8025,7 @@ namespace getfem {
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
- I1, imd1, alpha1, I2, imd2, alpha2, gis.ipt); // 
constructor without gis.coeff
+ I1, imd1, gis.ONE, I2, imd2, gis.ONE, gis.ONE, gis.ipt); 
// without gis.coeff
 rmi.instructions.push_back(std::move(pgai));
   } // for j2
   const bool initialize = true;



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit f32d6888dd04b004f3a2f50109946fa519e9bf13
Author: Konstantinos Poulios 
AuthorDate: Sat Apr 4 02:18:29 2020 +0200

Explicit recording of terms that require post-assembly reduction

# Conflicts:
#   src/getfem/getfem_generic_assembly_compile_and_exec.h
---
 .../getfem_generic_assembly_compile_and_exec.h |   1 +
 src/getfem_generic_assembly_compile_and_exec.cc|  21 +++-
 src/getfem_generic_assembly_workspace.cc   | 125 ++---
 3 files changed, 79 insertions(+), 68 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index f8da58e..1a39731 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -93,6 +93,7 @@ namespace getfem {
 bgeot::geotrans_precomp_pool gp_pool;
 fem_precomp_pool fp_pool;
 std::map neighbor_corresp;
+std::set> unreduced_terms;
 
 using region_mim_tuple = std::tuple;
 struct region_mim : public region_mim_tuple {
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index e9671d9..5aa3205 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -7385,6 +7385,7 @@ namespace getfem {
   ga_instruction_set , size_type order, bool condensation) 
{
 gis.transformations.clear();
 gis.all_instructions.clear();
+gis.unreduced_terms.clear();
 workspace.clear_temporary_variable_intervals();
 
 std::map
@@ -7581,6 +7582,9 @@ namespace getfem {
(root->tensor(), Vr, Vu, ctx,
 vgi.I, vgi.mf, vgi.reduced_mf,
 gis.coeff, gis.nbpt, gis.ipt, interpolate);
+for (const std::string 
+ : workspace.variable_group(root->name_test1))
+  gis.unreduced_terms.emplace(name, "");
   } else {
 base_vector  = mf->is_reduced() ? Vu : Vr;
 const gmm::sub_interval
@@ -7591,6 +7595,8 @@ namespace getfem {
 pgai = std::make_shared
(root->tensor(), V, ctx, I, *mf,
 gis.coeff, gis.nbpt, gis.ipt, interpolate);
+if (mf->is_reduced())
+  gis.unreduced_terms.emplace(root->name_test1, "");
   }
 } else if (imd) {
   GMM_ASSERT1(root->interpolate_name_test1.size() == 0,
@@ -7847,6 +7853,12 @@ namespace getfem {
   }
 } else if (!workspace.is_internal_variable(root->name_test1) &&
!workspace.is_internal_variable(root->name_test2)) {
+
+  if ((mf1 && mf1->is_reduced()) || (mf2 && mf2->is_reduced())
+  || has_var_group1 || has_var_group2)
+gis.unreduced_terms.emplace(root->name_test1,
+root->name_test2);
+
   auto  = (mf1 && mf1->is_reduced()) ? Kuu : Kru;
   auto  = (mf1 && mf1->is_reduced()) ? Kur : Krr;
   auto  = (mf2 && mf2->is_reduced()) ? Kuu : Kur;
@@ -8025,13 +8037,15 @@ namespace getfem {
   "The internal coupling matrix needs to be allocated with "
   "nb_primary_dof()+nb_internal_dof() number of rows, even if "
   "only the last nb_internal_dof() rows are filled in.");
-if (mf2)
+if (mf2) {
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
  I1, imd1, alpha1, I2, *mf2, alpha2, gis.ipt); // 
constructor without gis.coeff
 // TODO: name_test2 variable group
-else // for global variable imd2 == 0
+if (mf2->is_reduced())
+  gis.unreduced_terms.emplace(name_test1, name_test2);
+} else // for global variable imd2 == 0
   pgai =
 std::make_shared
 (Kq1j2pr, KQJpr, gis.ctx, gis.ctx,
@@ -8102,6 +8116,9 @@ namespace getfem {
 auto  = (mf2 && mf2->is_reduced()) ? Kru : Krr;
 auto  = (mf2 && mf2->is_reduced()) ? Kxu : Kxr;
 
+if ((mf1 && mf1->is_reduced()) || (mf2 && mf2->is_reduced()))
+  gis.unreduced_terms.emplace(name_test1, name_test2);
+
 if (mf1 && mf2) // TODO: name_test1 or name_test2 variable 
group
   pgai = std::make_shared
  
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 59f2314..315088c 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ 

[Getfem-commits] [getfem-commits] master updated (7262aa3 -> 4c176ff)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 7262aa3  Fix bug in rhs computation of models with internal variables
 new f32d688  Explicit recording of terms that require post-assembly 
reduction
 new 4c176ff  Simplification


Summary of changes:
 .../getfem_generic_assembly_compile_and_exec.h |   3 +
 src/getfem_generic_assembly_compile_and_exec.cc|  49 
 src/getfem_generic_assembly_workspace.cc   | 125 ++---
 3 files changed, 83 insertions(+), 94 deletions(-)



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 988ba0f123146b5e2a5d881746969958659d4ac4
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 11:51:40 2020 +0100

Mention internal variables in the model object documentation
---
 doc/sphinx/source/userdoc/model_object.rst | 23 +++
 src/getfem/getfem_models.h |  8 
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/doc/sphinx/source/userdoc/model_object.rst 
b/doc/sphinx/source/userdoc/model_object.rst
index 139fae0..c84d5ca 100644
--- a/doc/sphinx/source/userdoc/model_object.rst
+++ b/doc/sphinx/source/userdoc/model_object.rst
@@ -136,6 +136,29 @@ The main useful methods on a |mo| object are
variable. Note that for complex terms, only
the real part is considered to filter the multiplier.
 
+.. c:function:: add_im_variable(name, imd)
+
+   Add a variable defined on the integration points of the ``im_data`` object 
imd.
+   The variable can be scalar-valued, vector-valued or tensor-valued depending 
on
+   the dimension of imd.
+   It increases the model degrees of freedom by the number of integration 
points
+   time the size of the variable at one integration point.
+
+.. c:function:: add_internal_im_variable(name, imd)
+
+   Add a variable defined on the integration points of the ``im_data`` object
+   ``imd`` that will be statically condensed out during the linearization of 
the
+   problem. The variable can be scalar-valued, vector-valued or tensor-valued
+   depending on the dimension of imd.
+   It does not add degrees of freedom to the model.
+
+.. c:function:: add_im_data(name, imd)
+
+   Add a data object deignated with the string ``name``, defined at all
+   integration points of the ``im_data`` object ``imd``.
+   The data can be scalar-valued, vector-valued or tensor-valued depending on
+   the dimension of imd.
+
 .. c:function:: real_variable(name, niter=1)
 
Gives the access to the vector value of a variable or data. Real version.
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 07f056c..03cd55f 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -786,13 +786,13 @@ namespace getfem {
 
 
 /** Add variable defined at integration points. */
-void add_im_variable(const std::string , const im_data _data,
+void add_im_variable(const std::string , const im_data ,
  size_type niter = 1);
-/** Add internal variable, defined at integration points and condensated. 
*/
+/** Add internal variable, defined at integration points and condensed. */
 void add_internal_im_variable(const std::string ,
-  const im_data _data);
+  const im_data );
 /** Add data defined at integration points. */
-void add_im_data(const std::string , const im_data _data,
+void add_im_data(const std::string , const im_data ,
  size_type niter = 1);
 
 /** Add a variable being the dofs of a finite element method to the model.



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit cc6b8bcca2812961959672c2b6249d9cbeeac733
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 10:55:10 2020 +0100

Fixes and simplifications in internal variable condensation

  - First working version
---
 src/getfem/getfem_generic_assembly.h|   3 +-
 src/getfem_generic_assembly_compile_and_exec.cc | 186 
 src/getfem_generic_assembly_workspace.cc|  28 ++--
 3 files changed, 79 insertions(+), 138 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index d52d463..d19ccbc 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -372,7 +372,7 @@ namespace getfem {
 model_real_sparse_matrix col_unreduced_K,
  row_unreduced_K,
  row_col_unreduced_K;
-base_vector unreduced_V;
+base_vector unreduced_V, cached_V;
 base_tensor assemb_t;
 bool include_empty_int_pts = false;
 
@@ -391,6 +391,7 @@ namespace getfem {
 model_real_sparse_matrix _matrix() { return *K; }
 const base_vector _vector() const { return *V; }
 base_vector _vector() { return *V; }
+const base_vector _vector() const { return cached_V; }
 const base_tensor _tensor() const { return assemb_t; }
 base_tensor _tensor() { return assemb_t; }
 const scalar_type _potential() const {
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 42a74b0..188fbf1 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -5028,10 +5028,10 @@ namespace getfem {
 gmm::dense_matrix KQJprime;
 std::vector RQprime;
 gmm::dense_matrix KQQloc, KQJloc;
-std::vector RQloc;
 base_tensor invK, Kqqjj;
 base_vector Rqq;
 std::vector> partQ, partJ;
+const scalar_type  // ,  ?
 virtual int exec() { // implementation can be optimized
   GA_DEBUG_INFO("Instruction: variable cluster subdiagonal condensation");
   // copy from KQQ to invK
@@ -5081,7 +5081,7 @@ namespace getfem {
   gmm::clear(Kqqjj.as_vector());
   gmm::clear(Rqq);
 
-  // multiply invK with all submatrices in KQJloc and RQloc and store
+  // multiply invK with all submatrices in KQJloc and RQprime and store
   // the results in Kqqjj and Rqq
   for (const auto  : partJ) {
 size_type j = jjj[0], jjstart = jjj[1], jjend = jjj[2];
@@ -5103,13 +5103,13 @@ namespace getfem {
   } // in partJ
   for (const auto  : partQ) {
 size_type q2 = qqq2[0], qq2start = qqq2[1], qq2end = qqq2[2];
-if (RQloc[q2]) {
-  auto itr = RQloc[q2]->cbegin();
+if (RQprime[q2]) {
+  auto itr = RQprime[q2]->cbegin();
   for (size_type qq2=qq2start; qq2 < qq2end; ++qq2, ++itr) {
 for (size_type qq1=0; qq1 < invK.size(0); ++qq1)
   Rqq[qq1] += invK(qq1,qq2)*(*itr);
   } // for qq2
-  GMM_ASSERT1(itr == RQloc[q2]->cend(), "Internal error");
+  GMM_ASSERT1(itr == RQprime[q2]->cend(), "Internal error");
 }
   } // in partQ
 
@@ -5120,7 +5120,7 @@ namespace getfem {
 { // writing into RQprime
   auto itw = RQprime[q1]->begin();
   for (size_type qq1=qq1start; qq1 < qq1end; ++qq1)
-*itw++ = Rqq[qq1];
+*itw++ = Rqq[qq1]/coeff;
 }
 for (const auto  : partJ) {
   size_type j2 = jjj2[0], jj2start = jjj2[1], jj2end = jjj2[2];
@@ -5134,20 +5134,18 @@ namespace getfem {
 }
 
 ga_instruction_condensation_sub(gmm::dense_matrix ,
-std::vector ,
+std::vector , // 
input/output
 const gmm::dense_matrix 
,
 const gmm::dense_matrix 
,
-const std::vector ,
-const std::set )
-  : KQJprime(KQJpr), RQprime(RQpr)
+const std::set ,
+const scalar_type _)
+  : KQJprime(KQJpr), RQprime(RQpr), coeff(coeff_)
 {
   // * to const *
   KQQloc.resize(KQQ.nrows(), KQQ.ncols());
   KQJloc.resize(KQJ.nrows(), KQJ.ncols());
-  RQloc.resize(RQ.size());
   for (size_type i=0; i < KQQ.as_vector().size(); ++i) KQQloc[i] = KQQ[i];
   for (size_type i=0; i < KQJ.as_vector().size(); ++i) KQJloc[i] = KQJ[i];
-  for (size_type i=0; i < RQ.size(); ++i) RQloc[i] = RQ[i];
 
   for (size_type j=0; j < KQJ.ncols(); ++j)
 for (const size_type  : Qset)
@@ -5219,7 +5217,7 @@ namespace getfem {
 
   struct ga_instruction_condensation_super_R : public ga_instruction {
 base_tensor 
-std::vector KiQ, RQ; // indexed wrt q in Q
+std::vector KiQ, RQpr; // indexed wrt q in Q
 

[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 2722c83bff4df1f817e450cbc0085059369e948e
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 11:28:19 2020 +0100

Add unit test for internal variable condensation
---
 tests/Makefile.am  |   4 +
 tests/test_condensation.cc | 184 +
 tests/test_condensation.pl | 105 ++
 3 files changed, 293 insertions(+)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba8b7a3..296934f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@ check_PROGRAMS =   \
test_assembly_assignment   \
test_interpolated_fem  \
test_internal_variables\
+   test_condensation  \
test_range_basis   \
laplacian  \
laplacian_with_bricks  \
@@ -100,6 +101,7 @@ geo_trans_inv_SOURCES = geo_trans_inv.cc
 test_int_set_SOURCES = test_int_set.cc
 test_interpolated_fem_SOURCES = test_interpolated_fem.cc
 test_internal_variables_SOURCES = test_internal_variables.cc
+test_condensation_SOURCES = test_condensation.cc
 test_tree_sorted_SOURCES = test_tree_sorted.cc
 test_mat_elem_SOURCES = test_mat_elem.cc
 test_slice_SOURCES = test_slice.cc
@@ -141,6 +143,7 @@ TESTS = \
test_assembly_assignment.pl   \
test_interpolated_fem.pl  \
test_internal_variables.pl\
+   test_condensation.pl  \
test_range_basis.pl   \
laplacian.pl  \
laplacian_with_bricks.pl  \
@@ -182,6 +185,7 @@ EXTRA_DIST =
\
test_int_set.pl \
test_interpolated_fem.pl\
test_internal_variables.pl  \
+   test_condensation.pl\
test_slice.pl   \
test_mesh_im_level_set.pl   \
thermo_elasticity_electrical_coupling.pl\
diff --git a/tests/test_condensation.cc b/tests/test_condensation.cc
new file mode 100644
index 000..2a3ec22
--- /dev/null
+++ b/tests/test_condensation.cc
@@ -0,0 +1,184 @@
+/*===
+
+ Copyright (C) 2019-2020 Konstantinos Poulios.
+
+ This file is a part of GetFEM++
+
+ GetFEM++  is  free software;  you  can  redistribute  it  and/or modify it
+ under  the  terms  of the  GNU  Lesser General Public License as published
+ by  the  Free Software Foundation;  either version 3 of the License,  or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program  is  distributed  in  the  hope  that it will be useful,  but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You  should  have received a copy of the GNU Lesser General Public License
+ along  with  this program;  if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+
+===*/
+#include "getfem/getfem_regular_meshes.h"
+#include "getfem/getfem_export.h"
+#include "getfem/getfem_model_solvers.h"
+
+using bgeot::dim_type;
+using bgeot::size_type;
+using bgeot::scalar_type;
+using bgeot::base_node;
+
+static bool debug=false;
+
+int main(int argc, char *argv[]) {
+
+  gmm::set_traces_level(1);
+
+  bgeot::md_param PARAM;
+  PARAM.add_int_param("NX", 1);
+  PARAM.add_int_param("NY", 1);
+  PARAM.add_int_param("FEM_ORDER", 1);
+  PARAM.add_int_param("IM_ORDER", 1);
+  PARAM.add_int_param("DIFFICULTY", 0);
+  PARAM.read_command_line(argc, argv);
+  size_type NX = PARAM.int_value("NX", "Number of elements in X direction");
+  size_type NY = PARAM.int_value("NY", "Number of elements in Y direction");
+  dim_type FEM_ORDER = dim_type(PARAM.int_value("FEM_ORDER", "Degree of finite 
element basis"));
+  dim_type IM_ORDER = dim_type(PARAM.int_value("IM_ORDER", "Degree of 
integration method"));
+  size_type DIFFICULTY = PARAM.int_value("DIFFICULTY", "Difficulty of test");
+
+  getfem::mesh m;
+  getfem::regular_unit_mesh(m, {NX, NY}, 
bgeot::geometric_trans_descriptor("GT_QK(2, 2)"));
+
+  getfem::mesh_region outer_faces;
+  getfem::outer_faces_of_mesh(m, outer_faces);
+  m.region(98) = getfem::select_faces_of_normal(m, outer_faces, base_node(-1, 
0), 0.001);
+  m.region(99) = getfem::select_faces_of_normal(m, outer_faces, base_node(1, 
0), 0.001);
+
+  const dim_type N(m.dim());
+  getfem::mesh_fem mf(m, N);
+  mf.set_classical_finite_element(FEM_ORDER);
+  if (DIFFICULTY % 1000 <= 99) {
+dal::bit_vector kept;
+kept.add(0, 

[Getfem-commits] [getfem-commits] master updated (4c176ff -> 988ba0f)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 4c176ff  Simplification
 new cc6b8bc  Fixes and simplifications in internal variable condensation
 new 47ea7f9  Fix model class for internal variable condensation
 new 2722c83  Add unit test for internal variable condensation
 new 988ba0f  Mention internal variables in the model object documentation


Summary of changes:
 doc/sphinx/source/userdoc/model_object.rst  |  23 +++
 src/getfem/getfem_generic_assembly.h|   3 +-
 src/getfem/getfem_models.h  |   8 +-
 src/getfem_generic_assembly_compile_and_exec.cc | 186 
 src/getfem_generic_assembly_workspace.cc|  28 ++--
 src/getfem_models.cc|  13 +-
 tests/Makefile.am   |   4 +
 tests/test_condensation.cc  | 184 +++
 tests/test_condensation.pl  | 105 +
 9 files changed, 405 insertions(+), 149 deletions(-)
 create mode 100644 tests/test_condensation.cc
 create mode 100644 tests/test_condensation.pl



[Getfem-commits] (no subject)

2020-04-03 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 47ea7f9dd6904fe317a3955ae2c8712cf5a025f7
Author: Konstantinos Poulios 
AuthorDate: Sat Feb 1 11:23:55 2020 +0100

Fix model class for internal variable condensation
---
 src/getfem_models.cc | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 477a1b3..950257b 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2625,8 +2625,11 @@ namespace getfem {
   if (version & BUILD_RHS) approx_external_load_ += brick.external_load;
 }
 
-if (gmm::vect_size(full_rrhs)) { // i.e. if has_internal_variables()
+if (version & BUILD_RHS && version & BUILD_WITH_INTERNAL) {
+  GMM_ASSERT1(gmm::vect_size(full_rrhs) > 0 && has_internal_variables(),
+  "Internal error");
   gmm::sub_interval IP(0,gmm::vect_size(rrhs));
+  gmm::fill(full_rrhs, 0.);
   gmm::copy(rrhs, gmm::sub_vector(full_rrhs, IP)); // TICTIC
 }
 
@@ -2684,14 +2687,12 @@ namespace getfem {
 if (with_internal) { // Condensation reads from/writes to rhs
   gmm::copy(res0_distro.get(), res1_distro.get());
   gmm::add(gmm::scaled(full_rrhs, scalar_type(-1)),
-   res1_distro.get()); // TIC: initial value residual=-rhs
+   res1_distro.get()); // initial value residual=-rhs 
(actually only the internal variables residual is needed)
   workspace.set_assembled_vector(res1_distro);
   workspace.set_internal_coupling_matrix(intern_mat_distro);
 }
 workspace.set_assembled_matrix(tangent_matrix_distro);
 workspace.assembly(2, with_internal);
-if (with_internal) // TOC: diff from initial value, hack to make 
OMP work
-  gmm::add(full_rrhs, res1_distro.get());
   ) // end GETFEM_OMP_PARALLEL
 } // end of res0_distro scope
 else { // only BUILD_MATRIX
@@ -2700,14 +2701,12 @@ namespace getfem {
 add_assignments_and_expressions_to_workspace(workspace);
 if (with_internal) { // Condensation reads from/writes to rhs
   gmm::copy(gmm::scaled(full_rrhs, scalar_type(-1)),
-res1_distro.get()); // TIC: initial value residual=-rhs
+res1_distro.get()); // initial value residual=-rhs 
(actually only the internal variables residual is needed)
   workspace.set_assembled_vector(res1_distro);
   workspace.set_internal_coupling_matrix(intern_mat_distro);
 }
 workspace.set_assembled_matrix(tangent_matrix_distro);
 workspace.assembly(2, with_internal);
-if (with_internal) // TOC: diff from initial value, hack to make 
OMP work
-  gmm::add(full_rrhs, res1_distro.get());
   ) // end GETFEM_OMP_PARALLEL
 }
   } // end of tangent_matrix_distro, intern_mat_distro, res1_distro scope



[Getfem-commits] [getfem-commits] branch master updated: Support EXT_SUFFIX of distutils in Python 3

2020-03-25 Thread Konstantinos Poulios via Getfem-commits
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 4bcad6f  Support EXT_SUFFIX of distutils in Python 3
4bcad6f is described below

commit 4bcad6f9da1fdfffe86269c1dc5c8a9171bda978
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 25 14:49:49 2020 +0100

Support EXT_SUFFIX of distutils in Python 3
---
 configure.ac |  2 ++
 interface/src/python/Makefile.am | 10 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index c4771aa..b5d52fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1013,6 +1013,8 @@ dnl  AM_PATH_PYTHON(2.2)
   WARNING_MSG="$WARNING_MSG\n$MSG"
 fi
   fi
+  PYTHON_SO=`$PYTHON -c "import distutils.sysconfig, sys; get = 
distutils.sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or 
get('SO') or '.so');"`
+  AC_SUBST(PYTHON_SO)
 fi
 
 AM_CONDITIONAL(BUILDPYTHON, test x$usepython = xYES)
diff --git a/interface/src/python/Makefile.am b/interface/src/python/Makefile.am
index 8dd5132..8b241a1 100644
--- a/interface/src/python/Makefile.am
+++ b/interface/src/python/Makefile.am
@@ -23,13 +23,13 @@ gfpythondir=$(pythondir)/getfem
 gfpyexecdir=$(pyexecdir)/getfem
 
 gfpython_PYTHON = getfem.py __init__.py
-nodist_gfpyexec_PYTHON = _getfem.so
+nodist_gfpyexec_PYTHON = _getfem$(PYTHON_SO)
 
 EXTRA_DIST = getfem_python.c
 
 # $(warning PSEUDO_FUNCTIONS= $(PSEUDO_FUNCTIONS))
 
-CLEANFILES = getfem.py _getfem.so *.o getfem_python_c.o getfem_python_c.c 
getfem.pyc
+CLEANFILES = getfem.py _getfem*.so *.o getfem_python_c.o getfem_python_c.c 
getfem.pyc
 
 if BUILDPYTHONPAR
 
@@ -53,13 +53,13 @@ getfem_python_c.c : getfem_python.c
cp $(srcdir)/getfem_python.c getfem_python_c.c
 
 # ARCHFLAGS is set to empty to disable universal binaries with python 2.5 on 
macos 10.5
-_getfem.so: getfem_python_c.c ../libgetfemint.la $(GETFEM_LIB_LA)
-   touch _getfem.so && rm _getfem.so
+_getfem$(PYTHON_SO): getfem_python_c.c ../libgetfemint.la $(GETFEM_LIB_LA)
+   touch _getfem$(PYTHON_SO) && rm _getfem$(PYTHON_SO)
ARCHFLAGS="" CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py -v build 
@PYTHON_CC_ARG@ --build-temp . --build-base . --build-lib . --force
 #LDSHARED="$(CXX) -shared" ARCHFLAGS="" python setup.py -v build --build-temp 
. --build-base . --build-lib . --force
 
 
-all: _getfem.so getfem.py
+all: _getfem$(PYTHON_SO) getfem.py
 #pyexec_LTLIBRARIES = libgfpython.la
 #libgfpython_la_LIBADD = ../.libs/libgetfemint.a @GETFEM_STATICLIBS@
 #libgfpython_la_SOURCES = \



[Getfem-commits] [getfem-commits] branch master updated: Allow to override the dimension of the detected faces by Mesh.outer_faces()

2020-03-25 Thread Konstantinos Poulios via Getfem-commits
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 58b2f3b  Allow to override the dimension of the detected faces by 
Mesh.outer_faces()
58b2f3b is described below

commit 58b2f3bb60f3ccf513e29788f9ed6f88bc445a2f
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 25 15:01:15 2020 +0100

Allow to override the dimension of the detected faces by Mesh.outer_faces()

For example outer_faces(2) will detect edges of a surface mesh even if this 
is in 3D.
---
 interface/src/gf_mesh_get.cc | 43 +++
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/interface/src/gf_mesh_get.cc b/interface/src/gf_mesh_get.cc
index bebe46e..b7a2677 100644
--- a/interface/src/gf_mesh_get.cc
+++ b/interface/src/gf_mesh_get.cc
@@ -154,7 +154,8 @@ typedef 
dal::dynamic_tree_sorted mesh_faces_by_pts_l
 
 
 static void
-outer_faces(const getfem::mesh , mexargs_in , mexargs_out , const 
std::string ="")
+outer_faces(const getfem::mesh , mexargs_in , mexargs_out ,
+const std::string ="")
 {
   mesh_faces_by_pts_list lst;
   dal::bit_vector cvlst, checked_pids, rejected_pids;
@@ -188,11 +189,15 @@ outer_faces(const getfem::mesh , mexargs_in , 
mexargs_out , const std::
 radius = in.pop().to_scalar();
   }
 
+  dim_type elm_dim = m.dim();
+  if (in.remaining() && in.front().is_integer())
+   elm_dim = dim_type(in.pop().to_integer());
+
   if (in.remaining()) cvlst = in.pop().to_bit_vector(_index());
   else cvlst = m.convex_index();
 
   for (dal::bv_visitor ic(cvlst); !ic.finished(); ++ic) {
-if (m.structure_of_convex(ic)->dim() == m.dim()) {
+if (m.structure_of_convex(ic)->dim() == elm_dim) {
   for (short_type f = 0; f < m.structure_of_convex(ic)->nb_faces(); f++) {
 bgeot::mesh_structure::ind_pt_face_ct pt
   = m.ind_points_of_face_of_convex(ic, f);
@@ -200,7 +205,7 @@ outer_faces(const getfem::mesh , mexargs_in , 
mexargs_out , const std::
 size_type idx = lst.add_norepeat(mesh_faces_by_pts_list_elt(ic,f,p));
 lst[idx].cnt++;
   }
-} 
+}
 // else { // DEPRECATED
 //   bgeot::mesh_structure::ind_cv_ct pt = m.ind_points_of_convex(ic);
 //   std::vector p(pt.begin(), pt.end());
@@ -818,17 +823,20 @@ void gf_mesh_get(getfemint::mexargs_in& m_in,
);
 
 
-/*@GET CVFIDs = ('outer faces'[, CVIDs])
+/*@GET CVFIDs = ('outer faces'[, dim][, CVIDs])
 Return the set of faces not shared by two elements.
 
 The output `CVFIDs` is a two-rows matrix, the first row lists
 convex #ids, and the second one lists face numbers (local number
-in the convex). If `CVIDs` is not given, all convexes are
-considered, and it basically returns the mesh boundary. If `CVIDs`
+in the convex). If `dim` is provided, the function is forced to
+detect faces of elements that have dimension `dim`, e.g. `dim`=2 will
+detect edges of surface elements, even if these belong to a 3D mesh.
+If `CVIDs` is not given, all convexes are considered, and the
+function basically returns the mesh boundary. If `CVIDs`
 is given, it returns the boundary of the convex set whose #ids are
 listed in `CVIDs`.@*/
 sub_command
-  ("outer faces", 0, 1, 0, 1,
+  ("outer faces", 0, 2, 0, 1,
check_empty_mesh(pmesh);
outer_faces(*pmesh, in, out);
);
@@ -853,42 +861,45 @@ void gf_mesh_get(getfemint::mexargs_in& m_in,
all_faces(*pmesh, in, out);
);
 
-/*@GET CVFIDs = ('outer faces with direction', @vec v, @scalar angle [, 
CVIDs])
+/*@GET CVFIDs = ('outer faces with direction', @vec v, @scalar angle[, 
dim][, CVIDs])
 Return the set of faces not shared by two convexes and with a mean outward 
vector lying within an angle `angle` (in radians) from vector `v`.
 
 The output `CVFIDs` is a two-rows matrix, the first row lists convex
 #ids, and the second one lists face numbers (local number in the
-convex). If `CVIDs` is given, it returns portion of the boundary of
+convex). The argument `dim` works as in outer_faces().
+If `CVIDs` is given, it returns portion of the boundary of
 the convex set defined by the #ids listed in `CVIDs`.@*/
 sub_command
-  ("outer faces with direction", 2, 3, 0, 1,
+  ("outer faces with direction", 2, 4, 0, 1,
check_empty_mesh(pmesh);
outer_faces(*pmesh, in, out, "direction");
);
 
 
-/*@GET CVFIDs = ('outer faces in box', @vec pmin, @vec pmax [, CVIDs])
+/*@GET CVFIDs = ('outer faces in box', @vec pmin, @vec pmax[, dim][, 
CVIDs])
 Return the set of faces not shared by two convexes and lying within the 
box defined by the corner points `pmin` and `pmax`.
 
 The output `CVFIDs` is a two-rows matrix, the first row lists convex
 #ids, and the second one lists face numbers 

[Getfem-commits] [getfem-commits] branch master updated: Fix python 3 module import

2020-04-01 Thread Konstantinos Poulios via Getfem-commits
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 e3fa52a  Fix python 3 module import
e3fa52a is described below

commit e3fa52a6ac917295537aefe78ac01b3f8d0a69b8
Author: Konstantinos Poulios 
AuthorDate: Wed Apr 1 18:21:10 2020 +0200

Fix python 3 module import
---
 bin/extract_doc  | 2 +-
 interface/src/python/__init__.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/extract_doc b/bin/extract_doc
index 3d5788c..72bdf25 100755
--- a/bin/extract_doc
+++ b/bin/extract_doc
@@ -1622,7 +1622,7 @@ except ImportError:
 
 from numpy import *
 
-from _getfem import *
+from ._getfem import *
 obj_count = {}
 getfem('workspace', 'clear all')
 
diff --git a/interface/src/python/__init__.py b/interface/src/python/__init__.py
index 1971861..d0cb235 100644
--- a/interface/src/python/__init__.py
+++ b/interface/src/python/__init__.py
@@ -13,4 +13,4 @@ __LICENSE__ = """\
 GetFEM++ is free software; you can redistribute it and/or modify it under the 
terms of the GNU Lesser General Public License as published by the Free 
Software Foundation; either version 3 of the License, or (at your option) any 
later version along with the GCC Runtime Library Exception either version 3.1 
or (at your option) any later version. This program is distributed in the hope 
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
warranty of MERCHANTABILITY or F [...]
 """
 
-from getfem import *
+from .getfem import *



Re: [Getfem-commits] split mumps script in python test

2020-04-26 Thread Konstantinos Poulios via Getfem-commits
Hi Tetsuo,

Thanks for running the tests on different systems. I don't think that this
is a good option. We should not remove the tests that fail. We should
instead fix the issue. That's what the tests are for.

Best regards
Kostas

On Fri, Apr 24, 2020 at 6:44 PM Tetsuo Koyama  wrote:

> Dear getfem project
>
> Hi all. Ubunut20.04 was released and I run git repository test in that
> enviroment.
> But, there is a problem that the test which use mumps didn't end (I
> wated about 1 hours.) . When I set --enable-mumps=no, all the tests
> are passed. I expect that this is a problem of mumps library (not
> getfem).
>
> By the way there is a python mumps solving script which run when I set
> --enable-mumps=no. So I fixed Makefile.am.
>
> Could you merge devel-tetsuo-mumps-option?
>
> BR Tetsuo
>
>


[Getfem-commits] [getfem-commits] branch master updated: Small adaptation of the release notes

2020-04-21 Thread Konstantinos Poulios via Getfem-commits
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 3c282a2  Small adaptation of the release notes
3c282a2 is described below

commit 3c282a22785b0baef1e1075fcfebd3b80e8ed421
Author: Konstantinos Poulios 
AuthorDate: Tue Apr 21 22:23:53 2020 +0200

Small adaptation of the release notes
---
 doc/sphinx/source/whatsnew/5.4.rst | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/doc/sphinx/source/whatsnew/5.4.rst 
b/doc/sphinx/source/whatsnew/5.4.rst
index 54b8e66..647e30c 100644
--- a/doc/sphinx/source/whatsnew/5.4.rst
+++ b/doc/sphinx/source/whatsnew/5.4.rst
@@ -4,22 +4,26 @@
   What's New in |gf| 5.4
 
 
-The main contribution of this version is the extension of the language 
allowing macro definition and explicit differentiation.
+The main contribution of this version is a fully functional scripting language 
interface to Octave and support for definition and condensation of internal 
variables.
 
-Released version, 2020/06/01.
+Released version, 2020/04/21.
 
 The main changes are:
 
-   * A support for variables defined at integration points 
+   * A fully working Octave interface. Many thanks to Abderrahmane Bendali
+ for the initial adaptation of this interface from Matlab's one.
 
-   * A full support for the automatic condensation of variables determined by 
local equations (for instance for plasticity) (Konstantinos Poulios 
contribution)
+   * Support for (internal) variables defined at integration points
 
-   * A fully working Octave interface. Many thanks to Abderrahmane Bendali for 
the first adaptation of this interface from Matlab's one.
+   * Full support for the automatic condensation of internal variables by
+ local equations expressed in the generice weal form language. Useful
+ for instance in the implementation of plasticity models.
 
* The use of Python 3 instead of Python 2.7 by default
 
-   * A support for HHO methods
-   
-   * A support for the the assembly of product of terms defined on two 
different domains (integration on the product of two domains with a kernel, for 
instance).
+   * Support for Hybrid High-Order methods

+   * Support for the the assembly of product of terms defined on two
+ different domains (integration on the product of two domains with a
+ kernel, for instance).
 



Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-07 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo

I think it is an important contribution to add vtu support, especially if
it is binary/compressed, just ascii is not very useful. However we might
need to discuss a bit on how to do it. As far as I can see you have used
boost for xml writing. I think we had dropped our dependency on boost and I
am not very keen on reintroducing a dependency on boost.

Before we merge this, I would like to hear some arguments for one solution
or another. The first thing to check is what others do. How is vtu export
implemented in other software like e.g. fenics? What is the more
future-proof way of implementing vtu support? What is a solution with least
dependencies? If we have to depend on an external library it might be
better to depend on vtk directly
https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU

Have you done some research regarding these questions?

There is also another thing that I would like to ask you about. Could you
please don't use markup in your git commit description? It might look nice
in your git client but it looks ugly and difficult to read on other's
systems.

Best regards
Kostas




On Thu, May 7, 2020 at 2:07 AM Tetsuo Koyama  wrote:

> Dear getfem project
>
> Could you merge devel-tetsuo-xml?
> This branch is addition of vtu_export class.
> By using this class we can export xml unstructured grid format vtk
> (only ascii format and write_point_data).
> I tested it by using meshio package (https://github.com/nschloe/meshio).
> In the future, the binary format and write_cell_data method may be
> extended.
>
> Thank you for reading.
>
> BR Tetsuo
>
>


Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-07 Thread Konstantinos Poulios via Getfem-commits
just to add that for compressed vtu files I use the attached conversion
script based on binary vtk files exported from getfem.

On Thu, May 7, 2020 at 11:59 AM Konstantinos Poulios <
logar...@googlemail.com> wrote:

> Dear Tetsuo
>
> I think it is an important contribution to add vtu support, especially if
> it is binary/compressed, just ascii is not very useful. However we might
> need to discuss a bit on how to do it. As far as I can see you have used
> boost for xml writing. I think we had dropped our dependency on boost and I
> am not very keen on reintroducing a dependency on boost.
>
> Before we merge this, I would like to hear some arguments for one solution
> or another. The first thing to check is what others do. How is vtu export
> implemented in other software like e.g. fenics? What is the more
> future-proof way of implementing vtu support? What is a solution with least
> dependencies? If we have to depend on an external library it might be
> better to depend on vtk directly
> https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU
>
> Have you done some research regarding these questions?
>
> There is also another thing that I would like to ask you about. Could you
> please don't use markup in your git commit description? It might look nice
> in your git client but it looks ugly and difficult to read on other's
> systems.
>
> Best regards
> Kostas
>
>
>
>
> On Thu, May 7, 2020 at 2:07 AM Tetsuo Koyama  wrote:
>
>> Dear getfem project
>>
>> Could you merge devel-tetsuo-xml?
>> This branch is addition of vtu_export class.
>> By using this class we can export xml unstructured grid format vtk
>> (only ascii format and write_point_data).
>> I tested it by using meshio package (https://github.com/nschloe/meshio).
>> In the future, the binary format and write_cell_data method may be
>> extended.
>>
>> Thank you for reading.
>>
>> BR Tetsuo
>>
>>
import sys
import os
import glob
from paraview.simple import *

if hasattr(sys, 'argv') and len(sys.argv) > 1:
   namepattern = sys.argv[1]
   files = glob.glob(namepattern+"*.vtk")
   cleanup = (len(sys.argv) > 2 and sys.argv[2] == "cleanup")
   for f in files:
  r = LegacyVTKReader( FileNames=[f] )
  w = XMLUnstructuredGridWriter()
  w.DataMode = "Appended"
  w.CompressorType = "ZLib"
  w.FileName = f[:-3]+"vtu"
  w.UpdatePipeline()
  if cleanup:
 os.remove(f)
else:
   print('Usage: pvpython convert_vtk_to_vtu.py "./results/filebasename" "cleanup"')


Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-10 Thread Konstantinos Poulios via Getfem-commits
the other thing is the big overlapping between the vtk_export class and the
new vtu_export class. Duplicating code is not a very good strategy. I think
you should just keep the old vtk_export class and add an optional argument
for the user to choose if exporting to xml format or not.

Best regards
Kostas

On Sun, May 10, 2020 at 10:23 PM Konstantinos Poulios <
logar...@googlemail.com> wrote:

> by the way, the "remove_dof_unused" function you should make it work
> in-place on the passed by reference V vector, as was the code that you
> replaced with this function. The line
> gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W)
> and the temporary W vector are completely unnecessary, and just add
> redundant copy operations.
>
> Best regards
> Kostas
>
> On Sun, May 10, 2020 at 10:16 PM Konstantinos Poulios <
> logar...@googlemail.com> wrote:
>
>> Dear Tetsuo,
>>
>> Thanks for your answer. Your code looks quite nice actually. I have one
>> question about the lines
>>   std::vector W(Q*pmf_dof_used.card());
>>   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
>>   write_dataset_(V, name, qdim);
>> Since you do not do anything with vector W, what is the meaning of having
>> it? Should the last line be:
>>   write_dataset_(W, name, qdim);
>> instead?
>>
>> Apart from that, I think we need a bit cleaner workflow without too many
>> unnecessary commits. I remember that I had advised you in the past against
>> too large commits, but the ideal is somewhere in the middle. The commits
>> must in general be organized in logical units from the perspective of
>> someone looking at the git history. The work you have done here, I would
>> put it into one or two commits. All the forth and back during the
>> development, it doesn't need to be part of the repository history.
>>
>> You can just make a new branch and put the outcome of your development in
>> one or two commits and then we can merge that branch. Sorry for being
>> picky, but establishing some good development habits will make our life
>> easier in the future.
>>
>> Best regards
>> Kostas
>>
>> On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama 
>> wrote:
>>
>>> P.S.
>>> I had a typo
>>>
>>> >That is a good point. It maybe a good idea of using library, but we
>>> have to use cmake to link vtk librayr.
>>> That is a good point. It maybe a good idea of using library, but we
>>> have to use cmake to link vtk library.
>>>
>>> 2020年5月7日(木) 22:17 Tetsuo Koyama :
>>> >
>>> > Dear Kostas
>>> >
>>> > Thank you very much for taking the time to review.
>>> >
>>> > > I think it is an important contribution to add vtu support,
>>> especially if it is binary/compressed, just ascii is not very useful.
>>> > Thanks. I agree that binary/compressed is important. After this change
>>> > is confirmed, I would like to add that option.
>>> >
>>> > > However we might need to discuss a bit on how to do it. As far as I
>>> can see you have used boost for xml writing. I think we
>>> > > had dropped our dependency on boost and I am not very keen on
>>> reintroducing a dependency on boost.
>>> > I agree with the policy that projects don't use boost. In the end, I
>>> > made changes to eliminate the dependence on boost in the end. If there
>>> > is any remaining dependence, please point out . I am sorry that the
>>> > commit is complicated. The current vtu object does not require
>>> > dependency to boost even if when extending to binaries.
>>> >
>>> > >Before we merge this, I would like to hear some arguments for one
>>> solution or another. The first thing to check is what others do.
>>> > > How is vtu export implemented in other software like e.g. fenics?
>>> What is the more future-proof way of implementing vtu support?
>>> > I didn't search fenics but meshio package (This is a major package
>>> > which is used to convert mesh format. You can install by `apt install
>>> > python3-meshio`) and mayavi2.
>>> > Both are built by full scratches of writing text and binary like
>>> > getfem project is doing. They reffer vtk file format pdf.
>>> > https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
>>> >
>>> > > What is a solution with least dependencies? If we have to depend on
>>> an external library it might be better to depend
>>> > > on vtk directly
>>> https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU
>>> > That is a good point. It maybe a good idea of using library, but we
>>> > have to use cmake to link vtk librayr. I think it is difficult to use
>>> > with getfem using automake. (Is there any plan to use cmake in
>>> > getfem?)
>>> >
>>> > This is hello world of vtk library.
>>> >
>>> https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/CylinderExample/
>>> >
>>> > > Have you done some research regarding these questions?
>>> > That is all. If I need I search of fenics I will do it !
>>> >
>>> > > There is also another thing that I would like to ask you about.
>>> Could you please don't use markup in your git commit description? It might
>>> 

Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-10 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo,

Thanks for your answer. Your code looks quite nice actually. I have one
question about the lines
  std::vector W(Q*pmf_dof_used.card());
  gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
  write_dataset_(V, name, qdim);
Since you do not do anything with vector W, what is the meaning of having
it? Should the last line be:
  write_dataset_(W, name, qdim);
instead?

Apart from that, I think we need a bit cleaner workflow without too many
unnecessary commits. I remember that I had advised you in the past against
too large commits, but the ideal is somewhere in the middle. The commits
must in general be organized in logical units from the perspective of
someone looking at the git history. The work you have done here, I would
put it into one or two commits. All the forth and back during the
development, it doesn't need to be part of the repository history.

You can just make a new branch and put the outcome of your development in
one or two commits and then we can merge that branch. Sorry for being
picky, but establishing some good development habits will make our life
easier in the future.

Best regards
Kostas

On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama  wrote:

> P.S.
> I had a typo
>
> >That is a good point. It maybe a good idea of using library, but we
> have to use cmake to link vtk librayr.
> That is a good point. It maybe a good idea of using library, but we
> have to use cmake to link vtk library.
>
> 2020年5月7日(木) 22:17 Tetsuo Koyama :
> >
> > Dear Kostas
> >
> > Thank you very much for taking the time to review.
> >
> > > I think it is an important contribution to add vtu support, especially
> if it is binary/compressed, just ascii is not very useful.
> > Thanks. I agree that binary/compressed is important. After this change
> > is confirmed, I would like to add that option.
> >
> > > However we might need to discuss a bit on how to do it. As far as I
> can see you have used boost for xml writing. I think we
> > > had dropped our dependency on boost and I am not very keen on
> reintroducing a dependency on boost.
> > I agree with the policy that projects don't use boost. In the end, I
> > made changes to eliminate the dependence on boost in the end. If there
> > is any remaining dependence, please point out . I am sorry that the
> > commit is complicated. The current vtu object does not require
> > dependency to boost even if when extending to binaries.
> >
> > >Before we merge this, I would like to hear some arguments for one
> solution or another. The first thing to check is what others do.
> > > How is vtu export implemented in other software like e.g. fenics? What
> is the more future-proof way of implementing vtu support?
> > I didn't search fenics but meshio package (This is a major package
> > which is used to convert mesh format. You can install by `apt install
> > python3-meshio`) and mayavi2.
> > Both are built by full scratches of writing text and binary like
> > getfem project is doing. They reffer vtk file format pdf.
> > https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
> >
> > > What is a solution with least dependencies? If we have to depend on an
> external library it might be better to depend
> > > on vtk directly
> https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU
> > That is a good point. It maybe a good idea of using library, but we
> > have to use cmake to link vtk librayr. I think it is difficult to use
> > with getfem using automake. (Is there any plan to use cmake in
> > getfem?)
> >
> > This is hello world of vtk library.
> >
> https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/CylinderExample/
> >
> > > Have you done some research regarding these questions?
> > That is all. If I need I search of fenics I will do it !
> >
> > > There is also another thing that I would like to ask you about. Could
> you please don't use markup in your git commit description? It might look
> nice in your git client but it looks ugly and difficult to read on other's
> systems.
> > Thank you for pointing it out. I used emoji prefix which is popular in
> > my local. It is not good to use it in a global community. Sorry.
> >
> > > just to add that for compressed vtu files I use the attached
> conversion script based on binary vtk files exported from getfem.
> > Thanks. I'll use it.
> >
> > Thank you for reading.
> >
> > BR Tetsuo
> >
> > 2020年5月7日(木) 19:21 Konstantinos Poulios :
> > >
> > > just to add that for compressed vtu files I use the attached
> conversion script based on binary vtk files exported from getfem.
> > >
> > > On Thu, May 7, 2020 at 11:59 AM Konstantinos Poulios <
> logar...@googlemail.com> wrote:
> > >>
> > >> Dear Tetsuo
> > >>
> > >> I think it is an important contribution to add vtu support,
> especially if it is binary/compressed, just ascii is not very useful.
> However we might need to discuss a bit on how to do it. As far as I can see
> you have used boost for xml writing. I think we had dropped our 

Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-10 Thread Konstantinos Poulios via Getfem-commits
The FOOTER_WRITTEN enumeration entry is not used anywhere, so it has to be
removed.

Is it intentional that you did not support exporting slices in the vtu
format? What prevents us from exporting slices?

For now, you can continue working on your current branch, and when the code
is ready for merging we can move the final result to a new clean branch to
merge to master.

Best regards
Kostas

On Sun, May 10, 2020 at 10:34 PM Konstantinos Poulios <
logar...@googlemail.com> wrote:

> the other thing is the big overlapping between the vtk_export class and
> the new vtu_export class. Duplicating code is not a very good strategy. I
> think you should just keep the old vtk_export class and add an optional
> argument for the user to choose if exporting to xml format or not.
>
> Best regards
> Kostas
>
> On Sun, May 10, 2020 at 10:23 PM Konstantinos Poulios <
> logar...@googlemail.com> wrote:
>
>> by the way, the "remove_dof_unused" function you should make it work
>> in-place on the passed by reference V vector, as was the code that you
>> replaced with this function. The line
>> gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W)
>> and the temporary W vector are completely unnecessary, and just add
>> redundant copy operations.
>>
>> Best regards
>> Kostas
>>
>> On Sun, May 10, 2020 at 10:16 PM Konstantinos Poulios <
>> logar...@googlemail.com> wrote:
>>
>>> Dear Tetsuo,
>>>
>>> Thanks for your answer. Your code looks quite nice actually. I have one
>>> question about the lines
>>>   std::vector W(Q*pmf_dof_used.card());
>>>   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
>>>   write_dataset_(V, name, qdim);
>>> Since you do not do anything with vector W, what is the meaning of
>>> having it? Should the last line be:
>>>   write_dataset_(W, name, qdim);
>>> instead?
>>>
>>> Apart from that, I think we need a bit cleaner workflow without too many
>>> unnecessary commits. I remember that I had advised you in the past against
>>> too large commits, but the ideal is somewhere in the middle. The commits
>>> must in general be organized in logical units from the perspective of
>>> someone looking at the git history. The work you have done here, I would
>>> put it into one or two commits. All the forth and back during the
>>> development, it doesn't need to be part of the repository history.
>>>
>>> You can just make a new branch and put the outcome of your development
>>> in one or two commits and then we can merge that branch. Sorry for being
>>> picky, but establishing some good development habits will make our life
>>> easier in the future.
>>>
>>> Best regards
>>> Kostas
>>>
>>> On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama 
>>> wrote:
>>>
 P.S.
 I had a typo

 >That is a good point. It maybe a good idea of using library, but we
 have to use cmake to link vtk librayr.
 That is a good point. It maybe a good idea of using library, but we
 have to use cmake to link vtk library.

 2020年5月7日(木) 22:17 Tetsuo Koyama :
 >
 > Dear Kostas
 >
 > Thank you very much for taking the time to review.
 >
 > > I think it is an important contribution to add vtu support,
 especially if it is binary/compressed, just ascii is not very useful.
 > Thanks. I agree that binary/compressed is important. After this change
 > is confirmed, I would like to add that option.
 >
 > > However we might need to discuss a bit on how to do it. As far as I
 can see you have used boost for xml writing. I think we
 > > had dropped our dependency on boost and I am not very keen on
 reintroducing a dependency on boost.
 > I agree with the policy that projects don't use boost. In the end, I
 > made changes to eliminate the dependence on boost in the end. If there
 > is any remaining dependence, please point out . I am sorry that the
 > commit is complicated. The current vtu object does not require
 > dependency to boost even if when extending to binaries.
 >
 > >Before we merge this, I would like to hear some arguments for one
 solution or another. The first thing to check is what others do.
 > > How is vtu export implemented in other software like e.g. fenics?
 What is the more future-proof way of implementing vtu support?
 > I didn't search fenics but meshio package (This is a major package
 > which is used to convert mesh format. You can install by `apt install
 > python3-meshio`) and mayavi2.
 > Both are built by full scratches of writing text and binary like
 > getfem project is doing. They reffer vtk file format pdf.
 > https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
 >
 > > What is a solution with least dependencies? If we have to depend on
 an external library it might be better to depend
 > > on vtk directly
 https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU
 > That is a good point. It maybe a good idea of using library, but we

Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-10 Thread Konstantinos Poulios via Getfem-commits
by the way, the "remove_dof_unused" function you should make it work
in-place on the passed by reference V vector, as was the code that you
replaced with this function. The line
gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W)
and the temporary W vector are completely unnecessary, and just add
redundant copy operations.

Best regards
Kostas

On Sun, May 10, 2020 at 10:16 PM Konstantinos Poulios <
logar...@googlemail.com> wrote:

> Dear Tetsuo,
>
> Thanks for your answer. Your code looks quite nice actually. I have one
> question about the lines
>   std::vector W(Q*pmf_dof_used.card());
>   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
>   write_dataset_(V, name, qdim);
> Since you do not do anything with vector W, what is the meaning of having
> it? Should the last line be:
>   write_dataset_(W, name, qdim);
> instead?
>
> Apart from that, I think we need a bit cleaner workflow without too many
> unnecessary commits. I remember that I had advised you in the past against
> too large commits, but the ideal is somewhere in the middle. The commits
> must in general be organized in logical units from the perspective of
> someone looking at the git history. The work you have done here, I would
> put it into one or two commits. All the forth and back during the
> development, it doesn't need to be part of the repository history.
>
> You can just make a new branch and put the outcome of your development in
> one or two commits and then we can merge that branch. Sorry for being
> picky, but establishing some good development habits will make our life
> easier in the future.
>
> Best regards
> Kostas
>
> On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama  wrote:
>
>> P.S.
>> I had a typo
>>
>> >That is a good point. It maybe a good idea of using library, but we
>> have to use cmake to link vtk librayr.
>> That is a good point. It maybe a good idea of using library, but we
>> have to use cmake to link vtk library.
>>
>> 2020年5月7日(木) 22:17 Tetsuo Koyama :
>> >
>> > Dear Kostas
>> >
>> > Thank you very much for taking the time to review.
>> >
>> > > I think it is an important contribution to add vtu support,
>> especially if it is binary/compressed, just ascii is not very useful.
>> > Thanks. I agree that binary/compressed is important. After this change
>> > is confirmed, I would like to add that option.
>> >
>> > > However we might need to discuss a bit on how to do it. As far as I
>> can see you have used boost for xml writing. I think we
>> > > had dropped our dependency on boost and I am not very keen on
>> reintroducing a dependency on boost.
>> > I agree with the policy that projects don't use boost. In the end, I
>> > made changes to eliminate the dependence on boost in the end. If there
>> > is any remaining dependence, please point out . I am sorry that the
>> > commit is complicated. The current vtu object does not require
>> > dependency to boost even if when extending to binaries.
>> >
>> > >Before we merge this, I would like to hear some arguments for one
>> solution or another. The first thing to check is what others do.
>> > > How is vtu export implemented in other software like e.g. fenics?
>> What is the more future-proof way of implementing vtu support?
>> > I didn't search fenics but meshio package (This is a major package
>> > which is used to convert mesh format. You can install by `apt install
>> > python3-meshio`) and mayavi2.
>> > Both are built by full scratches of writing text and binary like
>> > getfem project is doing. They reffer vtk file format pdf.
>> > https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf
>> >
>> > > What is a solution with least dependencies? If we have to depend on
>> an external library it might be better to depend
>> > > on vtk directly
>> https://www.paraview.org/Wiki/VTK/Examples/Cxx/IO/WriteVTU
>> > That is a good point. It maybe a good idea of using library, but we
>> > have to use cmake to link vtk librayr. I think it is difficult to use
>> > with getfem using automake. (Is there any plan to use cmake in
>> > getfem?)
>> >
>> > This is hello world of vtk library.
>> >
>> https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/CylinderExample/
>> >
>> > > Have you done some research regarding these questions?
>> > That is all. If I need I search of fenics I will do it !
>> >
>> > > There is also another thing that I would like to ask you about. Could
>> you please don't use markup in your git commit description? It might look
>> nice in your git client but it looks ugly and difficult to read on other's
>> systems.
>> > Thank you for pointing it out. I used emoji prefix which is popular in
>> > my local. It is not good to use it in a global community. Sorry.
>> >
>> > > just to add that for compressed vtu files I use the attached
>> conversion script based on binary vtk files exported from getfem.
>> > Thanks. I'll use it.
>> >
>> > Thank you for reading.
>> >
>> > BR Tetsuo
>> >
>> > 2020年5月7日(木) 19:21 Konstantinos Poulios :

[Getfem-commits] [getfem-commits] branch devel-logari81-gcc9-openmp updated: Prioritize generic blas detection

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-gcc9-openmp
in repository getfem.

The following commit(s) were added to refs/heads/devel-logari81-gcc9-openmp by 
this push:
 new 77d6f76  Prioritize generic blas detection
77d6f76 is described below

commit 77d6f761bf8c9c681960c28c0d42b79856b65bd6
Author: Konstantinos Poulios 
AuthorDate: Sat May 23 10:12:24 2020 +0200

Prioritize generic blas detection
---
 configure.ac | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 37d561a..914cef6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -576,6 +576,11 @@ if test $acx_blas_ok = no; then
 LIBS="$save_LIBS"
 fi
 
+# Generic BLAS library?
+if test $acx_blas_ok = no; then
+AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"])
+fi
+
 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
 if test $acx_blas_ok = no; then
 AC_CHECK_LIB(atlas, ATL_xerbla,
@@ -636,11 +641,7 @@ if test $acx_blas_ok = no; then
 [], [-lblas $FLIBS])])
 fi
 
-# Generic BLAS library?
-if test $acx_blas_ok = no; then
-AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"])
-fi
-
+# Generic BLAS library with fortran dependency?
 if test $acx_blas_ok = no; then
 AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas 
$FCLIBS"])
 fi



[Getfem-commits] (no subject)

2020-05-22 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-gcc9-openmp
commit efe0d4541f6b972d1c48ad685131f42d68ff56b8
Author: Konstantinos Poulios 
AuthorDate: Fri May 22 12:01:45 2020 +0200

Fix compilation and test errors with --enable-openmp
---
 src/getfem/getfem_omp.h| 5 -
 tests/test_kdtree.cc   | 2 ++
 tests/test_small_vector.cc | 3 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/getfem/getfem_omp.h b/src/getfem/getfem_omp.h
index f8dbaa7..f224ffe 100644
--- a/src/getfem/getfem_omp.h
+++ b/src/getfem/getfem_omp.h
@@ -54,6 +54,9 @@ namespace getfem
   using bgeot::size_type;
 
 #ifdef GETFEM_HAS_OPENMP
+  void parallel_execution(std::function lambda,
+  bool iterate_over_partitions);
+
   //declaring a thread lock, to protect multi-threaded accesses to
   //asserts, traces and warnings. Using a global mutex
   class omp_guard
@@ -486,4 +489,4 @@ namespace getfem
 
   #endif
 
-}  /* end of namespace getfem. */
\ No newline at end of file
+}  /* end of namespace getfem. */
diff --git a/tests/test_kdtree.cc b/tests/test_kdtree.cc
index 331b569..9e29656 100644
--- a/tests/test_kdtree.cc
+++ b/tests/test_kdtree.cc
@@ -115,7 +115,9 @@ void speed_test(unsigned N, unsigned NPT, unsigned nrepeat) 
{
 for (dim_type k = 0; k < N; ++k) 
   pt[k] = gmm::random(double())*2.;
 tree.add_point(pt);
+#ifndef GETFEM_HAS_OPENMP
 assert(pt.refcnt()>1);
+#endif
   }
   t = gmm::uclock_sec();
   cout << "point list built in " << gmm::uclock_sec() - t << " seconds.\n";
diff --git a/tests/test_small_vector.cc b/tests/test_small_vector.cc
index 6aac7f1..7abf61a 100644
--- a/tests/test_small_vector.cc
+++ b/tests/test_small_vector.cc
@@ -779,7 +779,8 @@ namespace getfem {
 //rrun(mv);
 rrun(Sv);
 //rrun(av);
-bgeot::static_block_allocator::palloc->memstats();
+if (bgeot::static_block_allocator::palloc)
+  bgeot::static_block_allocator::palloc->memstats();
 cout << "sizeof(size_type)=" << sizeof(size_type) 
 << ", sizeof(base_node)=" << sizeof(base_node) 
 << ", sizeof(base_small_vector)=" << sizeof(base_small_vector) << "\n";



[Getfem-commits] [getfem-commits] branch devel-logari81-gcc9-openmp created (now efe0d45)

2020-05-22 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-gcc9-openmp.

  at efe0d45  Fix compilation and test errors with --enable-openmp

This branch includes the following new commits:

 new efe0d45  Fix compilation and test errors with --enable-openmp




[Getfem-commits] [getfem-commits] branch devel-logari81-xml created (now db725b2)

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-xml.

  at db725b2  Move enumeration from header file

This branch includes the following new commits:

 new db725b2  Move enumeration from header file




[Getfem-commits] (no subject)

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-xml
commit db725b2e96688a40a9d5ed83d0876f941134fdb1
Author: Konstantinos Poulios 
AuthorDate: Sat May 23 20:37:25 2020 +0200

Move enumeration from header file
---
 src/getfem/getfem_export.h | 20 ---
 src/getfem_export.cc   | 63 ++
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index de1a654..6687804 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -85,26 +85,6 @@ namespace getfem {
 void write_separ();
 
   public:
-typedef enum { VTK_VERTEX = 1,
-   VTK_LINE = 3,
-   VTK_TRIANGLE = 5,
-   VTK_PIXEL = 8,
-   VTK_QUAD = 9,
-   VTK_TETRA = 10,
-   VTK_VOXEL = 11,
-   VTK_HEXAHEDRON = 12,
-   VTK_WEDGE = 13,
-   VTK_PYRAMID = 14,
-   VTK_QUADRATIC_EDGE = 21,
-   VTK_QUADRATIC_TRIANGLE = 22,
-   VTK_QUADRATIC_QUAD = 23,
-   VTK_QUADRATIC_TETRA = 24,
-   VTK_QUADRATIC_HEXAHEDRON = 25,
-   VTK_QUADRATIC_WEDGE = 26,
-   VTK_QUADRATIC_PYRAMID = 27,
-   VTK_BIQUADRATIC_QUAD = 28,
-   VTK_TRIQUADRATIC_HEXAHEDRON = 29,
-   VTK_BIQUADRATIC_QUADRATIC_WEDGE = 32 } vtk_cell_type;
 vtk_export(const std::string& fname, bool ascii_ = false);
 vtk_export(std::ostream _, bool ascii_ = false);
 
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index f3de086..811cbf3 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -33,6 +33,27 @@ namespace getfem
   struct gf2vtk_dof_mapping : public std::vector > {};
   struct gf2vtk_vtk_type : public std::vector {};
 
+  typedef enum { VTK_VERTEX = 1,
+ VTK_LINE = 3,
+ VTK_TRIANGLE = 5,
+ VTK_PIXEL = 8,
+ VTK_QUAD = 9,
+ VTK_TETRA = 10,
+ VTK_VOXEL = 11,
+ VTK_HEXAHEDRON = 12,
+ VTK_WEDGE = 13,
+ VTK_PYRAMID = 14,
+ VTK_QUADRATIC_EDGE = 21,
+ VTK_QUADRATIC_TRIANGLE = 22,
+ VTK_QUADRATIC_QUAD = 23,
+ VTK_QUADRATIC_TETRA = 24,
+ VTK_QUADRATIC_HEXAHEDRON = 25,
+ VTK_QUADRATIC_WEDGE = 26,
+ VTK_QUADRATIC_PYRAMID = 27,
+ VTK_BIQUADRATIC_QUAD = 28,
+ VTK_TRIQUADRATIC_HEXAHEDRON = 29,
+ VTK_BIQUADRATIC_QUADRATIC_WEDGE = 32 } vtk_cell_type;
+
   typedef enum { NO_VTK_MAPPING,
  N1_TO_VTK_VERTEX,
  N2_TO_VTK_LINE,
@@ -66,48 +87,48 @@ namespace getfem
 vtkmaps.resize(25);
 vtktypes.resize(25);
 
-vtktypes[N1_TO_VTK_VERTEX] = vtk_export::VTK_VERTEX;
+vtktypes[N1_TO_VTK_VERTEX] = VTK_VERTEX;
 vtkmaps [N1_TO_VTK_VERTEX] = {0};
-vtktypes[N2_TO_VTK_LINE] = vtk_export::VTK_LINE;
+vtktypes[N2_TO_VTK_LINE] = VTK_LINE;
 vtkmaps [N2_TO_VTK_LINE] = {0, 1};
-vtktypes[N3_TO_VTK_TRIANGLE] = vtk_export::VTK_TRIANGLE;
+vtktypes[N3_TO_VTK_TRIANGLE] = VTK_TRIANGLE;
 vtkmaps [N3_TO_VTK_TRIANGLE] = {0, 1, 2};
-vtktypes[N4_TO_VTK_PIXEL] = vtk_export::VTK_PIXEL;
+vtktypes[N4_TO_VTK_PIXEL] = VTK_PIXEL;
 vtkmaps [N4_TO_VTK_PIXEL] = {0, 1, 2, 3};
-vtktypes[N4_TO_VTK_QUAD] = vtk_export::VTK_QUAD;
+vtktypes[N4_TO_VTK_QUAD] = VTK_QUAD;
 vtkmaps [N4_TO_VTK_QUAD] = {0, 1, 3, 2};
-vtktypes[N4_TO_VTK_TETRA] = vtk_export::VTK_TETRA;
+vtktypes[N4_TO_VTK_TETRA] = VTK_TETRA;
 vtkmaps [N4_TO_VTK_TETRA] = {0, 1, 2, 3};
-vtktypes[N8_TO_VTK_VOXEL] = vtk_export::VTK_VOXEL;
+vtktypes[N8_TO_VTK_VOXEL] = VTK_VOXEL;
 vtkmaps [N8_TO_VTK_VOXEL] = {0, 1, 2, 3, 4, 5, 6, 7};
-vtktypes[N8_TO_VTK_HEXAHEDRON] = vtk_export::VTK_HEXAHEDRON;
+vtktypes[N8_TO_VTK_HEXAHEDRON] = VTK_HEXAHEDRON;
 vtkmaps [N8_TO_VTK_HEXAHEDRON] = {0, 1, 3, 2, 4, 5, 7, 6};
-vtktypes[N6_TO_VTK_WEDGE] = vtk_export::VTK_WEDGE;
+vtktypes[N6_TO_VTK_WEDGE] = VTK_WEDGE;
 vtkmaps [N6_TO_VTK_WEDGE] = {0, 1, 2, 3, 4, 5};
-vtktypes[N5_TO_VTK_PYRAMID] = vtk_export::VTK_PYRAMID;
+vtktypes[N5_TO_VTK_PYRAMID] = VTK_PYRAMID;
 vtkmaps [N5_TO_VTK_PYRAMID] = {0, 1, 3, 2, 4};
-vtktypes[N3_TO_VTK_QUADRATIC_EDGE] = vtk_export::VTK_QUADRATIC_EDGE;
+vtktypes[N3_TO_VTK_QUADRATIC_EDGE] = VTK_QUADRATIC_EDGE;
 vtkmaps [N3_TO_VTK_QUADRATIC_EDGE] = {0, 2, 1};
-vtktypes[N6_TO_VTK_QUADRATIC_TRIANGLE] = 
vtk_export::VTK_QUADRATIC_TRIANGLE;
+vtktypes[N6_TO_VTK_QUADRATIC_TRIANGLE] = VTK_QUADRATIC_TRIANGLE;
 vtkmaps [N6_TO_VTK_QUADRATIC_TRIANGLE] = {0, 2, 5, 1, 4, 3};
-vtktypes[N8_TO_VTK_QUADRATIC_QUAD] = vtk_export::VTK_QUADRATIC_QUAD;
+vtktypes[N8_TO_VTK_QUADRATIC_QUAD] = VTK_QUADRATIC_QUAD;
 

[Getfem-commits] (no subject)

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-xml
commit dbeb54b5b4d48d384c11eb293064841985f6d6a4
Author: Konstantinos Poulios 
AuthorDate: Sat May 23 20:48:23 2020 +0200

Minor changes
---
 src/getfem/getfem_export.h |  2 +-
 src/getfem_export.cc   | 62 +++---
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index 6687804..eb24d4b 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -548,7 +548,7 @@ namespace getfem {
 
 size_type view;
 dim_type dim;
-enum { EMPTY, HEADER_WRITTEN, STRUCTURE_WRITTEN, IN_CELL_DATA} state;
+enum { EMPTY, HEADER_WRITTEN, STRUCTURE_WRITTEN, IN_CELL_DATA } state;
 std::ofstream real_os;
 
   public:
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 811cbf3..3b12008 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -26,6 +26,27 @@
 
 namespace getfem
 {
+
+  /* try to check if a quad or hexahedric cell is "rectangular" and oriented
+ along the axes */
+  template static bool check_voxel(const C& c) {
+scalar_type h[3];
+unsigned N = c[0].size();
+if (c.size() != (1U << N)) return false;
+const base_node P0 = c[0];
+h[0] = c[1][0] - P0[0];
+h[1] = c[2][0] - P0[0];
+if (c.size() != 4) h[2] = c[4][0] - P0[0];
+for (unsigned i=1; i < c.size(); ++i) {
+  const base_node d = c[i] - P0;
+  for (unsigned j=0; j < N; ++j)
+if (gmm::abs(d[j]) > 1e-7*h[j] && gmm::abs(d[j] - h[j]) > 1e-7*h[j])
+  return false;
+}
+return true;
+  }
+
+
   /* -
* VTK export
* - */
@@ -145,24 +166,23 @@ namespace getfem
 return vtktypes[t];
   }
 
+
   vtk_export::vtk_export(std::ostream _, bool ascii_)
 : os(os_), ascii(ascii_) { init(); }
 
   vtk_export::vtk_export(const std::string& fname, bool ascii_)
 : os(real_os), ascii(ascii_),
-real_os(fname.c_str(), !ascii ? std::ios_base::binary | std::ios_base::out 
:
-std::ios_base::out) {
-GMM_ASSERT1(real_os, "impossible to write to vtk file '" << fname << "'");
+real_os(fname.c_str(), !ascii ? std::ios_base::binary | std::ios_base::out
+  : std::ios_base::out) {
+GMM_ASSERT1(real_os, "impossible to write to file '" << fname << "'");
 init();
   }
 
   void vtk_export::init() {
-static int test_endian = 0x01234567;
-strcpy(header, "Exported by getfem++");
+strcpy(header, "Exported by GetFEM");
 psl = 0; dim_ = dim_type(-1);
-if (*((char*)_endian) == 0x67)
-  reverse_endian = true;
-else reverse_endian = false;
+static int test_endian = 0x01234567;
+reverse_endian = (*((char*)_endian) == 0x67);
 state = EMPTY;
   }
 
@@ -194,26 +214,6 @@ namespace getfem
   }
 
 
-  /* try to check if a quad or hexahedric cell is "rectangular" and oriented
- along the axes */
-  template static bool check_voxel(const C& c) {
-scalar_type h[3];
-unsigned N = c[0].size();
-if (c.size() != (1U << N)) return false;
-const base_node P0 = c[0];
-h[0] = c[1][0] - P0[0];
-h[1] = c[2][0] - P0[0];
-if (c.size() != 4) h[2] = c[4][0] - P0[0];
-for (unsigned i=1; i < c.size(); ++i) {
-  const base_node d = c[i] - P0;
-  for (unsigned j=0; j < N; ++j)
-if (gmm::abs(d[j]) > 1e-7*h[j] && gmm::abs(d[j] - h[j]) > 1e-7*h[j])
-  return false;
-}
-return true;
-  }
-
-
   void vtk_export::exporting(const stored_mesh_slice& sl) {
 psl =  dim_ = dim_type(sl.dim());
 GMM_ASSERT1(psl->dim() <= 3, "attempt to export a " << int(dim_)
@@ -223,7 +223,7 @@ namespace getfem
   void vtk_export::exporting(const mesh& m) {
 dim_ = m.dim();
 GMM_ASSERT1(dim_ <= 3, "attempt to export a " << int(dim_)
-  << "D slice (not supported)");
+<< "D mesh (not supported)");
 pmf = std::make_unique(const_cast(m), dim_type(1));
 for (dal::bv_visitor cv(m.convex_index()); !cv.finished(); ++cv) {
   bgeot::pgeometric_trans pgt = m.trans_of_convex(cv);
@@ -236,7 +236,7 @@ namespace getfem
   void vtk_export::exporting(const mesh_fem& mf) {
 dim_ = mf.linked_mesh().dim();
 GMM_ASSERT1(dim_ <= 3, "attempt to export a " << int(dim_)
-  << "D slice (not supported)");
+<< "D mesh_fem (not supported)");
 if ( != pmf.get())
   pmf = std::make_unique(mf.linked_mesh());
 /* initialize pmf with finite elements suitable for VTK (which only knows
@@ -498,7 +498,7 @@ namespace getfem
   }
 
   void dx_export::init() {
-strcpy(header, "Exported by getfem++");
+strcpy(header, "Exported by GetFEM");
 psl = 0; dim_ = dim_type(-1); connections_dim = dim_type(-1);
 psl_use_merged = false;
 header_written = false;



[Getfem-commits] (no subject)

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-xml
commit 9f956bb759bda182a25ae071f8e691c4a345bf12
Author: Konstantinos Poulios 
AuthorDate: Sat May 23 21:06:56 2020 +0200

Export to VTU file format (only ascii), based on the original 
implementation by Tetsuo Koyama
---
 doc/sphinx/source/replaces.txt   |   5 +-
 doc/sphinx/source/userdoc/export.rst |  53 
 src/getfem/getfem_export.h   |  57 --
 src/getfem_export.cc | 113 ++-
 4 files changed, 159 insertions(+), 69 deletions(-)

diff --git a/doc/sphinx/source/replaces.txt b/doc/sphinx/source/replaces.txt
index 5710048..38ed62a 100644
--- a/doc/sphinx/source/replaces.txt
+++ b/doc/sphinx/source/replaces.txt
@@ -2,6 +2,7 @@
 .. |gnu| replace:: *GNU*
 .. |c++| replace:: *C++*
 .. |vtk| replace:: *VTK*
+.. |vtu| replace:: *VTU*
 .. |opendx| replace:: *OpenDX*
 .. |gmsh| replace:: *Gmsh*
 .. |emc2| replace:: *emc2*
@@ -48,6 +49,7 @@
 .. |gf_sl_a| replace:: ``getfem::slicer_action``
 .. |gf_sl_ddb| replace:: ``getfem::mesh_slice_cv_dof_data_base``
 .. |gf_vtk_export| replace:: ``getfem::vtk_export``
+.. |gf_vtu_export| replace:: ``getfem::vtu_export``
 .. |gf_dx_export| replace:: ``getfem::dx_export``
 .. |gf_pos_export| replace:: ``getfem::pos_export``
 .. |gf_gasm| replace:: ``getfem::generic_assembly``
@@ -84,7 +86,8 @@
 .. _specific guides: http://getfem.org/index.html
 .. _user documentation: http://getfem.org/userdoc/index.html
 .. _vocabulary: http://getfem.org/getfem_reference/index.html
-.. _VTK: http://www.vtk.org
+.. _VTK: https://vtk.org/Wiki/VTK_XML_Formats
+.. _VTU: https://vtk.org/Wiki/VTK_XML_Formats
 .. _MayaVi: http://mayavi.sourceforge.net
 .. _OpenDX: http://www.opendx.org
 .. _Gmsh: http://www.geuz.org/gmsh
diff --git a/doc/sphinx/source/userdoc/export.rst 
b/doc/sphinx/source/userdoc/export.rst
index 945b656..1433153 100644
--- a/doc/sphinx/source/userdoc/export.rst
+++ b/doc/sphinx/source/userdoc/export.rst
@@ -12,7 +12,7 @@ Export and view a solution
 There are essentially four ways to view the result of getfem computations:
 
 * Scilab, Octave or Matlab, with the interface.
-* The open-source Paraview or Mayavi or any other VTK files viewer.
+* The open-source Paraview or Mayavi or any other VTK/VTU file viewer.
 * The open-source OpenDX program.
 * The open-source Gmsh program.
 
@@ -43,9 +43,13 @@ and then, under Scilab, Octave or Matlab:
 
 See the getfem-matlab interface documentation for more details.
 
-Two other file formats are supported for export: the `VTK`_ file format, the
-`OpenDX`_ file format and the `Gmsh`_ post-processing file format. Both can 
export
-either a |gf_m| or |gf_mf| , but also the more versatile |gf_smsl|.
+Four file formats are supported for export: the `VTK`_ and `VTU`_ file
+formats, the`OpenDX`_ file format and the `Gmsh`_ post-processing file
+format. All four can be used for exporting either a |gf_m| or |gf_mf|, and
+all except `VTU`_ can be used for exporting the more versatile |gf_smsl|.
+The corresponding four classes: |gf_vtk_export|, |gf_vtu_export|,
+|gf_dx_export| and |gf_pos_export| are contained in the file
+:file:`getfem/getfem_export.h`.
 
 Examples of use can be found in the examples of the tests directory.
 
@@ -178,22 +182,15 @@ In order to build a |gf_smsl| object during the slicing 
operation, the ``stored_
getfem::slicer_half_space(base_node(0,0), base_node(1, 0), -1),
nrefine);
 
-The simplest way to use these slices is to export them to |vtk|, |opendx|, or
-|gmsh|. The file :file:`getfem/getfem_export.h` contains three classes:
-|gf_vtk_export|, |gf_dx_export| and |gf_pos_export|.
+The simplest way to use these slices is to export them to |vtk|,
+|opendx|, or |gmsh|.
 
 
-Exporting |m|, |mf| or slices to VTK
-
+Exporting |m|, |mf| or slices to VTK/VTU
+-
 
-First, it is important to know the limitation of VTK data files: each file can
-contain only one mesh, with at most one scalar field and one vector field and 
one
-tensor field on this mesh (in that order). VTK files can handle data on 
segment,
-triangles, quadrangles, tetrahedrons and hexahedrons. Although quadratic
-triangles, segments etc are said to be supported, it is just equivalent to 
using
-``nrefine=2`` when building a slice. VTK data file do support meshes with more
-than one type of element (i.e. meshes with triangles and quadrangles, for
-example).
+VTK/VTU files can handle data on segment, triangles, quadrangles,
+tetrahedrons and hexahedrons of first or second degree.
 
 For example, supposing that a |smsl| ``sl`` has already been built::
 
@@ -204,11 +201,10 @@ For example, supposing that a |smsl| ``sl`` has already 
been built::
   exp.write_point_data(mfp, P, "pressure"); // write a scalar field
   exp.write_point_data(mfu, U, "displacement"); // write a vector field
 
-In this example, the fields ``P`` and ``U`` are interpolated on the 

[Getfem-commits] [getfem-commits] devel-logari81-xml updated (db725b2 -> 9f956bb)

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-xml.

from db725b2  Move enumeration from header file
 new dbeb54b  Minor changes
 new 9f956bb  Export to VTU file format (only ascii), based on the original 
implementation by Tetsuo Koyama


Summary of changes:
 doc/sphinx/source/replaces.txt   |   5 +-
 doc/sphinx/source/userdoc/export.rst |  53 ++-
 src/getfem/getfem_export.h   |  59 
 src/getfem_export.cc | 175 +++
 4 files changed, 191 insertions(+), 101 deletions(-)



Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-23 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo,

I have revised your code and refactored it in my logari81-devel-xml branch.
Can you test that my refactored version works as your original version? I
removed your "only_mesh" option intentionally.

Moreover, it would be nice if you could:
1) implement the scripting interface for vtu export.
2) make exporting slices work for VTU. Based on my refactored version, it
shouldn't be difficult.
3) implement the binary version of VTU.

Best regards
Kostas

On Wed, May 13, 2020 at 3:35 PM Tetsuo Koyama  wrote:

> I forgot to CC: in the last email, so I am re-sending it.
> --
> Dear Kostas
>
> Thank you for your reply.
> > Thanks for your answer. Your code looks quite nice actually. I have one
> question about the lines
> >   std::vector W(Q*pmf_dof_used.card());
> >   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
> >   write_dataset_(V, name, qdim);
> > Since you do not do anything with vector W, what is the meaning of
> having it? Should the last line be:
> >   write_dataset_(W, name, qdim);
> > instead?
> Yes you are right. Sorry my test was not enough. I fixed it.
>
> > You can just make a new branch and put the outcome of your development
> in one or two commits and then we can merge that branch. Sorry for being
> picky, but establishing some good development habits will make our life
> easier in the future.
> Thanks. Your advice is very helpful to me. I made new branch
> devel-tetsuo-xml02. It is a squash of commit of devel-tetsuo-xml.
>
> Thank you for reading.
>
> Best regards Tetsuo
>
> >
> > 2020年5月11日(月) 5:16 Konstantinos Poulios :
> > >
> > > Dear Tetsuo,
> > >
> > > Thanks for your answer. Your code looks quite nice actually. I have
> one question about the lines
> > >   std::vector W(Q*pmf_dof_used.card());
> > >   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
> > >   write_dataset_(V, name, qdim);
> > > Since you do not do anything with vector W, what is the meaning of
> having it? Should the last line be:
> > >   write_dataset_(W, name, qdim);
> > > instead?
> > >
> > > Apart from that, I think we need a bit cleaner workflow without too
> many unnecessary commits. I remember that I had advised you in the past
> against too large commits, but the ideal is somewhere in the middle. The
> commits must in general be organized in logical units from the perspective
> of someone looking at the git history. The work you have done here, I would
> put it into one or two commits. All the forth and back during the
> development, it doesn't need to be part of the repository history.
> > >
> > > You can just make a new branch and put the outcome of your development
> in one or two commits and then we can merge that branch. Sorry for being
> picky, but establishing some good development habits will make our life
> easier in the future.
> > >
> > > Best regards
> > > Kostas
> > >
> > > On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama 
> wrote:
> > >>
> > >> P.S.
> > >> I had a typo
> > >>
> > >> >That is a good point. It maybe a good idea of using library, but we
> > >> have to use cmake to link vtk librayr.
> > >> That is a good point. It maybe a good idea of using library, but we
> > >> have to use cmake to link vtk library.
> > >>
> > >> 2020年5月7日(木) 22:17 Tetsuo Koyama :
> > >> >
> > >> > Dear Kostas
> > >> >
> > >> > Thank you very much for taking the time to review.
> > >> >
> > >> > > I think it is an important contribution to add vtu support,
> especially if it is binary/compressed, just ascii is not very useful.
> > >> > Thanks. I agree that binary/compressed is important. After this
> change
> > >> > is confirmed, I would like to add that option.
> > >> >
> > >> > > However we might need to discuss a bit on how to do it. As far as
> I can see you have used boost for xml writing. I think we
> > >> > > had dropped our dependency on boost and I am not very keen on
> reintroducing a dependency on boost.
> > >> > I agree with the policy that projects don't use boost. In the end, I
> > >> > made changes to eliminate the dependence on boost in the end. If
> there
> > >> > is any remaining dependence, please point out . I am sorry that the
> > >> > commit is complicated. The current vtu object does not require
> > >> > dependency to boost even if when extending to binaries.
> > >> >
> > >> > >Before we merge this, I would like to hear some arguments for one
> solution or another. The first thing to check is what others do.
> > >> > > How is vtu export implemented in other software like e.g. fenics?
> What is the more future-proof way of implementing vtu support?
> > >> > I didn't search fenics but meshio package (This is a major package
> > >> > which is used to convert mesh format. You can install by `apt
> install
> > >> > python3-meshio`) and mayavi2.
> > >> > Both are built by full scratches of writing text and binary like
> > >> > getfem project is doing. They reffer vtk file format pdf.
> > >> > 

[Getfem-commits] [getfem-commits] branch master updated: Fix bug in second derivative of inverse operator

2020-10-03 Thread Konstantinos Poulios via Getfem-commits
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 3507069  Fix bug in second derivative of inverse operator
3507069 is described below

commit 3507069aa22f5d232bd3cf5b3e3d45c500e5c5ba
Author: Konstantinos Poulios 
AuthorDate: Sun Oct 4 01:00:02 2020 +0200

Fix bug in second derivative of inverse operator
---
 src/getfem_generic_assembly_functions_and_operators.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_functions_and_operators.cc 
b/src/getfem_generic_assembly_functions_and_operators.cc
index 6081028..1c889ac 100644
--- a/src/getfem_generic_assembly_functions_and_operators.cc
+++ b/src/getfem_generic_assembly_functions_and_operators.cc
@@ -331,7 +331,7 @@ namespace getfem {
   gmm::copy(__mat_aux1().as_vector(), result.as_vector());
 }
 
-// Derivative : -M^{-1}{ik}M^{-1}{lj}  (comes from H -> M^{-1}HM^{-1})
+// Derivative : -M^{-1}{ik}M^{-1}{lj}  (comes from H -> -M^{-1}HM^{-1})
 void derivative(const arg_list , size_type,
 base_tensor ) const { // to be verified
   size_type N = args[0]->sizes()[0];
@@ -374,7 +374,7 @@ namespace getfem {
   for (size_type j = 0; j < N; ++j)
 for (size_type i = 0; i < N; ++i, ++it)
   *it = __mat_aux1()(i,k)*__mat_aux1()(l,m)*__mat_aux1()(n,j)
-+ __mat_aux1()(i,m)*__mat_aux1()(m,k)*__mat_aux1()(l,j);
++ __mat_aux1()(i,m)*__mat_aux1()(n,k)*__mat_aux1()(l,j);
   GA_DEBUG_ASSERT(it == result.end(), "Internal error");
 }
   };



Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-05-25 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo,

Great, thanks for testing and for the original vtu implementation. It is a
very useful feature.

I will let Yves do the merge. I think he will prepare a 5.4.1 version soon
to fix the issues with 5.4. on Ubuntu 20.04.

Best regards
Kostas


On Mon, May 25, 2020 at 2:32 PM Tetsuo Koyama  wrote:

> Dear Kostas
>
> My test of branch devel-logari81-xml was passed.
> Your branch is awesome.
> I think it is a very good idea to add vtk as a option too.
> Could you merge this branch?
> After that I will checkout new branch to add more functionality.
>
> Best regards Tetsuo
>
> 2020年5月24日(日) 20:49 Tetsuo Koyama :
> >
> > Dear Kostas
> >
> > Sorry for my late reply and thank you for your refactoring.
> > I'll check it and will continue you proposal. After I finished
> > development, I'll contact getfem project to merge.
> > Thanks for your advice.
> >
> > Best regards Tetsuo
> >
> > 2020年5月24日(日) 4:13 Konstantinos Poulios :
> > >
> > > Dear Tetsuo,
> > >
> > > I have revised your code and refactored it in my logari81-devel-xml
> branch. Can you test that my refactored version works as your original
> version? I removed your "only_mesh" option intentionally.
> > >
> > > Moreover, it would be nice if you could:
> > > 1) implement the scripting interface for vtu export.
> > > 2) make exporting slices work for VTU. Based on my refactored version,
> it shouldn't be difficult.
> > > 3) implement the binary version of VTU.
> > >
> > > Best regards
> > > Kostas
> > >
> > > On Wed, May 13, 2020 at 3:35 PM Tetsuo Koyama 
> wrote:
> > >>
> > >> I forgot to CC: in the last email, so I am re-sending it.
> > >> --
> > >> Dear Kostas
> > >>
> > >> Thank you for your reply.
> > >> > Thanks for your answer. Your code looks quite nice actually. I have
> one question about the lines
> > >> >   std::vector W(Q*pmf_dof_used.card());
> > >> >   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
> > >> >   write_dataset_(V, name, qdim);
> > >> > Since you do not do anything with vector W, what is the meaning of
> having it? Should the last line be:
> > >> >   write_dataset_(W, name, qdim);
> > >> > instead?
> > >> Yes you are right. Sorry my test was not enough. I fixed it.
> > >>
> > >> > You can just make a new branch and put the outcome of your
> development in one or two commits and then we can merge that branch. Sorry
> for being picky, but establishing some good development habits will make
> our life easier in the future.
> > >> Thanks. Your advice is very helpful to me. I made new branch
> > >> devel-tetsuo-xml02. It is a squash of commit of devel-tetsuo-xml.
> > >>
> > >> Thank you for reading.
> > >>
> > >> Best regards Tetsuo
> > >>
> > >> >
> > >> > 2020年5月11日(月) 5:16 Konstantinos Poulios :
> > >> > >
> > >> > > Dear Tetsuo,
> > >> > >
> > >> > > Thanks for your answer. Your code looks quite nice actually. I
> have one question about the lines
> > >> > >   std::vector W(Q*pmf_dof_used.card());
> > >> > >   gmm::copy(remove_dof_unused(V, pmf_dof_used, Q), W);
> > >> > >   write_dataset_(V, name, qdim);
> > >> > > Since you do not do anything with vector W, what is the meaning
> of having it? Should the last line be:
> > >> > >   write_dataset_(W, name, qdim);
> > >> > > instead?
> > >> > >
> > >> > > Apart from that, I think we need a bit cleaner workflow without
> too many unnecessary commits. I remember that I had advised you in the past
> against too large commits, but the ideal is somewhere in the middle. The
> commits must in general be organized in logical units from the perspective
> of someone looking at the git history. The work you have done here, I would
> put it into one or two commits. All the forth and back during the
> development, it doesn't need to be part of the repository history.
> > >> > >
> > >> > > You can just make a new branch and put the outcome of your
> development in one or two commits and then we can merge that branch. Sorry
> for being picky, but establishing some good development habits will make
> our life easier in the future.
> > >> > >
> > >> > > Best regards
> > >> > > Kostas
> > >> > >
> > >> > > On Thu, May 7, 2020 at 3:23 PM Tetsuo Koyama <
> tkoyama...@gmail.com> wrote:
> > >> > >>
> > >> > >> P.S.
> > >> > >> I had a typo
> > >> > >>
> > >> > >> >That is a good point. It maybe a good idea of using library,
> but we
> > >> > >> have to use cmake to link vtk librayr.
> > >> > >> That is a good point. It maybe a good idea of using library, but
> we
> > >> > >> have to use cmake to link vtk library.
> > >> > >>
> > >> > >> 2020年5月7日(木) 22:17 Tetsuo Koyama :
> > >> > >> >
> > >> > >> > Dear Kostas
> > >> > >> >
> > >> > >> > Thank you very much for taking the time to review.
> > >> > >> >
> > >> > >> > > I think it is an important contribution to add vtu support,
> especially if it is binary/compressed, just ascii is not very useful.
> > >> > >> > Thanks. I agree that binary/compressed is important. After
> this change
> > >> > >> > is 

[Getfem-commits] [getfem-commits] branch devel-logari81-gcc9-openmp updated: Fix compilation warnings and reduce code duplication

2020-05-22 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch devel-logari81-gcc9-openmp
in repository getfem.

The following commit(s) were added to refs/heads/devel-logari81-gcc9-openmp by 
this push:
 new b63998e  Fix compilation warnings and reduce code duplication
b63998e is described below

commit b63998e72d5d508542797b769a160f13402e4467
Author: Konstantinos Poulios 
AuthorDate: Fri May 22 22:16:16 2020 +0200

Fix compilation warnings and reduce code duplication
---
 src/getfem/bgeot_small_vector.h | 253 +---
 1 file changed, 108 insertions(+), 145 deletions(-)

diff --git a/src/getfem/bgeot_small_vector.h b/src/getfem/bgeot_small_vector.h
index 3a7ec80..e0aa95a 100644
--- a/src/getfem/bgeot_small_vector.h
+++ b/src/getfem/bgeot_small_vector.h
@@ -44,7 +44,7 @@
 # define SVEC_ASSERT(x) assert(x)
 #else
 # define SVEC_ASSERT(x)
-#endif 
+#endif
 
 namespace bgeot {
 
@@ -54,7 +54,7 @@ namespace bgeot {
 typedef gmm::uint32_type node_id;
 typedef gmm::uint32_type size_type;
 /* number of objects stored in a same block, power of 2 */
-enum { p2_BLOCKSZ = 8, BLOCKSZ = 1<(::operator new(BLOCKSZ*objsz + 
BLOCKSZ)); 
+   clear();
+   data = static_cast(::operator new(BLOCKSZ*objsz + 
BLOCKSZ));
/* first BLOCKSZ bytes are used for reference counting */
memset(data, 0, BLOCKSZ);
//cout << "init block&" << this << " allocated data: " << (void*)data 
<< "\n";
   }
-  void clear() { 
+  void clear() {
//cout << "clear block&" << this << " frees data: " << (void*)data << 
"\n";
-   if (data) { ::operator delete(data); }; 
+   if (data) { ::operator delete(data); };
data = 0; first_unused_chunk = 0; count_unused_chunk = BLOCKSZ;
   }
   unsigned char& refcnt(size_type pos) { return data[pos]; }
   bool empty() const { return data == 0; }
   /* could be smarter .. */
 };
-/* container of all blocks .. a vector ensures fast access to 
+/* container of all blocks .. a vector ensures fast access to
any element (better than deque) */
-std::vector blocks; 
+std::vector blocks;
 /* pointers to free (or partially free) blocks for each object size */
 size_type first_unfilled[OBJ_SIZE_LIMIT];
   public:
@@ -145,17 +145,60 @@ namespace bgeot {
 void insert_block_into_unfilled(block_allocator::size_type bid);
 void remove_block_from_unfilled(block_allocator::size_type bid);
   };
-  
+
   /* common class for all mini_vec, provides access to the common static 
allocator */
   struct APIDECL static_block_allocator {
-/* must be a pointer ... sgi CC is not able to order correctly the 
+/* must be a pointer ... sgi CC is not able to order correctly the
destructors of static variables */
 static block_allocator *palloc;
 static_block_allocator() { if (!palloc) 
palloc=::singleton::instance(); } //new 
block_allocator(); }
   };
-  
-#if !defined GETFEM_HAS_OPENMP
-  /** container for small vectors of POD (Plain Old Data) types. Should be as 
fast as 
+
+#ifdef GETFEM_HAS_OPENMP
+  /**In case of multi-threaded assembly with OpenMP using std::vector derived
+  class for it's thread safety*/
+  template class small_vector : public std::vector
+  {
+  public:
+using typename std::vector::const_iterator;
+using typename std::vector::iterator;
+const_iterator begin() const { return std::vector::begin(); }
+iterator begin() { return std::vector::begin(); }
+const_iterator end() const { return std::vector::end(); }
+iterator end() { return std::vector::end(); }
+
+const_iterator const_begin() const { return std::vector::cbegin(); }
+const_iterator const_end() const { return std::vector::cend(); }
+dim_type size() const { return dim_type(std::vector::size()); }
+
+const small_vector& operator=(const small_vector& other) {
+  std::vector::operator=(other);
+  return *this;
+}
+
+small_vector() : std::vector()  {}
+
+explicit small_vector(size_type n) : std::vector(n) {}
+
+small_vector(const small_vector& v) : std::vector(v) {}
+
+small_vector(const std::vector&  v) : std::vector(v) {}
+
+small_vector(T v1, T v2) : std::vector(2)
+{ (*this)[0] = v1; (*this)[1] = v2; }
+
+small_vector(T v1, T v2, T v3) : std::vector(3)
+{ (*this)[0] = v1; (*this)[1] = v2; (*this)[2] = v3; }
+
+template small_vector(const small_vector& a, UNOP op)
+  : std::vector(a.size())
+{ std::transform(a.begin(), a.end(), begin(), op); }
+
+template small_vector(const small_vector& a, const 
small_vector& b, BINOP op)
+  : std::vector(a.size())
+{ std::transform(a.begin(), a.end(), b.begin(), begin(), op); }
+#else
+  /** container for small vectors of POD (Plain Old Data) types. Should be as 
fast as
   std::vector while beeing smaller and uses copy-on-write. The gain is 
especially
   valuable on 64 bits 

[Getfem-commits] [getfem-commits] branch master updated: Add finite strain plasticity examples with linear isotropic hardening

2020-12-25 Thread Konstantinos Poulios via Getfem-commits
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 4ff15ca  Add finite strain plasticity examples with linear isotropic 
hardening
4ff15ca is described below

commit 4ff15ca9bd431068e9318a645a320edf383a4e13
Author: Konstantinos Poulios 
AuthorDate: Sat Dec 26 01:03:59 2020 +0100

Add finite strain plasticity examples with linear isotropic hardening

 - 3D
 - plane strain (2D)
 - axisymmetric (2D)
---
 configure.ac   |   1 +
 contrib/Makefile.am|   3 +-
 contrib/{ => continuum_mechanics}/Makefile.am  |  20 +-
 ...ty_finite_strain_linear_hardening_tension_3D.py | 250 +
 ...strain_linear_hardening_tension_axisymmetric.py | 239 
 ...strain_linear_hardening_tension_plane_strain.py | 237 +++
 6 files changed, 746 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index a19ba7e..14fb370 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1192,6 +1192,7 @@ contrib/level_set_contact/Makefile
  \
 contrib/static_contact_gears/Makefile   \
 contrib/test_plasticity/Makefile\
 contrib/opt_assembly/Makefile   \
+contrib/continuum_mechanics/Makefile\
 bin/Makefile\
 interface/Makefile  \
 interface/src/Makefile  \
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 02a044e..5d1d655 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -17,4 +17,5 @@
 
 SUBDIRS = icare delaminated_crack aposteriori xfem_stab_unilat_contact  \
  bimaterial_crack_test mixed_elastostatic xfem_contact crack_plate \
- static_contact_gears level_set_contact test_plasticity opt_assembly
+ static_contact_gears level_set_contact test_plasticity opt_assembly \
+ continuum_mechanics
diff --git a/contrib/Makefile.am b/contrib/continuum_mechanics/Makefile.am
similarity index 65%
copy from contrib/Makefile.am
copy to contrib/continuum_mechanics/Makefile.am
index 02a044e..fddd257 100644
--- a/contrib/Makefile.am
+++ b/contrib/continuum_mechanics/Makefile.am
@@ -15,6 +15,20 @@
 #  along  with  this program;  if not, write to the Free Software Foundation,
 #  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 
-SUBDIRS = icare delaminated_crack aposteriori xfem_stab_unilat_contact  \
- bimaterial_crack_test mixed_elastostatic xfem_contact crack_plate \
- static_contact_gears level_set_contact test_plasticity opt_assembly
+check_PROGRAMS = 
+
+CLEANFILES = 
+
+if BUILDPYTHON
+TESTS = plasticity_finite_strain_linear_hardening_tension_plane_strain.py
+
+AM_TESTS_ENVIRONMENT = \
+   export PYTHONPATH=$(top_builddir)/interface/src/python; \
+   export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(top_builddir)/src/.libs;
+LOG_COMPILER = $(PYTHON)
+endif
+
+EXTRA_DIST = \
+   plasticity_finite_strain_linear_hardening_tension_3D.py \
+   plasticity_finite_strain_linear_hardening_tension_axisymmetric.py \
+   plasticity_finite_strain_linear_hardening_tension_plane_strain.py
diff --git 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
new file mode 100644
index 000..f041500
--- /dev/null
+++ 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
@@ -0,0 +1,250 @@
+#!/usr/bin/env python3
+# -*- coding: UTF8 -*-
+# Python GetFEM interface
+#
+# Copyright (C) 2020-2020 Konstantinos Poulios.
+#
+# This file is a part of GetFEM
+#
+# GetFEM  is  free software;  you  can  redistribute  it  and/or modify it
+# under  the  terms  of the  GNU  Lesser General Public License as published
+# by  the  Free Software Foundation;  either version 3 of the License,  or
+# (at your option) any later version along with the GCC Runtime Library
+# Exception either version 3.1 or (at your option) any later version.
+# This program  is  distributed  in  the  hope  that it will be useful,  but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License and GCC Runtime Library Exception for more details.
+# You  should  have received a copy of the GNU Lesser General Public License
+# along  with  this program;  if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+#

[Getfem-commits] [getfem-commits] branch master updated: Fix redundant integration points in projected_fem

2021-01-06 Thread Konstantinos Poulios via Getfem-commits
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 f60023b  Fix redundant integration points in projected_fem
f60023b is described below

commit f60023bf46fafbf1a283674307d9ce022b282945
Author: Konstantinos Poulios 
AuthorDate: Wed Jan 6 09:10:27 2021 +0100

Fix redundant integration points in projected_fem
---
 src/getfem_projected_fem.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/getfem_projected_fem.cc b/src/getfem_projected_fem.cc
index 31daf88..fa73548 100644
--- a/src/getfem_projected_fem.cc
+++ b/src/getfem_projected_fem.cc
@@ -364,7 +364,8 @@ namespace getfem {
 bgeot::geotrans_precomp(pgt, pai->pintegration_points(), 0);
   size_type last_cv = size_type(-1); // refers to the source mesh
   short_type last_f = short_type(-1); // refers to the source mesh
-  size_type nb_pts = i.is_face() ? pai->nb_points_on_face(f) : 
pai->nb_points();
+  size_type nb_pts = i.is_face() ? pai->nb_points_on_face(f)
+ : pai->nb_points_on_convex();
   size_type start_pt = i.is_face() ? pai->ind_first_point_on_face(f) : 0;
   elt_projection_data  = elements[cv];
   base_node gpt(N);



[Getfem-commits] [getfem-commits] branch master updated: Remove invalid assertion

2020-12-18 Thread Konstantinos Poulios via Getfem-commits
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 8324be3  Remove invalid assertion
8324be3 is described below

commit 8324be3a1a98e71566b397a4b51a076458aa70b0
Author: Konstantinos Poulios 
AuthorDate: Fri Dec 18 17:58:24 2020 +0100

Remove invalid assertion
---
 src/getfem_models.cc | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index a33ae53..94cf1b3 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2902,9 +2902,6 @@ namespace getfem {
   return mi;
 } else if (imd) {
   bgeot::multi_index mi = imd->tensor_size();
-  size_type q = n * imd->nb_filtered_index();
-  GMM_ASSERT1(q % imd->nb_tensor_elem() == 0,
-  "Invalid mesh im data vector");
   if (n > 1 || it->second.qdims.size() > 1) {
 size_type i = 0;
 if (mi.back() == 1) { mi.back() *= it->second.qdims[0]; ++i; }



[Getfem-commits] [getfem-commits] branch master updated: Fix GWFL inconsistency in slicing of tensors with single element leading dimensions

2020-12-21 Thread Konstantinos Poulios via Getfem-commits
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 91fb8d3  Fix GWFL inconsistency in slicing of tensors with single 
element leading dimensions
91fb8d3 is described below

commit 91fb8d39aac4fbe4ecaed49f57b2bdac9643057e
Author: Konstantinos Poulios 
AuthorDate: Mon Dec 21 10:48:02 2020 +0100

Fix GWFL inconsistency in slicing of tensors with single element leading 
dimensions
---
 src/getfem_generic_assembly_compile_and_exec.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 56ffbd1..0344b65 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -7126,13 +7126,13 @@ namespace getfem {
 
   } else { // Access to a component of the tensor
 bgeot::multi_index mi1(size0.size()), indices;
+size_type nb_test = pnode->nb_test_functions();
 if (pnode->tensor().size() == 1) {
   for (size_type i = 0; i < child0->tensor_order(); ++i)
-mi1[i] = size_type(round(pnode->children[i+1]->tensor()[0])-1);
+mi1[i+nb_test] = 
size_type(round(pnode->children[i+1]->tensor()[0])-1);
   pgai = std::make_shared
 (pnode->tensor()[0], child0->tensor()(mi1));
 } else {
-  size_type nb_test = pnode->nb_test_functions();
   for (size_type i = 0; i < nb_test; ++i) indices.push_back(i);
   for (size_type i = 0; i < child0->tensor_order(); ++i) {
 if (pnode->children[i+1]->node_type != GA_NODE_ALLINDICES)



[Getfem-commits] [getfem-commits] branch master updated: Fix issue with internal variables and reduced fem

2020-12-22 Thread Konstantinos Poulios via Getfem-commits
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 fb97892  Fix issue with internal variables and reduced fem
fb97892 is described below

commit fb97892482904578ebcc3043d73fdb92f91e4677
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 22 13:57:37 2020 +0100

Fix issue with internal variables and reduced fem
---
 interface/src/gf_model_get.cc| 17 +
 src/getfem_generic_assembly_workspace.cc | 20 ++--
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/interface/src/gf_model_get.cc b/interface/src/gf_model_get.cc
index ed39b48..cf79d78 100644
--- a/interface/src/gf_model_get.cc
+++ b/interface/src/gf_model_get.cc
@@ -363,10 +363,10 @@ void gf_model_get(getfemint::mexargs_in& m_in,
 /*@GET ('assembly'[, @str option])
   Assembly of the tangent system taking into account the terms
   from all bricks. `option`, if specified, should be 'build_all',
-  'build_rhs', 'build_matrix'.
-  The default is to build the whole
-  tangent linear system (matrix and rhs). This function is useful
-  to solve your problem with you own solver. @*/
+  'build_rhs', 'build_matrix', 'build_rhs_with_internal',
+  'build_matrix_condensed', 'build_all_condensed'.
+  The default is to build the whole tangent linear system (matrix and rhs).
+  This function is useful to solve your problem with you own solver. @*/
 sub_command
   ("assembly", 0, 1, 0, 0,
std::string option = "build_all";
@@ -381,6 +381,15 @@ void gf_model_get(getfemint::mexargs_in& m_in,
else if (cmd_strmatch(option, "build matrix") ||
 cmd_strmatch(option, "build_matrix"))
  version = getfem::model::BUILD_MATRIX;
+   else if (cmd_strmatch(option, "build rhs with internal") ||
+cmd_strmatch(option, "build_rhs_with_internal"))
+ version = getfem::model::BUILD_RHS_WITH_INTERNAL;
+   else if (cmd_strmatch(option, "build matrix condensed") ||
+cmd_strmatch(option, "build_matrix_condensed"))
+ version = getfem::model::BUILD_MATRIX_CONDENSED;
+   else if (cmd_strmatch(option, "build all condensed") ||
+cmd_strmatch(option, "build_all_condensed"))
+ version = getfem::model::BUILD_ALL_CONDENSED;
else THROW_BADARG("bad option: " << option);
md->assembly(version);
);
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 1888af5..2fa936f 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -898,22 +898,22 @@ namespace getfem {
   uI2 = temporary_interval_of_variable(vname2),
   I1 = interval_of_variable(vname1),
   I2 = interval_of_variable(vname2);
-if (mf1 && mf1->is_reduced() && mf2 && mf2->is_reduced()) {
-  model_real_sparse_matrix aux(I1.size(), uI2.size());
-  model_real_row_sparse_matrix M(I1.size(), I2.size());
-  gmm::mult(gmm::transposed(mf1->extension_matrix()),
-gmm::sub_matrix(row_col_unreduced_K, uI1, uI2),
-aux);
-  gmm::mult(aux, mf2->extension_matrix(), M);
-  gmm::add(M, gmm::sub_matrix(*K, I1, I2));
-} else if (mf1 && mf1->is_reduced()) {
+if (mf1 && mf1->is_reduced()) {
   if (condensation && vars_vec_done.count(vname1) == 0) {
 gmm::mult_add(gmm::transposed(mf1->extension_matrix()),
   gmm::sub_vector(unreduced_V, uI1),
   gmm::sub_vector(*V, I1));
 vars_vec_done.insert(vname1);
   }
-  if (I2.first() < nb_prim_dof) { // 
!is_internal_variable(vname2)
+  if (mf2 && mf2->is_reduced()) {
+model_real_sparse_matrix aux(I1.size(), uI2.size());
+model_real_row_sparse_matrix M(I1.size(), I2.size());
+gmm::mult(gmm::transposed(mf1->extension_matrix()),
+  gmm::sub_matrix(row_col_unreduced_K, uI1, uI2),
+  aux);
+gmm::mult(aux, mf2->extension_matrix(), M);
+gmm::add(M, gmm::sub_matrix(*K, I1, I2));
+  } else if (I2.first() < nb_prim_dof) { // 
!is_internal_variable(vname2)
 model_real_sparse_matrix M(I1.size(), I2.size());
 gmm::mult(gmm::transposed(mf1->extension_matrix()),
   gmm::sub_matrix(row_unreduced_K, uI1, I2), M);



[Getfem-commits] [getfem-commits] branch master updated: Fix memory leak due to lack of base class virtual destructor

2021-01-08 Thread Konstantinos Poulios via Getfem-commits
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 36bcd58  Fix memory leak due to lack of base class virtual destructor
36bcd58 is described below

commit 36bcd583e022f5f63345d6e6962c1ed76052d45a
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 8 15:10:16 2021 +0100

Fix memory leak due to lack of base class virtual destructor
---
 src/getfem_model_solvers.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/getfem_model_solvers.cc b/src/getfem_model_solvers.cc
index fd00044..fe11ca7 100644
--- a/src/getfem_model_solvers.cc
+++ b/src/getfem_model_solvers.cc
@@ -70,8 +70,8 @@ namespace getfem {
 }
 
 pb_base(PLSOLVER linsolv, const MATRIX _, VECTOR _)
-  : linear_solver(linsolv), K(K_), rhs(rhs_), state(gmm::vect_size(rhs_))
-{}
+  : linear_solver(linsolv), K(K_), rhs(rhs_), state(gmm::vect_size(rhs_)) 
{}
+virtual ~pb_base() {}
   };
 
   /* * */



[Getfem-commits] [getfem-commits] branch master updated: Fix empty response error in exported vtu files

2021-01-08 Thread Konstantinos Poulios via Getfem-commits
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 6af44d9  Fix empty response error in exported vtu files
6af44d9 is described below

commit 6af44d98ceb7ca69edf7ecb430ca84fd2d8f4e9a
Author: Tetsuo Koyama 
AuthorDate: Fri Jan 8 12:17:28 2021 +0100

Fix empty response error in exported vtu files
---
 ...ty_finite_strain_linear_hardening_tension_3D.py |   5 +-
 ...strain_linear_hardening_tension_axisymmetric.py |   5 +-
 ...strain_linear_hardening_tension_plane_strain.py |   5 +-
 interface/tests/python/check_export_vtu.py | 120 +
 src/getfem/getfem_export.h |   4 +-
 src/getfem_export.cc   | 109 ++-
 6 files changed, 165 insertions(+), 83 deletions(-)

diff --git 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
index f041500..431131e 100644
--- 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
+++ 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py
@@ -128,7 +128,7 @@ if dH > 0:
   pts[2,i] -= (z*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L))
mesh.set_pts(pts)
 
-mesh.export_to_vtk("%s/mesh.vtk" % resultspath)
+mesh.export_to_vtu("%s/mesh.vtu" % resultspath)
 
 # FEM
 mfN = gf.MeshFem(mesh, N)
@@ -166,7 +166,6 @@ md.add_initialized_data("disp", [0.])
 
 md.add_initialized_data("K", E/(3.*(1.-2.*nu))) # Bulk modulus
 md.add_initialized_data("mu", E/(2*(1+nu))) # Shear modulus
-md.add_initialized_data("Y", np.sqrt(2./3.)*pl_sigma_0) # Initial yield limit
 md.add_macro("F", "Id(3)+Grad_u")
 md.add_macro("J", "Det(F)")
 md.add_macro("tauH", "K*log(J)")
@@ -238,7 +237,7 @@ with open("%s/tension_3D.dat" % resultspath, "w") as f1:
 mfu, md.variable("u"), "Displacements",
 mfout2, md.interpolation("dirmult", mfout2, XP_RG), "Nominal 
reaction traction",
 mfout2, md.local_projection(mim, "gamma", mfout2), "plastic 
strain")
-  mfout2.export_to_vtk("%s/tension_3D_%i.vtk" % (resultspath, step), 
*output)
+  mfout2.export_to_vtu("%s/tension_3D_%i.vtu" % (resultspath, step), 
*output)
 
   md.set_variable("gamma0", md.interpolation("gamma", mimd1, -1))
   md.set_variable("invCp0vec",
diff --git 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py
 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py
index 8fc92ae..7969b23 100644
--- 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py
+++ 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py
@@ -119,7 +119,7 @@ if dH > 0:
   pts[1,i] -= (y*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L))
mesh.set_pts(pts)
 
-mesh.export_to_vtk("%s/mesh.vtk" % resultspath)
+mesh.export_to_vtu("%s/mesh.vtu" % resultspath)
 
 # FEM
 mfN = gf.MeshFem(mesh, N)
@@ -156,7 +156,6 @@ md.add_initialized_data("disp", [0.])
 
 md.add_initialized_data("K", E/(3.*(1.-2.*nu))) # Bulk modulus
 md.add_initialized_data("mu", E/(2*(1+nu))) # Shear modulus
-md.add_initialized_data("Y", np.sqrt(2./3.)*pl_sigma_0) # Initial yield limit
 md.add_macro("F", "Id(2)+Grad_u")
 md.add_macro("F3d", 
"Id(3)+[0,0,0;0,0,0;0,0,1/X(2)]*u(2)+[1,0;0,1;0,0]*Grad_u*[1,0,0;0,1,0]")
 md.add_macro("J", "Det(F)*(1+u(2)/X(2))")
@@ -227,7 +226,7 @@ with open("%s/tension_axisymmetric.dat" % resultspath, "w") 
as f1:
 mfu, md.variable("u"), "Displacements",
 mfout2, md.interpolation("dirmult", mfout2, XP_RG), "Nominal 
reaction traction",
 mfout2, md.local_projection(mim, "gamma", mfout2), "plastic 
strain")
-  mfout2.export_to_vtk("%s/tension_axisymmetric_%i.vtk" % (resultspath, 
step), *output)
+  mfout2.export_to_vtu("%s/tension_axisymmetric_%i.vtu" % (resultspath, 
step), *output)
 
   md.set_variable("gamma0", md.interpolation("gamma", mimd1, -1))
   md.set_variable("invCp0vec",
diff --git 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py
 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py
index 422efe1..a80d325 100644
--- 
a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py
+++ 
b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py
@@ -118,7 +118,7 @@ if dH > 0:
   pts[1,i] -= (y*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L))
mesh.set_pts(pts)
 
-mesh.export_to_vtk("%s/mesh.vtk" % resultspath)
+mesh.export_to_vtu("%s/mesh.vtu" % resultspath)
 
 # FEM
 mfN = gf.MeshFem(mesh, N)
@@ -155,7 +155,6 @@ 

[Getfem-commits] [getfem-commits] branch master updated: Print model variables categorized as variables, disabled variables and data

2021-01-08 Thread Konstantinos Poulios via Getfem-commits
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 dfb5b39  Print model variables categorized as variables, disabled 
variables and data
dfb5b39 is described below

commit dfb5b3915a140e127fc4dfd9bfdebb54347475ba
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 8 15:37:10 2021 +0100

Print model variables categorized as variables, disabled variables and data
---
 src/getfem_models.cc | 54 
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 94cf1b3..1aec2c3 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -661,39 +661,43 @@ namespace getfem {
   ost << "Model with no variable nor data" << endl;
 else {
   ost << "List of model variables and data:" << endl;
-  for (const auto  : variables) {
-const var_description  = v.second;
-if (vdescr.is_variable) ost << "Variable   ";
-else ost << "Data   ";
-ost << std::setw(30) << std::left << v.first;
-if (vdescr.n_iter == 1)
-  ost << " 1 copy   ";
-else
-  ost << std::setw(2) << std::right << vdescr.n_iter << " copies ";
-if (vdescr.is_fem_dofs) ost << "fem dependant ";
-else ost << "constant size ";
-size_type si = vdescr.size();
-ost << std::setw(8) << std::right << si;
-if (is_complex()) ost << " complex";
-ost << " double" << ((si > 1) ? "s." : ".");
-if (vdescr.is_variable &&
-is_disabled_variable(v.first)) ost << "\t (disabled)";
-else   ost << "\t   ";
-if (vdescr.imd != 0) ost << "\t (is im_data)";
-if (vdescr.is_affine_dependent) ost << "\t (is affine dependent)";
-ost << endl;
-  }
+  for (int vartype=0; vartype < 3; ++vartype)
+for (const auto  : variables) {
+  const var_description  = v.second;
+  bool is_variable = vdescr.is_variable;
+  bool is_disabled = is_variable && is_disabled_variable(v.first);
+  if (vartype == 0) {  // Only enabled variables
+if (!is_variable || is_disabled) continue;
+  } else if (vartype == 1) { // Only disabled variables
+if (!is_disabled) continue;
+  } else if (vartype == 2) { // Only data
+if (is_variable) continue;
+  }
+  ost << (is_variable ? "Variable   " : "Data   ");
+  ost << std::setw(30) << std::left << v.first;
+  ost << std::setw(2) << std::right << vdescr.n_iter;
+  ost << ((vdescr.n_iter == 1) ? " copy   " : " copies ");
+  ost << (vdescr.is_fem_dofs ? "fem dependant " : "constant size ");
+  ost << std::setw(8) << std::right << vdescr.size();
+  if (is_complex()) ost << " complex";
+  ost << ((vdescr.size() > 1) ? " doubles." : " double.");
+  ost << (is_disabled ? "\t (disabled)" : "\t   ");
+  if (vdescr.imd != 0) ost << "\t (is im_data)";
+  if (vdescr.is_affine_dependent) ost << "\t (is affine dependent)";
+  ost << endl;
+}
   for (const auto  : variable_groups) {
 ost << "Variable group " << std::setw(30) << std::left
 << vargroup.first;
 if (vargroup.second.size()) {
   bool first(true);
   for (const std::string vname : vargroup.second) {
-if (!first) ost << ","; else first = false;
-ost << " " << vname;
+ost << (first ? " " : ", ") << vname;
+first = false;
   }
   ost << endl;
-} else ost << " empty" << endl;
+} else
+  ost << " empty" << endl;
   }
 }
   }



Re: [Getfem-commits] [getfem-commits] master updated (3326ae3 -> 18bcf86)

2021-05-05 Thread Konstantinos Poulios via Getfem-commits
It seems that I did not get the reading of physical groups from gmsh v4
mesh format correct in this commit.

v4 format saves entity tags for each element group instead of saving
physical groups. To convert from entity tags to physical group numbers we
need to read the $Entities section of the msh file, as explained in

https://bthierry.pages.math.cnrs.fr/tutorial/gmsh/basics_physical_vs_elementary/

and the gmsh documentation.

Is version 4 of the gmsh mesh format not used by anyone out there?

Best regards
Kostas


On Sun, Dec 2, 2018 at 9:16 PM Konstantinos Poulios 
wrote:

> logari81 pushed a change to branch master.
>
>   from  3326ae3   minor fix
>new  18bcf86   Add initial support for gmsh mesh format version 4
>
>
> Summary of changes:
>  src/getfem_import.cc | 460
> ++-
>  1 file changed, 239 insertions(+), 221 deletions(-)
>
>


[Getfem-commits] [getfem-commits] branch mpi-fixes created (now 98925a4)

2021-05-23 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch mpi-fixes.

  at 98925a4  Just code style changes

This branch includes the following new commits:

 new 98925a4  Just code style changes




[Getfem-commits] (no subject)

2021-05-23 Thread Konstantinos Poulios via Getfem-commits
branch: mpi-fixes
commit 98925a43e41a9fd15c7369f7d7811cff892fe9cf
Author: Konstantinos Poulios 
AuthorDate: Sun May 23 14:32:50 2021 +0200

Just code style changes
---
 src/getfem/getfem_models.h |   9 ++--
 src/getfem_models.cc   | 123 +++--
 2 files changed, 57 insertions(+), 75 deletions(-)

diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index d875ace..9707404 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -241,9 +241,12 @@ namespace getfem {
 return 0;
   }
 
-  size_type size() const // Should control that the variable is
- // indeed initialized by actualize_sizes() ...
-  { return is_complex ? complex_value[0].size() : real_value[0].size(); }
+  size_type size() const { // Should control that the variable is
+   // indeed initialized by actualize_sizes() ...
+return is_complex ? complex_value[0].size()
+  : real_value[0].size();
+  }
+  inline bool is_enabled() const { return !is_disabled; }
 
   void set_size();
 }; // struct var_description
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 9e08ad1..fbbd361 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -247,7 +247,7 @@ namespace getfem {
   bool model::is_internal_variable(const std::string ) const {
 if (is_old(name)) return false;
 const auto _descr = variable_description(name);
-return var_descr.is_internal && !var_descr.is_disabled;
+return var_descr.is_internal && var_descr.is_enabled();
   }
 
   bool model::is_affine_dependent_variable(const std::string ) const {
@@ -318,7 +318,7 @@ namespace getfem {
 size_type primary_size = full_size;
 
 for (auto & : variables)
-  if (v.second.is_internal && !v.second.is_disabled) { // 
is_internal_variable()
+  if (v.second.is_internal && v.second.is_enabled()) { // 
is_internal_variable()
 v.second.I = gmm::sub_interval(full_size, v.second.size());
 full_size += v.second.size();
   }
@@ -2411,166 +2411,145 @@ namespace getfem {
 
 if (cplx) { // complex term in complex model
   if (term.is_matrix_term && (version & BUILD_MATRIX) && !isprevious
-  && (isg || (!(var1->is_disabled) && !(var2->is_disabled {
+  && (isg || (var1->is_enabled() && var2->is_enabled( {
 gmm::add(gmm::scaled(brick.cmatlist[j], alpha),
  gmm::sub_matrix(cTM, I1, I2));
-if (term.is_symmetric && I1.first() != I2.first()) {
+if (term.is_symmetric && I1.first() != I2.first())
   gmm::add(gmm::scaled(gmm::transposed(brick.cmatlist[j]), alpha),
gmm::sub_matrix(cTM, I2, I1));
-}
   }
   if (version & BUILD_RHS) {
-if (isg || !(var1->is_disabled)) {
-  if (brick.pdispatch) {
+if (isg || var1->is_enabled()) {
+  if (brick.pdispatch)
 for (size_type k = 0; k < brick.nbrhs; ++k)
   gmm::add(gmm::scaled(brick.cveclist[k][j],
brick.coeffs[k]),
gmm::sub_vector(crhs, I1));
-  }
-  else {
+  else
 gmm::add(gmm::scaled(brick.cveclist[0][j],
  complex_type(alpha1)),
  gmm::sub_vector(crhs, I1));
-  }
 }
 if (term.is_matrix_term && brick.pbr->is_linear() && is_linear()) {
-  if (var2->is_affine_dependent
-  && !(var1->is_disabled))
+  if (var2->is_affine_dependent && var1->is_enabled())
 gmm::mult_add(brick.cmatlist[j],
   gmm::scaled(var2->affine_complex_value,
   complex_type(-alpha1)),
   gmm::sub_vector(crhs, I1));
   if (term.is_symmetric && I1.first() != I2.first()
-  && var1->is_affine_dependent
-  && !(var2->is_disabled)) {
+  && var1->is_affine_dependent && var2->is_enabled())
 gmm::mult_add(gmm::conjugated(brick.cmatlist[j]),
   gmm::scaled(var1->affine_complex_value,
   complex_type(-alpha2)),
   gmm::sub_vector(crhs, I2));
-  }
 }
 if (term.is_matrix_term && brick.pbr->is_linear()
-&& (!is_linear() || (version & BUILD_WITH_LIN))) {
-  if (!(var1->is_disabled))
-gmm::mult_add(brick.cmatlist[j],
-  gmm::scaled(var2->complex_value[0],
-  complex_type(-alpha1)),
-  gmm::sub_vector(crhs, I1));

[Getfem-commits] [getfem-commits] branch mpi-fixes updated: MPI fixes form model residual assembly

2021-05-23 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch mpi-fixes
in repository getfem.

The following commit(s) were added to refs/heads/mpi-fixes by this push:
 new cb06b64  MPI fixes form model residual assembly
cb06b64 is described below

commit cb06b642bac2466c534a37418354f87648e54677
Author: Konstantinos Poulios 
AuthorDate: Sun May 23 14:38:53 2021 +0200

MPI fixes form model residual assembly
---
 src/getfem_models.cc | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index fbbd361..40ff2e8 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2845,7 +2845,9 @@ namespace getfem {
 }
 
 if (version & BUILD_RHS) {
-  approx_external_load_ = MPI_SUM_SCALAR(approx_external_load_);
+   // some contributions are added only in the master process
+   // send the correct result to all other processes
+   MPI_BCAST0_SCALAR(approx_external_load_);
 }
 
 #if GETFEM_PARA_LEVEL > 1
@@ -3281,10 +3283,14 @@ namespace getfem {
   gmm::clear(vecl[0]);
 
   if (expr.size()) {
+const mesh_im  = *mims[0];
+mesh_region rg(region);
+mim.linked_mesh().intersect_with_mpi_region(rg);
+
 // reenables disabled variables
 ga_workspace workspace(md, ga_workspace::inherit::ALL);
 GMM_TRACE2(name << ": generic source term assembly");
-workspace.add_expression(expr, *(mims[0]), region, 1, 
secondary_domain);
+workspace.add_expression(expr, mim, rg, 1, secondary_domain);
 workspace.assembly(1);
 const auto =workspace.assembled_vector();
 for (size_type i = 0; i < vl_test1.size(); ++i) {



[Getfem-commits] [getfem-commits] branch mpi-fixes updated: MPI fixes for affine and linear terms in nonlinear model residual

2021-05-23 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch mpi-fixes
in repository getfem.

The following commit(s) were added to refs/heads/mpi-fixes by this push:
 new 6cd266c  MPI fixes for affine and linear terms in nonlinear model 
residual
6cd266c is described below

commit 6cd266c0715bee7831e874829db40f35a514121b
Author: Konstantinos Poulios 
AuthorDate: Sun May 23 14:43:21 2021 +0200

MPI fixes for affine and linear terms in nonlinear model residual
---
 src/getfem_models.cc | 86 ++--
 1 file changed, 57 insertions(+), 29 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 40ff2e8..c9eedf8 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2339,6 +2339,9 @@ namespace getfem {
 "Invalid assembly version BUILD_WITH_INTERNAL");
 #if GETFEM_PARA_LEVEL > 1
 double t_ref = MPI_Wtime();
+int rk=0, nbp=1;
+MPI_Comm_rank(MPI_COMM_WORLD, );
+MPI_Comm_size(MPI_COMM_WORLD, );
 #endif
 
 context_check(); if (act_size_to_be_done) actualize_sizes();
@@ -2419,6 +2422,7 @@ namespace getfem {
gmm::sub_matrix(cTM, I2, I1));
   }
   if (version & BUILD_RHS) {
+//FIXME MPI_SUM_VECTOR(crhs)
 if (isg || var1->is_enabled()) {
   if (brick.pdispatch)
 for (size_type k = 0; k < brick.nbrhs; ++k)
@@ -2479,6 +2483,7 @@ namespace getfem {
gmm::sub_matrix(cTM, I2, I1));
   }
   if (version & BUILD_RHS) {
+//FIXME MPI_SUM_VECTOR(crhs)
 if (isg || var1->is_enabled()) {
   if (brick.pdispatch)
 for (size_type k = 0; k < brick.nbrhs; ++k)
@@ -2539,54 +2544,77 @@ namespace getfem {
   }
   if (version & BUILD_RHS) {
 // Contributions to interval I1 of var1
+auto vec_out1 = gmm::sub_vector(rrhs, I1);
 if (isg || var1->is_enabled()) {
   if (brick.pdispatch)
 for (size_type k = 0; k < brick.nbrhs; ++k)
   gmm::add(gmm::scaled(brick.rveclist[k][j],
brick.coeffs[k]),
-   gmm::sub_vector(rrhs, I1));
+   vec_out1);
   else
 gmm::add(gmm::scaled(brick.rveclist[0][j], alpha1),
- gmm::sub_vector(rrhs, I1));
+ vec_out1);
 }
-if (var1->is_enabled()) {
-  // Contributions from affine dependent variables
-  if (term.is_matrix_term && brick.pbr->is_linear() && is_linear()
-  && var2->is_affine_dependent)
-gmm::mult_add(brick.rmatlist[j],
-  gmm::scaled(var2->affine_real_value, -alpha1),
-  gmm::sub_vector(rrhs, I1));
-  // Contributions from linear terms
-  if (term.is_matrix_term && brick.pbr->is_linear()
-  && (!is_linear() || (version & BUILD_WITH_LIN)))
-gmm::mult_add(brick.rmatlist[j],
-  gmm::scaled(var2->real_value[0], -alpha1),
-  gmm::sub_vector(rrhs, I1));
+if (var1->is_enabled()
+&& term.is_matrix_term && brick.pbr->is_linear()) {
+  bool affine_contrib(is_linear() && var2->is_affine_dependent);
+  bool linear_contrib(!is_linear() || (version & BUILD_WITH_LIN));
+  const auto  = brick.rmatlist[j];
+  const auto vec_affine2 = gmm::scaled(var2->affine_real_value,
+   -alpha1);
+  const auto vec_linear2 = gmm::scaled(var2->real_value[0],
+   -alpha1);
+  if (nbp > 1) {
+model_real_plain_vector vec_tmp1(I1.size(), 0.);
+if (affine_contrib) // Affine dependent variable contribution
+  gmm::mult(matj, vec_affine2, vec_tmp1);
+if (linear_contrib) // Linear term contribution
+  gmm::mult_add(matj, vec_linear2, vec_tmp1);
+MPI_SUM_VECTOR(vec_tmp1);
+gmm::add(vec_tmp1, vec_out1);
+  } else { // nbp == 1
+if (affine_contrib) // Affine dependent variable contribution
+  gmm::mult_add(matj, vec_affine2, vec_out1);
+if (linear_contrib) // Linear term contribution
+  gmm::mult_add(matj, vec_linear2, vec_out1);
+  }
 }
 
 // Contributions to interval I2 of var2 due to symmetric terms
 if (term.is_symmetric && I1.first() != I2.first() &&
 var2->is_enabled()) {
+  auto vec_out2 = gmm::sub_vector(rrhs, I2);
   if (brick.pdispatch)
  

[Getfem-commits] [getfem-commits] branch master updated: Rename brick addition functions and new interface function for lumped mass brick

2021-04-22 Thread Konstantinos Poulios via Getfem-commits
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 0241496  Rename brick addition functions and new interface function 
for lumped mass brick
0241496 is described below

commit 0241496a72624aca5f7f6a4f3725accee863d46e
Author: Tetsuo Koyama 
AuthorDate: Thu Apr 22 18:59:19 2021 +0200

Rename brick addition functions and new interface function for lumped mass 
brick
---
 .../source/userdoc/model_linear_elasticity.rst |  4 +--
 interface/src/gf_model_set.cc  | 35 ++
 interface/tests/matlab-octave/demo_elasticity.m|  4 +--
 interface/tests/python/demo_wave_equation.py   | 11 +++
 src/getfem/getfem_models.h |  6 ++--
 src/getfem_models.cc   | 12 
 6 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/doc/sphinx/source/userdoc/model_linear_elasticity.rst 
b/doc/sphinx/source/userdoc/model_linear_elasticity.rst
index 6ebbf1f..ca28a87 100644
--- a/doc/sphinx/source/userdoc/model_linear_elasticity.rst
+++ b/doc/sphinx/source/userdoc/model_linear_elasticity.rst
@@ -56,13 +56,13 @@ representing the |Lame| coefficients.
 
 The function which adds this brick to a model and parametrized with Young 
modulus and Poisson ratio is::
 
-  ind_brick = getfem::add_isotropic_linearized_elasticity_brick_pstrain
+  ind_brick = getfem::add_isotropic_linearized_elasticity_pstrain_brick
   (md, mim, varname, data_E, data_nu, region = size_type(-1));
 
 
 This brick represent a plane strain approximation when it is applied to a 2D 
mesh (and a standard model on a 3D mesh). In order to obtain a plane stress 
approximation for 2D meshes, one can use::
 
-  ind_brick = getfem::add_isotropic_linearized_elasticity_brick_pstress
+  ind_brick = getfem::add_isotropic_linearized_elasticity_pstress_brick
   (md, mim, varname, data_E, data_nu, region = size_type(-1));
 
 For 3D meshes, the two previous bricks give the same result.
diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc
index 288572d..2c90b65 100644
--- a/interface/src/gf_model_set.cc
+++ b/interface/src/gf_model_set.cc
@@ -1978,7 +1978,7 @@ void gf_model_set(getfemint::mexargs_in& m_in,
out.pop().from_integer(int(ind));
);
 
-/*@SET ind = ('add isotropic linearized elasticity brick pstrain', @tmim 
mim, @str varname, @str data_E, @str data_nu[, @int region])
+/*@SET ind = ('add isotropic linearized elasticity pstrain brick', @tmim 
mim, @str varname, @str data_E, @str data_nu[, @int region])
   Add an isotropic linearized elasticity term to the model relatively to
   the variable `varname`. `data_E` and `data_nu` should
   contain the Young modulus and Poisson ratio, respectively.
@@ -1990,7 +1990,7 @@ void gf_model_set(getfemint::mexargs_in& m_in,
   standard model. 
   Return the brick index in the model.@*/
 sub_command
-  ("add isotropic linearized elasticity brick pstrain", 4, 5, 0, 1,
+  ("add isotropic linearized elasticity pstrain brick", 4, 5, 0, 1,
getfem::mesh_im *mim = to_meshim_object(in.pop());
std::string varname = in.pop().to_string();
std::string data_E = in.pop().to_string();
@@ -1998,14 +1998,14 @@ void gf_model_set(getfemint::mexargs_in& m_in,
size_type region = size_type(-1);
if (in.remaining()) region = in.pop().to_integer();
size_type ind
-   = getfem::add_isotropic_linearized_elasticity_brick_pstrain
+   = getfem::add_isotropic_linearized_elasticity_pstrain_brick
(*md, *mim, varname, data_E, data_nu, region)
+ config::base_index();
workspace().set_dependence(md, mim);
out.pop().from_integer(int(ind));
);
 
-/*@SET ind = ('add isotropic linearized elasticity brick pstress', @tmim 
mim, @str varname, @str data_E, @str data_nu[, @int region])
+/*@SET ind = ('add isotropic linearized elasticity pstress brick', @tmim 
mim, @str varname, @str data_E, @str data_nu[, @int region])
   Add an isotropic linearized elasticity term to the model relatively to
   the variable `varname`. `data_E` and `data_nu` should
   contain the Young modulus and Poisson ratio, respectively.
@@ -2017,7 +2017,7 @@ void gf_model_set(getfemint::mexargs_in& m_in,
   standard model. 
   Return the brick index in the model.@*/
 sub_command
-  ("add isotropic linearized elasticity brick pstress", 4, 5, 0, 1,
+  ("add isotropic linearized elasticity pstress brick", 4, 5, 0, 1,
getfem::mesh_im *mim = to_meshim_object(in.pop());
std::string varname = in.pop().to_string();
std::string data_E = in.pop().to_string();
@@ -2025,7 +2025,7 @@ void gf_model_set(getfemint::mexargs_in& m_in,
size_type region = size_type(-1);
if (in.remaining()) 

Re: [Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash

2021-04-22 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo,

Thanks for tidying things up and testing. I have merged your branch. Maybe
Yves will suggest some deprecation aliases for the old function names, but
if so we can still add these later.

BR
Kostas

On Wed, Apr 21, 2021 at 2:59 AM Tetsuo Koyama  wrote:

> Dear Kostas
>
> Thanks for your point out.I fixed it and checked that all tests passed in
> C++, python, scilab octave except matlab (sorry, but I don't have a matlab
> license).
>
> Best regards
> Tetsuo
>
> 2021年4月19日(月) 19:42 Konstantinos Poulios :
>
>> Dear Tetsuo,
>>
>> Could I get you to update some uses of the old pstress and pstrain brick
>> names in the following files?
>>
>> model_linear_elasticity.rst
>> demo_elasticity.m
>>
>> I hope I haven't missed any other affected files.
>>
>> Otherwise if all tests run successfully, then it is fine for me to merge
>> the branch.
>>
>> Best regards
>> Kostas
>>
>> On Fri, Apr 16, 2021 at 1:29 PM Tetsuo Koyama 
>> wrote:
>>
>>> Dear Yves and Kostas
>>>
>>> Thanks for your comments.
>>> I updated the method names.
>>> Please review it.
>>>
>>> Best regards,
>>>
>>> Tetsuo
>>>
>>> 2021年4月16日(金) 17:37 Yves Renard :
>>>


 Dear Tetsuo,

 I also think that these name changes are convenient.

 Best regards,

 Yves

 On 10/04/2021 06:57, Tetsuo Koyama wrote:

 Dear Kostas and Yves

 @Kostas Thank you for your comment. It is a good point.
 I am a fan of adding brick at the end of the methods.

 add_isotropic_linearized_elasticity_pstrain_brick
 add_isotropic_linearized_elasticity_pstrain_brick
 add_lumped_mass_for_first_order_brick

 If you don't mind I will fix the name of these methods in this branch.

 Best regards Tetsuo

 2021年4月10日(土) 4:24 Konstantinos Poulios :

> Dear Tetsuo and Yves
>
> @Tetsuo thanks for this interface functions. I would like to use this
> opportunity to discuss about the word "brick" in the naming of our
> functions adding PDE term matrices. Traditionally, "brick" was only used 
> at
> the end of the function name. More recently, Yves started skipping "brick"
> from some of the newer terms, which I think is fine. Now we have a mix 
> with
> names including "brick" and some without. Apart from that, there are 3
> functions that do not follow the old naming convention at all:
>
> add_isotropic_linearized_elasticity_brick_pstrainadd_isotropic_linearized_elasticity_brick_pstrainadd_lumped_mass_brick_for_first_order
>
> I would like to avoid this kind of inconsistencies in the naming so
> that all functions for adding a PDE matrix either have "brick" at the end
> of their name or that they do not include it at all.
>
> For Tetsuo's function I would suggest one of
> add_lumped_mass_matrix_for_first_order
> add_lumped_mass_for_first_order_brick
>
> Both in c++ and the interfaces.
>
> What do you think?
>
> Best regards
> Kostas
>
> On Fri, Apr 9, 2021 at 11:23 AM Tetsuo Koyama 
> wrote:
>
>> Dear GetFEM project
>>
>> I added the lumped mass for first order to the python interface.
>> Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ?
>>
>> BR Tetsuo
>>
>
 --

   Yves Renard (yves.ren...@insa-lyon.fr)   tel : (33) 04.72.43.87.08
   INSA-Lyon
   20, rue Albert Einstein
   69621 Villeurbanne Cedex, FRANCE
   http://math.univ-lyon1.fr/~renard

 -




  1   2   3   >