[Getfem-commits] [getfem-commits] branch master updated: Add missing part from last commit

2024-05-10 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 b79b7680 Add missing part from last commit
b79b7680 is described below

commit b79b76805216ed4ec3571a1e4de18ed92e6900d7
Author: Konstantinos Poulios 
AuthorDate: Fri May 10 10:29:20 2024 +0200

Add missing part from last commit
---
 src/getfem_mesh_fem_global_function.cc | 106 +
 1 file changed, 106 insertions(+)

diff --git a/src/getfem_mesh_fem_global_function.cc 
b/src/getfem_mesh_fem_global_function.cc
index 6b05af2f..d1129799 100644
--- a/src/getfem_mesh_fem_global_function.cc
+++ b/src/getfem_mesh_fem_global_function.cc
@@ -318,6 +318,112 @@ namespace getfem {
 mf.set_functions(funcs, mim);
   }
 
+  void define_uniform_bspline_basis_functions_for_mesh_fem
+  (mesh_fem_global_function ,
+   size_type NX, size_type NY, size_type NZ, size_type order,
+   bspline_boundary bcX_low,
+   bspline_boundary bcY_low,
+   bspline_boundary bcZ_low,
+   bspline_boundary bcX_high,
+   bspline_boundary bcY_high,
+   bspline_boundary bcZ_high, const mesh_im ) {
+
+GMM_ASSERT1(mf.linked_mesh().dim() == 3,
+"This function expects a mesh_fem defined in 3d");
+
+base_node Pmin, Pmax;
+mf.linked_mesh().bounding_box(Pmin, Pmax);
+const scalar_type x0=Pmin[0], x1=Pmax[0],
+  y0=Pmin[1], y1=Pmax[1],
+  z0=Pmin[2], z1=Pmax[2];
+
+std::vector xmin, xmax, xshift;
+std::vector xtype;
+params_for_uniform_1d_bspline_basis_functions
+  (x0, x1, NX, order, bcX_low, bcX_high, // input
+   xmin, xmax, xshift, xtype);   // output
+std::vector ymin, ymax, yshift;
+std::vector ytype;
+params_for_uniform_1d_bspline_basis_functions
+  (y0, y1, NY, order, bcY_low, bcY_high, // input
+   ymin, ymax, yshift, ytype);   // output
+std::vector zmin, zmax, zshift;
+std::vector ztype;
+params_for_uniform_1d_bspline_basis_functions
+  (z0, z1, NZ, order, bcZ_low, bcZ_high, // input
+   zmin, zmax, zshift, ztype);   // output
+
+std::vector funcs(0);
+for (size_type i=0; i < xtype.size(); ++i) {
+  for (size_type j=0; j < ytype.size(); ++j) {
+for (size_type k=0; k < ztype.size(); ++k) {
+
+  bool has_xshift = gmm::abs(xshift[i]) >= 1e-10;
+  bool has_yshift = gmm::abs(yshift[j]) >= 1e-10;
+  bool has_zshift = gmm::abs(zshift[k]) >= 1e-10;
+  if (not(has_xshift) && not(has_yshift) && not(has_yshift))
+funcs.push_back(global_function_bspline
+(xmin[i], xmax[i],
+ ymin[j], ymax[j],
+ zmin[k], zmax[k],
+ order, xtype[i], ytype[j], ztype[k])) ;
+  else {
+std::vector sum;
+sum.push_back(global_function_bspline
+  (xmin[i], xmax[i],
+   ymin[j], ymax[j],
+   zmin[k], zmax[k],
+   order, xtype[i], ytype[j], ztype[k]));
+if (has_xshift) // xshift
+  sum.push_back(global_function_bspline
+(xmin[i]+xshift[i], xmax[i]+xshift[i],
+ ymin[j], ymax[j],
+ zmin[k], zmax[k],
+ order, xtype[i], ytype[j], ztype[k]));
+if (has_yshift) // yshift
+  sum.push_back(global_function_bspline
+(xmin[i], xmax[i],
+ ymin[j]+yshift[j], ymax[j]+yshift[j],
+ zmin[k], zmax[k],
+ order, xtype[i], ytype[j], ztype[k]));
+if (has_zshift) // zshift
+  sum.push_back(global_function_bspline
+(xmin[i], xmax[i],
+ ymin[j], ymax[j],
+ zmin[k]+zshift[k], zmax[k]+zshift[k],
+ order, xtype[i], ytype[j], ztype[k]));
+if (has_xshift && has_yshift) // xshift + yshift
+  sum.push_back(global_function_bspline
+(xmin[i]+xshift[i], xmax[i]+xshift[i],
+ ymin[j]+yshift[j], ymax[j]+yshift[j],
+ zmin[k], zmax[k],
+ order, xtype[i], ytype[j], ztype[k]));
+if (has_yshift && has_zshift) // yshift + zshift
+  sum.push_back(global_function_bspline
+(xmin[i], xmax[i],
+ ymin[j]+yshift[j], ymax[j]+yshift[j],
+ zmin[k]+zshift[k], zmax[k]+zshift[k],
+ order, xtype[i], ytype[j], ztype[k]));
+if (has_zshift && has_xshift) // zshift + 

[Getfem-commits] [getfem-commits] branch master updated: Add 3D version of bspline basis functions on uniform rectilinear grid

2024-05-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 6da9ff14 Add 3D version of bspline basis functions on uniform 
rectilinear grid
6da9ff14 is described below

commit 6da9ff14cc0ccdea3c26781f7004d1789f67a7bd
Author: Konstantinos Poulios 
AuthorDate: Mon May 6 15:50:55 2024 +0200

Add 3D version of bspline basis functions on uniform rectilinear grid
---
 interface/src/gf_mesh_fem.cc |  60 ++---
 src/getfem/getfem_global_function.h  |   7 +
 src/getfem/getfem_mesh_fem_global_function.h |  30 +
 src/getfem_global_function.cc| 192 +++
 4 files changed, 274 insertions(+), 15 deletions(-)

diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc
index cf675d81..ee26fbfe 100644
--- a/interface/src/gf_mesh_fem.cc
+++ b/interface/src/gf_mesh_fem.cc
@@ -253,38 +253,46 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in,
);
 
 
-/*@INIT MF = ('bspline_uniform', @tmesh m, @int NX[, @int NY,] @int 
order[, @str bcX_low[, @str bcY_low[, @str bcX_high][, @str bcY_high]]])
+/*@INIT MF = ('bspline_uniform', @tmesh m, @int NX[, @int NY[, @int NZ]], 
@int order[, @str bcX_low[, @str bcY_low[, @str bcZ_low]][, @str bcX_high[, 
@str bcY_high[, @str bcZ_high)
   Create a @tmf on mesh `m`, whose base functions are global functions
-  corresponding to bspline basis of order `order`, in an NX x NY grid
-  (just NX in 1s) that spans the entire bounding box of `m`.
+  corresponding to bspline basis of order `order`, in an NX x NY x NZ
+  grid (just NX in 1D or NX x NY in 2D) that spans the entire bounding
+  box of `m`.
   Optionally boundary conditions at the edges of the domain can be
-  defined with `bcX_low`, `bcY_low`, `bcX_high`, abd `bcY_high` set to
-  'free' (default) or 'periodic' or 'symmetry'. @*/
+  defined with `bcX_low`, `bcY_low`, `bcZ_low`, `bcX_high`, `bcY_high`,
+  and `bcZ_high` set to 'free' (default) or 'periodic' or 'symmetry'. @*/
 sub_command
-  ("bspline_uniform", 3, 8, 0, 1,
+  ("bspline_uniform", 3, 11, 0, 1,
mm = extract_mesh_object(in.pop());
dim_type dim = mm->dim();
-   if (dim > 2)
- THROW_ERROR("Uniform bspline only supported for dim = 1 or 2");
+   if (dim > 3)
+ THROW_ERROR("Uniform bspline only supported for dim = 1,2,3");
size_type NX = in.pop().to_integer(1,1000);
size_type NY = (dim >= 2) ? in.pop().to_integer(1,1000) : 0;
-   if (dim == 2 && (!in.remaining() || !in.front().is_integer()))
- THROW_ERROR("In 2d, 3 integers are expected for NX,NY,order");
+   size_type NZ = (dim == 3) ? in.pop().to_integer(1,1000) : 0;
+   if (!in.remaining() || !in.front().is_integer())
+ THROW_ERROR("One integer was expected for bspline order");
size_type order = in.pop().to_integer(3,5);
std::string bcx_low("free");
std::string bcy_low("free");
+   std::string bcz_low("free");
std::string bcx_high("");
std::string bcy_high("");
+   std::string bcz_high("");
if (in.remaining()) bcx_low = in.pop().to_string();
-   if (dim == 2 && in.remaining()) bcy_low = in.pop().to_string();
+   if (dim >= 2 && in.remaining()) bcy_low = in.pop().to_string();
+   if (dim == 3 && in.remaining()) bcz_low = in.pop().to_string();
if (in.remaining()) bcx_high = in.pop().to_string();
-   if (dim == 2 && in.remaining()) bcy_high = in.pop().to_string();
-   if (dim == 1 && in.remaining())
- THROW_ERROR("Too many arguments for 1d bspline");
+   if (dim >= 2 && in.remaining()) bcy_high = in.pop().to_string();
+   if (dim == 3 && in.remaining()) bcz_high = in.pop().to_string();
+   if (in.remaining())
+ THROW_ERROR("Too many arguments for bspline mesh_fem");
getfem::bspline_boundary bcX_low(getfem::bspline_boundary::FREE);
getfem::bspline_boundary bcY_low(getfem::bspline_boundary::FREE);
+   getfem::bspline_boundary bcZ_low(getfem::bspline_boundary::FREE);
getfem::bspline_boundary bcX_high(getfem::bspline_boundary::FREE);
getfem::bspline_boundary bcY_high(getfem::bspline_boundary::FREE);
+   getfem::bspline_boundary bcZ_high(getfem::bspline_boundary::FREE);
if (bcx_low == "periodic")
  bcX_high = bcX_low = getfem::bspline_boundary::PERIODIC;
else if (bcx_low == "symmetry")
@@ -299,6 +307,13 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in,
else if (bcy_low != "free")
  THROW_ERROR("Unknown boundary condition " << bcy_low);
 
+   if (bcz_low == "periodic")
+ bcZ_high = bcZ_low = getfem::bspline_boundary::PERIODIC;
+   else if (bcz_low == "symmetry")
+ bcZ_high = bcZ_low = 

[Getfem-commits] [getfem-commits] branch master updated: Enable accessing parallel MUMPS in the scripting API linsolve function

2024-04-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 master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new 3f88b0cb Enable accessing parallel MUMPS in the scripting API linsolve 
function
3f88b0cb is described below

commit 3f88b0cbaf33dc600183b70dd5f69107e383627e
Author: Konstantinos Poulios 
AuthorDate: Sun Apr 28 10:37:44 2024 +0200

Enable accessing parallel MUMPS in the scripting API linsolve function
---
 interface/src/gf_linsolve.cc | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index d3f7da65..5e07e7ca 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -106,7 +106,13 @@ mumps_solver(gsparse ,
   garray b = in.pop().to_garray(int(gsp.nrows()), T());
   garray x = out.pop().create_array(b.getm(), b.getn(), T());
   gsp.to_csc();
-  gmm::MUMPS_solve(gsp.csc(T()),x,b);
+# if GETFEM_PARA_LEVEL > 1
+  double t_ref = MPI_Wtime();
+  gmm::MUMPS_distributed_matrix_solve(gsp.csc(T()), x, b);
+  if (getfem::MPI_IS_MASTER()) cout << "MUMPS solve time " << 
MPI_Wtime()-t_ref << endl;
+# else
+  gmm::MUMPS_solve(gsp.csc(T()), x, b);
+# endif
 }
 #endif
 



[Getfem-commits] [getfem-commits] branch master updated: Minor fix

2024-04-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 master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new 04b6aac6 Minor fix
04b6aac6 is described below

commit 04b6aac6c9edd78c3ba2b38879af02807013a57a
Author: Konstantinos Poulios 
AuthorDate: Sun Apr 28 10:35:45 2024 +0200

Minor fix
---
 src/getfem_models.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 81d015cd..36979703 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -2337,7 +2337,7 @@ namespace getfem {
 GMM_ASSERT1(version != BUILD_WITH_INTERNAL,
 "Invalid assembly version BUILD_WITH_INTERNAL");
 int nbp=1;
-#if GETFEM_PARA_LEVEL > 1
+#if GETFEM_PARA_LEVEL > 0
 double t_ref = MPI_Wtime();
 int rk=0;
 MPI_Comm_rank(MPI_COMM_WORLD, );
@@ -2878,8 +2878,7 @@ namespace getfem {
MPI_BCAST0_SCALAR(approx_external_load_);
 }
 
-#if GETFEM_PARA_LEVEL > 1
-// int rk; MPI_Comm_rank(MPI_COMM_WORLD, );
+#if GETFEM_PARA_LEVEL > 0
 if (MPI_IS_MASTER()) cout << "Assembly time " << MPI_Wtime()-t_ref << endl;
 #endif
 



[Getfem-commits] [getfem-commits] branch master updated: Minor fix in scripting API

2024-04-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 master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new 9e1450d7 Minor fix in scripting API
9e1450d7 is described below

commit 9e1450d7c4049ab7bb3d0901c291cbe9e2394653
Author: Konstantinos Poulios 
AuthorDate: Sun Apr 28 10:34:41 2024 +0200

Minor fix in scripting API
---
 interface/src/gf_util.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/interface/src/gf_util.cc b/interface/src/gf_util.cc
index 4fed4dab..c36a181f 100644
--- a/interface/src/gf_util.cc
+++ b/interface/src/gf_util.cc
@@ -119,7 +119,7 @@ void gf_util(getfemint::mexargs_in& m_in, 
getfemint::mexargs_out& m_out) {
);
 
 
-/*@FUNC tl = ('warning level', @int level)
+/*@FUNC tl = ('warning level' [, @int level])
   Filter the less important warnings displayed by getfem.
 
   0 means no warnings, default level is 3. if no level is given,



[Getfem-commits] [getfem-commits] branch master updated: Whitespace and typos

2024-04-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 master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new 98f393a0 Whitespace and typos
98f393a0 is described below

commit 98f393a0e635ac66ccb81ff7db0543b64cc13b0e
Author: Konstantinos Poulios 
AuthorDate: Sun Apr 28 10:33:41 2024 +0200

Whitespace and typos
---
 contrib/xfem_contact/xfem_dirichlet.cc | 761 -
 src/getfem/getfem_mesh_region.h|   4 +-
 src/gmm/gmm_MUMPS_interface.h  |  32 +-
 3 files changed, 396 insertions(+), 401 deletions(-)

diff --git a/contrib/xfem_contact/xfem_dirichlet.cc 
b/contrib/xfem_contact/xfem_dirichlet.cc
index dc792d51..740d4fdc 100644
--- a/contrib/xfem_contact/xfem_dirichlet.cc
+++ b/contrib/xfem_contact/xfem_dirichlet.cc
@@ -73,8 +73,8 @@ typedef getfem::modeling_standard_plain_vector  plain_vector;
 
 typedef gmm::row_matrix sparse_row_matrix;
 
-/* 
- * Exact solution 
+/*
+ * Exact solution
  */
 double Radius;
 int u_version;
@@ -89,7 +89,7 @@ double u_exact(const base_node ) {
   switch (u_version) {
   case 0: {
 double sum = std::accumulate(p.begin(), p.end(), double(0));
-
+
 return 5.0 * sin(sum) * (r*r - Radius*Radius);
   }
   case 1: {
@@ -98,11 +98,11 @@ double u_exact(const base_node ) {
   }
   case 2: {
 double A=u_alpha, n=u_n, B=u_B;
-return (R*R - r*r *(1+A*(1.0 + sin(n*T * cos(B*r);  
+return (R*R - r*r *(1+A*(1.0 + sin(n*T * cos(B*r);
   }
   case 3: {
 double A=u_alpha, n=u_n;
-return 5*(R*R*R*R - r*r*r*r*(1+A*(1.0 + sin(n*T;  
+return 5*(R*R*R*R - r*r*r*r*(1+A*(1.0 + sin(n*T;
   }
   case 4:{
 return 5.0 * (r*r*r - Radius*Radius*Radius);
@@ -114,17 +114,17 @@ double u_exact(const base_node ) {
   }
   case 6:{
 double sum = std::accumulate(p.begin(), p.end(), double(0));
-
+
 return 5.0 * sin(sum) * (r*r*r - Radius*Radius*Radius);
   }
   case 7:{
 double sum = std::accumulate(p.begin(), p.end(), double(0));
-
+
 return 5.0 * sin(sum) * (r*r*r*r - Radius*Radius*Radius*Radius);
   }
   case 8:{
-double rho=gmm::sqrt(p[0]*p[0]+ p[1]*p[1]+ p[2]*p[2]); 
-
+double rho=gmm::sqrt(p[0]*p[0]+ p[1]*p[1]+ p[2]*p[2]);
+
 return 5.0 * ( Radius*Radius* Radius-rho*rho*rho);
   }
   }
@@ -140,33 +140,33 @@ double g_exact(const base_node ) {
 double sum=std::accumulate(p.begin(), p.end(), double(0)), norm_sqr = r*r;
 if (norm_sqr < 1e-10) norm_sqr = 1e-10;
 return 5.0 * (sum * cos(sum) * (norm_sqr - R*R)
- + 2.0 * norm_sqr * sin(sum)) / sqrt(norm_sqr);
+  + 2.0 * norm_sqr * sin(sum)) / sqrt(norm_sqr);
   }
   case 1: {
 double A=u_alpha, T=atan2(p[1], p[0])+dtheta, n=u_n;
 return - 
sqrt(r*r*pow(2.0*sin(T)+2.0*sin(T)*A+2.0*sin(T)*A*sin(n*T)+cos(T)*A*cos(n*T)*n,2.0)+r*r*pow(-2.0*cos(T)-2.0*cos(T)*A-2.0*cos(T)*A*sin(n*T)+sin(T)*A*cos(n*T)*n,2.0));
-  } 
+  }
   case 2: {
 double A=u_alpha, T=atan2(p[1], p[0])+dtheta, n=u_n,B=u_B;
 if (gmm::abs(r) < 1e-10) r = 1e-10;
 return -(4.0*r*cos(B*r)+8.0*r*cos(B*r)*A+8.0*r*cos(B*r)*A*A
-+2.0*sin(B*r)*B*R*R-2.0*sin(B*r)*B*r*r
-+r*A*A*pow(cos(n*T),2.0)*n*n*cos(B*r)+8.0*r*cos(B*r)*A*A*sin(n*T)
--4.0*sin(B*r)*B*r*r*A*sin(n*T)
-+2.0*sin(B*r)*B*r*r*A*A*pow(cos(n*T),2.0)
--4.0*r*cos(B*r)*A*A*pow(cos(n*T),2.0)+8.0*r*cos(B*r)*A*sin(n*T)
--4.0*sin(B*r)*B*r*r*A*A*sin(n*T)-4.0*sin(B*r)*B*r*r*A*A
--4.0*sin(B*r)*B*r*r*A+2.0*sin(B*r)*B*R*R*A
-+2.0*sin(B*r)*B*R*R*A*sin(n*T))
+ +2.0*sin(B*r)*B*R*R-2.0*sin(B*r)*B*r*r
+ +r*A*A*pow(cos(n*T),2.0)*n*n*cos(B*r)+8.0*r*cos(B*r)*A*A*sin(n*T)
+ -4.0*sin(B*r)*B*r*r*A*sin(n*T)
+ +2.0*sin(B*r)*B*r*r*A*A*pow(cos(n*T),2.0)
+ -4.0*r*cos(B*r)*A*A*pow(cos(n*T),2.0)+8.0*r*cos(B*r)*A*sin(n*T)
+ -4.0*sin(B*r)*B*r*r*A*A*sin(n*T)-4.0*sin(B*r)*B*r*r*A*A
+ -4.0*sin(B*r)*B*r*r*A+2.0*sin(B*r)*B*R*R*A
+ +2.0*sin(B*r)*B*R*R*A*sin(n*T))
   / sqrt(A*A*pow(cos(n*T),2.0)*n*n +4.0+8.0*A+8.0*A*sin(n*T)
-+8.0*A*A+8.0*A*A*sin(n*T)-4.0*A*A*pow(cos(n*T),2.0));
+ +8.0*A*A+8.0*A*A*sin(n*T)-4.0*A*A*pow(cos(n*T),2.0));
   }
   case 3: {
 double A=u_alpha, T=atan2(p[1], p[0])+dtheta, n=u_n;
 return -5*r*r*r*sqrt(16.0 + 32.0*A*A + 32.0*A*sin(n*T) + 32.0*A
-+ 32.0*A*A*sin(n*T) - 16*gmm::sqr(A*cos(n*T))
-+ gmm::sqr(A*cos(n*T)*n));
-  }   
+ + 32.0*A*A*sin(n*T) - 16*gmm::sqr(A*cos(n*T))
+ + gmm::sqr(A*cos(n*T)*n));
+  }
   case 4: {
 r=gmm::vect_norm2(p);
 return 15*r*r;
@@ -175,20 +175,20 @@ double g_exact(const base_node ) {
 double a = sol5_a, b = sol5_b;
 double T = atan2(p[1], p[0]);
 return 5.0*r*sqrt( 

[Getfem-commits] [getfem-commits] branch master updated: Fix preprocessor options handling

2024-04-24 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 12935f5a Fix preprocessor options handling
12935f5a is described below

commit 12935f5a868c71e08aed4d7e32993159f742e309
Author: Konstantinos Poulios 
AuthorDate: Wed Apr 24 11:50:38 2024 +0200

Fix preprocessor options handling
---
 contrib/xfem_contact/xfem_dirichlet.cc   | 12 ++--
 contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc |  4 ++--
 interface/src/gf_asm.cc  |  4 ++--
 src/getfem/getfem_config.h   |  2 +-
 src/getfem_mesh.cc   |  4 ++--
 src/gmm/gmm_std.h|  4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/contrib/xfem_contact/xfem_dirichlet.cc 
b/contrib/xfem_contact/xfem_dirichlet.cc
index 6c1eefaf..dc792d51 100644
--- a/contrib/xfem_contact/xfem_dirichlet.cc
+++ b/contrib/xfem_contact/xfem_dirichlet.cc
@@ -38,7 +38,7 @@
 #include "getfem/bgeot_mesh_structure.h"
 #include "getfem/getfem_config.h"
 
-#if GETFEM_HAVE_METIS_OLD_API
+#if defined(GETFEM_HAVE_METIS_OLD_API)
 extern "C" void METIS_PartGraphKway(int *, int *, int *, int *, int *, int *,
 int *, int *, int *, int *, int *);
 extern "C" void METIS_PartGraphRecursive(int *, int *, int *, int *, int *, 
int *,
@@ -47,7 +47,7 @@ extern "C" void METIS_mCPartGraphKway(int *, int *, int *, 
int *, int *, int *,
   int *, int *, float *, int *, int *, int 
*);
 extern "C" void METIS_mCPartGraphRecursive(int *, int *, int *, int *, int *, 
int *, int *,
int *, int *, int *, int *, int *);
-#elif GETFEM_HAVE_METIS
+#elif defined(GETFEM_HAVE_METIS)
 # include 
 #endif
 
@@ -471,9 +471,9 @@ h
   cout<<"ratio size beween mesh and coarse mesh= "<< ratio_size < adjwgt(k); // actually Metis would also accept NULL instead 
of an empty array
   int wgtflag = 2, numflag = 0, edgecut;
   // float ubvec[1] = {1.03f};
@@ -885,9 +885,9 @@ int main(int argc, char *argv[]) {
   cout<<"ratio size between mesh and coarse mesh= "<< ratio_size < adjwgt(k); // actually Metis would also accept NULL 
instead of an empty array
   int wgtflag = 2, numflag = 0, edgecut;
   int options[5] = {0,0,0,0,0};
diff --git a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc 
b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
index 4f5a7ea4..9ece2d64 100644
--- a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
+++ b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
@@ -41,7 +41,7 @@
 #include "getfem/getfem_mesh_fem_sum.h"
 #include "gmm/gmm_inoutput.h"
 
-#if GETFEM_HAVE_METIS_OLD_API
+#if defined(GETFEM_HAVE_METIS_OLD_API)
 extern "C" void METIS_PartGraphKway(int *, int *, int *, int *, int *, int *,
 int *, int *, int *, int *, int *);
 extern "C" void METIS_PartGraphRecursive(int *, int *, int *, int *, int *, 
int *,
@@ -50,7 +50,7 @@ extern "C" void METIS_mCPartGraphKway(int *, int *, int *, 
int *, int *, int *,
   int *, int *, float *, int *, int *, int 
*);
 extern "C" void METIS_mCPartGraphRecursive(int *, int *, int *, int *, int *, 
int *, int *,
int *, int *, int *, int *, int *);
-#elif GETFEM_HAVE_METIS
+#elif defined(GETFEM_HAVE_METIS)
 # include 
 #endif
 
diff --git a/interface/src/gf_asm.cc b/interface/src/gf_asm.cc
index 7a4da996..5d666cf9 100644
--- a/interface/src/gf_asm.cc
+++ b/interface/src/gf_asm.cc
@@ -33,7 +33,7 @@
 #include 
 #include 
 
-#if GETFEM_HAVE_METIS_OLD_API
+#if defined(GETFEM_HAVE_METIS_OLD_API)
 extern "C" void METIS_PartGraphKway(int *, int *, int *, int *, int *, int *,
 int *, int *, int *, int *, int *);
 extern "C" void METIS_PartGraphRecursive(int *, int *, int *, int *, int *,
@@ -46,7 +46,7 @@ extern "C" void METIS_mCPartGraphRecursive(int *, int *, int 
*, int *, int *,
int *, int *, int *, int *, int *,
int *, int *);
 
-#elif GETFEM_HAVE_METIS
+#elif defined(GETFEM_HAVE_METIS)
 # include 
 #endif
 
diff --git a/src/getfem/getfem_config.h b/src/getfem/getfem_config.h
index 64bd5e1d..ef0aba89 100644
--- a/src/getfem/getfem_config.h
+++ b/src/getfem/getfem_config.h
@@ -167,7 +167,7 @@
 #define GETFEM_MPI_INIT(argc, argv) {GMM_TRACE1("Running sequential Getfem");}
 #define GETFEM_MPI_FINALIZE {}
 
-#if GMM_USES_MPI > 0
+#if defined(GMM_USES_MPI)
 # include 
 
 # undef GMM_TRACE_MSG_MPI
diff --git a/src/getfem_mesh.cc b/src/getfem_mesh.cc
index ecaba792..35649d99 100644
--- a/src/getfem_mesh.cc
+++ 

[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 18e801fef4a0420d4e1b5903c17a90bc687c8f76
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:13:46 2024 +0200

Require relaxing overstrict security checks with MSVC
---
 src/gmm/gmm_std.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gmm/gmm_std.h b/src/gmm/gmm_std.h
index 3a2e4b13..c0ade0fc 100644
--- a/src/gmm/gmm_std.h
+++ b/src/gmm/gmm_std.h
@@ -60,6 +60,9 @@
 # define SECURE_SPRINTF2(S, l, st, p1, p2) sprintf_s(S, l, st, p1, p2)
 # define SECURE_SPRINTF4(S, l, st, p1, p2, p3, p4) sprintf_s(S, l, st, p1, p2, 
p3, p4)
 # define SECURE_STRDUP(s) _strdup(s)
+# ifndef _CRT_SECURE_NO_DEPRECATE
+#  error Add _CRT_SECURE_NO_DEPRECATE to your compilation options, Microsoft 
is overstrict (e.g. bans fopen) without offering portable alternatives
+# endif
 #else
 # define SECURE_NONCHAR_SSCANF sscanf
 # define SECURE_NONCHAR_FSCANF fscanf



[Getfem-commits] [getfem-commits] master updated (77d406e1 -> 9216a7ac)

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

from 77d406e1 Disable the use of lapack interface when building Matlab 
interface because of conflict with 64 bit lapack used by Matlab.
 new 9e3d4ec6 Variables renaming and typo fixes
 new 18e801fe Require relaxing overstrict security checks with MSVC
 new e5b68e12 Fix minor compilation issues
 new ae3680ea Fix configure issue with clang
 new 30067565 Treat clang separately in autoconf system and other minor 
build system changes
 new 9216a7ac Avoid nested preprocessor macros in gmm blas interface


Summary of changes:
 CMakeLists.txt  |  2 +-
 configure.ac| 36 +++-
 m4/ax_check_cxx_flag.m4 |  4 +--
 src/getfem/bgeot_tensor.h   |  2 --
 src/getfem_fem.cc   |  4 +--
 src/getfem_generic_assembly_compile_and_exec.cc | 22 ++---
 src/getfem_generic_assembly_tree.cc |  2 +-
 src/gmm/gmm_arch_config.h.in|  2 +-
 src/gmm/gmm_blas_interface.h| 44 -
 src/gmm/gmm_std.h   |  3 ++
 tests/test_interpolation.cc |  6 ++--
 11 files changed, 72 insertions(+), 55 deletions(-)



[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit ae3680eac2c860e17921f5ef09de7995fba77340
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:15:02 2024 +0200

Fix configure issue with clang
---
 m4/ax_check_cxx_flag.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/m4/ax_check_cxx_flag.m4 b/m4/ax_check_cxx_flag.m4
index 6513885a..aebdf5fd 100644
--- a/m4/ax_check_cxx_flag.m4
+++ b/m4/ax_check_cxx_flag.m4
@@ -16,8 +16,8 @@ dnl Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301, USA.
 AC_DEFUN([AC_CHECK_CXX_FLAG],
 [AC_MSG_CHECKING([whether ${CXX} accepts $1])
 
-echo 'int main(){}' > conftest.c
-if test -z "`${CXX} $1 -o conftest conftest.c 2>&1`"; then
+echo 'int main(){}' > conftest.cc
+if test -z "`${CXX} $1 -o conftest conftest.cc 2>&1`"; then
   $2="${$2} $1"
   echo "yes"
 else



[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit e5b68e126f672926cfd6171c7d886964f831324e
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:14:33 2024 +0200

Fix minor compilation issues
---
 src/getfem/bgeot_tensor.h | 2 --
 src/getfem_fem.cc | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/getfem/bgeot_tensor.h b/src/getfem/bgeot_tensor.h
index b5e28210..46e3d01a 100644
--- a/src/getfem/bgeot_tensor.h
+++ b/src/getfem/bgeot_tensor.h
@@ -130,9 +130,7 @@ namespace bgeot {
 template inline const T& operator ()(const CONT ) const {
   typename CONT::const_iterator it = c.begin();
   multi_index::const_iterator q = coeff_.begin(), e = coeff_.end();
-#ifndef NDEBUG
   multi_index::const_iterator qv = sizes_.begin();
-#endif
   size_type d = 0;
   for ( ; q != e; ++q, ++it) {
 d += (*q) * (*it);
diff --git a/src/getfem_fem.cc b/src/getfem_fem.cc
index 2cc58661..8456df84 100644
--- a/src/getfem_fem.cc
+++ b/src/getfem_fem.cc
@@ -4426,8 +4426,8 @@ namespace getfem {
 THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_last = nullptr;
 THREAD_SAFE_STATIC short_type k_last = short_type(-1);
 THREAD_SAFE_STATIC pfem fem_last = nullptr;
-THREAD_SAFE_STATIC char complete_last = 0;
-THREAD_SAFE_STATIC char discont_last = 0;
+THREAD_SAFE_STATIC bool complete_last = 0;
+THREAD_SAFE_STATIC bool discont_last = 0;
 THREAD_SAFE_STATIC scalar_type alpha_last = 0;
 
 bool found = false;



[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 9e3d4ec635fdadf84c744c66f622a5e7ad0b6040
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:12:27 2024 +0200

Variables renaming and typo fixes
---
 src/getfem_generic_assembly_compile_and_exec.cc | 22 +++---
 src/getfem_generic_assembly_tree.cc |  2 +-
 src/gmm/gmm_arch_config.h.in|  2 +-
 tests/test_interpolation.cc |  6 ++
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 7ae88cb6..15857c0e 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -1873,20 +1873,20 @@ namespace getfem {
   struct ga_instruction_transpose : public ga_instruction { // To be optimized
 base_tensor 
 const base_tensor 
-size_type n1, n2, nn;
+size_type J, K, I;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: transpose");
   GA_DEBUG_ASSERT(t.size() == tc1.size(), "Wrong sizes");
 
-  size_type n0 = tc1.size() / (n1*n2*nn);
+  size_type L = tc1.size() / (J*K*I);
   auto it = t.begin();
-  for (size_type i = 0; i < nn; ++i) {
-size_type s1 = i*n1*n2*n0;
-for (size_type j = 0; j < n1; ++j) {
-  size_type s2 = s1 + j*n0;
-  for (size_type k = 0; k < n2; ++k) {
-size_type s3 = s2 + k*n1*n0;
-for (size_type l = 0; l < n0; ++l, ++it)
+  for (size_type i = 0; i < I; ++i) {
+size_type s1 = i*J*K*L;
+for (size_type j = 0; j < J; ++j) {
+  size_type s2 = s1 + j*L;
+  for (size_type k = 0; k < K; ++k) {
+size_type s3 = s2 + k*J*L;
+for (size_type l = 0; l < L; ++l, ++it)
   *it = tc1[s3+l];
   }
 }
@@ -1895,8 +1895,8 @@ namespace getfem {
   return 0;
 }
 ga_instruction_transpose(base_tensor _, const base_tensor _,
- size_type n1_, size_type n2_, size_type nn_)
-  : t(t_), tc1(tc1_), n1(n1_), n2(n2_), nn(nn_) {}
+ size_type J_, size_type K_, size_type I_)
+  : t(t_), tc1(tc1_), J(J_), K(K_), I(I_) {}
   };
 
   struct ga_instruction_swap_indices : public ga_instruction {// To be 
optimized
diff --git a/src/getfem_generic_assembly_tree.cc 
b/src/getfem_generic_assembly_tree.cc
index 3dee62a8..0450930f 100644
--- a/src/getfem_generic_assembly_tree.cc
+++ b/src/getfem_generic_assembly_tree.cc
@@ -1713,7 +1713,7 @@ namespace getfem {
 if (t_type != GA_NAME)
   ga_throw_error(expr, pos,
  "First argument of Interpolate should the "
- "interpolate transformtion name ");
+ "interpolate transformation name ");
 tree.current_node->interpolate_name_der
   = std::string(&((*expr)[token_pos]), token_length);
 t_type = ga_get_token(*expr, pos, token_pos, token_length);
diff --git a/src/gmm/gmm_arch_config.h.in b/src/gmm/gmm_arch_config.h.in
index 2dd8f0f0..3e656c3a 100644
--- a/src/gmm/gmm_arch_config.h.in
+++ b/src/gmm/gmm_arch_config.h.in
@@ -9,7 +9,7 @@
 /* defined if GMM is linked to a lapack library */
 #undef GMM_USES_LAPACK
 
-/* defined if GMM is linked to a lapack library */
+/* defined if GMM is used when building the Matlab interface */
 #undef GMM_MATLAB_INTERFACE
 
 /* defined if GMM uses MPI */
diff --git a/tests/test_interpolation.cc b/tests/test_interpolation.cc
index 99ea0692..6199a2d4 100644
--- a/tests/test_interpolation.cc
+++ b/tests/test_interpolation.cc
@@ -242,8 +242,7 @@ void test_same_mesh(int mat_version, size_type N, size_type 
NX, size_type K, siz
   /* force evaluation of a number of things which are not part of 
interpolation */
   size_type d = mf1.nb_dof(); d -= mf2.nb_dof();
   double err = 0.;  
-  for (int i=0; i<3; ++i) { /* pour amortir/cout de la construction du 
maillage, et de divers trucs
-  (�a a un gros impact) */
+  for (int i=0; i<3; ++i) { /* To mitigate the cost of mesh generation etc. 
(has a significant impact). */
 c.init().tic();
 double err2 = interpolate_check(mf1, mf2, i, mat_version); 
 if (i==0 || (mat_version > 0 && i == 1)) err = err2;
@@ -269,8 +268,7 @@ void test_different_mesh(int mat_version, size_type dim, 
size_type N, size_type
   /* force evaluation of a number of things which are not part of 
interpolation */
   size_type d = mf1.nb_dof(); d -= mf2.nb_dof();
   double err = 0;
-  for (int i=0; i<3; ++i) { /* pour amortir/cout de la construction du 
maillage, et de divers trucs
-  (�a a un gros impact) */
+  for (int i=0; i<3; ++i) { /* To mitigate the cost of mesh generation etc. 
(has a significant impact). */
 c.init().tic();
 double err2 = interpolate_check(mf1, mf2, i, mat_version); 
 if (i==0 || (mat_version > 0 

[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 9216a7acc4c992e99beaf8eeccfce871348a2e55
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:16:53 2024 +0200

Avoid nested preprocessor macros in gmm blas interface
---
 src/gmm/gmm_blas_interface.h | 44 +---
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 4c8deddf..1b83f1cd 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -385,41 +385,39 @@ namespace gmm {
   }
 
 
-# define axpy_interface(param1, trans1, blas_name, base_type)  \
-  inline void add(param1(base_type), std::vector ) {  \
+# define axpy_interface(blas_name, base_type)  \
+  inline void add(const std::vector , \
+  std::vector ) { \
 GMMLAPACK_TRACE("axpy_interface"); \
-BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \
+BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); base_type a(1);\
 if(n == 0) return; \
 else if(n < 25) add_for_short_vectors(x, y, n);\
 else blas_name(, , [0], , [0], );  \
   }
 
-# define axpy2_interface(param1, trans1, blas_name, base_type) \
-  inline void add(param1(base_type), std::vector ) {  \
+  axpy_interface(saxpy_, BLAS_S)
+  axpy_interface(daxpy_, BLAS_D)
+  axpy_interface(caxpy_, BLAS_C)
+  axpy_interface(zaxpy_, BLAS_Z)
+
+
+# define axpy2_interface(blas_name, base_type) \
+  inline void add  \
+  (const scaled_vector_const_ref,base_type> _,\
+   std::vector ) {\
 GMMLAPACK_TRACE("axpy_interface"); \
-BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \
+BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
+const std::vector& x = *(linalg_origin(x_));\
+base_type a(x_.r); \
 if(n == 0) return; \
 else if(n < 25) add_for_short_vectors(x, y, a, n); \
 else blas_name(, , [0], , [0], );  \
   }
 
-# define axpy_p1(base_type) const std::vector 
-# define axpy_trans1(base_type) base_type a(1)
-# define axpy_p1_s(base_type)  \
-const scaled_vector_const_ref,base_type> _
-# define axpy_trans1_s(base_type)  \
- const std::vector  = *(linalg_origin(x_));   \
- base_type a(x_.r)
-
-  axpy_interface(axpy_p1, axpy_trans1, saxpy_, BLAS_S)
-  axpy_interface(axpy_p1, axpy_trans1, daxpy_, BLAS_D)
-  axpy_interface(axpy_p1, axpy_trans1, caxpy_, BLAS_C)
-  axpy_interface(axpy_p1, axpy_trans1, zaxpy_, BLAS_Z)
-
-  axpy2_interface(axpy_p1_s, axpy_trans1_s, saxpy_, BLAS_S)
-  axpy2_interface(axpy_p1_s, axpy_trans1_s, daxpy_, BLAS_D)
-  axpy2_interface(axpy_p1_s, axpy_trans1_s, caxpy_, BLAS_C)
-  axpy2_interface(axpy_p1_s, axpy_trans1_s, zaxpy_, BLAS_Z)
+  axpy2_interface(saxpy_, BLAS_S)
+  axpy2_interface(daxpy_, BLAS_D)
+  axpy2_interface(caxpy_, BLAS_C)
+  axpy2_interface(zaxpy_, BLAS_Z)
 
 
   /* * */



[Getfem-commits] (no subject)

2024-04-12 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 30067565d5dd21989381d4cbd84dd3155b3e0c31
Author: Konstantinos Poulios 
AuthorDate: Fri Apr 12 16:16:02 2024 +0200

Treat clang separately in autoconf system and other minor build system 
changes
---
 CMakeLists.txt |  2 +-
 configure.ac   | 36 
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f8694be..b6dd7b7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,7 @@ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH 
"Installation prefix")
 
 
 # General tests and configurations
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 14 CACHE STRING "Set C++ standard version (default: 14))
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 check_include_file_cxx("cxxabi.h" GETFEM_HAVE_CXXABI_H)
 check_cxx_source_compiles(
diff --git a/configure.ac b/configure.ac
index 339025ba..8d03612d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,7 +27,7 @@ dnl thus, updating cache ./config.cache avoided.
 define([AC_CACHE_LOAD], )dnl
 define([AC_CACHE_SAVE], )dnl
 
-AC_INIT(getfem, 5.4.2)
+AC_INIT([getfem],[5.4.2])
 MAJOR_VERSION="5"
 MINOR_VERSION="4"
 PATCH_VERSION="2"
@@ -40,7 +40,7 @@ AC_DEFINE_UNQUOTED(GMM_VERSION,"${PACKAGE_VERSION}",[GMM 
version])
 AC_CONFIG_SRCDIR([install-sh])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config_autogenerated_not_used.h 
src/getfem/getfem_arch_config.h src/gmm/gmm_arch_config.h])
-AC_PREREQ(2.61)
+AC_PREREQ([2.71])
 AC_ARG_PROGRAM
 
 dnl 
@@ -114,15 +114,12 @@ dnl AC_CXX_FULL_SPECIALIZATION_SYNTAX (c)Luc Maisonobe v 
1.1.1.1 (2001/07/26)
 dnl with some modification to test partial specialization
 AC_CACHE_CHECK(whether the compiler recognizes the partial specialization 
syntax,
 ac_cv_cxx_partial_specialization_syntax,
-[AC_DIAGNOSE([obsolete],[Instead of using `AC_LANG', `AC_LANG_SAVE', and 
`AC_LANG_RESTORE',
-you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])dnl
-AC_LANG_SAVE
- AC_LANG([C++])
+[AC_LANG_PUSH([C++])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 template class A{ public : int f () const { return 1; } };
 template class A{ public : int f () const { return 0; } };]], 
[[
 A a; return 
a.f();]])],[ac_cv_cxx_partial_specialization_syntax=yes],[ac_cv_cxx_partial_specialization_syntax=no])
- AC_LANG_POP([])
+ AC_LANG_POP([C++])
 ])
 if test "$ac_cv_cxx_partial_specialization_syntax" != yes; then
   echo "Your compiler ($CXX) does not support partial template specialization, 
trash it"
@@ -135,6 +132,29 @@ echo "you are compiling GetFEM on a $host"
 
 case $CXX in

+ clang++)
+   GLANGVER=`$CXX --version | head -n 1 | grep -o -E 
"[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"`
+   echo "Using the clang++ compiler $GLANGVER"
+   AC_CHECK_CXX_FLAG([$with_optimization],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-fmessage-length=0],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-fvisibility-inlines-hidden],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-ftemplate-depth-100],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-std=c++14], CXXFLAGS, [AC_MSG_ERROR([Used clang++ 
version does not support option -std=c++14.])])
+   AC_CHECK_CXX_FLAG([-fPIC],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wall -W -Wextra],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wshadow],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wno-unknown-pragmas],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wno-variadic-macros],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wno-unused-but-set-variable],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wpointer-arith],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wcast-qual],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wwrite-strings],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wconversion],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wredundant-decls],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-Wno-long-long],CXXFLAGS)
+   AC_CHECK_CXX_FLAG([-rdynamic],SUPLDFLAGS)
+CFLAGS="$CFLAGS $with_optimization -fPIC"
+   ;;
  *g++* | c++)
GCCVER=`$CXX --version | head -1 | cut -d ' ' -f3`
echo "Using the GNU g++ compiler $GCCVER"
@@ -142,7 +162,7 @@ case $CXX in
AC_CHECK_CXX_FLAG([-fmessage-length=0],CXXFLAGS)
AC_CHECK_CXX_FLAG([-fvisibility-inlines-hidden],CXXFLAGS)
AC_CHECK_CXX_FLAG([-ftemplate-depth-100],CXXFLAGS)
-   AC_CHECK_CXX_FLAG([-std=c++14], 
CXXFLAGS,[AC_CHECK_CXX_FLAG([-std=c++0x],CXXFLAGS,[AC_MSG_ERROR([g++ do not 
support option -std=c++14. Update g++ to at least release 4.9])] )])
+   AC_CHECK_CXX_FLAG([-std=c++14], 
CXXFLAGS,[AC_CHECK_CXX_FLAG([-std=c++0x],CXXFLAGS,[AC_MSG_ERROR([Used g++ does 
not support option -std=c++14. Update g++ to at least release 4.9])] )])
AC_CHECK_CXX_FLAG([-fPIC],CXXFLAGS)
AC_CHECK_CXX_FLAG([-Wall -W -Wextra],CXXFLAGS)
dnl AC_CHECK_CXX_FLAG([-pedantic],CXXFLAGS)



[Getfem-commits] [getfem-commits] branch master updated: Remove hack for treating blas64 in gmm

2024-03-26 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 cbe1442c Remove hack for treating blas64 in gmm
cbe1442c is described below

commit cbe1442c4bb2b4fea804d47054ab55dc0bfe238c
Author: Konstantinos Poulios 
AuthorDate: Tue Mar 26 13:00:00 2024 +0100

Remove hack for treating blas64 in gmm

  - BLAS integer type must be fixed at configure time in gmm_arch_config.h
through the GMM_USE_BLAS64_INTERFACE macro
  - lu_factor interface returns 0 if successful, or a pivot number if a
pivot is negative or 0, it does not distinguish between the latter two
---
 src/gmm/gmm_dense_lu.h | 68 +++---
 src/gmm/gmm_lapack_interface.h | 16 --
 2 files changed, 24 insertions(+), 60 deletions(-)

diff --git a/src/gmm/gmm_dense_lu.h b/src/gmm/gmm_dense_lu.h
index 52102366..4823f3f3 100644
--- a/src/gmm/gmm_dense_lu.h
+++ b/src/gmm/gmm_dense_lu.h
@@ -73,47 +73,11 @@
 
 namespace gmm {
 
-  /* ** */
-  /* IPVT structure.*/
-  /* ** */
-  // For compatibility with lapack version with 64 or 32 bit integer.
-  // Should be replaced by std::vector if 32 bit integer version
-  // of lapack is not used anymore (and lapack_ipvt_int set to size_type)
-
-  // Do not use iterators of this interface container
-  class lapack_ipvt : public std::vector {
-bool is_int64;
-size_type [](size_type i)
-{ return std::vector::operator[](i); }
-size_type operator[] (size_type i) const
-{ return std::vector::operator[](i); }
-void begin() const {}
-void begin() {}
-void end() const {}
-void end() {}
-
-  public:
-void set_to_int32() { is_int64 = false; }
-const size_type *pfirst() const
-{ return &(*(std::vector::begin())); }
-size_type *pfirst() { return &(*(std::vector::begin())); }
-
-lapack_ipvt(size_type n) :  std::vector(n), is_int64(true) {}
-
-size_type get(size_type i) const {
-  const size_type *p = pfirst();
-  return is_int64 ? p[i] : size_type(((const int *)(p))[i]);
-}
-void set(size_type i, size_type val) {
-  size_type *p = pfirst();
-  if (is_int64) p[i] = val; else ((int *)(p))[i] = int(val);
-}
-  };
-}
-
-#include "gmm_opt.h"
-
-namespace gmm {
+#if defined(GMM_USES_BLAS) || defined(GMM_USES_LAPACK)
+  typedef std::vector lapack_ipvt;
+#else
+  typedef std::vector lapack_ipvt;
+#endif
 
   /** LU Factorization of a general (dense) matrix (real or complex).
   
@@ -125,9 +89,10 @@ namespace gmm {
   The pivot indices in ipvt are indexed starting from 1
   so that this is compatible with LAPACK (Fortran).
   */
-  template 
-  size_type lu_factor(DenseMatrix& A, lapack_ipvt& ipvt) {
+  template 
+  size_type lu_factor(DenseMatrix& A, Pvector& ipvt) {
 typedef typename linalg_traits::value_type T;
+typedef typename linalg_traits::value_type INT;
 typedef typename number_traits::magnitude_type R;
 size_type info(0), i, j, jp, M(mat_nrows(A)), N(mat_ncols(A));
 if (M == 0 || N == 0)
@@ -136,14 +101,14 @@ namespace gmm {
 std::vector c(M), r(N);
 
 GMM_ASSERT2(ipvt.size()+1 >= NN, "IPVT too small");
-for (i = 0; i+1 < NN; ++i) ipvt.set(i, i);
+for (i = 0; i+1 < NN; ++i) ipvt[i] = INT(i);
 
 if (M || N) {
   for (j = 0; j+1 < NN; ++j) {
 R max = gmm::abs(A(j,j)); jp = j;
 for (i = j+1; i < M; ++i)   /* find pivot.  */
   if (gmm::abs(A(i,j)) > max) { jp = i; max = gmm::abs(A(i,j)); }
-ipvt.set(j, jp + 1);
+ipvt[j] = INT(jp + 1);
 
 if (max == R(0)) { info = j + 1; break; }
 if (jp != j) for (i = 0; i < N; ++i) std::swap(A(jp, i), A(j, i));
@@ -153,7 +118,7 @@ namespace gmm {
 rank_one_update(sub_matrix(A, sub_interval(j+1, M-j-1),
  sub_interval(j+1, N-j-1)), c, conjugated(r));
   }
-  ipvt.set(NN-1, NN);
+  ipvt[NN-1] = INT(NN);
 }
 return info;
   }
@@ -167,7 +132,7 @@ namespace gmm {
 typedef typename linalg_traits::value_type T;
 copy(b, x);
 for(size_type i = 0; i < pvector.size(); ++i) {
-  size_type perm = pvector.get(i)-1;   // permutations stored in 1's offset
+  size_type perm = size_type(pvector[i]-1);   // permutations stored in 
1's offset
   if (i != perm) { T aux = x[i]; x[i] = x[perm]; x[perm] = aux; }
 }
 /* solve  Ax = b  ->  LUx = b  ->  Ux = L^-1 b.*/
@@ -198,7 +163,7 @@ namespace gmm {
 lower_tri_solve(transposed(LU), x, false);
 upper_tri_solve(transposed(LU), x, true);
 for (size_type i = pvector.size(); i > 0; --i) {
-  size_type perm = 

[Getfem-commits] [getfem-commits] branch master updated: Remove detection of blas64 in matlab

2024-03-26 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 96250123 Remove detection of blas64 in matlab
96250123 is described below

commit 9625012326b595d08ca3f8372e9b66e82c3604ec
Author: Konstantinos Poulios 
AuthorDate: Tue Mar 26 12:50:48 2024 +0100

Remove detection of blas64 in matlab

  - deployment of BLAS is already too messy to try to automatically
detect its features by heuristic methods
  - remove redundant preprocessor if-statement
---
 configure.ac | 21 +
 src/gmm/gmm_blas_interface.h |  2 --
 2 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/configure.ac b/configure.ac
index ea077f22..33faee1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -547,7 +547,7 @@ fi
 acx_blas_save_LIBS="$LIBS"
 LIBS="$LIBS $FLIBS"
 echo "BLAS_LIBS=$BLAS_LIBS"
-# First, check BLAS_LIBS environment variable
+# First, check BLAS_LIBS environment variable (can also be set using the 
--with-blas= option)
 if test "x$BLAS_LIBS" = xbuiltin; then
   echo "Using builtin blas lib";
   BLAS_LIBS=""
@@ -665,25 +665,6 @@ AC_ARG_ENABLE(blas64-support,
   no) useblas64support=NO;;
   esac], [useblas64support=NO])
 
-if test x$useblas64support = xNO && test x$usematlab = xYES; then
-  # 32 or 64 bits blas interface
-  AC_RUN_IFELSE([AC_LANG_SOURCE([[
-  #include 
-  int main() {
-int a; long b;
-int *pa; long *pb; void *pc;
-
-if (sizeof(long) > sizeof(int)) {
-  a = 0x3E0024; b = 0;
-  pb =  pc = (void *)(pb); pa = (int *)(pc); *pa = a;
-  if (int(b) != a) exit(1);
-  *pa = 0x3E0024;
-  if (int(b) != a) exit(1);
-  if (b != long(a)) exit(1);
-} 
-  } ]])],[useblas64support=YES],[],[])
-fi
-
 if test x$useblas64support = xYES; then
   AC_DEFINE(GMM_USE_BLAS64_INTERFACE,,[Use blas with 64 bits integers])
 fi
diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index cab18d7d..4c8deddf 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -183,7 +183,6 @@ namespace gmm {
 void  sger_(...); void  dger_(...); void  cgerc_(...); void  zgerc_(...);
   }
 
-#if 1
 
   /* * */
   /* vect_norm2(x).*/
@@ -1009,7 +1008,6 @@ namespace gmm {
   trsv_interface(upper_tri_solve, trsv_lower, gem_p1_c, gem_trans1_c,
  ztrsv_, BLAS_Z)
 
-#endif
 }
 
 #endif // GMM_BLAS_INTERFACE_H



[Getfem-commits] [getfem-commits] branch master updated: Fix regression from previous commit due to incompatible ABI between GNU and Intel BLAS

2024-03-26 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 17dd4ee3 Fix regression from previous commit due to incompatible ABI 
between GNU and Intel BLAS
17dd4ee3 is described below

commit 17dd4ee38d0878f3c2451f355b2c1f8e8b88f278
Author: Konstantinos Poulios 
AuthorDate: Tue Mar 26 12:46:29 2024 +0100

Fix regression from previous commit due to incompatible ABI between GNU and 
Intel BLAS

  - autoconf detects if BLAS fortran functions return complex reals by
value or as argument, and sets the GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT
macro if necessary
  - detection in CMake still needs to be implemented, until then the user
has to define GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT at configure time
manually, if necessary
  - BLAS ABI should not be changed after gmm has been configured, if the
user wants to switch to a BLAS with a different ABI nevertheless,
the only option is to edit the gmm_arch_config.h file manually
---
 cmake/gmm_arch_config.h.in   |  3 +++
 configure.ac | 26 ++
 src/gmm/gmm_arch_config.h.in |  3 +++
 src/gmm/gmm_blas_interface.h | 15 +++
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/cmake/gmm_arch_config.h.in b/cmake/gmm_arch_config.h.in
index 50f47daa..dff9b566 100644
--- a/cmake/gmm_arch_config.h.in
+++ b/cmake/gmm_arch_config.h.in
@@ -22,5 +22,8 @@
 /* Use blas with 64 bits integers */
 #cmakedefine GMM_USE_BLAS64_INTERFACE
 
+/* defined if the BLAS fortran ABI does not return complex values directly 
(e.g. Intel's MKL) */
+#cmakedefine GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT
+
 /* GMM version */
 #define GMM_VERSION "@GMM_VERSION@"
diff --git a/configure.ac b/configure.ac
index 6f7d6c82..ea077f22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -688,6 +688,32 @@ if test x$useblas64support = xYES; then
   AC_DEFINE(GMM_USE_BLAS64_INTERFACE,,[Use blas with 64 bits integers])
 fi
 
+# check fortran ABI with regard to complex function in BLAS
+# by defult assume a fortran ABI where complex real/double functions return by 
value
+  AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include 
+#if defined(GMM_USE_BLAS64_INTERFACE)
+  #define INT long
+#else
+  #define INT int
+#endif
+extern "C" {
+void cdotu_(std::complex*, const INT*, const std::complex*, 
const INT*,
+const std::complex*, const INT*);
+}
+int main() {
+const INT one=1;
+std::complex x(1.,2.), y(1.,-2.), result;
+cdotu_(, , , , , );
+return (fabs(result.real()-5.) < 1e-8) ? 0 : 1;
+}
+  ]])],[ acx_blas_fortan_abi=Intel ], [ acx_blas_fortan_abi=GNU ], [])
+
+if test x$acx_blas_fortan_abi = xIntel; then
+  echo "BLAS found to have the Intel fortran ABI, i.e. returning complex 
function value by argument";
+  AC_DEFINE(GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT,,[defined if the BLAS fortran 
ABI does not return complex values directly (e.g. Intel's MKL)])
+fi
+
 dnl --LAPACK TEST
 
 if test x"$acx_blas_ok" = xyes; then
diff --git a/src/gmm/gmm_arch_config.h.in b/src/gmm/gmm_arch_config.h.in
index 0d46b9ab..ed5bb8fa 100644
--- a/src/gmm/gmm_arch_config.h.in
+++ b/src/gmm/gmm_arch_config.h.in
@@ -21,5 +21,8 @@
 /* Use blas with 64 bits integers */
 #undef GMM_USE_BLAS64_INTERFACE
 
+/* defined if the BLAS fortran ABI does not return complex values directly 
(e.g. Intel's MKL) */
+#undef GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT
+
 /* GMM version */
 #undef GMM_VERSION
diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 44f99ae3..cab18d7d 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -152,6 +152,13 @@ namespace gmm {
 # define BLAS_C std::complex
 # define BLAS_Z std::complex
 
+// Hack due to BLAS ABI mess
+#if defined(GMM_BLAS_RETURN_COMPLEX_AS_ARGUMENT)
+# define BLAS_CPLX_FUNC_CALL(blasname, res, ...) blasname(, __VA_ARGS__)
+#else
+# define BLAS_CPLX_FUNC_CALL(blasname, res, ...) res = blasname(__VA_ARGS__)
+#endif
+
   /* * */
   /* BLAS functions used.  */
   /* * */
@@ -252,7 +259,7 @@ namespace gmm {
 GMMLAPACK_TRACE(msg);  \
 base_type res; \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
-blas_name(, , [0], , [0], ); \
+BLAS_CPLX_FUNC_CALL(blas_name, res, , [0], , [0], ); \
 return res;\
   }\
   inline base_type funcname 

[Getfem-commits] [getfem-commits] branch master updated: Fix BLAS interface not supported by MKL and avoid nested macros

2024-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 d8be9712 Fix BLAS interface not supported by MKL and avoid nested 
macros
d8be9712 is described below

commit d8be97120c1ba18729ac9c00c2a24a6b65775e3a
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 25 16:55:10 2024 +0100

Fix BLAS interface not supported by MKL and avoid nested macros
---
 src/gmm/gmm_blas_interface.h | 141 ---
 1 file changed, 64 insertions(+), 77 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 07861ec5..44f99ae3 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -196,115 +196,102 @@ namespace gmm {
   nrm2_interface(dznrm2_, BLAS_Z)
 
   /* * */
-  /* vect_sp(x, y).*/
+  /* vect_sp(x,y) = vect_hp(x,y) for real vectors  */
   /* * */
 
-# define dot_interface(blas_name, base_type)   \
-  inline base_type vect_sp(const std::vector ,\
-   const std::vector ) {  \
-GMMLAPACK_TRACE("dot_interface");  \
+# define dot_interface(funcname, msg, blas_name, base_type)\
+  inline base_type funcname(const std::vector ,   \
+const std::vector ) { \
+GMMLAPACK_TRACE(msg);  \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
 return blas_name(, [0], , [0], );\
   }\
-  inline base_type vect_sp \
+  inline base_type funcname\
(const scaled_vector_const_ref,base_type> _,   \
 const std::vector ) { \
-GMMLAPACK_TRACE("dot_interface");  \
+GMMLAPACK_TRACE(msg);  \
 const std::vector  = *(linalg_origin(x_));\
 base_type a(x_.r); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
-return a* blas_name(, [0], , [0], ); \
+return a * blas_name(, [0], , [0], );\
   }\
-  inline base_type vect_sp \
+  inline base_type funcname\
 (const std::vector ,  \
  const scaled_vector_const_ref,base_type> _) {\
-GMMLAPACK_TRACE("dot_interface");  \
+GMMLAPACK_TRACE(msg);  \
 const std::vector  = *(linalg_origin(y_));\
 base_type b(y_.r); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
-return b* blas_name(, [0], , [0], ); \
+return b * blas_name(, [0], , [0], );\
   }\
-  inline base_type vect_sp \
+  inline base_type funcname\
 (const scaled_vector_const_ref,base_type> _,  \
  const scaled_vector_const_ref,base_type> _) {\
-GMMLAPACK_TRACE("dot_interface");  \
+GMMLAPACK_TRACE(msg);  \
 const std::vector  = *(linalg_origin(x_));\
-base_type a(x_.r); \
 const std::vector  = *(linalg_origin(y_));\
-base_type b(y_.r); \
+base_type a(x_.r), b(y_.r);\
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
-return a* b* blas_name(, [0], , [0], );  \
+return a*b * blas_name(, [0], , [0], );  \
   }
 
-  dot_interface(sdot_,  BLAS_S)
-  dot_interface(ddot_,  BLAS_D)
-  dot_interface(cdotu_, BLAS_C)
-  dot_interface(zdotu_, BLAS_Z)
+  dot_interface(vect_sp, "dot_interface", sdot_,  BLAS_S)
+  dot_interface(vect_sp, "dot_interface", ddot_,  BLAS_D)
+  dot_interface(vect_hp, 

[Getfem-commits] [getfem-commits] branch master updated: Remove const_cast occurrences

2024-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 90a30c01 Remove const_cast occurrences
90a30c01 is described below

commit 90a30c01a9f7cf0d39e254d69e6ac0cf1cd58a0b
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 25 11:20:26 2024 +0100

Remove const_cast occurrences
---
 src/gmm/gmm_blas_interface.h   | 59 --
 src/gmm/gmm_lapack_interface.h | 34 
 2 files changed, 38 insertions(+), 55 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 71663bdd..07861ec5 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -210,8 +210,7 @@ namespace gmm {
(const scaled_vector_const_ref,base_type> _,   \
 const std::vector ) { \
 GMMLAPACK_TRACE("dot_interface");  \
-std::vector  =   \
-  const_cast &>(*(linalg_origin(x_))); \
+const std::vector  = *(linalg_origin(x_));\
 base_type a(x_.r); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
 return a* blas_name(, [0], , [0], ); \
@@ -220,8 +219,7 @@ namespace gmm {
 (const std::vector ,  \
  const scaled_vector_const_ref,base_type> _) {\
 GMMLAPACK_TRACE("dot_interface");  \
-std::vector  =   \
-  const_cast &>(*(linalg_origin(y_))); \
+const std::vector  = *(linalg_origin(y_));\
 base_type b(y_.r); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
 return b* blas_name(, [0], , [0], ); \
@@ -230,11 +228,9 @@ namespace gmm {
 (const scaled_vector_const_ref,base_type> _,  \
  const scaled_vector_const_ref,base_type> _) {\
 GMMLAPACK_TRACE("dot_interface");  \
-std::vector  =   \
-  const_cast &>(*(linalg_origin(x_))); \
+const std::vector  = *(linalg_origin(x_));\
 base_type a(x_.r); \
-std::vector  =   \
-  const_cast &>(*(linalg_origin(y_))); \
+const std::vector  = *(linalg_origin(y_));\
 base_type b(y_.r); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
 return a* b* blas_name(, [0], , [0], );  \
@@ -263,8 +259,7 @@ namespace gmm {
 # define dotc_p1_s(base_type)  \
 const scaled_vector_const_ref,base_type> _
 # define dotc_trans1_s(base_type)  \
- std::vector  =  \
- const_cast &>(*(linalg_origin(x_)));  \
+ const std::vector  = *(linalg_origin(x_));   \
  base_type a(x_.r)
 
 # define dotc_p2(base_type) const std::vector 
@@ -272,8 +267,7 @@ namespace gmm {
 # define dotc_p2_s(base_type)  \
 const scaled_vector_const_ref,base_type> _
 # define dotc_trans2_s(base_type)  \
- std::vector  =  \
- const_cast &>(*(linalg_origin(y_)));  \
+ const std::vector  = *(linalg_origin(y_));   \
  base_type b(gmm::conj(y_.r))
 
   dotc_interface(dotc_p1, dotc_trans1, (BLAS_S),
@@ -421,8 +415,7 @@ namespace gmm {
 # define axpy_p1_s(base_type)  \
 const scaled_vector_const_ref,base_type> _
 # define axpy_trans1_s(base_type)  \
- std::vector  =  \
- const_cast &>(*(linalg_origin(x_)));  \
+ const std::vector  = *(linalg_origin(x_));   \
  base_type a(x_.r)
 
   axpy_interface(axpy_p1, axpy_trans1, saxpy_, BLAS_S)
@@ -458,15 +451,15 @@ namespace gmm {
 # define gem_trans1_n(base_type) const char t = 'N'
 # define gem_p1_t(base_type)   \
  const transposed_col_ref *> _
-# define gem_trans1_t(base_type) dense_matrix  = \
- const_cast &>(*(linalg_origin(A_))); \
+# define gem_trans1_t(base_type) const dense_matrix  =\
+   *(linalg_origin(A_));   \
  const char t = 'T'
 # define 

[Getfem-commits] [getfem-commits] branch master updated: Only white space

2024-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 6e2e0c56 Only white space
6e2e0c56 is described below

commit 6e2e0c56e539843f079cb91c86c90745e698c9e4
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 25 11:17:24 2024 +0100

Only white space
---
 src/gmm/gmm_blas_interface.h   | 98 +-
 src/gmm/gmm_lapack_interface.h | 36 
 2 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 7ba97f4b..71663bdd 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -183,8 +183,8 @@ namespace gmm {
   /* * */
 
 # define nrm2_interface(blas_name, base_type) \
-  inline number_traits::magnitude_type\
-  vect_norm2(const std::vector ) {  \
+  inline number_traits::magnitude_type \
+  vect_norm2(const std::vector ) {   \
 GMMLAPACK_TRACE("nrm2_interface");\
 BLAS_INT inc(1), n(BLAS_INT(vect_size(x)));   \
 return blas_name(, [0], );\
@@ -200,8 +200,8 @@ namespace gmm {
   /* * */
 
 # define dot_interface(blas_name, base_type)   \
-  inline base_type vect_sp(const std::vector ,   \
-   const std::vector ) { \
+  inline base_type vect_sp(const std::vector ,\
+   const std::vector ) {  \
 GMMLAPACK_TRACE("dot_interface");  \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
 return blas_name(, [0], , [0], );\
@@ -258,19 +258,19 @@ namespace gmm {
 return mult1 mult2 blas_name(, [0], , [0], );\
   }
 
-# define dotc_p1(base_type) const std::vector 
+# define dotc_p1(base_type) const std::vector 
 # define dotc_trans1(base_type)
 # define dotc_p1_s(base_type)  \
-const scaled_vector_const_ref, base_type > _
+const scaled_vector_const_ref,base_type> _
 # define dotc_trans1_s(base_type)  \
  std::vector  =  \
  const_cast &>(*(linalg_origin(x_)));  \
  base_type a(x_.r)
 
-# define dotc_p2(base_type) const std::vector 
+# define dotc_p2(base_type) const std::vector 
 # define dotc_trans2(base_type)
 # define dotc_p2_s(base_type)  \
-const scaled_vector_const_ref, base_type > _
+const scaled_vector_const_ref,base_type> _
 # define dotc_trans2_s(base_type)  \
  std::vector  =  \
  const_cast &>(*(linalg_origin(y_)));  \
@@ -399,7 +399,7 @@ namespace gmm {
 
 
 # define axpy_interface(param1, trans1, blas_name, base_type)  \
-  inline void add(param1(base_type), std::vector ) { \
+  inline void add(param1(base_type), std::vector ) {  \
 GMMLAPACK_TRACE("axpy_interface"); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \
 if(n == 0) return; \
@@ -408,7 +408,7 @@ namespace gmm {
   }
 
 # define axpy2_interface(param1, trans1, blas_name, base_type) \
-  inline void add(param1(base_type), std::vector ) { \
+  inline void add(param1(base_type), std::vector ) {  \
 GMMLAPACK_TRACE("axpy_interface"); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \
 if(n == 0) return; \
@@ -416,10 +416,10 @@ namespace gmm {
 else blas_name(, , [0], , [0], );  \
   }
 
-# define axpy_p1(base_type) const std::vector 
+# define axpy_p1(base_type) const std::vector 
 # define axpy_trans1(base_type) base_type a(1)
 # define axpy_p1_s(base_type)  \
-const scaled_vector_const_ref, base_type > _
+const scaled_vector_const_ref,base_type> _
 # define axpy_trans1_s(base_type)  \
  std::vector  =  \
  const_cast &>(*(linalg_origin(x_)));  \
@@ -443,7 +443,7 @@ namespace gmm {
 # define gemv_interface(param1, trans1, param2, trans2, blas_name, \
 base_type, orien)  \
   inline void mult_add_spec(param1(base_type), param2(base_type),  \
-   

[Getfem-commits] [getfem-commits] branch master updated: Avoid nested macros

2024-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 66e40968 Avoid nested macros
66e40968 is described below

commit 66e40968bb8da5623d0a78e88a141970a5d70b28
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 25 09:09:29 2024 +0100

Avoid nested macros
---
 src/gmm/gmm_blas_interface.h | 100 ++-
 1 file changed, 41 insertions(+), 59 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index a81f7ab5..7ba97f4b 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -199,69 +199,51 @@ namespace gmm {
   /* vect_sp(x, y).*/
   /* * */
 
-# define dot_interface(param1, trans1, mult1, param2, trans2, mult2,   \
- blas_name, base_type) \
-  inline base_type vect_sp(param1(base_type), param2(base_type)) { \
+# define dot_interface(blas_name, base_type)   \
+  inline base_type vect_sp(const std::vector ,   \
+   const std::vector ) { \
 GMMLAPACK_TRACE("dot_interface");  \
-trans1(base_type); trans2(base_type);  \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
-return mult1 mult2 blas_name(, [0], , [0], );\
+return blas_name(, [0], , [0], );\
+  }\
+  inline base_type vect_sp \
+   (const scaled_vector_const_ref,base_type> _,   \
+const std::vector ) { \
+GMMLAPACK_TRACE("dot_interface");  \
+std::vector  =   \
+  const_cast &>(*(linalg_origin(x_))); \
+base_type a(x_.r); \
+BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
+return a* blas_name(, [0], , [0], ); \
+  }\
+  inline base_type vect_sp \
+(const std::vector ,  \
+ const scaled_vector_const_ref,base_type> _) {\
+GMMLAPACK_TRACE("dot_interface");  \
+std::vector  =   \
+  const_cast &>(*(linalg_origin(y_))); \
+base_type b(y_.r); \
+BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
+return b* blas_name(, [0], , [0], ); \
+  }\
+  inline base_type vect_sp \
+(const scaled_vector_const_ref,base_type> _,  \
+ const scaled_vector_const_ref,base_type> _) {\
+GMMLAPACK_TRACE("dot_interface");  \
+std::vector  =   \
+  const_cast &>(*(linalg_origin(x_))); \
+base_type a(x_.r); \
+std::vector  =   \
+  const_cast &>(*(linalg_origin(y_))); \
+base_type b(y_.r); \
+BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\
+return a* b* blas_name(, [0], , [0], );  \
   }
 
-# define dot_p1(base_type) const std::vector 
-# define dot_trans1(base_type)
-# define dot_p1_s(base_type)   \
-const scaled_vector_const_ref, base_type > _
-# define dot_trans1_s(base_type)   \
- std::vector  =  \
- const_cast &>(*(linalg_origin(x_)));  \
- base_type a(x_.r)
-
-# define dot_p2(base_type) const std::vector 
-# define dot_trans2(base_type)
-# define dot_p2_s(base_type)   \
-const scaled_vector_const_ref, base_type > _
-# define dot_trans2_s(base_type)   \
- std::vector  =  \
- const_cast &>(*(linalg_origin(y_)));  \
- base_type b(y_.r)
-
-  dot_interface(dot_p1, dot_trans1, (BLAS_S),
-dot_p2, dot_trans2, (BLAS_S), sdot_,  BLAS_S)
-  dot_interface(dot_p1, 

[Getfem-commits] [getfem-commits] branch master updated: Remove redundant macro arguments

2024-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 7c08587f Remove redundant macro arguments
7c08587f is described below

commit 7c08587f62b2b47c60cc30cc84706981c9db2f30
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 25 09:04:03 2024 +0100

Remove redundant macro arguments
---
 src/gmm/gmm_blas_interface.h | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index cc8fdee4..a81f7ab5 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -182,21 +182,18 @@ namespace gmm {
   /* vect_norm2(x).*/
   /* * */
 
-# define nrm2_interface(param1, trans1, blas_name, base_type)  \
-  inline number_traits::magnitude_type \
-  vect_norm2(param1(base_type)) {  \
-GMMLAPACK_TRACE("nrm2_interface"); \
-BLAS_INT inc(1), n(BLAS_INT(vect_size(x))); trans1(base_type); \
-return blas_name(, [0], ); \
+# define nrm2_interface(blas_name, base_type) \
+  inline number_traits::magnitude_type\
+  vect_norm2(const std::vector ) {  \
+GMMLAPACK_TRACE("nrm2_interface");\
+BLAS_INT inc(1), n(BLAS_INT(vect_size(x)));   \
+return blas_name(, [0], );\
   }
 
-# define nrm2_p1(base_type) const std::vector 
-# define nrm2_trans1(base_type)
-
-  nrm2_interface(nrm2_p1, nrm2_trans1, snrm2_,  BLAS_S)
-  nrm2_interface(nrm2_p1, nrm2_trans1, dnrm2_,  BLAS_D)
-  nrm2_interface(nrm2_p1, nrm2_trans1, scnrm2_, BLAS_C)
-  nrm2_interface(nrm2_p1, nrm2_trans1, dznrm2_, BLAS_Z)
+  nrm2_interface(snrm2_,  BLAS_S)
+  nrm2_interface(dnrm2_,  BLAS_D)
+  nrm2_interface(scnrm2_, BLAS_C)
+  nrm2_interface(dznrm2_, BLAS_Z)
 
   /* * */
   /* vect_sp(x, y).*/



[Getfem-commits] [getfem-commits] branch master updated: Simplify example script

2024-03-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 86286ae1 Simplify example script
86286ae1 is described below

commit 86286ae1de1fb43a59e564f64f9f190ca7a67933
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 21 14:20:39 2024 +0100

Simplify example script
---
 interface/tests/python/demo_laplacian.py | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/interface/tests/python/demo_laplacian.py 
b/interface/tests/python/demo_laplacian.py
index 84493754..df100283 100644
--- a/interface/tests/python/demo_laplacian.py
+++ b/interface/tests/python/demo_laplacian.py
@@ -34,10 +34,8 @@ import getfem as gf
 plot_result = False;
 
 if plot_result:
-  import vtk
-  from matplotlib.pyplot import figure
-  import matplotlib.pyplot as plt
   import meshio
+  import matplotlib.pyplot as plt
   from matplotlib import ticker
 
 ## Parameters
@@ -141,21 +139,21 @@ print('Error in H1 norm : ', H1error)
 
 # Export data
 sl4 = gf.Slice(("none",), mfu, 1)
-sl4.export_to_vtk('laplacian.vtk', "ascii", mfu, Ue,'Exact_solution', mfu, 
U,'Computed_solution')
+sl4.export_to_vtu('laplacian.vtu', "ascii", mfu, Ue, 'Exact_solution', mfu, 
U,'Computed_solution')
 print('You can view the solution with (for example):')
-print('Paraview laplacian.vtk')
+print('paraview laplacian.vtu')
 
 
 if plot_result:
-  reader = meshio.read('laplacian.vtk')
+  reader = meshio.read('laplacian.vtu')
   points = reader.points
   cells = reader.cells[0].data
   point_data = reader.point_data["Computed_solution"]
-  fig = figure(figsize=(7, 7))
+  fig = plt.figure(figsize=(7, 7))
   axes2 = fig.add_subplot(aspect="auto",projection='3d')
   axes2.triplot(points[:, 0], points[:, 1], cells, color="gray")
   contour = axes2.plot_trisurf(points[:, 0], points[:, 1],
-point_data[:,0], cmap="jet")
+point_data, cmap="jet")
   fig.colorbar(contour)
   axes2.view_init(30, 100)
   fig.tight_layout()
@@ -167,12 +165,6 @@ if plot_result:
   plt.show()
 
 
-
-
-
-
-
-
 if (H1error > 1e-3):
 print('Error too large !')
 exit(1)



[Getfem-commits] [getfem-commits] branch master updated: Remove unused class members

2024-03-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 1fbeda65 Remove unused class members
1fbeda65 is described below

commit 1fbeda651db11cb8f28d282a1ead869db41d3e7a
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 18 07:35:21 2024 +0100

Remove unused class members
---
 src/getfem/getfem_model_solvers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem/getfem_model_solvers.h 
b/src/getfem/getfem_model_solvers.h
index da570c01..5fcf943e 100644
--- a/src/getfem/getfem_model_solvers.h
+++ b/src/getfem/getfem_model_solvers.h
@@ -255,7 +255,7 @@ namespace getfem {
   struct quadratic_newton_line_search : public abstract_newton_line_search {
 double R0_, R1_;
 
-double alpha, alpha_mult, first_res, alpha_max_ratio, alpha_min;
+double alpha, first_res;
 virtual void init_search(double r, size_t git, double R0 = 0.0) {
   GMM_ASSERT1(R0 != 0.0, "You have to specify R0");
   glob_it = git;



[Getfem-commits] [getfem-commits] branch master updated: Fix issues with cmake builds

2024-03-11 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 99920d7b Fix issues with cmake builds
99920d7b is described below

commit 99920d7b5cbf020a795a8b2371b1b26b1acaf75e
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 11 13:40:09 2024 +0100

Fix issues with cmake builds
---
 CMakeLists.txt | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 184e9392..0f8694be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -461,7 +461,7 @@ if(ENABLE_SUPERLU)
 endif()
 if(ENABLE_MUMPS)
   target_include_directories(libgetfem PRIVATE ${MUMPS_INCLUDE_PATH})
-  target_link_libraries(libgetfem PRIVATE "${MUMPS_LIBS}")
+  target_link_libraries(libgetfem PUBLIC "${MUMPS_LIBS}")
 endif()
 
 if(NOT GETFEM_PARA_LEVEL MATCHES "^(0|1|2)$")
@@ -570,6 +570,9 @@ if(ENABLE_PYTHON)
 target_include_directories(libgetfemint PRIVATE ${CMAKE_BINARY_DIR})
 target_include_directories(libgetfemint PRIVATE ${CMAKE_SOURCE_DIR}/src)
 target_include_directories(libgetfemint PRIVATE 
${CMAKE_SOURCE_DIR}/interface/src)
+if(ENABLE_MUMPS)
+  target_include_directories(libgetfemint PRIVATE ${MUMPS_INCLUDE_PATH})
+endif()
 
 find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
 
@@ -589,6 +592,7 @@ if(ENABLE_PYTHON)
 $)
 target_include_directories(_getfem PRIVATE ${CMAKE_BINARY_DIR}/getfem)
 target_include_directories(_getfem PRIVATE 
${CMAKE_SOURCE_DIR}/interface/src)
+target_include_directories(_getfem PRIVATE ${Python3_NumPy_INCLUDE_DIRS})
 target_link_libraries(_getfem PRIVATE libgetfem)
 
 # find the installation directory for python libraries (ported from 
autotools)
@@ -600,6 +604,7 @@ print(sysconfig.get_path('purelib', scheme, vars={'base': 
'${CMAKE_INSTALL_PREFI
 message("Python3_SITEARCH = ${Python3_SITEARCH} (not used)")
 message("Python3_SITELIB = ${Python3_SITELIB} (not used)")
 message("PYTHON_SITE_PACKAGES = ${PYTHON_SITE_PACKAGES} (used)")
+message("Python3_NumPy_INCLUDE_DIRS = ${Python3_NumPy_INCLUDE_DIRS} 
(used)")
   endif()
 endif()
 
@@ -625,7 +630,7 @@ endif()
 # in the cmake build, BLAS and Lapack are hard requirements
 find_package(BLAS REQUIRED)
 find_package(LAPACK REQUIRED)
-target_link_libraries(libgetfem PRIVATE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
+target_link_libraries(libgetfem PUBLIC ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
 set(GMM_USES_BLAS 1)
 set(GMM_USES_LAPACK 1)
 



[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warning

2024-03-11 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 105e1626 Fix compilation warning
105e1626 is described below

commit 105e1626c8f03ad49eb3fcec53012c278f48294f
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 11 09:03:09 2024 +0100

Fix compilation warning
---
 contrib/crack_plate/crack_bilaplacian_problem.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/crack_plate/crack_bilaplacian_problem.cc 
b/contrib/crack_plate/crack_bilaplacian_problem.cc
index 13ad0a13..ff114914 100644
--- a/contrib/crack_plate/crack_bilaplacian_problem.cc
+++ b/contrib/crack_plate/crack_bilaplacian_problem.cc
@@ -1081,10 +1081,10 @@ bool bilaplacian_crack_problem::solve(plain_vector ) {
 plain_vector b = model.real_rhs();
 gmm::scale(b, -1.);
 plain_vector X(b);
-scalar_type condest;
 #if defined(GMM_USES_MUMPS)
 gmm::MUMPS_solve(A, X, gmm::scaled(b, scalar_type(-1)));
 #else
+scalar_type condest;
 gmm::SuperLU_solve(A, X, gmm::scaled(b, scalar_type(-1)), condest, 1);
 cout << "cond super LU = " << 1./condest << "\n";
 #endif



[Getfem-commits] [getfem-commits] master updated (e3372b14 -> 8921634b)

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

from e3372b14 Move function implementations from header to source file
 new 5ddd2b51 Improve compatibility with MSVC compiler
 new 8921634b Improve portability of auxiliary python script


Summary of changes:
 bin/extract_doc  | 34 +-
 interface/src/python/getfem_python.c |  7 +++
 2 files changed, 16 insertions(+), 25 deletions(-)



[Getfem-commits] (no subject)

2024-03-11 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 5ddd2b51f5bf0dc7086eadc2ae24230acfc11e8e
Author: Konstantinos Poulios 
AuthorDate: Fri Mar 8 00:16:50 2024 +0100

Improve compatibility with MSVC compiler
---
 interface/src/python/getfem_python.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/interface/src/python/getfem_python.c 
b/interface/src/python/getfem_python.c
index 0f5c6f5d..2a42e844 100644
--- a/interface/src/python/getfem_python.c
+++ b/interface/src/python/getfem_python.c
@@ -739,7 +739,11 @@ call_getfem_(PyObject *self, PyObject *args, int 
in__init__)
 result = Py_None; Py_INCREF(Py_None);
   } else if (out) {
 int i, err = 0;
+#if defined(_MSC_VER)
+PyObject **d = (PyObject **)malloc(out_cnt*sizeof(PyObject*));
+#else
 PyObject *d[out_cnt];
+#endif
 for (i = 0; i < out_cnt; ++i) {
   if (!err && !(d[i] = gfi_array_to_PyObject(out[i], in__init__)))
 err = 1;
@@ -753,6 +757,9 @@ call_getfem_(PyObject *self, PyObject *args, int in__init__)
 for (i = 0; i < out_cnt; ++i) PyTuple_SET_ITEM(result,i,d[i]);
   } else result = d[0];
 }
+#if defined(_MSC_VER)
+free(d);
+#endif
   }
 }
   }



[Getfem-commits] (no subject)

2024-03-11 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 8921634bf2c210f28eadebe0a7a202fd2be573c3
Author: Konstantinos Poulios 
AuthorDate: Mon Mar 11 09:01:59 2024 +0100

Improve portability of auxiliary python script
---
 bin/extract_doc | 34 +-
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/bin/extract_doc b/bin/extract_doc
index d444e652..fc41752a 100755
--- a/bin/extract_doc
+++ b/bin/extract_doc
@@ -30,6 +30,7 @@ import string
 import os
 import textwrap
 import sys
+import glob
 
 class ParseError(Exception):
 def __init__(self, value):
@@ -483,14 +484,9 @@ option = sys.argv[2]
 # List the filenames and extract object and command names.
 #
 
-fl = os.popen('(cd ' + directory + '; ls gf_*.cc)');
-lines = fl.readlines();
-a = fl.close()
-if (a) : # Windows
-fl = os.popen('((cd ' + directory + ') & (ls gf_*.cc))');
-lines = fl.readlines();
-a = fl.close()
-
+directory=os.path.abspath(directory)
+os.chdir(directory)
+lines = glob.glob('gf_*.cc')
 
 objects = set()
 objects.add('eltm');
@@ -519,19 +515,12 @@ commands = sorted(commands, key=cmp_to_key(cmpobj))
 
 if (option == 'pseudo_loc'):
 
-fl = os.popen('cd ' + directory + ' && ls gf_*.cc')
-
-for l in fl:
-l = l.strip()
+for l in glob.glob('gf_*.cc'):
 sys.stdout.write(l+' ')
 
 elif (option == 'pseudo_gen'):
 
-directory_abs=os.path.abspath(directory)
-fl = os.popen('ls ' + directory_abs+'/gf_*.cc')
-
-for l in fl:
-l = l.strip()
+for l in glob.glob(directory+'/gf_*.cc'):
 sys.stdout.write(l+' ')
 
 elif (option == 'mobj_dirs'):
@@ -541,19 +530,14 @@ elif (option == 'mobj_dirs'):
 sys.stdout.write('@gf'+oname+' ')
 
 elif (option == 'cubature'):
-directory_abs=os.path.abspath(directory+'/../../cubature')
-fl = os.popen('ls ' + directory_abs+'/*.IM')
 
-for l in fl:
-l = l.strip()
+for l in glob.glob(os.path.abspath(directory+'/../../cubature/*.IM')):
 sys.stdout.write(l+' ')
 
 elif (option == 'cubature_loc'):
-directory_abs=os.path.abspath(directory+'/../../cubature')
-fl = os.popen('cd ' + directory_abs + ' && ls *.IM')
 
-for l in fl:
-l = l.strip()
+os.chdir(os.path.abspath(directory+'/../../cubature'))
+for l in glob.glob('*.IM'):
 sys.stdout.write(l+' ')
 
 



[Getfem-commits] (no subject)

2024-03-07 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 25aa8df02ca1cc95c967e33b137eecba41582a7e
Author: Konstantinos Poulios 
AuthorDate: Fri Mar 8 00:13:15 2024 +0100

Whitespace
---
 src/getfem_mesh_slicers.cc | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/getfem_mesh_slicers.cc b/src/getfem_mesh_slicers.cc
index cdc6a409..e636dc4b 100644
--- a/src/getfem_mesh_slicers.cc
+++ b/src/getfem_mesh_slicers.cc
@@ -657,12 +657,12 @@ namespace getfem {
   }
 
   void mesh_slicer::exec(const std::vector ,
-const mesh_region& cvlst) {
+ const mesh_region& cvlst) {
 exec_([0], 1, cvlst);
   }
 
   static bool check_orient(size_type cv, bgeot::pgeometric_trans pgt,
-  const mesh& m) {
+   const mesh& m) {
 if (pgt->dim() == m.dim() && m.dim()>=2) { /* no orient check for 
   convexes of lower dim */
   base_matrix G; bgeot::vectors_to_base_matrix(G,m.points_of_convex(cv));
@@ -681,7 +681,7 @@ namespace getfem {
 
 #if OLD_MESH_SLICER
   void mesh_slicer::exec_(const short_type *pnrefine, int nref_stride,
- const mesh_region& cvlst) {
+  const mesh_region& cvlst) {
 std::vector cvm_pts;
 const bgeot::basic_mesh *cvm = 0;
 const bgeot::mesh_structure *cvms = 0;
@@ -835,7 +835,7 @@ namespace getfem {
   /* update structure-dependent data */
   /* TODO : fix levelset handling when slicing faces .. */
   if (prev_cvr != cvr || nrefine != prev_nrefine
- || discont || prev_discont) {
+  || discont || prev_discont) {
 if (discont) {
   cvm = _simplex_mesh_for_convex_cut_by_level_set
 (mls->mesh_of_convex(cv), unsigned(nrefine));
@@ -851,7 +851,7 @@ namespace getfem {
   if (face < dim_type(-1)) {
 if (!discont) {
   cvms = bgeot::refined_simplex_mesh_for_convex_faces
-   (cvr, short_type(nrefine))[face].get();
+(cvr, short_type(nrefine))[face].get();
 } else {
   cvms = _simplex_mesh_for_convex_faces_cut_by_level_set(face);
 }



[Getfem-commits] [getfem-commits] master updated (ebeaddb0 -> e3372b14)

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

from ebeaddb0 Fix test runs
 new 25aa8df0 Whitespace
 new e3372b14 Move function implementations from header to source file


Summary of changes:
 src/getfem/getfem_mesh_slicers.h |  81 +++-
 src/getfem_mesh_slicers.cc   | 112 ---
 2 files changed, 114 insertions(+), 79 deletions(-)



[Getfem-commits] (no subject)

2024-03-07 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit e3372b14e48bb32d6271f6c4658799a922968712
Author: Konstantinos Poulios 
AuthorDate: Fri Mar 8 00:14:06 2024 +0100

Move function implementations from header to source file
---
 src/getfem/getfem_mesh_slicers.h |  81 +++
 src/getfem_mesh_slicers.cc   | 102 ++-
 2 files changed, 109 insertions(+), 74 deletions(-)

diff --git a/src/getfem/getfem_mesh_slicers.h b/src/getfem/getfem_mesh_slicers.h
index e69e7078..d8f613e3 100644
--- a/src/getfem/getfem_mesh_slicers.h
+++ b/src/getfem/getfem_mesh_slicers.h
@@ -324,14 +324,7 @@ namespace getfem {
 slicer_volume(int orient_) : orient(orient_) {}
 
 /** Utility function */
-static scalar_type trinom(scalar_type a, scalar_type b, scalar_type c) {
-  scalar_type delta = b*b - 4*a*c;
-  if (delta < 0.) return 1./EPS;
-  delta = sqrt(delta);
-  scalar_type s1 = (-b - delta) / (2*a);
-  scalar_type s2 = (-b + delta) / (2*a);
-  if (gmm::abs(s1-.5) < gmm::abs(s2-.5)) return s1; else return s2;
-}
+static scalar_type trinom(scalar_type a, scalar_type b, scalar_type c);
 void split_simplex(mesh_slicer ,
slice_simplex s, /* s is NOT a reference, it is on
  * purpose(push_back in the function)*/
@@ -346,22 +339,9 @@ namespace getfem {
   */
   class slicer_half_space : public slicer_volume {
 const base_node x0, n; /* normal directed from inside toward outside */
-void test_point(const base_node& P, bool& in, bool& bound) const {
-  scalar_type s = gmm::vect_sp(P-x0,n);
-  in = (s <= 0); bound = (s*s <= EPS); // gmm::vect_norm2_sqr(P-x0)); No!
-  // do not try to be smart with the boundary check .. easily broken with
-  // slicer_mesh_with_mesh
-}
+void test_point(const base_node& P, bool& in, bool& bound) const;
 scalar_type edge_intersect(size_type iA, size_type iB,
-   const mesh_slicer::cs_nodes_ct& nodes) const {
-  const base_node& A=nodes[iA].pt;
-  const base_node& B=nodes[iB].pt;
-  scalar_type s1 = 0., s2 = 0.;
-  for (unsigned i=0; i < A.size(); ++i)
-{ s1 += (A[i] - B[i])*n[i]; s2 += (A[i]-x0[i])*n[i]; }
-  if (gmm::abs(s1) < EPS) return 1./EPS;
-  else return s2/s1;
-}
+   const mesh_slicer::cs_nodes_ct& nodes) const;
   public:
 slicer_half_space(base_node x0_, base_node n_, int orient_) : 
   slicer_volume(orient_), x0(x0_), n(n_/gmm::vect_norm2(n_)) {
@@ -375,22 +355,9 @@ namespace getfem {
   class slicer_sphere : public slicer_volume {
 base_node x0;
 scalar_type R;
-void test_point(const base_node& P, bool& in, bool& bound) const {
-  scalar_type R2 = gmm::vect_dist2_sqr(P,x0);
-  bound = (R2 >= (1-EPS)*R*R && R2 <= (1+EPS)*R*R);
-  in = R2 <= R*R;
-}
+void test_point(const base_node& P, bool& in, bool& bound) const;
 scalar_type edge_intersect(size_type iA, size_type iB,
-   const mesh_slicer::cs_nodes_ct& nodes) const {
-  const base_node& A=nodes[iA].pt;
-  const base_node& B=nodes[iB].pt;
-  scalar_type a,b,c; // a*x^2 + b*x + c = 0
-  a = gmm::vect_norm2_sqr(B-A);
-  if (a < EPS) return pt_bin.is_in(iA) ? 0. : 1./EPS;
-  b = 2*gmm::vect_sp(A-x0,B-A);
-  c = gmm::vect_norm2_sqr(A-x0)-R*R;
-  return slicer_volume::trinom(a,b,c);
-}
+   const mesh_slicer::cs_nodes_ct& nodes) const;
   public:
 /* orient = -1 => select interior, 
orient = 0  => select boundary 
@@ -406,35 +373,9 @@ namespace getfem {
   class slicer_cylinder : public slicer_volume {
 base_node x0, d;
 scalar_type R;
-void test_point(const base_node& P, bool& in, bool& bound) const {
-  base_node N = P;
-  if (2 == N.size()) { /* Add Z coorinate if mesh is 2D */
-N.push_back(0.0);
-  }
-  N = N-x0;
-  scalar_type axpos = gmm::vect_sp(d, N);
-  scalar_type dist2 = gmm::vect_norm2_sqr(N) - gmm::sqr(axpos);
-  bound = gmm::abs(dist2-R*R) < EPS;
-  in = dist2 < R*R;
-}
+void test_point(const base_node& P, bool& in, bool& bound) const;
 scalar_type edge_intersect(size_type iA, size_type iB,
-   const mesh_slicer::cs_nodes_ct& nodes) const {
-  base_node F=nodes[iA].pt;
-  base_node D=nodes[iB].pt-nodes[iA].pt;
-  if (2 == F.size()) {
-F.push_back(0.0);
-D.push_back(0.0);
-  }
-  F = F - x0;
-  scalar_type Fd = gmm::vect_sp(F,d);
-  scalar_type Dd = gmm::vect_sp(D,d);
-  scalar_type a = gmm::vect_norm2_sqr(D) - gmm::sqr(Dd);
-  if (a < EPS) return pt_bin.is_in(iA) ? 0. : 1./EPS;
-  assert(a> -EPS);
-  scalar_type b = 2*(gmm::vect_sp(F,D) - Fd*Dd);
-  scalar_type c = gmm::vect_norm2_sqr(F) - gmm::sqr(Fd) - gmm::sqr(R);
-  return slicer_volume::trinom(a,b,c);
-}
+  

[Getfem-commits] [getfem-commits] branch master updated: Fix test runs

2024-03-07 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 ebeaddb0 Fix test runs
ebeaddb0 is described below

commit ebeaddb0ef5e65cdd41532ac38671696c03d437c
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 18:55:54 2024 +0100

Fix test runs
---
 interface/tests/python/Makefile.am | 2 +-
 tests/make_gmm_test.pl | 6 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/interface/tests/python/Makefile.am 
b/interface/tests/python/Makefile.am
index 753c59aa..6e7f1306 100644
--- a/interface/tests/python/Makefile.am
+++ b/interface/tests/python/Makefile.am
@@ -84,7 +84,7 @@ TESTS =   \
$(optpy)
 
 AM_TESTS_ENVIRONMENT = \
-   export PYTHONPATH=$(top_builddir)/interface/src/python; \
+   export PYTHONPATH=$(PYTHONPATH):$(top_builddir)/interface/src/python; \
export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(top_builddir)/src/.libs;
 LOG_COMPILER = $(PYTHON)
 endif
diff --git a/tests/make_gmm_test.pl b/tests/make_gmm_test.pl
index f469c5da..313a2fdc 100755
--- a/tests/make_gmm_test.pl
+++ b/tests/make_gmm_test.pl
@@ -336,8 +336,12 @@ for ($iter = 1; $iter <= $nb_iter; ++$iter) {
 $compilo=`sh ../gmm-config --cxx` || die('cannot execute ../gmm-config 
--cxx'); chomp($compilo);
 $compile_options=`sh ../gmm-config --build-flags`;
 chomp($compile_options);
+$compile_options=$compile_options . " " . `sh ../gmm-config --cflags`;
+chomp($compile_options);
 $compile_options="$compile_options -I$srcdir/../src -I$srcdir/../include 
-I../src -I../include";
-$compile_libs=`sh ../gmm-config --libs`;
+$compile_libs=`sh ../gmm-config --build-libs`;
+chomp($compile_libs);
+$compile_libs=$compile_libs . " " . `sh ../gmm-config --libs`;
 if ($with_qd) { $compile_libs="-lqd $compile_libs"; }
 #   print "$compilo $compile_options $dest_name -o $root_name $compile_libs\n";
 print `$compilo $compile_options $dest_name -o $root_name $compile_libs`;



[Getfem-commits] [getfem-commits] branch master updated: Fix test case (second try)

2024-03-07 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 5b848f84 Fix test case (second try)
5b848f84 is described below

commit 5b848f84736d9c067752856ca5e802040c232520
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 10:44:03 2024 +0100

Fix test case (second try)
---
 tests/test_small_vector.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test_small_vector.cc b/tests/test_small_vector.cc
index d31a7f10..42c6930a 100644
--- a/tests/test_small_vector.cc
+++ b/tests/test_small_vector.cc
@@ -750,7 +750,7 @@ namespace getfem {
   hop2 >();
   hop >();   
 }
-bgeot::static_block_allocator::>memstats();
+bgeot::static_block_allocator().memstats();
 for (size_type i=0; i < 5; ++i) {
   hop2 >();
   //hop2 >();
@@ -759,7 +759,7 @@ namespace getfem {
   hop2 >();
   hop >(); 
 }
-test::static_block_allocator::alloc.memstats();
+test::static_block_allocator().memstats();
   }
   */
 
@@ -781,7 +781,7 @@ namespace getfem {
 //rrun(mv);
 rrun(Sv);
 //rrun(av);
-bgeot::static_block_allocator::memstats();
+bgeot::static_block_allocator().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 master updated: Fix test broken by last commit

2024-03-07 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 77091caf Fix test broken by last commit
77091caf is described below

commit 77091caf6df652137d83507c85421c7b3af855c7
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 10:36:10 2024 +0100

Fix test broken by last commit
---
 tests/test_small_vector.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tests/test_small_vector.cc b/tests/test_small_vector.cc
index cf5289a0..d31a7f10 100644
--- a/tests/test_small_vector.cc
+++ b/tests/test_small_vector.cc
@@ -750,7 +750,7 @@ namespace getfem {
   hop2 >();
   hop >();   
 }
-bgeot::static_block_allocator::palloc->memstats();
+bgeot::static_block_allocator::>memstats();
 for (size_type i=0; i < 5; ++i) {
   hop2 >();
   //hop2 >();
@@ -781,8 +781,7 @@ namespace getfem {
 //rrun(mv);
 rrun(Sv);
 //rrun(av);
-if (bgeot::static_block_allocator::palloc)
-  bgeot::static_block_allocator::palloc->memstats();
+bgeot::static_block_allocator::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 master updated: Do not expose static member variable outside the compilation unit

2024-03-07 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 0d311bf4 Do not expose static member variable outside the compilation 
unit
0d311bf4 is described below

commit 0d311bf45bb9bf5b8f430f01c1b6199dc520da48
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 10:16:12 2024 +0100

Do not expose static member variable outside the compilation unit
---
 src/bgeot_small_vector.cc   | 18 +-
 src/getfem/bgeot_small_vector.h | 11 +++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/bgeot_small_vector.cc b/src/bgeot_small_vector.cc
index e0a582d0..7cb75108 100644
--- a/src/bgeot_small_vector.cc
+++ b/src/bgeot_small_vector.cc
@@ -23,6 +23,22 @@
 namespace bgeot { 
   block_allocator *static_block_allocator::palloc = 0;
 
+  static_block_allocator::static_block_allocator() {
+if (!palloc) palloc = ::singleton::instance();
+  }
+  void static_block_allocator::memstats() {
+  if (palloc) palloc->memstats();
+  }
+  block_allocator& static_block_allocator::allocator() const {
+return *palloc;
+  }
+  bool static_block_allocator::allocator_destroyed() const {
+return palloc == 0;
+  }
+  void static_block_allocator::destroy() {
+palloc = 0;
+  }
+
   block_allocator::block_allocator() {
 for (size_type i=0; i < OBJ_SIZE_LIMIT; ++i) 
   first_unfilled[i] = i ? size_type(-1) : 0; 
@@ -32,7 +48,7 @@ namespace bgeot {
   block_allocator::~block_allocator() {
 for (size_type i=0; i < blocks.size(); ++i) 
   if (!blocks[i].empty()) blocks[i].clear();
-static_block_allocator::palloc = 0;
+static_block_allocator().destroy();
   }
   block_allocator::node_id 
block_allocator::allocate(block_allocator::size_type n) {
 if (n == 0) return 0;
diff --git a/src/getfem/bgeot_small_vector.h b/src/getfem/bgeot_small_vector.h
index e0aa95ad..95be0a6b 100644
--- a/src/getfem/bgeot_small_vector.h
+++ b/src/getfem/bgeot_small_vector.h
@@ -147,11 +147,16 @@ namespace bgeot {
   };
 
   /* common class for all mini_vec, provides access to the common static 
allocator */
-  struct APIDECL static_block_allocator {
+  class APIDECL static_block_allocator {
 /* 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(); }
+  public:
+static_block_allocator();
+void memstats();
+block_allocator& allocator() const;
+bool allocator_destroyed() const;
+void destroy();
   };
 
 #ifdef GETFEM_HAS_OPENMP
@@ -329,8 +334,6 @@ namespace bgeot {
 const_pointer const_base() const {
   SVEC_ASSERT(id == 0 || refcnt()); return 
static_cast(allocator().obj_data(id));
 }
-block_allocator& allocator() const { return *palloc; }
-bool allocator_destroyed() const { return palloc == 0; }
 node_id allocate(size_type n) {
   return 
node_id(allocator().allocate(gmm::uint32_type(n*sizeof(value_type; 
SVEC_ASSERT(refcnt() == 1);
 }



[Getfem-commits] [getfem-commits] branch master updated: Fix mistake in cmake file

2024-03-07 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 6824fbf6 Fix mistake in cmake file
6824fbf6 is described below

commit 6824fbf6410eabc2e7282317261805c57c37a121
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 10:04:03 2024 +0100

Fix mistake in cmake file
---
 CMakeLists.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d33dc58..184e9392 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -646,7 +646,7 @@ else()
   message("Building with Qhull explicitly disabled")
 endif()
 
-if(ENABLE_MULTITHREADED_BLAS)
+if(NOT ENABLE_MULTITHREADED_BLAS)
   find_library(DL_LIB NAMES dl)
   set(CMAKE_REQUIRED_LIBRARIES ${DL_LIB})
 check_library_exists(dl dlsym "" HAVE_DLSYM)
@@ -655,9 +655,9 @@ if(ENABLE_MULTITHREADED_BLAS)
 target_link_libraries(libgetfem PRIVATE ${DL_LIB})
   else()
 message(FATAL_ERROR
-"Could not find dlsym function required for enabling multithreaded 
BLAS")
+"Could not find dlsym function required for forcing singlethreaded 
BLAS")
   endif()
-else() # single threaded blas by default
+  # single threaded blas by default
   set(GETFEM_FORCE_SINGLE_THREAD_BLAS 1)
 endif()
 



[Getfem-commits] [getfem-commits] branch master updated: Remove strict requirement for MSVC flag

2024-03-07 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 0ac615a1 Remove strict requirement for MSVC flag
0ac615a1 is described below

commit 0ac615a12c0fe19fa112e7c430fce7f357c4e3ed
Author: Konstantinos Poulios 
AuthorDate: Thu Mar 7 09:23:38 2024 +0100

Remove strict requirement for MSVC flag
---
 src/gmm/gmm_std.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gmm/gmm_std.h b/src/gmm/gmm_std.h
index 6ed41a32..3a2e4b13 100644
--- a/src/gmm/gmm_std.h
+++ b/src/gmm/gmm_std.h
@@ -60,9 +60,6 @@
 # define SECURE_SPRINTF2(S, l, st, p1, p2) sprintf_s(S, l, st, p1, p2)
 # define SECURE_SPRINTF4(S, l, st, p1, p2, p3, p4) sprintf_s(S, l, st, p1, p2, 
p3, p4)
 # define SECURE_STRDUP(s) _strdup(s)
-# ifndef _SCL_SECURE_NO_DEPRECATE
-#   error Add the option /D_SCL_SECURE_NO_DEPRECATE to the compilation command
-# endif
 #else
 # define SECURE_NONCHAR_SSCANF sscanf
 # define SECURE_NONCHAR_FSCANF fscanf
@@ -313,6 +310,12 @@ typedef fixed_size_integer_generator<8>::uint_base_type 
uint64_type;
 # define ALWAYS_INLINE
 #endif
 
+#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
+# define NOINLINE __declspec(noinline)
+#elif defined(__GNUC__) && !defined(__ICC)
+# define NOINLINE __attribute__((noinline))
+#endif
+
 }
 
   /*  */



[Getfem-commits] [getfem-commits] branch master updated: Fix incompatibility with MSVC compiler

2024-03-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 98fe5824 Fix incompatibility with MSVC compiler
98fe5824 is described below

commit 98fe582480409c471a5e950089ca92fa62dd66fc
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 6 23:55:01 2024 +0100

Fix incompatibility with MSVC compiler
---
 src/getfem/getfem_global_function.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/getfem/getfem_global_function.h 
b/src/getfem/getfem_global_function.h
index b07434e9..e40ea564 100644
--- a/src/getfem/getfem_global_function.h
+++ b/src/getfem/getfem_global_function.h
@@ -202,7 +202,8 @@ namespace getfem {
   /** below a list of simple functions of (x,y)
   used for building the crack singular functions
   */
-  struct abstract_xy_function : virtual public dal::static_stored_object {
+  class abstract_xy_function : virtual public dal::static_stored_object {
+  public:
 virtual scalar_type val(scalar_type x, scalar_type y) const = 0;
 virtual base_small_vector grad(scalar_type x, scalar_type y) const = 0;
 virtual base_matrix hess(scalar_type x, scalar_type y) const = 0;



[Getfem-commits] [getfem-commits] branch master updated: Fix mumps linking issue when building with cmake

2024-03-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 c1cd6267 Fix mumps linking issue when building with cmake
c1cd6267 is described below

commit c1cd62672d95c9e2546378110b57e3ab745bb026
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 6 23:54:12 2024 +0100

Fix mumps linking issue when building with cmake
---
 CMakeLists.txt | 61 +-
 1 file changed, 39 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c31e2ef..6d33dc58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,39 +106,56 @@ if(ENABLE_MUMPS)
   set(MUMPS_LIBS "")
   if(GETFEM_PARA_LEVEL LESS_EQUAL 1) # try to find "?mumps_seq" named libs 
first
 if(NOT BUILD_SHARED_LIBS)
-  find_library(SMUMPS_STATIC_LIB NAMES libsmumps_seq.a PATHS 
${MUMPS_LIB_DIR})
-  find_library(DMUMPS_STATIC_LIB NAMES libdmumps_seq.a PATHS 
${MUMPS_LIB_DIR})
-  find_library(CMUMPS_STATIC_LIB NAMES libcmumps_seq.a PATHS 
${MUMPS_LIB_DIR})
-  find_library(ZMUMPS_STATIC_LIB NAMES libzmumps_seq.a PATHS 
${MUMPS_LIB_DIR})
+  find_library(SMUMPS_STATIC_LIB NAMES libsmumps_seq.a libsmumps.a 
smumps.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(DMUMPS_STATIC_LIB NAMES libdmumps_seq.a libdmumps.a 
dmumps.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(CMUMPS_STATIC_LIB NAMES libcmumps_seq.a libcmumps.a 
cmumps.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(ZMUMPS_STATIC_LIB NAMES libzmumps_seq.a libzmumps.a 
zmumps.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(MUMPS_COMMON_STATIC_LIB NAMES libmumps_common.a  
mumps_common.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(PORD_STATIC_LIB NAMES libpord.a pord.lib PATHS 
${MUMPS_LIB_DIR})
+  find_library(MPISEQ_STATIC_LIB NAMES libmpiseq.a libmpiseq_seq.a 
mpiseq.lib PATHS ${MUMPS_LIB_DIR})
 endif()
-if(SMUMPS_STATIC_LIB AND DMUMPS_STATIC_LIB AND CMUMPS_STATIC_LIB AND 
ZMUMPS_STATIC_LIB)
-  set(MUMPS_LIBS ${SMUMPS_STATIC_LIB} ${DMUMPS_STATIC_LIB} 
${CMUMPS_STATIC_LIB} ${ZMUMPS_STATIC_LIB})
+if(SMUMPS_STATIC_LIB AND DMUMPS_STATIC_LIB AND CMUMPS_STATIC_LIB AND 
ZMUMPS_STATIC_LIB
+   AND MUMPS_COMMON_STATIC_LIB AND PORD_STATIC_LIB AND MPISEQ_STATIC_LIB)
+  set(MUMPS_LIBS ${SMUMPS_STATIC_LIB} ${DMUMPS_STATIC_LIB} 
${CMUMPS_STATIC_LIB} ${ZMUMPS_STATIC_LIB}
+ ${MUMPS_COMMON_STATIC_LIB} ${PORD_STATIC_LIB} 
${MPISEQ_STATIC_LIB})
 else()
-  find_library(SMUMPS_LIB NAMES smumps_seq PATHS ${MUMPS_LIB_DIR})
-  find_library(DMUMPS_LIB NAMES dmumps_seq PATHS ${MUMPS_LIB_DIR})
-  find_library(CMUMPS_LIB NAMES cmumps_seq PATHS ${MUMPS_LIB_DIR})
-  find_library(ZMUMPS_LIB NAMES zmumps_seq PATHS ${MUMPS_LIB_DIR})
-  if (SMUMPS_LIB AND DMUMPS_LIB AND CMUMPS_LIB AND ZMUMPS_LIB)
-set(MUMPS_LIBS ${SMUMPS_LIB} ${DMUMPS_LIB} ${CMUMPS_LIB} ${ZMUMPS_LIB})
+  find_library(SMUMPS_LIB NAMES smumps_seq smumps PATHS ${MUMPS_LIB_DIR})
+  find_library(DMUMPS_LIB NAMES dmumps_seq dmumps PATHS ${MUMPS_LIB_DIR})
+  find_library(CMUMPS_LIB NAMES cmumps_seq cmumps PATHS ${MUMPS_LIB_DIR})
+  find_library(ZMUMPS_LIB NAMES zmumps_seq zmumps PATHS ${MUMPS_LIB_DIR})
+  find_library(MUMPS_COMMON_LIB NAMES mumps_common PATHS ${MUMPS_LIB_DIR})
+  find_library(PORD_LIB NAMES pord PATHS ${MUMPS_LIB_DIR})
+  find_library(MPISEQ_LIB NAMES mpiseq mpiseq_seq PATHS ${MUMPS_LIB_DIR})
+  if (SMUMPS_LIB AND DMUMPS_LIB AND CMUMPS_LIB AND ZMUMPS_LIB
+  AND MUMPS_COMMON_LIB AND PORD_LIB AND MPISEQ_LIB)
+set(MUMPS_LIBS ${SMUMPS_LIB} ${DMUMPS_LIB} ${CMUMPS_LIB} ${ZMUMPS_LIB}
+   ${MUMPS_COMMON_LIB} ${PORD_LIB} ${MPISEQ_LIB})
   endif()
 endif()
-  endif()
-  if("${MUMPS_LIBS}" STREQUAL "") # try to find "?mumps" named libs
+  else() # GETFEM_PARA_LEVEL = 2
 if(NOT BUILD_SHARED_LIBS)
-  find_library(SMUMPS_STATIC_LIB NAMES libsmumps.a PATHS ${MUMPS_LIB_DIR})
-  find_library(DMUMPS_STATIC_LIB NAMES libdmumps.a PATHS ${MUMPS_LIB_DIR})
-  find_library(CMUMPS_STATIC_LIB NAMES libcmumps.a PATHS ${MUMPS_LIB_DIR})
-  find_library(ZMUMPS_STATIC_LIB NAMES libzmumps.a PATHS ${MUMPS_LIB_DIR})
+  find_library(SMUMPS_STATIC_LIB NAMES libsmumps.a smumps.lib PATHS 
${MUMPS_LIB_DIR})
+  find_library(DMUMPS_STATIC_LIB NAMES libdmumps.a dmumps.lib PATHS 
${MUMPS_LIB_DIR})
+  find_library(CMUMPS_STATIC_LIB NAMES libcmumps.a cmumps.lib PATHS 
${MUMPS_LIB_DIR})
+  find_library(ZMUMPS_STATIC_LIB NAMES libzmumps.a zmumps.lib PATHS 
${MUMPS_LIB_DIR})
+  find_library(MUMPS_COMMON_STATIC_LIB NAMES libmumps_common.a 
mumps_common.lib PATHS ${MUMPS_LIB_DIR})
+  find_library(PORD_STATIC_LIB NAMES libpord.a pord.lib PATHS 
${MUMPS_LIB_DIR})
 endif()
-if(SMUMPS_STATIC_LIB AND DMUMPS_STATIC_LIB AND CMUMPS_STATIC_LIB AND 
ZMUMPS_STATIC_LIB)
-  

[Getfem-commits] [getfem-commits] branch master updated: Make perl a soft build dependency with cmake

2024-03-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 98e03c6e Make perl a soft build dependency with cmake
98e03c6e is described below

commit 98e03c6e5e53ed236a0328bc98a730b06d7d264c
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 6 23:53:20 2024 +0100

Make perl a soft build dependency with cmake
---
 CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac5a9e12..8c31e2ef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,7 @@ option(ENABLE_SUPERLU "Enable SuperLU support" ON) # might be 
turned off by cmak
 option(ENABLE_MUMPS "Enable MUMPS support" ON) # might be turned off by 
cmake if MUMPS is not found
 # Configure option for enabling/disabling multithreaded BLAS (requires the dl 
library)
 option(ENABLE_MULTITHREADED_BLAS "Enable multithreaded blas support" OFF)
+option(GENERATE_GETFEM_IM_LIST_H "Run perl script that (re-)generates header 
file with integration methods" ON)
 
 option(BUILD_SHARED_LIBS "Build libraries as SHARED, equivalent to 
BUILD_LIBRARY_TYPE=SHARED" ON)
 set(BUILD_LIBRARY_TYPE "SHARED" CACHE STRING
@@ -662,11 +663,13 @@ message(STATUS "GetFEM version ${GETFEM_VERSION}")
 configure_file(cmake/gmm_arch_config.h.in 
${CMAKE_BINARY_DIR}/gmm/gmm_arch_config.h)
 configure_file(cmake/getfem_arch_config.h.in 
${CMAKE_BINARY_DIR}/getfem/getfem_arch_config.h)
 
+if(GENERATE_GETFEM_IM_LIST_H)
 add_custom_command(
   OUTPUT ${CMAKE_SOURCE_DIR}/src/getfem/getfem_im_list.h
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/getfem/
   COMMAND perl ${CMAKE_SOURCE_DIR}/cubature/make_getfem_im_list 
${CMAKE_SOURCE_DIR}/cubature
   COMMENT "Generating getfem_im_list.h")
+endif()
 
 install(TARGETS libgetfem
 FILE_SET header_set1



[Getfem-commits] [getfem-commits] branch master updated: Whitespace and typo fixes

2024-03-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 5627f987 Whitespace and typo fixes
5627f987 is described below

commit 5627f987bc593d6eda7dd1f876f7798501132297
Author: Konstantinos Poulios 
AuthorDate: Wed Mar 6 23:28:38 2024 +0100

Whitespace and typo fixes
---
 CMakeLists.txt  |  2 +-
 interface/src/gf_global_function.cc | 36 ++--
 src/getfem_fem.cc   |  4 ++--
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ff2cdd8..ac5a9e12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,7 @@ option(ENABLE_MUMPS "Enable MUMPS support" ON) # might be 
turned off by cmak
 # Configure option for enabling/disabling multithreaded BLAS (requires the dl 
library)
 option(ENABLE_MULTITHREADED_BLAS "Enable multithreaded blas support" OFF)
 
-option(BUILD_SHARED_LIBS "Build libraries as SHARED, equivalent to 
BUILD_LYBRARY_TYPE=SHARED" ON)
+option(BUILD_SHARED_LIBS "Build libraries as SHARED, equivalent to 
BUILD_LIBRARY_TYPE=SHARED" ON)
 set(BUILD_LIBRARY_TYPE "SHARED" CACHE STRING
 "Type of library to build, choose among SHARED, STATIC, 
STATIC_BUNDLE_DEPS")
 set_property(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS
diff --git a/interface/src/gf_global_function.cc 
b/interface/src/gf_global_function.cc
index 6181c998..202023c0 100644
--- a/interface/src/gf_global_function.cc
+++ b/interface/src/gf_global_function.cc
@@ -42,8 +42,8 @@ using namespace getfemint;
 struct sub_gf_globfunc : virtual public dal::static_stored_object {
   int arg_in_min, arg_in_max, arg_out_min, arg_out_max;
   virtual void run(getfemint::mexargs_in& in,
-  getfemint::mexargs_out& out,
-  getfem::pxy_function ) = 0;
+   getfemint::mexargs_out& out,
+   getfem::pxy_function ) = 0;
 };
 
 typedef std::shared_ptr psub_command;
@@ -52,21 +52,21 @@ typedef std::shared_ptr psub_command;
 template  static inline void dummy_func(T &) {}
 
 #define sub_command(name, arginmin, arginmax, argoutmin, argoutmax, code) { \
-struct subc : public sub_gf_globfunc { \
-  virtual void run(getfemint::mexargs_in& in,  \
-  getfemint::mexargs_out& out, \
-  getfem::pxy_function )   \
-  { dummy_func(in); dummy_func(out); code }
\
-}; \
-psub_command psubc = std::make_shared(); \
-psubc->arg_in_min = arginmin; psubc->arg_in_max = arginmax;
\
-psubc->arg_out_min = argoutmin; psubc->arg_out_max = argoutmax;\
-subc_tab[cmd_normalize(name)] = psubc; \
+struct subc : public sub_gf_globfunc {  \
+  virtual void run(getfemint::mexargs_in& in,   \
+   getfemint::mexargs_out& out, \
+   getfem::pxy_function )   \
+  { dummy_func(in); dummy_func(out); code } \
+};  \
+psub_command psubc = std::make_shared();  \
+psubc->arg_in_min = arginmin; psubc->arg_in_max = arginmax; \
+psubc->arg_out_min = argoutmin; psubc->arg_out_max = argoutmax; \
+subc_tab[cmd_normalize(name)] = psubc;  \
   }
 
 
 void gf_global_function(getfemint::mexargs_in& m_in,
-   getfemint::mexargs_out& m_out) {
+getfemint::mexargs_out& m_out) {
   typedef std::map SUBC_TAB;
   static SUBC_TAB subc_tab;
 
@@ -104,9 +104,9 @@ void gf_global_function(getfemint::mexargs_in& m_in,
std::string sgrad = "[0;0]";
std::string shess = "[0,0;0,0]";
if (in.remaining() && in.front().is_string())
-sgrad = in.pop().to_string();
+ sgrad = in.pop().to_string();
if (in.remaining() && in.front().is_string())
-shess = in.pop().to_string();
+ shess = in.pop().to_string();
ggf = std::make_shared(sval,sgrad,shess);
);
 
@@ -143,14 +143,14 @@ void gf_global_function(getfemint::mexargs_in& m_in,
   SUBC_TAB::iterator it = subc_tab.find(cmd);
   if (it != subc_tab.end()) {
 check_cmd(cmd, it->first.c_str(), m_in, m_out, it->second->arg_in_min,
- it->second->arg_in_max, it->second->arg_out_min,
- it->second->arg_out_max);
+  it->second->arg_in_max, it->second->arg_out_min,
+  it->second->arg_out_max);
 it->second->run(m_in, m_out, ggf);
   

[Getfem-commits] (no subject)

2024-01-23 Thread Konstantinos Poulios via Getfem-commits
branch: add-umfpack-interface
commit 0534ebd1d8da9030871e8d8b7bc813e3c8520a07
Author: Konstantinos Poulios 
AuthorDate: Tue Jan 23 11:31:15 2024 +0100

Convert file to utf8 and add option for umfpack solver
---
 contrib/icare/icare.cc | 43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/contrib/icare/icare.cc b/contrib/icare/icare.cc
index 10846366..0cb77ae1 100644
--- a/contrib/icare/icare.cc
+++ b/contrib/icare/icare.cc
@@ -1,6 +1,6 @@
 /*===
 
- Copyright (C) 2002-2020 Michel Fourni�, Julien Pommier,
+ Copyright (C) 2002-2020 Michel Fournié, Julien Pommier,
 
  This file is a part of GetFEM
 
@@ -972,7 +972,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
 
   }
 
-  //Prise en compte de fa�on faible
+  //Prise en compte de façon faible
   plain_vector HP(nbdof_p);
   { plain_vector A(nbdof_p);
 getfem::generic_assembly assem;
@@ -987,14 +987,14 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   //K2(nbdof_p,nbdof_p) = 0.0;
   */
 
-  //Prise en compte de fa�on forte
+  //Prise en compte de façon forte
   for (unsigned i=0; i <= nbdof_p; ++i) {
 K2(nbdof_p,i) = K2(i,nbdof_p) = 1.0; // mean value of the pressure = 0
 //K2(nbdof_p, 0) = K2(0, nbdof_p) = 1.0; // set the first pressure dof to 0
   }
   K2(nbdof_p,nbdof_p) = 0.0;
 
-#if !defined(GMM_USES_MUMPS)
+#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU)
   gmm::SuperLU_factor SLUsys2;
   SLUsys2.build_with(K2);
 #endif
@@ -1029,7 +1029,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   std::ofstream coeffTP("coeffTP.data");
   std::ofstream ptPartData("ptPart.data");
 
-  // Recherche d'un point de r�ference pour le calcul des coeff de train�e ...
+  // Recherche d'un point de réference pour le calcul des coeff de trainée ...
 
   scalar_type BoxXmin =  PARAM.real_value("BOXXmin", "Particular Point xMin");
   scalar_type BoxXmax =  PARAM.real_value("BOXXmax", "Particular Point xMax");
@@ -1063,7 +1063,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   bgeot::base_node BN =  mf_u.point_of_basic_dof(i);
   if (BN[0]==ptPartP[0] && BN[1]==ptPartP[1] ) {
 cout << "Point Part in Box -- i on mf_u= " << i 
<<",x="< en sortie i <-> pt sur la derni�re 
composante de la vitesse
+// Attention c'est vectoriel => en sortie i <-> pt sur la dernière 
composante de la vitesse
 // Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W
 // D'ou la modif dans ptPartU[2]
 ptPartU[0] = BN[0];
@@ -1092,7 +1092,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   bgeot :: base_node BN =  mf_u.point_of_basic_dof(i);
   if (BN[0]==ptPartP[0] && BN[1]==ptPartP[1]&& BN[2]==ptPartP[2] ) {
 cout << "Point Part in Box -- i on mf_u= " << i 
<<",x="< en sortie i <-> pt sur la derni�re 
composante de la vitesse
+// Attention c'est vectoriel => en sortie i <-> pt sur la dernière 
composante de la vitesse
 // Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W
 // D'ou la modif dans ptPartU[3]
 ptPartU[0] = BN[0];
@@ -1134,14 +1134,13 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   gmm :: sub_interval SUB_CT_V(0,nbdof_u);
   gmm :: sub_interval SUB_CT_P(0,nbdof_p);
 
-// id�ees
 //gmm::copy(gmm::sub_vector(F1generic,SUB_CT_V1full),F1full);
 //gmm::copy(gmm::sub_vector(X1full,SUB_CT_V),X1);
 //gmm::copy(gmm::sub_vector(X2full,SUB_CT_V),X2);
 //gmm::copy(X1,gmm::sub_vector(USTAR,gmm::sub_slice(0,nbdof_u,2)));
 //gmm::copy(X2,gmm::sub_vector(USTAR,gmm::sub_slice(1,nbdof_u,2)));
 
-#if !defined(GMM_USES_MUMPS)
+#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU)
   gmm::SuperLU_factor SLUsys3;
 #endif
   for (scalar_type t = Tinitial + dt; t <= T; t += dt) {
@@ -1178,7 +1177,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   //gmm::add(gmm::scaled(A2u,-1.0),A2v);
   //cout <<"A2 "<< gmm::mat_norminf(A2v) << endl;
 
-#if !defined(GMM_USES_MUMPS)
+#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU)
   SLUsys3.build_with(A2u);
 #endif
 }
@@ -1203,7 +1202,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   gmm::copy(gmm::transposed(HNR), gmm::sub_matrix(A2, I1, I4));
 
   // Factorization LU
-  //SLUsys3.build_with(A2); // pb en (u,v) coupl�
+  //SLUsys3.build_with(A2); // pb en (u,v) couple
 
   gmm::clear(A2u);
   //gmm::clear(A2v);
@@ -1211,7 +1210,7 @@ void 
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
   gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vu,SUB_CT_Vu),A2u);
   //gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vv,SUB_CT_Vv),A2v);
 
-#if !defined(GMM_USES_MUMPS)
+#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU)
   SLUsys3.build_with(A2u);
 #endif
 }
@@ -1334,7 +1333,7 @@ void 

[Getfem-commits] (no subject)

2024-01-23 Thread Konstantinos Poulios via Getfem-commits
branch: add-umfpack-interface
commit a3afc92c2b6a10b138da320b28e06baa75746e94
Author: Konstantinos Poulios 
AuthorDate: Tue Jan 23 11:30:21 2024 +0100

Add experimental UMFPACK support

  - compiles but does not work properly yet
---
 CMakeLists.txt|   1 +
 cmake/gmm_arch_config.h.in|   3 +
 configure.ac  | 107 ++-
 src/Makefile.am   |   1 +
 src/getfem/getfem_model_solvers.h |  21 
 src/gmm/gmm_UMFPACK_interface.h   | 188 ++
 src/gmm/gmm_arch_config.h.in  |   3 +
 src/gmm/gmm_solver_Schwarz_additive.h |   8 +-
 tests/test_condensation.cc|   4 +-
 9 files changed, 329 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ff2cdd8..be062820 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -322,6 +322,7 @@ set(HEADERS
 src/gmm/gmm_superlu_interface.h
 src/gmm/gmm_transposed.h
 src/gmm/gmm_tri_solve.h
+src/gmm/gmm_UMFPACK_interface.h
 src/gmm/gmm_vector.h
 src/gmm/gmm_vector_to_matrix.h
 src/getfem/bgeot_comma_init.h
diff --git a/cmake/gmm_arch_config.h.in b/cmake/gmm_arch_config.h.in
index 50f47daa..4b4b029a 100644
--- a/cmake/gmm_arch_config.h.in
+++ b/cmake/gmm_arch_config.h.in
@@ -19,6 +19,9 @@
 /* defined if GMM is linked to the superlu library */
 #cmakedefine GMM_USES_SUPERLU
 
+/* defined if GMM is linked to the umfpack library */
+#cmakedefine GMM_USES_UMFPACK
+
 /* Use blas with 64 bits integers */
 #cmakedefine GMM_USE_BLAS64_INTERFACE
 
diff --git a/configure.ac b/configure.ac
index cd519ed5..65e505ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -958,9 +958,98 @@ fi
 dnl ---END OF MUMPS TEST--
 
 
+dnl --UMFPACK TEST
+require_umfpack="auto"
+AC_ARG_ENABLE(umfpack,
+  [AS_HELP_STRING([--enable-umfpack], [Enable UMFPACK support])],
+  [require_umfpack=$enableval],
+  [require_umfpack="auto"])
+
+UMFPACK_LIBS="-lumfpack"
+# the user can override these defaults using --with-umfpack=
+AC_ARG_WITH(umfpack,
+ [AS_HELP_STRING([--with-umfpack=],[use UMFPACK library ])],
+ [case $with_umfpack in
+   yes | "")
+ if test "x$require_umfpack" = "xno"; then
+   AC_MSG_ERROR([Contradicting arguments between --enable-umfpack and 
--with-umfpack.])
+ elif test "x$require_umfpack" = "xauto"; then
+   require_umfpack="yes"
+ fi;;
+   no)
+ if test "x$require_umfpack" = "xyes"; then
+   AC_MSG_ERROR([Contradicting arguments between --enable-umfpack and 
--with-umfpack.])
+ elif test "x$require_umfpack" = "xauto"; then
+   require_umfpack="no"
+ fi;;
+   -* | */* | *.a | *.so | *.so.* | *.o| builtin) 
UMFPACK_LIBS="$with_umfpack";;
+   *) UMFPACK_LIBS=`echo $with_umfpack | sed -e 's/^/-l/g;s/ \+/ -l/g'`;;
+  esac]
+)
+
+UMFPACKINC=""
+AC_ARG_WITH(umfpack-include-dir,
+ [AS_HELP_STRING([--with-umfpack-include-dir],[directory in which the 
umfpack.h headers can be found])],
+ [ if test x$require_umfpack = xno; then
+ AC_MSG_ERROR([Inconsistent options for --enable-umfpack, --with-umfpack 
and --with-umfpack-include-dir.]);
+   else
+ require_umfpack="yes"
+ case $withval in
+   -I* ) UMFPACKINC="$withval";;
+   * ) UMFPACKINC="-I$withval";;
+ esac
+   fi;],
+)
+CPPFLAGS="$CPPFLAGS $UMFPACKINC"
 
-if test "x$found_superlu" = "xno" -a "x$found_mumps" = "xno"; then
-  AC_MSG_ERROR([Neither MUMPS nor SuperLU was enabled. At least one linear 
solver is required.])
+if test "x$require_umfpack" = "xno"; then
+  UMFPACK_LIBS=""
+  found_umfpack="no"
+  echo "Building with UMFPACK explicitly disabled";
+else
+  AC_CHECK_HEADERS(
+[umfpack.h],
+[found_umfpack="yes"],
+[ if test "x$require_umfpack" = "xyes"; then
+AC_MSG_ERROR([Header files of UMFPACK not found.]);
+  else
+found_umfpack="no"
+  fi;
+])
+  if test x$found_umfpack = xyes; then
+save_LIBS="$LIBS";
+AC_CHECK_LIB([umfpack], [umfpack_di_solve],
+ [AC_DEFINE(GMM_USES_UMFPACK,,[defined if GMM is linked to the 
umfpack library])],
+ [if test "x$require_umfpack" = "xyes"; then
+AC_MSG_ERROR([UMFPACK library not found]);
+  else
+found_umfpack="no"
+  fi;])
+if test "x$found_umfpack" = "xyes"; then
+  echo "Building with UMFPACK (use --enable-umfpack=no to disable it)"
+  LIBS="$UMFPACK_LIBS $save_LIBS"
+else
+  UMFPACK_LIBS=""
+  LIBS="$save_LIBS"
+fi
+  elif test "x$require_umfpack" = "xyes"; then
+AC_MSG_ERROR([UMFPACK header files not found but required by the user. 
Aborting configure...]);
+  else
+echo "UMFPACK header files not found, building without UMFPACK"
+UMPFPACK_LIBS=""
+  fi
+fi
+
+AM_CONDITIONAL(UMFPACK, test x$found_umfpack = xyes)
+AC_SUBST([UMFPACK_LIBS])
+if test 

[Getfem-commits] (no subject)

2024-01-23 Thread Konstantinos Poulios via Getfem-commits
branch: add-umfpack-interface
commit c33dc738a672c98c19dd3dc45bf80dc96bf3d583
Author: Konstantinos Poulios 
AuthorDate: Tue Jan 23 11:28:31 2024 +0100

Minor code maintenance changes
---
 src/gmm/gmm_matrix.h   | 68 +-
 tests/wave_equation.cc | 48 +--
 2 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/src/gmm/gmm_matrix.h b/src/gmm/gmm_matrix.h
index 60b29178..db375938 100644
--- a/src/gmm/gmm_matrix.h
+++ b/src/gmm/gmm_matrix.h
@@ -140,7 +140,7 @@ namespace gmm
 typedef typename linalg_traits::value_type value_type;
 
 row_matrix(size_type r, size_type c) : li(r, V(c)), nc(c) {}
-row_matrix(void) : nc(0) {}
+row_matrix() : nc(0) {}
 reference operator ()(size_type l, size_type c)
 { return li[l][c]; }
 value_type operator ()(size_type l, size_type c) const
@@ -149,13 +149,13 @@ namespace gmm
 void clear_mat();
 void resize(size_type m, size_type n);
 
-typename std::vector::iterator begin(void)
+typename std::vector::iterator begin()
 { return li.begin(); }
-typename std::vector::iterator end(void)
+typename std::vector::iterator end()
 { return li.end(); }
-typename std::vector::const_iterator begin(void) const
+typename std::vector::const_iterator begin() const
 { return li.begin(); }
-typename std::vector::const_iterator end(void) const
+typename std::vector::const_iterator end() const
 { return li.end(); }
 
 
@@ -164,8 +164,8 @@ namespace gmm
 V& operator[](size_type i) { return li[i]; }
 const V& operator[](size_type i) const { return li[i]; }
 
-inline size_type nrows(void) const { return li.size(); }
-inline size_type ncols(void) const { return nc;}
+inline size_type nrows() const { return li.size(); }
+inline size_type ncols() const { return nc;}
 
 void swap(row_matrix ) { std::swap(li, m.li); std::swap(nc, m.nc); }
 void swap_row(size_type i, size_type j) { std::swap(li[i], li[j]); }
@@ -248,7 +248,7 @@ namespace gmm
 typedef typename linalg_traits::value_type value_type;
 
 col_matrix(size_type r, size_type c) : li(c, V(r)), nr(r) { }
-col_matrix(void) : nr(0) {}
+col_matrix() : nr(0) {}
 reference operator ()(size_type l, size_type c)
 { return li[c][l]; }
 value_type operator ()(size_type l, size_type c) const
@@ -262,17 +262,17 @@ namespace gmm
 V& operator[](size_type i) { return li[i]; }
 const V& operator[](size_type i) const { return li[i]; }
 
-typename std::vector::iterator begin(void)
+typename std::vector::iterator begin()
 { return li.begin(); }
-typename std::vector::iterator end(void)
+typename std::vector::iterator end()
 { return li.end(); }
-typename std::vector::const_iterator begin(void) const
+typename std::vector::const_iterator begin() const
 { return li.begin(); }
-typename std::vector::const_iterator end(void) const
+typename std::vector::const_iterator end() const
 { return li.end(); }
 
-inline size_type ncols(void) const { return li.size(); }
-inline size_type nrows(void) const { return nr; }
+inline size_type ncols() const { return li.size(); }
+inline size_type nrows() const { return nr; }
 
 void swap(col_matrix ) { std::swap(li, m.li); std::swap(nr, m.nr); }
 void swap_col(size_type i, size_type j) { std::swap(li[i], li[j]); }
@@ -365,22 +365,22 @@ namespace gmm
   return *(this->begin() + c*nbl+l);
 }
 
-std::vector _vector(void) { return *this; }
-const std::vector _vector(void) const { return *this; }
+std::vector _vector() { return *this; }
+const std::vector _vector() const { return *this; }
 
 void resize(size_type, size_type);
 void base_resize(size_type, size_type);
 void reshape(size_type, size_type);
 
 void fill(T a, T b = T(0));
-inline size_type nrows(void) const { return nbl; }
-inline size_type ncols(void) const { return nbc; }
+inline size_type nrows() const { return nbl; }
+inline size_type ncols() const { return nbc; }
 void swap(dense_matrix )
 { std::vector::swap(m); std::swap(nbc, m.nbc); std::swap(nbl, m.nbl); }
 
 dense_matrix(size_type l, size_type c)
   : std::vector(c*l), nbc(c), nbl(l)  {}
-dense_matrix(void) { nbl = nbc = 0; }
+dense_matrix() { nbl = nbc = 0; }
   };
 
   template void dense_matrix::reshape(size_type m,size_type n) {
@@ -523,11 +523,11 @@ namespace gmm
 
 void init_with_identity(size_type n);
 
-csc_matrix(void) :  nc(0), nr(0) {}
+csc_matrix() :  nc(0), nr(0) {}
 csc_matrix(size_type nnr, size_type nnc);
 
-size_type nrows(void) const { return nr; }
-size_type ncols(void) const { return nc; }
+size_type nrows() const { return nr; }
+size_type ncols() const { return nc; }
 void swap(csc_matrix ) {
   std::swap(pr, m.pr);
   std::swap(ir, m.ir); std::swap(jc, 

[Getfem-commits] (no subject)

2024-01-23 Thread Konstantinos Poulios via Getfem-commits
branch: add-umfpack-interface
commit 87cf885eae1bbf2ffcdb1804a66ea35ca7949c95
Author: Konstantinos Poulios 
AuthorDate: Tue Jan 23 11:24:47 2024 +0100

Fix error in configure script
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6f7d6c82..cd519ed5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1275,7 +1275,7 @@ fi;
 if test "x$found_mumps" = "xyes"; then
   echo "- Mumps found. A direct solver for large sparse linear systems."
 else
-  if test "x$require_superlu" = "xno"; then
+  if test "x$require_mumps" = "xno"; then
 echo "- Not using the MUMPS library for large sparse linear systems."
   else
 echo "- Mumps not found. Not using the MUMPS library for large sparse 
linear systems."



[Getfem-commits] [getfem-commits] branch add-umfpack-interface created (now 0534ebd1)

2024-01-23 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch add-umfpack-interface.

  at 0534ebd1 Convert file to utf8 and add option for umfpack solver

This branch includes the following new commits:

 new 87cf885e Fix error in configure script
 new c33dc738 Minor code maintenance changes
 new a3afc92c Add experimental UMFPACK support
 new 0534ebd1 Convert file to utf8 and add option for umfpack solver




[Getfem-commits] [getfem-commits] branch overhaul-build-system deleted (was 8511ba82)

2024-01-09 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch overhaul-build-system.

 was 8511ba82 Add basic cmake build support

The revisions that were on this branch are still contained in
other references; therefore, this change does not discard any commits
from the repository.



[Getfem-commits] [getfem-commits] master updated (17155e82 -> 8511ba82)

2023-12-30 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 17155e82 Apply fixes from getfem_superlu.cc to gmm_superlu_interface.h
 add 4ff66802 Remove old copy of SuperLU, overhaul configure.ac, treat 
MUMPS and SuperLU equally
 add 8511ba82 Add basic cmake build support

No new revisions were added by this update.

Summary of changes:
 CMakeLists.txt |   685 +
 Makefile.am| 3 +-
 cmake/getfem_arch_config.h.in  |50 +
 cmake/gmm_arch_config.h.in |26 +
 configure.ac   |   458 +-
 contrib/crack_plate/crack_bilaplacian_problem.cc   |17 +-
 contrib/icare/icare.cc |43 +-
 contrib/xfem_contact/xfem_stokes.cc| 4 +
 .../xfem_stab_unilat_contact.cc| 9 +-
 interface/src/getfemint_precond.h  |12 +-
 interface/src/gf_linsolve.cc   | 6 +-
 interface/src/gf_precond.cc| 4 +
 interface/src/gfi_array.h  | 2 +-
 interface/src/octave/gfi_array.h   | 2 +-
 interface/src/python/getfem_python.c   |14 +-
 src/Makefile.am| 2 -
 src/getfem/bgeot_config.h  | 1 +
 src/getfem/getfem_arch_config.h.in |49 +
 src/getfem/getfem_config.h |36 +-
 src/getfem/getfem_model_solvers.h  |25 +-
 src/getfem/getfem_superlu.h|   130 -
 src/getfem_superlu.cc  |   430 -
 src/gmm/gmm_arch_config.h.in   |25 +
 src/gmm/gmm_solver_Schwarz_additive.h  |10 +-
 src/gmm/gmm_superlu_interface.h| 9 +-
 superlu/BLAS.c | 43902 ---
 superlu/BLAS/License.txt   |14 -
 superlu/BLAS/caxpy.f   |   102 -
 superlu/BLAS/ccopy.f   |94 -
 superlu/BLAS/cdotc.f   |   103 -
 superlu/BLAS/cdotu.f   |   100 -
 superlu/BLAS/cgbmv.f   |   390 -
 superlu/BLAS/cgemm.f   |   483 -
 superlu/BLAS/cgemv.f   |   350 -
 superlu/BLAS/cgerc.f   |   227 -
 superlu/BLAS/cgeru.f   |   227 -
 superlu/BLAS/chbmv.f   |   380 -
 superlu/BLAS/chemm.f   |   371 -
 superlu/BLAS/chemv.f   |   337 -
 superlu/BLAS/cher.f|   278 -
 superlu/BLAS/cher2.f   |   317 -
 superlu/BLAS/cher2k.f  |   442 -
 superlu/BLAS/cherk.f   |   396 -
 superlu/BLAS/chpmv.f   |   338 -
 superlu/BLAS/chpr.f|   279 -
 superlu/BLAS/chpr2.f   |   318 -
 superlu/BLAS/crotg.f   |74 -
 superlu/BLAS/cscal.f   |91 -
 superlu/BLAS/csrot.f   |   153 -
 superlu/BLAS/csscal.f  |94 -
 superlu/BLAS/cswap.f   |98 -
 superlu/BLAS/csymm.f   |   369 -
 superlu/BLAS/csyr2k.f  |   396 -
 superlu/BLAS/csyrk.f   |   363 -
 superlu/BLAS/ctbmv.f   |   429 -
 superlu/BLAS/ctbsv.f   |   432 -
 superlu/BLAS/ctpmv.f   |   388 -
 superlu/BLAS/ctpsv.f   |   390 -
 superlu/BLAS/ctrmm.f   |   452 -
 superlu/BLAS/ctrmv.f   |   373 -
 superlu/BLAS/ctrsm.f   |   477 -
 superlu/BLAS/ctrsv.f   |   375 -
 superlu/BLAS/dasum.f   |   111 -
 superlu/BLAS/daxpy.f   |   115 -
 superlu/BLAS/dcabs1.f  |58 -
 superlu/BLAS/dcopy.f   |   115 -
 superlu/BLAS/ddot.f|   117 -
 superlu/BLAS/dgbmv.f   |   370 -
 superlu/BLAS/dgemm.f   |   384 -
 superlu/BLAS/dgemv.f   |   330 -
 superlu/BLAS/dger.f|   227 -
 superlu/BLAS/dnrm2.f   |   112 -
 superlu/BLAS/drot.f|   101 -
 superlu/BLAS/drotg.f   |86 -
 superlu/BLAS/drotm.f  

[Getfem-commits] [getfem-commits] branch overhaul-build-system updated: Add basic cmake build support

2023-12-27 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch overhaul-build-system
in repository getfem.

The following commit(s) were added to refs/heads/overhaul-build-system by this 
push:
 new 8511ba82 Add basic cmake build support
8511ba82 is described below

commit 8511ba82bb8649aff8aedf27929cd5d314986307
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 27 16:55:57 2023 +0100

Add basic cmake build support

  - Non-intrusive implementation based on a single CMakeList.txt file
and just two header template files "cmake/gmm_arch_config.h.in" and
"cmake/getfem_arch_config.h.in" equivalent to those used by autotools
  - It can build the static and shared version of the libgetfem library
as well as the python module
  - Typical configuration examples:
$ cmake .. -DBUILD_LIBRARY_TYPE=STATIC -DCMAKE_INSTALL_PREFIX=/opt
$ cmake .. -DENABLE_PYTHON=ON --DCMAKE_INSTALL_PREFIX=/opt
  - It does neither support compiling and running unit tests, nor more
advanced features like MPI and OpenMP builds
---
 CMakeLists.txt| 685 ++
 cmake/getfem_arch_config.h.in |  50 +++
 cmake/gmm_arch_config.h.in|  26 ++
 3 files changed, 761 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index ..7ff2cdd8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,685 @@
+cmake_minimum_required(VERSION 3.23)
+include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
+include(CheckCXXSourceCompiles)
+include(CheckLibraryExists)
+
+string(ASCII 27 ESC)
+message("${ESC}[33m"
+"The cmake build system for GetFEM is an alternative to the "
+"autotools build. It is a work in progress and it does not "
+"support all options supported by the autotools system."
+"${ESC}[0m")
+project(GetFEM)
+
+# Set the project version
+set(VERSION_MAJOR 5)
+set(VERSION_MINOR 4)
+set(VERSION_PATCH 2)
+# applies to both GetFEM and GMM
+set(GETFEM_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+set(GMM_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+# mimic autotools package variables
+set(GETFEM_PACKAGE_NAME "getfem")
+set(GETFEM_PACKAGE_STRING "getfem ${GETFEM_VERSION}")
+set(GETFEM_PACKAGE_TARNAME "getfem")
+
+# Configure options for enabling/disabling Python, Octave, and MATLAB support
+option(ENABLE_PYTHON "Enable Python support" OFF)
+option(ENABLE_OCTAVE "Enable Octave support" OFF)
+option(ENABLE_MATLAB "Enable MATLAB support" OFF)
+# Configure option for enabling/disabling OpenMP support
+option(ENABLE_OPENMP "Enable OpenMP support" OFF)
+# Configure option to enable Qhull support
+option(ENABLE_QHULL "Enable Qhull support" ON)
+# Configure options for enabling/disabling linear solvers (at least one is 
required)
+option(ENABLE_SUPERLU "Enable SuperLU support" ON) # might be turned off by 
cmake if SuperLU is not found
+option(ENABLE_MUMPS "Enable MUMPS support" ON) # might be turned off by 
cmake if MUMPS is not found
+# Configure option for enabling/disabling multithreaded BLAS (requires the dl 
library)
+option(ENABLE_MULTITHREADED_BLAS "Enable multithreaded blas support" OFF)
+
+option(BUILD_SHARED_LIBS "Build libraries as SHARED, equivalent to 
BUILD_LYBRARY_TYPE=SHARED" ON)
+set(BUILD_LIBRARY_TYPE "SHARED" CACHE STRING
+"Type of library to build, choose among SHARED, STATIC, 
STATIC_BUNDLE_DEPS")
+set_property(CACHE BUILD_LIBRARY_TYPE PROPERTY STRINGS
+ "SHARED" "STATIC" "STATIC_BUNDLE_DEPS")
+if(NOT BUILD_LIBRARY_TYPE STREQUAL "SHARED" AND BUILD_SHARED_LIBS)
+  message(STATUS "BUILD_LIBRARY_TYPE=${BUILD_LIBRARY_TYPE} option overrides 
BUILD_SHARED_LIBS=ON")
+  set(BUILD_SHARED_LIBS OFF)
+elseif(NOT BUILD_SHARED_LIBS AND BUILD_LIBRARY_TYPE STREQUAL "SHARED")
+  message(STATUS "BUILD_SHARED_LIBS=OFF option overrides 
BUILD_LIBRARY_TYPE=SHARED")
+  set(BUILD_LIBRARY_TYPE "STATIC")
+endif()
+
+set(WITH_OPTIMIZATION "-O2" CACHE STRING "Set the optimization level (default: 
-O2)")
+set(GETFEM_PARA_LEVEL 0 CACHE STRING "Set the GETFEM_PARA_LEVEL option 
(default: 0)")
+
+# CMake variable for installation path
+set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation prefix")
+
+
+# General tests and configurations
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+check_include_file_cxx("cxxabi.h" GETFEM_HAVE_CXXABI_H)
+check_cxx_source_compiles(
+  "#include \nint main() {feenableexcept(FE_DIVBYZERO); return 0;}"
+  GETFEM_HAVE_FEENABLEEXCEPT)
+
+# Tests for availability of linear solvers
+if(ENABLE_SUPERLU)
+  if(NOT BUILD_SHARED_LIBS)
+find_library(SUPERLU_STATIC_LIBS NAMES libsuperlu.a PATHS 
${SUPERLU_LIB_DIR})
+  endif()
+  if(SUPERLU_STATIC_LIBS)
+set(SUPERLU_LIBS SUPERLU_STATIC_LIBS)
+  else()
+find_library(SUPERLU_LIBS NAMES superlu PATHS ${SUPERLU_LIB_DIR})
+  endif()
+  if(SUPERLU_LIBS)
+find_path(SUPERLU_INCLUDE_PATH NAMES 

[Getfem-commits] [getfem-commits] branch overhaul-build-system created (now 4ff66802)

2023-12-27 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch overhaul-build-system.

  at 4ff66802 Remove old copy of SuperLU, overhaul configure.ac, treat 
MUMPS and SuperLU equally

This branch includes the following new commits:

 new 4ff66802 Remove old copy of SuperLU, overhaul configure.ac, treat 
MUMPS and SuperLU equally




[Getfem-commits] [getfem-commits] branch master updated: Apply fixes from getfem_superlu.cc to gmm_superlu_interface.h

2023-12-27 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 17155e82 Apply fixes from getfem_superlu.cc to gmm_superlu_interface.h
17155e82 is described below

commit 17155e82aff70482d2e4c5fea3faa1a2189d4674
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 27 14:21:55 2023 +0100

Apply fixes from getfem_superlu.cc to gmm_superlu_interface.h
---
 src/gmm/gmm_superlu_interface.h | 95 +++--
 1 file changed, 54 insertions(+), 41 deletions(-)

diff --git a/src/gmm/gmm_superlu_interface.h b/src/gmm/gmm_superlu_interface.h
index 9605dc65..964efd43 100644
--- a/src/gmm/gmm_superlu_interface.h
+++ b/src/gmm/gmm_superlu_interface.h
@@ -43,13 +43,16 @@
 
 typedef int int_t;
 
-/* because SRC/util.h defines TRUE and FALSE ... */
+/* because slu_util.h defines TRUE, FALSE, EMPTY ... */
 #ifdef TRUE
 # undef TRUE
 #endif
 #ifdef FALSE
 # undef FALSE
 #endif
+#ifdef EMPTY
+# undef EMPTY
+#endif
 
 #include "superlu/slu_Cnames.h"
 #include "superlu/supermatrix.h"
@@ -118,17 +121,17 @@ namespace gmm {
 
   /*  interface for gssv */
 
-#define DECL_GSSV(NAMESPACE,FNAME,FLOATTYPE,KEYTYPE) \
+#define DECL_GSSV(NAMESPACE,FNAME,KEYTYPE) \
   inline void SuperLU_gssv(superlu_options_t *options, SuperMatrix *A, int *p, 
\
   int *q, SuperMatrix *L, SuperMatrix *U, SuperMatrix *B,   \
   SuperLUStat_t *stats, int *info, KEYTYPE) {   \
   NAMESPACE::FNAME(options, A, p, q, L, U, B, stats, info); \
   }
 
-  DECL_GSSV(SuperLU_S,sgssv,float,float)
-  DECL_GSSV(SuperLU_C,cgssv,float,std::complex)
-  DECL_GSSV(SuperLU_D,dgssv,double,double)
-  DECL_GSSV(SuperLU_Z,zgssv,double,std::complex)
+  DECL_GSSV(SuperLU_S,sgssv,float)
+  DECL_GSSV(SuperLU_C,cgssv,std::complex)
+  DECL_GSSV(SuperLU_D,dgssv,double)
+  DECL_GSSV(SuperLU_Z,zgssv,std::complex)
 
   /*  interface for gssvx */
 
@@ -158,9 +161,8 @@ namespace gmm {
   /* * */
 
   template 
-  int SuperLU_solve(const MAT , const VECTX _, const VECTB ,
+  int SuperLU_solve(const MAT , const VECTX , const VECTB ,
 double& rcond_, int permc_spec = 3) {
-VECTX  = const_cast(X_);
 /*
  * Get column permutation vector perm_c[], according to permc_spec:
  *   permc_spec = 0: use the natural ordering
@@ -171,13 +173,14 @@ namespace gmm {
 typedef typename linalg_traits::value_type T;
 typedef typename number_traits::magnitude_type R;
 
-int m = mat_nrows(A), n = mat_ncols(A), nrhs = 1, info = 0;
+int m = int(mat_nrows(A)), n = int(mat_ncols(A)), nrhs = 1, info = 0;
 
-csc_matrix csc_A(m, n); gmm::copy(A, csc_A);
+csc_matrix csc_A(m, n);
+gmm::copy(A, csc_A);
 std::vector rhs(m), sol(m);
 gmm::copy(B, rhs);
 
-int nz = nnz(csc_A);
+int nz = int(nnz(csc_A));
 if ((2 * nz / n) >= m)
   GMM_WARNING2("CAUTION : it seems that SuperLU has a problem"
" for nearly dense sparse matrices");
@@ -196,8 +199,9 @@ namespace gmm {
 StatInit();
 
 SuperMatrix SA, SL, SU, SB, SX; // SuperLU format.
-Create_CompCol_Matrix(, m, n, nz, (double *)(&(csc_A.pr[0])),
-  (int *)(&(csc_A.ir[0])), (int *)(&(csc_A.jc[0])));
+Create_CompCol_Matrix(, m, n, nz, (T *)(_A.pr[0]),
+  (int *)(_A.ir[0]),
+  (int *)(_A.jc[0]));
 Create_Dense_Matrix(, m, nrhs, [0], m);
 Create_Dense_Matrix(, m, nrhs, [0], m);
 memset(,0,sizeof SL);
@@ -226,19 +230,22 @@ namespace gmm {
   [0] /* relative backward error */,
   , , T());
 rcond_ = rcond;
-Destroy_SuperMatrix_Store();
-Destroy_SuperMatrix_Store();
-Destroy_SuperMatrix_Store();
-Destroy_SuperNode_Matrix();
-Destroy_CompCol_Matrix();
+if (SB.Store) Destroy_SuperMatrix_Store();
+if (SX.Store) Destroy_SuperMatrix_Store();
+if (SA.Store) Destroy_SuperMatrix_Store();
+if (SL.Store) Destroy_SuperNode_Matrix();
+if (SU.Store) Destroy_CompCol_Matrix();
 StatFree();
+GMM_ASSERT1(info != -3, "SuperLU was cancelled."); // user 
interruption (for matlab interface)
+
 GMM_ASSERT1(info >= 0, "SuperLU solve failed: info =" << info);
 if (info > 0) GMM_WARNING1("SuperLU solve failed: info =" << info);
-gmm::copy(sol, X);
+gmm::copy(sol, const_cast(X));
 return info;
   }
 
-  template  class SuperLU_factor {
+  template 
+  class SuperLU_factor {
 typedef typename number_traits::magnitude_type R;
 
 csc_matrix csc_A;
@@ -256,14 +263,22 @@ namespace gmm {
 
   public :
 enum { LU_NOTRANSP, LU_TRANSP, LU_CONJUGATED };
-void free_supermatrix(void);
+void free_supermatrix() {
+  if (is_init) {
+if (SB.Store) Destroy_SuperMatrix_Store();
+

[Getfem-commits] [getfem-commits] branch master updated: Ensure getfem/getfem_im_list.h is created after a maintainer-clean

2023-12-27 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 cb207a37 Ensure getfem/getfem_im_list.h is created after a 
maintainer-clean
cb207a37 is described below

commit cb207a37436e8bb561c14364e6041bc849798592
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 27 14:18:03 2023 +0100

Ensure getfem/getfem_im_list.h is created after a maintainer-clean
---
 cubature/Makefile.am | 1 +
 src/Makefile.am  | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/cubature/Makefile.am b/cubature/Makefile.am
index 58f811c2..7dd27822 100644
--- a/cubature/Makefile.am
+++ b/cubature/Makefile.am
@@ -22,5 +22,6 @@ EXTRA_DIST = $(IM_METHODS_LOC) make_getfem_im_list 
getfem_im_list.h
 
 getfem_im_list.h :  $(IM_METHODS)
$(top_srcdir)/cubature/make_getfem_im_list $(top_srcdir)/cubature
+   cp $(top_srcdir)/cubature/getfem_im_list.h 
$(top_srcdir)/src/getfem/getfem_im_list.h
 
 CLEANFILES = getfem_im_list.h
diff --git a/src/Makefile.am b/src/Makefile.am
index f90d9dbc..1e10d741 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -247,9 +247,6 @@ SRC =   \
getfem_continuation.cc
 #  getfem_enumeration_dof_para.cc
 
-getfem/getfem_im_list.h : ../cubature/getfem_im_list.h 
-   cp ../cubature/getfem_im_list.h getfem/getfem_im_list.h
-
 lib_LTLIBRARIES = libgetfem.la
 libgetfem_la_SOURCES = $(SRC)
 libgetfem_la_LDFLAGS = ${LIBTOOL_VERSION_INFO}



[Getfem-commits] [getfem-commits] branch master updated: Whitespace fixes and other minor changes

2023-12-26 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 752f0399 Whitespace fixes and other minor changes
752f0399 is described below

commit 752f03999a6c50af90bf20dc2f6224430e86fab2
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 26 20:39:58 2023 +0100

Whitespace fixes and other minor changes
---
 contrib/crack_plate/crack_bilaplacian_problem.cc | 1248 +++---
 interface/src/gf_linsolve.cc |4 +-
 src/gmm/gmm_solver_Schwarz_additive.h|4 +-
 tests/schwarz_additive.cc|   10 +-
 4 files changed, 635 insertions(+), 631 deletions(-)

diff --git a/contrib/crack_plate/crack_bilaplacian_problem.cc 
b/contrib/crack_plate/crack_bilaplacian_problem.cc
index d6fc76d9..f258a788 100644
--- a/contrib/crack_plate/crack_bilaplacian_problem.cc
+++ b/contrib/crack_plate/crack_bilaplacian_problem.cc
@@ -31,84 +31,82 @@ using std::ends; using std::cin;
 template  std::ostream  <<
   (std::ostream , const std::vector& m) { gmm::write(o,m); return o; }
 
-size_type is_global_dof_type_bis(getfem::pdof_description dof){
-size_type global_dof = 0 ;
-   for (dim_type d = 0; d < 4 ; ++d){
-   if (dof == getfem::global_dof(d)) {
-  global_dof = 1;
- }
-   }
-return global_dof ;
+size_type is_global_dof_type_bis(getfem::pdof_description dof) {
+  size_type global_dof = 0;
+  for (dim_type d = 0; d < 4; ++d) {
+if (dof == getfem::global_dof(d)) {
+  global_dof = 1;
+}
+  }
+  return global_dof;
 }
 
 / Exact Solution ***/
 
-scalar_type D  = 1.  ;
-scalar_type nu = 0.3 ;
-scalar_type AAA = 0.1 ;// mode II
-scalar_type BBB = AAA * (3. * nu + 5.)/ (3. * (nu - 1.))   ;
-scalar_type DD = 0.0 ;   // mode 1
-scalar_type CC = DD * (nu + 7.)/ (3. * (nu - 1.))   ;
-scalar_type EE = 0.0 ;   // singul 61
-scalar_type FF = 0.0 ;   // singul 62
-scalar_type GG = 0.0 ;   // singul 63
-scalar_type HH = 0.0 ; //3.0 // singul 6
-
-scalar_type P0 = 0.0 ;
-scalar_type P1 = 0.0 ;
-scalar_type P2 = 0.0 ;
-
-scalar_type sol_u(const base_node ){
- scalar_type r = sqrt( x[0] * x[0] + x[1] * x[1] ) ;
- //scalar_type theta = 2. * atan( x[1] / ( x[0] + r ) ) ;
- scalar_type theta = atan2(x[1], x[0]);
- return 
sqrt(r*r*r)*(AAA*sin(theta/2.0)+BBB*sin(3.0/2.0*theta)+CC*cos(3.0/2.0*theta)+DD*cos(theta/2.0))
 + EE * x[1] * (10. * x[1] * x[1]* x[1] + 1.) ;
-
+scalar_type D  = 1.;
+scalar_type nu = 0.3;
+scalar_type AAA = 0.1;// mode II
+scalar_type BBB = AAA * (3. * nu + 5.)/ (3. * (nu - 1.));
+scalar_type DD = 0.0;   // mode 1
+scalar_type CC = DD * (nu + 7.)/ (3. * (nu - 1.));
+scalar_type EE = 0.0;   // singul 61
+scalar_type FF = 0.0;   // singul 62
+scalar_type GG = 0.0;   // singul 63
+scalar_type HH = 0.0; //3.0 // singul 6
+
+scalar_type P0 = 0.0;
+scalar_type P1 = 0.0;
+scalar_type P2 = 0.0;
+
+scalar_type sol_u(const base_node ) {
+  scalar_type r = sqrt( x[0] * x[0] + x[1] * x[1] );
+  //scalar_type theta = 2. * atan( x[1] / ( x[0] + r ) );
+  scalar_type theta = atan2(x[1], x[0]);
+  return 
sqrt(r*r*r)*(AAA*sin(theta/2.0)+BBB*sin(3.0/2.0*theta)+CC*cos(3.0/2.0*theta)+DD*cos(theta/2.0))
 + EE * x[1] * (10. * x[1] * x[1]* x[1] + 1.);
 }
 
-scalar_type sol_F(const base_node &)
-{return 1.  ;//EE * D *  240. ;//256. * cos(2. * x[1]) ;
+scalar_type sol_F(const base_node &) {
+  return 1.; //EE * D *  240.; //256. * cos(2. * x[1]);
 }
 
 void exact_solution_bilap::init(getfem::level_set ) {
-  std::vector cfun(11) ;
+  std::vector cfun(11);
   for (unsigned j=0; j < 4; ++j)
-cfun[j] = bilaplacian_crack_singular(j, ls, nu, 0.) ;
-  cfun[4] = bilaplacian_crack_singular(61, ls, nu, 0.) ;
-  cfun[5] = bilaplacian_crack_singular(62, ls, nu, 0.) ;
-  cfun[6] = bilaplacian_crack_singular(63, ls, nu, 0.) ;
-  cfun[7] = bilaplacian_crack_singular(6, ls, nu, 0.) ;
-  cfun[8] = bilaplacian_crack_singular(10, ls, nu, 0.) ;
-  cfun[9] = bilaplacian_crack_singular(11, ls, nu, 0.) ;
-  cfun[10] = bilaplacian_crack_singular(12, ls, nu, 0.) ;
+cfun[j] = bilaplacian_crack_singular(j, ls, nu, 0.);
+  cfun[4] = bilaplacian_crack_singular(61, ls, nu, 0.);
+  cfun[5] = bilaplacian_crack_singular(62, ls, nu, 0.);
+  cfun[6] = bilaplacian_crack_singular(63, ls, nu, 0.);
+  cfun[7] = bilaplacian_crack_singular(6, ls, nu, 0.);
+  cfun[8] = bilaplacian_crack_singular(10, ls, nu, 0.);
+  cfun[9] = bilaplacian_crack_singular(11, ls, nu, 0.);
+  cfun[10] = bilaplacian_crack_singular(12, ls, nu, 0.);
 
   mf.set_functions(cfun);
   U.resize(11); assert(mf.nb_dof() == 11);
-  U[0] = AAA ;
-  U[1] = BBB ;
-  U[2] = CC ;
-  U[3] = DD ;
-  U[4] = EE ;
-  U[5] = FF ;
-  U[6] = GG ;
-  U[7] = HH ;
-  U[8] = P0 ;
-  U[9] = P1 ;
-  U[10] = P2 ;
-
+  U[0] = AAA;
+  U[1] = BBB;
+  U[2] = CC;
+  U[3] = DD;
+  U[4] = EE;
+  

[Getfem-commits] [getfem-commits] branch master updated: Remove leftovers and redundant includes, fix whitespace and other minor changes

2023-12-26 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 956a40ef Remove leftovers and redundant includes, fix whitespace and 
other minor changes
956a40ef is described below

commit 956a40eff0cb8a34dba51cce483ccd5d6f27e4c7
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 26 18:35:16 2023 +0100

Remove leftovers and redundant includes, fix whitespace and other minor 
changes
---
 configure.ac|   8 +-
 contrib/continuum_mechanics/Makefile.am |   2 -
 interface/src/gf_spmat_get.cc   |   2 +-
 src/Makefile.am |   2 +-
 src/dal_singleton.cc|   6 +-
 src/getfem_superlu.cc   |   2 +-
 src/gmm/gmm_MUMPS_interface.h   |   2 +-
 src/gmm/gmm_dense_qr.h  |  11 +-
 src/gmm/gmm_solver_Schwarz_additive.h   | 457 
 9 files changed, 244 insertions(+), 248 deletions(-)

diff --git a/configure.ac b/configure.ac
index 018bfd86..4fcf6c1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ dnl set the optimization level
 dnl --
 
 AC_ARG_WITH(optimization,
-   AC_HELP_STRING([--with-optimization=FLAG],[Set the optimization 
level (-O3 by default)]),
+   AS_HELP_STRING([--with-optimization=FLAG],[Set the optimization 
level (-O3 by default)]),
[with_optimization=$withval],
[with_optimization='-O3']
)   
@@ -647,12 +647,12 @@ LIBS="$acx_blas_save_LIBS"
 
 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
 if test x"$acx_blas_ok" = xyes; then
-   echo "OK, You have working BLAS libs ! Using $BLAS_LIBS" ; 
HAVE_VENDOR_BLAS=1
+  echo "OK, You have working BLAS libs ! Using $BLAS_LIBS" ; HAVE_VENDOR_BLAS=1
 else
-echo " *** YOU DONT HAVE BLAS! *** Using a cheap replacement" ; 
HAVE_VENDOR_BLAS=0
+  echo " *** YOU DONT HAVE BLAS! *** Using a cheap replacement" ; 
HAVE_VENDOR_BLAS=0
 fi
 
-dnl ACX_BLAS([ echo "OK, You have working BLAS libs !"; HAVE_VENDOR_BLAS=1 ], 
[echo "YOU DONT HAVE BLAS! Using a cheap replacement" ; HAVE_VENDOR_BLAS=0])
+dnl ACX_BLAS([ echo "OK, You have working BLAS libs !"; HAVE_VENDOR_BLAS=1 
],[echo "YOU DONT HAVE BLAS! Using a cheap replacement" ; HAVE_VENDOR_BLAS=0])
 LIBS="$LIBS $BLAS_LIBS"
 CPPFLAGS="$CPPFLAGS -DGMM_USES_BLAS"
 
diff --git a/contrib/continuum_mechanics/Makefile.am 
b/contrib/continuum_mechanics/Makefile.am
index dc5d9fc1..879ec8a9 100644
--- a/contrib/continuum_mechanics/Makefile.am
+++ b/contrib/continuum_mechanics/Makefile.am
@@ -22,8 +22,6 @@ EXTRA_DIST = \
 
 check_PROGRAMS = 
 
-CLEANFILES = 
-
 if BUILDPYTHON
 TESTS = plasticity_fin_strain_lin_hardening_plane_strain.py
 
diff --git a/interface/src/gf_spmat_get.cc b/interface/src/gf_spmat_get.cc
index ad59332a..44d75228 100644
--- a/interface/src/gf_spmat_get.cc
+++ b/interface/src/gf_spmat_get.cc
@@ -403,7 +403,7 @@ void gf_spmat_get(getfemint::mexargs_in& m_in,
);
 
 
-#if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H)
+#if defined(GMM_USES_MUMPS)
 /*@GET @CELL{mantissa_r, mantissa_i, exponent} = ('determinant')
   returns the matrix determinant calculated using MUMPS.@*/
 sub_command
diff --git a/src/Makefile.am b/src/Makefile.am
index 16d06fcc..f90d9dbc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -256,6 +256,6 @@ libgetfem_la_LDFLAGS = ${LIBTOOL_VERSION_INFO}
 libgetfem_la_LIBADD = @SUPERLU_LIBS@ @MUMPS_LIBS@
 AM_CPPFLAGS = -I$(top_srcdir)/src -I../src -I$(top_srcdir)
 
-CLEANFILES = ii_files/* *.o.d getfem/getfem_im_list.h 
+CLEANFILES = ii_files/* *.o.d getfem/getfem_im_list.h
 DISTCLEANFILES = getfem/getfem_arch_config.h gmm/gmm_arch_config.h
 
diff --git a/src/dal_singleton.cc b/src/dal_singleton.cc
index 183f093c..91a87825 100644
--- a/src/dal_singleton.cc
+++ b/src/dal_singleton.cc
@@ -20,10 +20,6 @@
 ===*/
 
 #include "getfem/dal_singleton.h"
-#include 
-#include "gmm/gmm.h"
-#include "getfem/getfem_omp.h"
-
 
 namespace dal {
 
@@ -64,4 +60,4 @@ namespace dal {
 }
   }
 
-}/* end of namespace dal   
  */
\ No newline at end of file
+}/* end of namespace dal   
  */
diff --git a/src/getfem_superlu.cc b/src/getfem_superlu.cc
index 4e7c3538..fe7d2803 100644
--- a/src/getfem_superlu.cc
+++ b/src/getfem_superlu.cc
@@ -23,7 +23,7 @@
 
 typedef int int_t;
 
-/* because SRC/util.h defines TRUE and FALSE ... */
+/* because slu_util.h defines TRUE and FALSE ... */
 #ifdef TRUE
 # undef TRUE
 #endif
diff --git a/src/gmm/gmm_MUMPS_interface.h b/src/gmm/gmm_MUMPS_interface.h
index 968f18d2..f912c145 100644
--- a/src/gmm/gmm_MUMPS_interface.h
+++ b/src/gmm/gmm_MUMPS_interface.h
@@ -35,7 +35,7 @@

[Getfem-commits] [getfem-commits] branch master updated: Make gmm qr_factor more consistent with lapack for real square matrices

2023-12-20 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 27cc7174 Make gmm qr_factor more consistent with lapack for real 
square matrices
27cc7174 is described below

commit 27cc7174e4ab7187452e331fa320e46158f93d54
Author: Konstantinos Poulios 
AuthorDate: Thu Dec 21 00:28:59 2023 +0100

Make gmm qr_factor more consistent with lapack for real square matrices

  - lapack skips the last reflection in dlargf.f for real square matrices
  - fixes make_gmm_test fails when compiled with the lapack interface
---
 src/gmm/gmm_dense_qr.h | 30 ++
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/gmm/gmm_dense_qr.h b/src/gmm/gmm_dense_qr.h
index 3b266868..4bdde208 100644
--- a/src/gmm/gmm_dense_qr.h
+++ b/src/gmm/gmm_dense_qr.h
@@ -54,8 +54,11 @@ namespace gmm {
 GMM_ASSERT2(m >= n, "dimensions mismatch");
 
 std::vector W(m), V(m);
-
-for (size_type j = 0; j < n; ++j) {
+// skip the last reflection for *real* square matrices (m-1 limit)
+// lapack does the same in dlarfg.f but not in zlarfg.f
+const size_type jmax = (m==n && !is_complex(T())) ? m-1
+  : n;
+for (size_type j = 0; j < jmax; ++j) {
   sub_interval SUBI(j, m-j), SUBJ(j, n-j);
   V.resize(m-j); W.resize(n-j);
 
@@ -80,7 +83,10 @@ namespace gmm {
 if (m == 0) return;
 std::vector V(m), W(mat_nrows(A));
 V[0] = T(1);
-for (size_type j = 0; j < n; ++j) {
+// assume that the last reflection was skipped for *real* square matrices
+const size_type jmax = (m==n && !is_complex(T())) ? m-1
+  : n;
+for (size_type j = 0; j < jmax; ++j) {
   V.resize(m-j);
   for (size_type i = j+1; i < m; ++i)
 V[i-j] = QR(i, j);
@@ -102,7 +108,10 @@ namespace gmm {
 if (m == 0) return;
 std::vector V(m), W(mat_ncols(A));
 V[0] = T(1);
-for (size_type j = 0; j < n; ++j) {
+// assume that the last reflection was skipped for *real* square matrices
+const size_type jmax = (m==n && !is_complex(T())) ? m-1
+  : n;
+for (size_type j = 0; j < jmax; ++j) {
   V.resize(m-j);
   for (size_type i = j+1; i < m; ++i) V[i-j] = QR(i, j);
   row_house_update(sub_matrix(A, sub_interval(j, m-j),
@@ -123,8 +132,11 @@ namespace gmm {
 
 std::vector W(m);
 dense_matrix VV(m, n);
-
-for (size_type j = 0; j < n; ++j) {
+// skip the last reflection for *real* square matrices (m-1 limit)
+// lapack does the same in dlarfg.f but not in zlarfg.f
+const size_type jmax = (m==n && !is_complex(T())) ? m-1
+  : n;
+for (size_type j = 0; j < jmax; ++j) {
   sub_interval SUBI(j, m-j), SUBJ(j, n-j);
 
   for (size_type i = j; i < m; ++i) VV(i,j) = Q(i, j);
@@ -136,8 +148,10 @@ namespace gmm {
 
 gmm::copy(sub_matrix(Q, sub_interval(0, n), sub_interval(0, n)), R);
 gmm::copy(identity_matrix(), Q);
-
-for (size_type j = n-1; j != size_type(-1); --j) {
+// assume that the last reflection was skipped for *real* square matrices
+const size_type jstart = (m==n && !is_complex(T())) ? m-2
+: n-1;
+for (size_type j = jstart; j != size_type(-1); --j) {
   sub_interval SUBI(j, m-j), SUBJ(j, n-j);
   row_house_update(sub_matrix(Q, SUBI, SUBJ),
sub_vector(mat_col(VV,j), SUBI), sub_vector(W, SUBJ));



[Getfem-commits] [getfem-commits] branch master updated: Detect zero size matrices in gmm_dense_lu functions

2023-12-20 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 840d5073 Detect zero size matrices in gmm_dense_lu functions
840d5073 is described below

commit 840d5073ac9fd40ba63f504db6aca3a6a61d19e2
Author: Konstantinos Poulios 
AuthorDate: Thu Dec 21 00:21:54 2023 +0100

Detect zero size matrices in gmm_dense_lu functions
---
 src/gmm/gmm_dense_lu.h | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/gmm/gmm_dense_lu.h b/src/gmm/gmm_dense_lu.h
index 1dbb0195..52102366 100644
--- a/src/gmm/gmm_dense_lu.h
+++ b/src/gmm/gmm_dense_lu.h
@@ -130,6 +130,8 @@ namespace gmm {
 typedef typename linalg_traits::value_type T;
 typedef typename number_traits::magnitude_type R;
 size_type info(0), i, j, jp, M(mat_nrows(A)), N(mat_ncols(A));
+if (M == 0 || N == 0)
+  return info;
 size_type NN = std::min(M, N);
 std::vector c(M), r(N);
 
@@ -176,8 +178,11 @@ namespace gmm {
   template 
   void lu_solve(const DenseMatrix , VectorX , const VectorB ) {
 typedef typename linalg_traits::value_type T;
-dense_matrix B(mat_nrows(A), mat_ncols(A));
-lapack_ipvt ipvt(mat_nrows(A));
+const size_type M(mat_nrows(A)), N(mat_ncols(A));
+if (M == 0 || N == 0)
+  return;
+dense_matrix B(M, N);
+lapack_ipvt ipvt(M);
 gmm::copy(A, B);
 size_type info = lu_factor(B, ipvt);
 GMM_ASSERT1(!info, "Singular system, pivot = " << info);
@@ -253,8 +258,11 @@ namespace gmm {
   lu_inverse(const DenseMatrix& A_, bool doassert = true) {
 typedef typename linalg_traits::value_type T;
 DenseMatrix& A = const_cast(A_);
-dense_matrix B(mat_nrows(A), mat_ncols(A));
-lapack_ipvt ipvt(mat_nrows(A));
+const size_type M(mat_nrows(A)), N(mat_ncols(A));
+if (M == 0 || N == 0)
+  return T(1);
+dense_matrix B(M, N);
+lapack_ipvt ipvt(M);
 gmm::copy(A, B);
 size_type info = lu_factor(B, ipvt);
 if (doassert) GMM_ASSERT1(!info, "Non invertible matrix, pivot = "<::value_type T;
 T det(1);
-for (size_type j = 0; j < std::min(mat_nrows(LU), mat_ncols(LU)); ++j)
+const size_type J=std::min(mat_nrows(LU), mat_ncols(LU));
+for (size_type j = 0; j < J; ++j)
   det *= LU(j,j);
 for(size_type i = 0; i < pvector.size(); ++i)
   if (i != size_type(pvector.get(i)-1)) { det = -det; }
@@ -279,8 +288,11 @@ namespace gmm {
   typename linalg_traits::value_type
   lu_det(const DenseMatrix& A) {
 typedef typename linalg_traits::value_type T;
-dense_matrix B(mat_nrows(A), mat_ncols(A));
-lapack_ipvt ipvt(mat_nrows(A));
+const size_type M(mat_nrows(A)), N(mat_ncols(A));
+if (M == 0 || N == 0)
+  return T(1);
+dense_matrix B(M, N);
+lapack_ipvt ipvt(M);
 gmm::copy(A, B);
 lu_factor(B, ipvt);
 return lu_det(B, ipvt);



[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warning

2023-12-20 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 8fa3c636 Fix compilation warning
8fa3c636 is described below

commit 8fa3c6364c0737f6dc8ebac7ec07e0635dbeb122
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 20 23:31:52 2023 +0100

Fix compilation warning
---
 src/gmm/gmm_sub_vector.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gmm/gmm_sub_vector.h b/src/gmm/gmm_sub_vector.h
index c75c8a7b..7c817975 100644
--- a/src/gmm/gmm_sub_vector.h
+++ b/src/gmm/gmm_sub_vector.h
@@ -319,6 +319,9 @@ namespace gmm {
 skyline_sub_vector_iterator
   (const skyline_sub_vector_iterator )
   : itb(it.itb), si(it.si) {}
+skyline_sub_vector_iterator &
+operator =(const skyline_sub_vector_iterator )
+  { itb=it.itb; si=it.si; return *this; }
   };
 
   template 



[Getfem-commits] [getfem-commits] branch master updated: Whitespace fixes

2023-12-20 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 dc63475e Whitespace fixes
dc63475e is described below

commit dc63475e720030ddbed8f967951d999fd61f9fe7
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 20 22:47:16 2023 +0100

Whitespace fixes
---
 src/gmm/gmm_solver_idgmres.h | 869 +--
 1 file changed, 426 insertions(+), 443 deletions(-)

diff --git a/src/gmm/gmm_solver_idgmres.h b/src/gmm/gmm_solver_idgmres.h
index d675dc81..ba987095 100644
--- a/src/gmm/gmm_solver_idgmres.h
+++ b/src/gmm/gmm_solver_idgmres.h
@@ -46,7 +46,7 @@ namespace gmm {
 
   template  compare_vp {
 bool operator()(const std::pair ,
-   const std::pair ) const
+const std::pair ) const
 { return (gmm::abs(a.first) > gmm::abs(b.first)); }
   }
 
@@ -57,35 +57,35 @@ namespace gmm {
 
 idgmres_state(size_type mm, size_type pp, size_type kk)
   : m(mm), tb_deb(1), tb_def(0), p(pp), k(kk), nb_want(0),
-   nb_unwant(0), nb_nolong(0), tb_deftot(0), tb_defwant(0),
-   conv(0), nb_un(0), fin(0), ok(false); {}
+nb_unwant(0), nb_nolong(0), tb_deftot(0), tb_defwant(0),
+conv(0), nb_un(0), fin(0), ok(false); {}
   }
 
-idgmres_state(size_type mm, size_type pp, size_type kk)
-  : m(mm), tb_deb(1), tb_def(0), p(pp), k(kk), nb_want(0),
-   nb_unwant(0), nb_nolong(0), tb_deftot(0), tb_defwant(0),
-   conv(0), nb_un(0), fin(0), ok(false); {}
-  
+  idgmres_state(size_type mm, size_type pp, size_type kk)
+: m(mm), tb_deb(1), tb_def(0), p(pp), k(kk), nb_want(0),
+  nb_unwant(0), nb_nolong(0), tb_deftot(0), tb_defwant(0),
+  conv(0), nb_un(0), fin(0), ok(false); {}
+
 
   template 
   apply_permutation(CONT , const IND ) {
 size_type m = ind.end() - ind.begin();
 std::vector sorted(m, false);
-
+
 for (size_type l = 0; l < m; ++l)
   if (!sorted[l] && ind[l] != l) {
 
-   typeid(cont[0]) aux = cont[l];
-   k = ind[l];
-   cont[l] = cont[k];
-   sorted[l] = true;
-   
-   for(k2 = ind[k]; k2 != l; k2 = ind[k]) {
- cont[k] = cont[k2];
- sorted[k] = true;
- k = k2;
-   }
-   cont[k] = aux;
+typeid(cont[0]) aux = cont[l];
+k = ind[l];
+cont[l] = cont[k];
+sorted[l] = true;
+
+for(k2 = ind[k]; k2 != l; k2 = ind[k]) {
+  cont[k] = cont[k2];
+  sorted[k] = true;
+  k = k2;
+}
+cont[k] = aux;
   }
   }
 
@@ -95,7 +95,7 @@ namespace gmm {
   See: C. Le Calvez, B. Molina, Implicitly restarted and deflated
   FOM and GMRES, numerical applied mathematics,
   (30) 2-3 (1999) pp191-212.
-  
+
   @param A Real or complex unsymmetric matrix.
   @param x initial guess vector and final result.
   @param b right hand side
@@ -109,14 +109,14 @@ namespace gmm {
   @param KS
   */
   template < typename Mat, typename Vec, typename VecB, typename Precond,
-typename Basis >
+ typename Basis >
   void idgmres(const Mat , Vec , const VecB , const Precond ,
-size_type m, size_type p, size_type k, double tol_vp,
-iteration , Basis& KS) {
+ size_type m, size_type p, size_type k, double tol_vp,
+ iteration , Basis& KS) {
 
 typedef typename linalg_traits::value_type T;
 typedef typename number_traits::magnitude_type R;
-
+
 R a, beta;
 idgmres_state st(m, p, k);
 
@@ -125,13 +125,12 @@ namespace gmm {
 std::vector y(m+1), ztest(m+1), gam(m+1);
 std::vector gamma(m+1);
 gmm::dense_matrix H(m+1, m), Hess(m+1, m),
-  Hobl(m+1, m), W(vect_size(x), m+1);
-
+ Hobl(m+1, m), W(vect_size(x), m+1);
 gmm::clear(H);
 
 outer.set_rhsnorm(gmm::vect_norm2(b));
 if (outer.get_rhsnorm() == 0.0) { clear(x); return; }
-
+
 mult(A, scaled(x, -1.0), b, w);
 mult(M, w, r);
 beta = gmm::vect_norm2(r);
@@ -140,9 +139,9 @@ namespace gmm {
 inner.reduce_noisy();
 inner.set_maxiter(m);
 inner.set_name("GMRes inner iter");
-
+
 while (! outer.finished(beta)) {
-  
+
   gmm::copy(gmm::scaled(r, 1.0/beta), KS[0]);
   gmm::clear(s);
   s[0] = beta;
@@ -150,47 +149,46 @@ namespace gmm {
 
   inner.set_maxiter(m - st.tb_deb + 1);
   size_type i = st.tb_deb - 1; inner.init();
-  
+
   do {
-   mult(A, KS[i], u);
-   mult(M, u, KS[i+1]);
-   orthogonalize_with_refinment(KS, mat_col(H, i), i);
-   H(i+1, i) = a = gmm::vect_norm2(KS[i+1]);
-   gmm::scale(KS[i+1], R(1) / a);
-
-   gmm::copy(mat_col(H, i), mat_col(Hess, i));
-   gmm::copy(mat_col(H, i), mat_col(Hobl, i));
-   
-
-   for (size_type l = 0; l < i; ++l)
- Apply_Givens_rotation_left(H(l,i), H(l+1,i), c_rot[l], 

[Getfem-commits] [getfem-commits] branch master updated: Fix bug in blas interface for the Hermitian product

2023-12-20 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 9fd428c7 Fix bug in blas interface for the Hermitian product
9fd428c7 is described below

commit 9fd428c7b377d7191455cbfe5b2515ea540dc625
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 20 22:43:14 2023 +0100

Fix bug in blas interface for the Hermitian product
---
 src/gmm/gmm_blas_interface.h | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 9a3ba519..cc8fdee4 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -169,6 +169,7 @@ namespace gmm {
 void saxpy_(...); /*void daxpy_(...); */void caxpy_(...); void zaxpy_(...);
 BLAS_S sdot_ (...); BLAS_D ddot_ (...);
 BLAS_C cdotu_(...); BLAS_Z zdotu_(...);
+// Hermitian product in {c,z}dotc is defined in reverse order than usually
 BLAS_C cdotc_(...); BLAS_Z zdotc_(...);
 BLAS_S snrm2_(...); BLAS_D dnrm2_(...);
 BLAS_S scnrm2_(...); BLAS_D dznrm2_(...);
@@ -300,37 +301,37 @@ namespace gmm {
  dotc_p2, dotc_trans2, (BLAS_S), sdot_,  BLAS_S)
   dotc_interface(dotc_p1, dotc_trans1, (BLAS_D),
  dotc_p2, dotc_trans2, (BLAS_D), ddot_,  BLAS_D)
-  dotc_interface(dotc_p1, dotc_trans1, (BLAS_C),
- dotc_p2, dotc_trans2, (BLAS_C), cdotc_, BLAS_C)
-  dotc_interface(dotc_p1, dotc_trans1, (BLAS_Z),
- dotc_p2, dotc_trans2, (BLAS_Z), zdotc_, BLAS_Z)
+  dotc_interface(dotc_p2, dotc_trans2, (BLAS_C),
+ dotc_p1, dotc_trans1, (BLAS_C), cdotc_, BLAS_C)
+  dotc_interface(dotc_p2, dotc_trans2, (BLAS_Z),
+ dotc_p1, dotc_trans1, (BLAS_Z), zdotc_, BLAS_Z)
 
   dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
  dotc_p2,   dotc_trans2,   (BLAS_S), sdot_,  BLAS_S)
   dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
  dotc_p2,   dotc_trans2,   (BLAS_D), ddot_,  BLAS_D)
-  dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
- dotc_p2,   dotc_trans2,   (BLAS_C), cdotc_, BLAS_C)
-  dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
- dotc_p2,   dotc_trans2,   (BLAS_Z), zdotc_, BLAS_Z)
+  dotc_interface(dotc_p2,   dotc_trans2,   (BLAS_C),
+ dotc_p1_s, dotc_trans1_s, a*,   cdotc_, BLAS_C)
+  dotc_interface(dotc_p2,   dotc_trans2,   (BLAS_Z),
+ dotc_p1_s, dotc_trans1_s, a*,   zdotc_, BLAS_Z)
 
   dotc_interface(dotc_p1,   dotc_trans1,   (BLAS_S),
  dotc_p2_s, dotc_trans2_s, b*,   sdot_,  BLAS_S)
   dotc_interface(dotc_p1,   dotc_trans1,   (BLAS_D),
  dotc_p2_s, dotc_trans2_s, b*,   ddot_,  BLAS_D)
-  dotc_interface(dotc_p1,   dotc_trans1,   (BLAS_C),
- dotc_p2_s, dotc_trans2_s, b*,   cdotc_, BLAS_C)
-  dotc_interface(dotc_p1,   dotc_trans1,   (BLAS_Z),
- dotc_p2_s, dotc_trans2_s, b*,   zdotc_, BLAS_Z)
+  dotc_interface(dotc_p2_s, dotc_trans2_s, b*,
+ dotc_p1,   dotc_trans1,   (BLAS_C), cdotc_, BLAS_C)
+  dotc_interface(dotc_p2_s, dotc_trans2_s, b*,
+ dotc_p1,   dotc_trans1,   (BLAS_Z), zdotc_, BLAS_Z)
 
   dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
  dotc_p2_s, dotc_trans2_s, b*, sdot_,  BLAS_S)
   dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
  dotc_p2_s, dotc_trans2_s, b*, ddot_,  BLAS_D)
-  dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
- dotc_p2_s, dotc_trans2_s, b*, cdotc_, BLAS_C)
-  dotc_interface(dotc_p1_s, dotc_trans1_s, a*,
- dotc_p2_s, dotc_trans2_s, b*, zdotc_, BLAS_Z)
+  dotc_interface(dotc_p2_s, dotc_trans2_s, b*,
+ dotc_p1_s, dotc_trans1_s, a*, cdotc_, BLAS_C)
+  dotc_interface(dotc_p2_s, dotc_trans2_s, b*,
+ dotc_p1_s, dotc_trans1_s, a*, zdotc_, BLAS_Z)
 
   /* * */
   /* add(x, y).*/



[Getfem-commits] [getfem-commits] branch master updated: Whitespace fixes and code readability improvements

2023-12-20 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 fc87d143 Whitespace fixes and code readability improvements
fc87d143 is described below

commit fc87d143ffc01ade1eb48988b618fdd48903e8f4
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 20 21:54:18 2023 +0100

Whitespace fixes and code readability improvements
---
 src/gmm/gmm_blas_interface.h| 598 
 src/gmm/gmm_dense_Householder.h |  10 +-
 src/gmm/gmm_dense_qr.h  |  27 +-
 3 files changed, 322 insertions(+), 313 deletions(-)

diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h
index 22351ab6..9a3ba519 100644
--- a/src/gmm/gmm_blas_interface.h
+++ b/src/gmm/gmm_blas_interface.h
@@ -48,8 +48,8 @@ namespace gmm {
 
   // Use ./configure --enable-blas-interface to activate this interface.
 
-#define GMMLAPACK_TRACE(f) 
-  // #define GMMLAPACK_TRACE(f) cout << "function " << f << " called" << endl;
+#define GMMLAPACK_TRACE(f)
+// #define GMMLAPACK_TRACE(f) cout << "function " << f << " called" << endl;
 
 #if defined(WeirdNEC) || defined(GMM_USE_BLAS64_INTERFACE)
   #define BLAS_INT long
@@ -74,7 +74,7 @@ namespace gmm {
   /* vect_hp(scaled(std::vector), scaled(std::vector))   */
   /*   */
   /* add(std::vector, std::vector)   */
-  /* add(scaled(std::vector, a), std::vector)*/ 
+  /* add(scaled(std::vector, a), std::vector)*/
   /*   */
   /* mult(dense_matrix, dense_matrix, dense_matrix)   */
   /* mult(transposed(dense_matrix), dense_matrix, dense_matrix)   */
@@ -172,7 +172,7 @@ namespace gmm {
 BLAS_C cdotc_(...); BLAS_Z zdotc_(...);
 BLAS_S snrm2_(...); BLAS_D dnrm2_(...);
 BLAS_S scnrm2_(...); BLAS_D dznrm2_(...);
-void  sger_(...); void  dger_(...); void  cgerc_(...); void  zgerc_(...); 
+void  sger_(...); void  dger_(...); void  cgerc_(...); void  zgerc_(...);
   }
 
 #if 1
@@ -181,19 +181,19 @@ namespace gmm {
   /* vect_norm2(x).*/
   /* * */
 
-# define nrm2_interface(param1, trans1, blas_name, base_type) \
-  inline number_traits::magnitude_type\
-  vect_norm2(param1(base_type)) { \
-GMMLAPACK_TRACE("nrm2_interface");\
+# define nrm2_interface(param1, trans1, blas_name, base_type)  \
+  inline number_traits::magnitude_type \
+  vect_norm2(param1(base_type)) {  \
+GMMLAPACK_TRACE("nrm2_interface"); \
 BLAS_INT inc(1), n(BLAS_INT(vect_size(x))); trans1(base_type); \
-return blas_name(, [0], );\
+return blas_name(, [0], ); \
   }
 
 # define nrm2_p1(base_type) const std::vector 
 # define nrm2_trans1(base_type)
 
-  nrm2_interface(nrm2_p1, nrm2_trans1, snrm2_ , BLAS_S)
-  nrm2_interface(nrm2_p1, nrm2_trans1, dnrm2_ , BLAS_D)
+  nrm2_interface(nrm2_p1, nrm2_trans1, snrm2_,  BLAS_S)
+  nrm2_interface(nrm2_p1, nrm2_trans1, dnrm2_,  BLAS_D)
   nrm2_interface(nrm2_p1, nrm2_trans1, scnrm2_, BLAS_C)
   nrm2_interface(nrm2_p1, nrm2_trans1, dznrm2_, BLAS_Z)
 
@@ -201,7 +201,7 @@ namespace gmm {
   /* vect_sp(x, y).*/
   /* * */
 
-# define dot_interface(param1, trans1, mult1, param2, trans2, mult2,  \
+# define dot_interface(param1, trans1, mult1, param2, trans2, mult2,   \
  blas_name, base_type) \
   inline base_type vect_sp(param1(base_type), param2(base_type)) { \
 GMMLAPACK_TRACE("dot_interface");  \
@@ -228,49 +228,49 @@ namespace gmm {
  const_cast &>(*(linalg_origin(y_)));  \
  base_type b(y_.r)
 
-  dot_interface(dot_p1, dot_trans1, (BLAS_S), dot_p2, dot_trans2, (BLAS_S),
-   sdot_ , BLAS_S)
-  dot_interface(dot_p1, dot_trans1, (BLAS_D), dot_p2, dot_trans2, (BLAS_D),
-   ddot_ , BLAS_D)
-  dot_interface(dot_p1, dot_trans1, (BLAS_C), dot_p2, dot_trans2, (BLAS_C),
-   cdotu_, BLAS_C)
-  dot_interface(dot_p1, dot_trans1, (BLAS_Z), dot_p2, dot_trans2, (BLAS_Z),
-   zdotu_, BLAS_Z)
-  
-  dot_interface(dot_p1_s, dot_trans1_s, a*, dot_p2, dot_trans2, (BLAS_S),
-   sdot_ ,BLAS_S)
-  dot_interface(dot_p1_s, 

[Getfem-commits] [getfem-commits] branch master updated: Style changes

2023-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 c8ed9342 Style changes
c8ed9342 is described below

commit c8ed934245a182656c57b35db0fe29b275cdbe55
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 19 02:05:28 2023 +0100

Style changes
---
 src/getfem/bgeot_config.h |  8 
 src/getfem/getfem_config.h|  4 ++--
 src/getfem/getfem_model_solvers.h |  8 
 src/gmm/gmm_blas.h|  3 ++-
 src/gmm/gmm_dense_Householder.h   |  6 +++---
 src/gmm/gmm_dense_lu.h|  8 
 src/gmm/gmm_dense_qr.h| 33 +++--
 7 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/src/getfem/bgeot_config.h b/src/getfem/bgeot_config.h
index 939054e5..ee5e7783 100644
--- a/src/getfem/bgeot_config.h
+++ b/src/getfem/bgeot_config.h
@@ -39,7 +39,7 @@
 
 #include "getfem/getfem_arch_config.h"
 
-#ifdef GETFEM_HAVE_FEENABLEEXCEPT
+#if defined(GETFEM_HAVE_FEENABLEEXCEPT)
 # include 
 # define FE_ENABLE_EXCEPT { feenableexcept(FE_DIVBYZERO | FE_INVALID | 
FE_OVERFLOW); }
 #else
@@ -50,9 +50,9 @@
 #include "gmm/gmm_kernel.h"
 #include "gmm/gmm_dense_lu.h"
 
-#ifdef GETFEM_HAVE_QDLIB
+#if defined(GETFEM_HAVE_QDLIB)
 // #  define NO_INLINE
-#  ifdef GETFEM_QDLIB_USE_QUAD
+#  if defined(GETFEM_QDLIB_USE_QUAD)
 #include 
 #  else
 #include 
@@ -83,7 +83,7 @@ namespace bgeot {
 # define LONG_SCALAR_EPS 1E-16
 # define LONG_SCAL(xx) long_scalar_type(xx)
 #else
-#  ifdef GETFEM_QDLIB_USE_QUAD
+#  if defined(GETFEM_QDLIB_USE_QUAD)
   typedef qd_real long_scalar_type;
   typedef qd_real opt_long_scalar_type;
   inline scalar_type to_scalar(const qd_real ) { return to_double(a); }
diff --git a/src/getfem/getfem_config.h b/src/getfem/getfem_config.h
index a06821bc..b04219fe 100644
--- a/src/getfem/getfem_config.h
+++ b/src/getfem/getfem_config.h
@@ -160,7 +160,7 @@
 //0 - Sequential
 //1 - Only the resolution of linear systems are parallelized
 //2 - Assembly procedures are also parallelized
-#ifndef GETFEM_PARA_LEVEL
+#if !defined(GETFEM_PARA_LEVEL)
 # define GETFEM_PARA_LEVEL 0
 #endif
 
@@ -168,7 +168,7 @@
 #define GETFEM_MPI_FINALIZE {}
 
 #if defined(GETFEM_HAVE_DMUMPS_C_H)
-# ifndef GMM_USES_MUMPS
+# if !defined(GMM_USES_MUMPS)
 #   define GMM_USES_MUMPS
 # endif
 #endif
diff --git a/src/getfem/getfem_model_solvers.h 
b/src/getfem/getfem_model_solvers.h
index 469896d8..4472bb9e 100644
--- a/src/getfem/getfem_model_solvers.h
+++ b/src/getfem/getfem_model_solvers.h
@@ -168,7 +168,7 @@ namespace getfem {
 }
   };
 
-#ifdef GMM_USES_MUMPS
+#if defined(GMM_USES_MUMPS)
   template 
   struct linear_solver_mumps : public abstract_linear_solver {
 void operator ()(const MAT , VECT , const VECT ,
@@ -631,11 +631,11 @@ namespace getfem {
   >();
 #else
 size_type ndof = md.nb_dof(), max3d = 15000, dim = md.leading_dimension();
-# ifdef GMM_USES_MUMPS
+# if defined(GMM_USES_MUMPS)
 max3d = 25;
 # endif
 if ((ndof<30 && dim<=2) || (ndof>();
   else
@@ -670,7 +670,7 @@ namespace getfem {
 else if (bgeot::casecmp(name, "dense_lu") == 0)
   return std::make_shared>();
 else if (bgeot::casecmp(name, "mumps") == 0) {
-#ifdef GMM_USES_MUMPS
+#if defined(GMM_USES_MUMPS)
 # if GETFEM_PARA_LEVEL <= 1
   return std::make_shared>();
 # else
diff --git a/src/gmm/gmm_blas.h b/src/gmm/gmm_blas.h
index 4426bb7d..b8390976 100644
--- a/src/gmm/gmm_blas.h
+++ b/src/gmm/gmm_blas.h
@@ -1568,7 +1568,8 @@ namespace gmm {
   if (it2 == ite2 || i1 < it2.index()) {
 l2[i1] = *it1; ++i1; ++it1;
 if (it1 == ite1) return;
-it2 = vect_begin(l2); ite2 = vect_end(l2);
+it2 = vect_begin(l2);
+ite2 = vect_end(l2);
   }
   if (ie1 > ite2.index()) {
 --ite1; l2[ie1 - 1] = *ite1;
diff --git a/src/gmm/gmm_dense_Householder.h b/src/gmm/gmm_dense_Householder.h
index ea010ed5..31725cfc 100644
--- a/src/gmm/gmm_dense_Householder.h
+++ b/src/gmm/gmm_dense_Householder.h
@@ -245,7 +245,7 @@ namespace gmm {
 
   template 
   void Householder_tridiagonalization(const MAT1 , const MAT2 ,
-  bool compute_q) {
+  bool compute_Q) {
 MAT1  = const_cast(AA); MAT2  = const_cast(QQ);
 typedef typename linalg_traits::value_type T;
 typedef typename number_traits::magnitude_type R;
@@ -267,8 +267,8 @@ namespace gmm {
   gmm::add(p, gmm::scaled(v, -vect_hp(v, p) / norm), w);
   rank_two_update(sub_matrix(A, SUBI), v, w);
   // it should be possible to compute only the upper or lower part
-
-  if (compute_q) col_house_update(sub_matrix(Q, SUBK, SUBI), v, ww);
+  if (compute_Q)
+col_house_update(sub_matrix(Q, SUBK, SUBI), v, ww);
 }
   }
 
diff --git a/src/gmm/gmm_dense_lu.h b/src/gmm/gmm_dense_lu.h

[Getfem-commits] [getfem-commits] branch remove-local-superlu updated: Fix typo

2023-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 remove-local-superlu
in repository getfem.

The following commit(s) were added to refs/heads/remove-local-superlu by this 
push:
 new c53ddd92 Fix typo
c53ddd92 is described below

commit c53ddd924d5c6f882813cd0b097717f45e2f348b
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 19 01:04:23 2023 +0100

Fix typo
---
 src/getfem/getfem_model_solvers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem/getfem_model_solvers.h 
b/src/getfem/getfem_model_solvers.h
index e3397197..ca93ceb2 100644
--- a/src/getfem/getfem_model_solvers.h
+++ b/src/getfem/getfem_model_solvers.h
@@ -642,7 +642,7 @@ namespace getfem {
 return std::make_shared>();
   else
 return std::make_shared>();
-# elif definded(GETFEM_USES_SUPERLU)
+# elif defined(GETFEM_USES_SUPERLU)
   return std::make_shared>();
 # else
   static_assert(false,



[Getfem-commits] (no subject)

2023-12-18 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit aa84a361909484226d0d1c59f382b8c88d8f4c34
Author: Konstantinos Poulios 
AuthorDate: Sat Nov 18 20:52:37 2023 +0100

Make SuperLU optional
---
 interface/src/getfemint_precond.h | 43 ---
 interface/src/gf_linsolve.cc  |  5 -
 interface/src/gf_precond.cc   |  4 
 src/Makefile.am   |  7 +--
 src/getfem/getfem_config.h|  7 +++
 src/getfem/getfem_model_solvers.h | 18 
 src/getfem/getfem_superlu.h   | 10 -
 tests/laplacian.cc|  4 +++-
 tests/schwarz_additive.cc | 28 +++--
 9 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/interface/src/getfemint_precond.h 
b/interface/src/getfemint_precond.h
index 8af6c79b..7dee1aaa 100644
--- a/interface/src/getfemint_precond.h
+++ b/interface/src/getfemint_precond.h
@@ -52,7 +52,7 @@ namespace getfemint {
 size_type ncols(void) const { return gsp ? gsp->ncols() : ncols_; }
 void set_dimensions(size_type m, size_type n) { nrows_ = m; ncols_ = n; }
 gprecond_base() : nrows_(0), ncols_(0), type(IDENTITY), gsp(0) {}
-const char *name() const { 
+const char *name() const {
   const char *p[] = { "IDENTITY", "DIAG", "ILDLT", "ILDLTT", "ILU", "ILUT",
  "SUPERLU", "GSPARSE" };
   return p[type];
@@ -69,7 +69,9 @@ namespace getfemint {
 std::unique_ptr > ildltt;
 std::unique_ptr > ilu;
 std::unique_ptr > ilut;
+#if defined(GETFEM_USES_SUPERLU)
 std::unique_ptr > superlu;
+#endif
 
 virtual size_type memsize() const {
   size_type sz = sizeof(*this);
@@ -81,10 +83,15 @@ namespace getfemint {
   case ILDLT:   sz += ildlt->memsize(); break;
   case ILDLTT:  sz += ildltt->memsize(); break;
   case SUPERLU:
-   sz += size_type(superlu->memsize()); break;
+#if defined(GETFEM_USES_SUPERLU)
+sz += size_type(superlu->memsize());
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case SPMAT:   sz += gsp->memsize(); break;
   }
-  return sz; 
+  return sz;
 }
   };
 
@@ -120,28 +127,32 @@ namespace gmm {
 switch (precond.type) {
   case getfemint::gprecond_base::IDENTITY: gmm::copy(v,w); break;
   case getfemint::gprecond_base::DIAG:
-   gmm::mult(*precond.diagonal, v, w);
-   break;
-  case getfemint::gprecond_base::ILDLT: 
-if (do_mult) gmm::mult(*precond.ildlt, v, w); 
+gmm::mult(*precond.diagonal, v, w);
+break;
+  case getfemint::gprecond_base::ILDLT:
+if (do_mult) gmm::mult(*precond.ildlt, v, w);
 else gmm::transposed_mult(*precond.ildlt, v, w);
 break;
-  case getfemint::gprecond_base::ILDLTT: 
-if (do_mult) gmm::mult(*precond.ildltt, v, w); 
+  case getfemint::gprecond_base::ILDLTT:
+if (do_mult) gmm::mult(*precond.ildltt, v, w);
 else gmm::transposed_mult(*precond.ildltt, v, w);
 break;
-  case getfemint::gprecond_base::ILU: 
-if (do_mult) gmm::mult(*precond.ilu, v, w); 
+  case getfemint::gprecond_base::ILU:
+if (do_mult) gmm::mult(*precond.ilu, v, w);
 else gmm::transposed_mult(*precond.ilu, v, w);
 break;
-  case getfemint::gprecond_base::ILUT: 
-if (do_mult) gmm::mult(*precond.ilut, v, w); 
+  case getfemint::gprecond_base::ILUT:
+if (do_mult) gmm::mult(*precond.ilut, v, w);
 else gmm::transposed_mult(*precond.ilut, v, w);
 break;
   case getfemint::gprecond_base::SUPERLU:
-   if (do_mult) precond.superlu->solve(w,v);
-   else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
-   break;
+#if defined(GETFEM_USES_SUPERLU)
+if (do_mult) precond.superlu->solve(w,v);
+else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case getfemint::gprecond_base::SPMAT:
precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
 break;
diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index a04adbe5..1b8f42ff 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype,
   else  iterative_gmm_solver(stype, gsp, in, out, 
scalar_type());
 }
 
+#if defined(GETFEM_USES_SUPERLU)
 template  static void
 superlu_solver(gsparse ,
getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) {
@@ -96,6 +97,7 @@ superlu_solver(gsparse ,
   if (out.remaining())
 out.pop().from_scalar(rcond ? 1./rcond : 0.);
 }
+#endif
 
 #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H)
 template  static void
@@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, 
getfemint::mexargs_out& m_out) {
);
 
 
+#if 

[Getfem-commits] (no subject)

2023-12-18 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit 8ce9151ff5378061db7784aa031250455b47c60a
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 5 14:04:25 2023 +0100

Improve configuration without superlu
---
 configure.ac | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 16a854de..1ab7d38d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -807,6 +807,7 @@ AC_ARG_WITH(superlu-include-dir,
 CPPFLAGS="$CPPFLAGS $SUPERLUINC"
 
 if test "x$require_superlu" = "xno"; then
+  SUPERLU_LIBS=""
   echo "Building with SuperLU explicitly disabled";
 else
   AC_CHECK_HEADERS(
@@ -834,6 +835,11 @@ else
   SUPERLU_LIBS=""
   LIBS="$save_LIBS"
 fi
+  elif test "x$require_superlu" = "xyes"; then
+AC_MSG_ERROR([SuperLU header files not found but required by the user. 
Aborting configure...]);
+  else
+echo "SuperLU header files not found, building without SuperLU"
+SUPERLU_LIBS=""
   fi
 fi
 



[Getfem-commits] [getfem-commits] remove-local-superlu updated (a7601235 -> 8ce9151f)

2023-12-18 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

 discard a7601235 Improve configuration without superlu
 discard cfad3bd4 Make SuperLU optional
 discard 19656941 Remove local SuperLU copy
 add 3c37cc1a minor modification for clang compatibility
 new ad5f71e5 Remove local SuperLU copy
 new aa84a361 Make SuperLU optional
 new 8ce9151f Improve configuration without superlu

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a7601235)
\
 N -- N -- N   refs/heads/remove-local-superlu (8ce9151f)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.


Summary of changes:
 contrib/bimaterial_crack_test/crack.cc |  16 ++--
 contrib/crack_plate/crack_bilaplacian_moment.cc|  14 +--
 contrib/delaminated_crack/delaminated_crack.cc |   2 +-
 contrib/icare/icare.cc |  26 +++---
 contrib/opt_assembly/opt_assembly.cc   |   4 +-
 .../xfem_stab_unilat_contact.cc|  16 ++--
 interface/src/gf_slice_get.cc  |   2 +-
 src/getfem/dal_basic.h |   6 ++
 src/getfem/dal_bit_vector.h|   8 ++
 src/getfem/dal_tas.h   |   8 +-
 src/getfem/getfem_generic_assembly.h   |   4 +-
 src/getfem/getfem_mesh_fem.h   |   6 +-
 src/getfem_contact_and_friction_large_sliding.cc   |  12 +--
 src/getfem_fem.cc  |   4 +-
 src/getfem_mesh_level_set.cc   |   4 +-
 src/getfem_mesher.cc   |   2 +-
 src/gmm/gmm_conjugated.h   |  10 ++-
 src/gmm/gmm_interface.h|   8 +-
 src/gmm/gmm_real_part.h|   4 +
 src/gmm/gmm_ref.h  |  18 
 src/gmm/gmm_scaled.h   |  14 ++-
 src/gmm/gmm_std.h  |   6 +-
 src/gmm/gmm_sub_matrix.h   |   8 +-
 src/gmm/gmm_sub_vector.h   |   4 +-
 src/gmm/gmm_vector.h   |   8 ++
 src/gmm/gmm_vector_to_matrix.h |   8 +-
 tests/crack.cc |  16 ++--
 tests/heat_equation.cc |   2 +-
 tests/integration.cc   | 100 ++---
 tests/nonlinear_elastostatic.cc|   2 +-
 tests/poly.cc  |   6 +-
 tests/schwarz_additive.cc  |   2 +-
 tests/test_assembly.cc |   4 +-
 tests/test_continuation.cc |  10 +--
 tests/test_interpolated_fem.cc |  32 +++
 tests/test_mat_elem.cc |  64 ++---
 tests/wave_equation.cc |   2 +-
 37 files changed, 274 insertions(+), 188 deletions(-)



[Getfem-commits] (no subject)

2023-12-07 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit cfad3bd4775148b5b41d301e83085eb52f239b09
Author: Konstantinos Poulios 
AuthorDate: Sat Nov 18 20:52:37 2023 +0100

Make SuperLU optional
---
 interface/src/getfemint_precond.h | 43 ---
 interface/src/gf_linsolve.cc  |  5 -
 interface/src/gf_precond.cc   |  4 
 src/Makefile.am   |  7 +--
 src/getfem/getfem_config.h|  7 +++
 src/getfem/getfem_model_solvers.h | 18 
 src/getfem/getfem_superlu.h   | 10 -
 tests/laplacian.cc|  4 +++-
 tests/schwarz_additive.cc | 28 +++--
 9 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/interface/src/getfemint_precond.h 
b/interface/src/getfemint_precond.h
index 8af6c79b..7dee1aaa 100644
--- a/interface/src/getfemint_precond.h
+++ b/interface/src/getfemint_precond.h
@@ -52,7 +52,7 @@ namespace getfemint {
 size_type ncols(void) const { return gsp ? gsp->ncols() : ncols_; }
 void set_dimensions(size_type m, size_type n) { nrows_ = m; ncols_ = n; }
 gprecond_base() : nrows_(0), ncols_(0), type(IDENTITY), gsp(0) {}
-const char *name() const { 
+const char *name() const {
   const char *p[] = { "IDENTITY", "DIAG", "ILDLT", "ILDLTT", "ILU", "ILUT",
  "SUPERLU", "GSPARSE" };
   return p[type];
@@ -69,7 +69,9 @@ namespace getfemint {
 std::unique_ptr > ildltt;
 std::unique_ptr > ilu;
 std::unique_ptr > ilut;
+#if defined(GETFEM_USES_SUPERLU)
 std::unique_ptr > superlu;
+#endif
 
 virtual size_type memsize() const {
   size_type sz = sizeof(*this);
@@ -81,10 +83,15 @@ namespace getfemint {
   case ILDLT:   sz += ildlt->memsize(); break;
   case ILDLTT:  sz += ildltt->memsize(); break;
   case SUPERLU:
-   sz += size_type(superlu->memsize()); break;
+#if defined(GETFEM_USES_SUPERLU)
+sz += size_type(superlu->memsize());
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case SPMAT:   sz += gsp->memsize(); break;
   }
-  return sz; 
+  return sz;
 }
   };
 
@@ -120,28 +127,32 @@ namespace gmm {
 switch (precond.type) {
   case getfemint::gprecond_base::IDENTITY: gmm::copy(v,w); break;
   case getfemint::gprecond_base::DIAG:
-   gmm::mult(*precond.diagonal, v, w);
-   break;
-  case getfemint::gprecond_base::ILDLT: 
-if (do_mult) gmm::mult(*precond.ildlt, v, w); 
+gmm::mult(*precond.diagonal, v, w);
+break;
+  case getfemint::gprecond_base::ILDLT:
+if (do_mult) gmm::mult(*precond.ildlt, v, w);
 else gmm::transposed_mult(*precond.ildlt, v, w);
 break;
-  case getfemint::gprecond_base::ILDLTT: 
-if (do_mult) gmm::mult(*precond.ildltt, v, w); 
+  case getfemint::gprecond_base::ILDLTT:
+if (do_mult) gmm::mult(*precond.ildltt, v, w);
 else gmm::transposed_mult(*precond.ildltt, v, w);
 break;
-  case getfemint::gprecond_base::ILU: 
-if (do_mult) gmm::mult(*precond.ilu, v, w); 
+  case getfemint::gprecond_base::ILU:
+if (do_mult) gmm::mult(*precond.ilu, v, w);
 else gmm::transposed_mult(*precond.ilu, v, w);
 break;
-  case getfemint::gprecond_base::ILUT: 
-if (do_mult) gmm::mult(*precond.ilut, v, w); 
+  case getfemint::gprecond_base::ILUT:
+if (do_mult) gmm::mult(*precond.ilut, v, w);
 else gmm::transposed_mult(*precond.ilut, v, w);
 break;
   case getfemint::gprecond_base::SUPERLU:
-   if (do_mult) precond.superlu->solve(w,v);
-   else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
-   break;
+#if defined(GETFEM_USES_SUPERLU)
+if (do_mult) precond.superlu->solve(w,v);
+else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case getfemint::gprecond_base::SPMAT:
precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
 break;
diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index a04adbe5..1b8f42ff 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype,
   else  iterative_gmm_solver(stype, gsp, in, out, 
scalar_type());
 }
 
+#if defined(GETFEM_USES_SUPERLU)
 template  static void
 superlu_solver(gsparse ,
getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) {
@@ -96,6 +97,7 @@ superlu_solver(gsparse ,
   if (out.remaining())
 out.pop().from_scalar(rcond ? 1./rcond : 0.);
 }
+#endif
 
 #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H)
 template  static void
@@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, 
getfemint::mexargs_out& m_out) {
);
 
 
+#if 

[Getfem-commits] (no subject)

2023-12-07 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit a7601235adf39a1b141542d8c7535aac9f54a29e
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 5 14:04:25 2023 +0100

Improve configuration without superlu
---
 configure.ac | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 16a854de..1ab7d38d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -807,6 +807,7 @@ AC_ARG_WITH(superlu-include-dir,
 CPPFLAGS="$CPPFLAGS $SUPERLUINC"
 
 if test "x$require_superlu" = "xno"; then
+  SUPERLU_LIBS=""
   echo "Building with SuperLU explicitly disabled";
 else
   AC_CHECK_HEADERS(
@@ -834,6 +835,11 @@ else
   SUPERLU_LIBS=""
   LIBS="$save_LIBS"
 fi
+  elif test "x$require_superlu" = "xyes"; then
+AC_MSG_ERROR([SuperLU header files not found but required by the user. 
Aborting configure...]);
+  else
+echo "SuperLU header files not found, building without SuperLU"
+SUPERLU_LIBS=""
   fi
 fi
 



[Getfem-commits] [getfem-commits] remove-local-superlu updated (597d39a0 -> a7601235)

2023-12-07 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

 discard 597d39a0 Improve configuration without superlu
 discard c7c7db69 Make SuperLU optional
 discard e0655e02 Remove local SuperLU copy
 add 0ce4bf39 Use hard coded loop unrollings
 add a6d784a5 Honor constness in ga_instruction classes and better variable 
names
 add 3812ecc6 Add hardcoded matmult for small matrices and possibility of 
BLAS gemm for larger ones
 add a2054d89 Some more BLAS alternative implementations in ga_instructions 
and fixes for the previous commit
 add 6b16bb19 More (optional) use of BLAS inside 
ga_instruction_contraction... classes and rearrange code
 add 138f66ec Enable use of BLAS in generic assembly instructions by default
 new 19656941 Remove local SuperLU copy
 new cfad3bd4 Make SuperLU optional
 new a7601235 Improve configuration without superlu

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (597d39a0)
\
 N -- N -- N   refs/heads/remove-local-superlu (a7601235)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.


Summary of changes:
 src/getfem_generic_assembly_compile_and_exec.cc | 1264 ---
 1 file changed, 898 insertions(+), 366 deletions(-)



[Getfem-commits] [getfem-commits] branch master updated: Enable use of BLAS in generic assembly instructions by default

2023-12-07 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 138f66ec Enable use of BLAS in generic assembly instructions by default
138f66ec is described below

commit 138f66ec338c6c5227ff670677e464689b10d3a2
Author: Konstantinos Poulios 
AuthorDate: Thu Dec 7 16:20:04 2023 +0100

Enable use of BLAS in generic assembly instructions by default

  - major performance improvement in 1 of the benchmarks in
test_assembly.cc
---
 src/getfem_generic_assembly_compile_and_exec.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 4dc34a28..7ae88cb6 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -25,7 +25,9 @@
 #include "getfem/getfem_generic_assembly_compile_and_exec.h"
 #include "getfem/getfem_generic_assembly_functions_and_operators.h"
 
-//#define GA_USES_BLAS
+#if defined(GMM_USES_BLAS)
+#define GA_USES_BLAS
+#endif
 
 // #define GA_DEBUG_INFO(a) { cout << a << endl; }
 #define GA_DEBUG_INFO(a)



[Getfem-commits] [getfem-commits] branch master updated: More (optional) use of BLAS inside ga_instruction_contraction... classes and rearrange code

2023-12-07 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 6b16bb19 More (optional) use of BLAS inside 
ga_instruction_contraction... classes and rearrange code
6b16bb19 is described below

commit 6b16bb199598cb673ec977fcb13e15cab38ed13b
Author: Konstantinos Poulios 
AuthorDate: Thu Dec 7 14:16:11 2023 +0100

More (optional) use of BLAS inside ga_instruction_contraction... classes 
and rearrange code
---
 src/getfem_generic_assembly_compile_and_exec.cc | 450 
 1 file changed, 228 insertions(+), 222 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index d6c398d1..4dc34a28 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -2091,6 +2091,187 @@ namespace getfem {
   : t(t_), c(c_), d(d_) {}
   };
 
+  template inline void dax__(base_tensor::iterator ,
+base_tensor::const_iterator ,
+const scalar_type ) {
+constexpr int I1 = I/8;
+constexpr int I2 = I - I1*8;
+for (int i=0; i < I1; ++i)
+  dax__<8>(it, itx , a);
+dax__(it, itx , a);
+  }
+  template<> inline void dax__<8>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<7>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<6>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<5>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<4>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<3>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<2>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<1>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<0>(base_tensor::iterator &,
+  base_tensor::const_iterator &,
+  const scalar_type &) {}
+
+
+  template inline
+  void reduc_elem_unrolled__(base_tensor::iterator ,
+ base_tensor::const_iterator , 
base_tensor::const_iterator ,
+ const size_type s1, const size_type s2) {
+*it = it1[0] * it2[0];
+for (int i=1; i < I; ++i)
+  *it += it1[i*s1] * it2[i*s2];
+  }
+  template<> inline
+  void reduc_elem_unrolled__<9>(base_tensor::iterator ,
+base_tensor::const_iterator , 
base_tensor::const_iterator ,
+const size_type s1, const size_type s2) {
+*it = it1[0]* it2[0]   // (*it1)* (*it2)
++ it1[s1]   * it2[s2]  // (*(it1+s1))   * (*(it2+s2))
++ it1[2*s1] * it2[2*s2]// (*(it1+2*s1)) * (*(it2+2*s2))
++ it1[3*s1] * it2[3*s2]// (*(it1+3*s1)) * (*(it2+3*s2))
++ it1[4*s1] * it2[4*s2]// (*(it1+4*s1)) * (*(it2+4*s2))
++ it1[5*s1] * it2[5*s2]// (*(it1+5*s1)) * (*(it2+5*s2))
++ it1[6*s1] * it2[6*s2]// (*(it1+6*s1)) * 

[Getfem-commits] [getfem-commits] branch master updated: Some more BLAS alternative implementations in ga_instructions and fixes for the previous commit

2023-12-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 a2054d89 Some more BLAS alternative implementations in ga_instructions 
and fixes for the previous commit
a2054d89 is described below

commit a2054d896bd8da7e877e03376154b1a0bc890b88
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 6 20:57:10 2023 +0100

Some more BLAS alternative implementations in ga_instructions and fixes for 
the previous commit
---
 src/getfem_generic_assembly_compile_and_exec.cc | 291 
 1 file changed, 191 insertions(+), 100 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 191e79a1..d6c398d1 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -2455,8 +2455,8 @@ namespace getfem {
 #if defined(GA_USES_BLAS)
   if (M*J*K > 27) {
 const BLAS_INT M_=BLAS_INT(M), J_=BLAS_INT(J), K_=BLAS_INT(K);
-char notrans = 'N';
-static const scalar_type one(1), zero(0);
+constexpr char notrans = 'N';
+constexpr scalar_type one(1), zero(0);
 gmm::dgemm_(, , _, _, _, ,
 &(tc1[0]), _, &(tc2[0]), _, , &(t[0]), _);
   } else
@@ -2507,6 +2507,20 @@ namespace getfem {
 "(dot product or matrix multiplication)");
   const size_type MI = tc1.size() / J,M = MI / I,
   NJ = tc2.size() / K,N = NJ / J;
+#if defined(GA_USES_BLAS)
+  const BLAS_INT J_ = BLAS_INT(J), M_ = BLAS_INT(M), N_ = BLAS_INT(N),
+ MI_ = BLAS_INT(MI);
+  constexpr char notrans = 'N', trans = 'T';
+  constexpr scalar_type one(1), zero(0);
+  size_type MN = M*N;
+  auto it = t.begin();
+  for (size_type k = 0; k < K; ++k)
+for (size_type i = 0; i < I; ++i, it += MN)  // => t[M*N*(i+I*k)]
+  gmm::dgemm_(, , _, _, _, ,
+  &(tc1[M*i]), _, &(tc2[NJ*k]), _, ,
+  &(*it), _);
+  GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+#else
   auto it = t.begin();
   for (size_type k = 0; k < K; ++k)
 for (size_type i = 0; i < I; ++i)
@@ -2517,6 +2531,7 @@ namespace getfem {
 *it += tc1[m+M*i+MI*j] * tc2[n+N*j+NJ*k];
 }
   GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+#endif
   return 0;
 }
 ga_instruction_matrix_mult_spec(base_tensor _,
@@ -2537,6 +2552,18 @@ namespace getfem {
 "(dot product or matrix multiplication)");
   const size_type MI = tc1.size() / J,
   NJ = tc2.size() / K,N = NJ / J;
+#if defined(GA_USES_BLAS)
+  const BLAS_INT J_ = BLAS_INT(J), MI_ = BLAS_INT(MI), N_ = BLAS_INT(N);
+  constexpr char notrans = 'N', trans = 'T';
+  constexpr scalar_type one(1), zero(0);
+  size_type NMI = N*MI;
+  auto it = t.begin();
+  for (size_type k = 0; k < K; ++k, it += NMI) // => it[N*M*I*k]
+gmm::dgemm_(, , _, _, _, ,
+&(tc2[NJ*k]), _, &(tc1[0]), _, ,
+&(*it), _);
+  GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+#else
   auto it = t.begin();
   for (size_type k = 0; k < K; ++k)
 for (size_type mi = 0; mi < MI; ++mi)
@@ -2546,6 +2573,7 @@ namespace getfem {
   *it += tc1[mi+MI*j] * tc2[n+N*j+NJ*k];
   }
   GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+#endif
   return 0;
 }
 ga_instruction_matrix_mult_spec2(base_tensor _,
@@ -2924,6 +2952,88 @@ namespace getfem {
 
 
 
+  template inline void dax__(base_tensor::iterator ,
+base_tensor::const_iterator ,
+const scalar_type ) {
+constexpr int I1 = I/8;
+constexpr int I2 = I - I1*8;
+for (int i=0; i < I1; ++i)
+  dax__<8>(it, itx , a);
+dax__(it, itx , a);
+  }
+  template<> inline void dax__<8>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<7>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+*it++ = *itx++ * a;
+  }
+  template<> inline void dax__<6>(base_tensor::iterator ,
+  base_tensor::const_iterator ,
+  const scalar_type ) {
+

[Getfem-commits] [getfem-commits] branch master updated: Add hardcoded matmult for small matrices and possibility of BLAS gemm for larger ones

2023-12-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 3812ecc6 Add hardcoded matmult for small matrices and possibility of 
BLAS gemm for larger ones
3812ecc6 is described below

commit 3812ecc64553d928311a79bee5a8b55c4c72144f
Author: Konstantinos Poulios 
AuthorDate: Wed Dec 6 14:40:33 2023 +0100

Add hardcoded matmult for small matrices and possibility of BLAS gemm for 
larger ones
---
 src/getfem_generic_assembly_compile_and_exec.cc | 308 +++-
 1 file changed, 243 insertions(+), 65 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 885fa512..191e79a1 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -2452,14 +2452,42 @@ namespace getfem {
 "(dot product or matrix multiplication)");
   size_type M = tc1.size() / J,
 K = tc2.size() / J;
-  auto it = t.begin();
-  for (size_type k = 0; k < K; ++k)
-for (size_type m = 0; m < M; ++m, ++it) {
-*it = scalar_type(0);
-for (size_type j = 0; j < J; ++j)
-  *it += tc1[m+M*j] * tc2[j+J*k];
-  }
-  GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+#if defined(GA_USES_BLAS)
+  if (M*J*K > 27) {
+const BLAS_INT M_=BLAS_INT(M), J_=BLAS_INT(J), K_=BLAS_INT(K);
+char notrans = 'N';
+static const scalar_type one(1), zero(0);
+gmm::dgemm_(, , _, _, _, ,
+&(tc1[0]), _, &(tc2[0]), _, , &(t[0]), _);
+  } else
+#endif
+  {
+auto it = t.begin();
+if (M==2 && J==2 && K == 2) {
+  *it++ = tc1[0]*tc2[0] + tc1[2]*tc2[1]; // k=0,m=0
+  *it++ = tc1[1]*tc2[0] + tc1[3]*tc2[1]; // k=0,m=1
+  *it++ = tc1[0]*tc2[2] + tc1[2]*tc2[3]; // k=1,m=0
+  *it++ = tc1[1]*tc2[2] + tc1[3]*tc2[3]; // k=1,m=1
+} else if (M==3 && J==3 && K == 3) {
+  *it++ = tc1[0]*tc2[0] + tc1[3]*tc2[1] + tc1[6]*tc2[2]; // k=0,m=0
+  *it++ = tc1[1]*tc2[0] + tc1[4]*tc2[1] + tc1[7]*tc2[2]; // k=0,m=1
+  *it++ = tc1[2]*tc2[0] + tc1[5]*tc2[1] + tc1[8]*tc2[2]; // k=0,m=2
+  *it++ = tc1[0]*tc2[3] + tc1[3]*tc2[4] + tc1[6]*tc2[5]; // k=1,m=0
+  *it++ = tc1[1]*tc2[3] + tc1[4]*tc2[4] + tc1[7]*tc2[5]; // k=1,m=1
+  *it++ = tc1[2]*tc2[3] + tc1[5]*tc2[4] + tc1[8]*tc2[5]; // k=1,m=2
+  *it++ = tc1[0]*tc2[6] + tc1[3]*tc2[7] + tc1[6]*tc2[8]; // k=2,m=0
+  *it++ = tc1[1]*tc2[6] + tc1[4]*tc2[7] + tc1[7]*tc2[8]; // k=2,m=1
+  *it++ = tc1[2]*tc2[6] + tc1[5]*tc2[7] + tc1[8]*tc2[8]; // k=2,m=2
+} else {
+  for (size_type k = 0; k < K; ++k)
+for (size_type m = 0; m < M; ++m, ++it) {
+*it = scalar_type(0);
+for (size_type j = 0; j < J; ++j)
+  *it += tc1[m+M*j] * tc2[j+J*k];
+  }
+}
+GA_DEBUG_ASSERT(it == t.end(), "Wrong sizes");
+  }
   return 0;
 }
 ga_instruction_matrix_mult(base_tensor _,
@@ -2899,100 +2927,100 @@ namespace getfem {
   template inline
   void reduc_elem_unrolled__(base_tensor::iterator ,
  base_tensor::const_iterator , 
base_tensor::const_iterator ,
- size_type s1, size_type s2) {
-*it = (*it1)*(*it2);
+ const size_type s1, const size_type s2) {
+*it = it1[0] * it2[0];
 for (int i=1; i < I; ++i)
-  *it += (*(it1+i*s1)) * (*(it2+i*s2));
+  *it += it1[i*s1] * it2[i*s2];
   }
   template<> inline
   void reduc_elem_unrolled__<9>(base_tensor::iterator ,
 base_tensor::const_iterator , 
base_tensor::const_iterator ,
-size_type s1, size_type s2) {
-*it = (*it1) * (*it2);
-*it += (*(it1+s1)) * (*(it2+s2));
-*it += (*(it1+2*s1)) * (*(it2+2*s2));
-*it += (*(it1+3*s1)) * (*(it2+3*s2));
-*it += (*(it1+4*s1)) * (*(it2+4*s2));
-*it += (*(it1+5*s1)) * (*(it2+5*s2));
-*it += (*(it1+6*s1)) * (*(it2+6*s2));
-*it += (*(it1+7*s1)) * (*(it2+7*s2));
-*it += (*(it1+8*s1)) * (*(it2+8*s2));
+const size_type s1, const size_type s2) {
+*it = it1[0]* it2[0]
++ it1[s1]   * it2[s2]
++ it1[2*s1] * it2[2*s2]
++ it1[3*s1] * it2[3*s2]
++ it1[4*s1] * it2[4*s2]
++ it1[5*s1] * it2[5*s2]
++ it1[6*s1] * it2[6*s2]
++ it1[7*s1] * it2[7*s2]
++ it1[8*s1] * it2[8*s2];
   }
   template<> inline
   void reduc_elem_unrolled__<8>(base_tensor::iterator ,
 base_tensor::const_iterator , 
base_tensor::const_iterator ,
-size_type s1, size_type s2) {
-*it = (*it1) * (*it2);
- 

[Getfem-commits] [getfem-commits] branch master updated: Honor constness in ga_instruction classes and better variable names

2023-12-05 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 a6d784a5 Honor constness in ga_instruction classes and better variable 
names
a6d784a5 is described below

commit a6d784a51c5f3b5058006cd6535df5f00f139952
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 5 21:49:13 2023 +0100

Honor constness in ga_instruction classes and better variable names
---
 src/getfem_generic_assembly_compile_and_exec.cc | 526 ++--
 1 file changed, 302 insertions(+), 224 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index f51bcf80..885fa512 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -2092,37 +2092,40 @@ namespace getfem {
   };
 
   struct ga_instruction_scalar_mult : public ga_instruction {
-base_tensor , 
+base_tensor 
+const base_tensor 
 const scalar_type 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: multiplication of a tensor by a scalar " << 
c);
   gmm::copy(gmm::scaled(tc1.as_vector(), c), t.as_vector());
   return 0;
 }
-ga_instruction_scalar_mult(base_tensor _, base_tensor _,
-   const scalar_type _)
+ga_instruction_scalar_mult(base_tensor _,
+   const base_tensor _, const scalar_type _)
   : t(t_), tc1(tc1_), c(c_) {}
   };
 
   struct ga_instruction_scalar_div : public ga_instruction {
-base_tensor , 
+base_tensor 
+const base_tensor 
 const scalar_type 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: division of a tensor by a scalar");
   GA_DEBUG_ASSERT(t.size() == tc1.size(), "Wrong sizes");
-
-  base_tensor::iterator it = t.begin(), it1 = tc1.begin();
+  base_tensor::iterator it = t.begin();
+  base_tensor::const_iterator it1 = tc1.cbegin();
   for (; it != t.end(); ++it, ++it1) *it = *it1/c;
   return 0;
 }
-ga_instruction_scalar_div(base_tensor _, base_tensor _,
-   const scalar_type _)
+ga_instruction_scalar_div(base_tensor _,
+  const base_tensor _, const scalar_type _)
   : t(t_), tc1(tc1_), c(c_) {}
   };
 
   // Performs Cross product in the presence of test functions
   struct ga_instruction_cross_product_tf : public ga_instruction {
-base_tensor , , 
+base_tensor 
+const base_tensor , 
 bool inv;
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: Cross product with test functions");
@@ -2130,11 +2133,11 @@ namespace getfem {
   size_type n1 = tc1.size() / 3, n2 =  tc2.size() / 3, nn=n1*n2;
   GA_DEBUG_ASSERT(t.size() == nn*3, "Bad tensor size for cross product");
   size_type mm=2*nn, n1_2 = 2*n1, n2_2 = 2*n2;
-  base_tensor::iterator it = t.begin(), it2 = tc2.begin();
-
+  base_tensor::iterator it = t.begin();
+  base_tensor::const_iterator it2 = tc2.cbegin();
   if (inv) {
 for (size_type i = 0; i < n2; ++i, ++it2) {
-  base_tensor::iterator it1 = tc1.begin();
+  base_tensor::const_iterator it1 = tc1.cbegin();
   for (size_type j = 0; j < n1; ++j, ++it, ++it1) {
 *it= - it1[n1]  *it2[n2_2] + it1[n1_2]*it2[n2];
 it[nn] = - it1[n1_2]*it2[0]+ it1[0]   *it2[n2_2];
@@ -2143,7 +2146,7 @@ namespace getfem {
 }
   } else {
 for (size_type i = 0; i < n2; ++i, ++it2) {
-  base_tensor::iterator it1 = tc1.begin();
+  base_tensor::const_iterator it1 = tc1.cbegin();
   for (size_type j = 0; j < n1; ++j, ++it, ++it1) {
 *it= it1[n1]  *it2[n2_2] - it1[n1_2]*it2[n2];
 it[nn] = it1[n1_2]*it2[0]- it1[0]   *it2[n2_2];
@@ -2153,14 +2156,16 @@ namespace getfem {
   } 
   return 0;
 }
-ga_instruction_cross_product_tf(base_tensor _, base_tensor _,
-base_tensor _, bool inv_)
+ga_instruction_cross_product_tf(base_tensor _,
+const base_tensor _,
+const base_tensor _, bool inv_)
   : t(t_), tc1(tc1_), tc2(tc2_), inv(inv_) {}
   };
 
   // Performs Cross product in the absence of test functions
   struct ga_instruction_cross_product : public ga_instruction {
-base_tensor , , 
+base_tensor 
+const base_tensor , 
 virtual int exec() {
   GA_DEBUG_INFO("Instruction: Cross product with test functions");
   GA_DEBUG_ASSERT(t.size() == 3 && tc1.size() == 3 && tc2.size() == 3,
@@ -2170,8 +2175,8 @@ namespace getfem {
   t[2] = tc1[0]*tc2[1] - tc1[1]*tc2[0];
   return 0;
 }
-ga_instruction_cross_product(base_tensor _, base_tensor _,
- base_tensor _)
+

[Getfem-commits] [getfem-commits] branch master updated: Use hard coded loop unrollings

2023-12-05 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 0ce4bf39 Use hard coded loop unrollings
0ce4bf39 is described below

commit 0ce4bf3963d748964714a90851e6cd1dfc17a4b8
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 5 18:24:02 2023 +0100

Use hard coded loop unrollings

  - recursive template unrolling seems to be fragile at least with gcc
  - changes do not introduce any significant slow down in test_assembly
benchmarks, when compiled with O2 optimizations
---
 src/getfem_generic_assembly_compile_and_exec.cc | 401 +---
 1 file changed, 289 insertions(+), 112 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 71793f6a..f51bcf80 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -25,7 +25,7 @@
 #include "getfem/getfem_generic_assembly_compile_and_exec.h"
 #include "getfem/getfem_generic_assembly_functions_and_operators.h"
 
-// #define GA_USES_BLAS // not so interesting, at least for debian blas
+//#define GA_USES_BLAS
 
 // #define GA_DEBUG_INFO(a) { cout << a << endl; }
 #define GA_DEBUG_INFO(a)
@@ -2515,43 +2515,46 @@ namespace getfem {
 
   // Performs Ani Bmi -> Cmn
   struct ga_instruction_contraction : public ga_instruction {
-base_tensor , , 
-size_type nn;
-virtual int exec() {
-  GA_DEBUG_INFO("Instruction: contraction operation of size " << nn);
-#if GA_USES_BLAS
-  long m = int(tc1.size()/nn), k = int(nn), n = int(tc2.size()/nn);
-  long lda = m, ldb = n, ldc = m;
-  char T = 'T', N = 'N';
-  scalar_type alpha(1), beta(0);
-  gmm::dgemm_(, , , , , , &(tc1[0]), , &(tc2[0]), ,
-  , &(t[0]), );
+base_tensor 
+const base_tensor , 
+const size_type I;
+virtual int exec() {
+  GA_DEBUG_INFO("Instruction: contraction operation of size " << I);
+#if defined(GA_USES_BLAS)
+  BLAS_INT N = BLAS_INT(tc1.size()/I), I_ = BLAS_INT(I),
+   M = BLAS_INT(tc2.size()/I);
+  char notrans = 'N', trans = 'T';
+  static const scalar_type one(1), zero(0);
+  gmm::dgemm_(, , , , _, ,
+  &(tc2[0]), , &(tc1[0]), , , &(t[0]), );
 #else
-  size_type s1 = tc1.size()/nn, s2 = tc2.size()/nn;
-  GA_DEBUG_ASSERT(t.size() == s1*s2, "Internal error");
+  size_type N = tc1.size()/I,
+M = tc2.size()/I;
+  GA_DEBUG_ASSERT(t.size() == N*M, "Internal error");
 
-  auto it1=tc1.begin(), it2=tc2.begin(), it2end=it2 + s2;
+  auto it1=tc1.begin(), it2=tc2.begin(), it2end=it2 + M;
   for (auto it = t.begin(); it != t.end(); ++it) {
 auto it11 = it1, it22 = it2;
 scalar_type a = (*it11) * (*it22);
-for (size_type i = 1; i < nn; ++i)
-  { it11 += s1; it22 += s2; a += (*it11) * (*it22); }
+for (size_type i = 1; i < I; ++i)
+  { it11 += N; it22 += M; a += (*it11) * (*it22); }
 *it = a;
 ++it2; if (it2 == it2end) { it2 = tc2.begin(), ++it1; }
   }
   // auto it = t.begin(); // Unoptimized version.
-  // for (size_type i = 0; i < s1; ++i)
-  //   for (size_type j = 0; j < s2; ++j, ++it) {
+  // for (size_type n = 0; n < N; ++n)
+  //   for (size_type m = 0; m < M; ++m, ++it) {
   // *it = scalar_type(0);
-  // for (size_type k = 0; k < nn; ++k)
-  //   *it += tc1[i+k*s1] * tc2[j+k*s2];
+  // for (size_type i = 0; i < I; ++i)
+  //   *it += tc1[n+N*i] * tc2[m+M*i];
   //   }
 #endif
   return 0;
 }
-ga_instruction_contraction(base_tensor _, base_tensor _,
- base_tensor _, size_type n_)
-  : t(t_), tc1(tc1_), tc2(tc2_), nn(n_) {}
+ga_instruction_contraction(base_tensor _,
+   const base_tensor _,
+   const base_tensor _, size_type I_)
+  : t(t_), tc1(tc1_), tc2(tc2_), I(I_) {}
   };
 
   // Performs Ani Bmi -> Cmn
@@ -2850,29 +2853,116 @@ namespace getfem {
 
 
 
-  template inline scalar_type reduc_elem_unrolled__
-  (base_tensor::iterator , base_tensor::iterator ,
-   size_type s1, size_type s2) {
-return (it1[(N-1)*s1])*(it2[(N-1)*s2])
-  + reduc_elem_unrolled__(it1, it2, s1, s2);
+  template inline
+  void reduc_elem_unrolled__(base_tensor::iterator ,
+ base_tensor::const_iterator , 
base_tensor::const_iterator ,
+ size_type s1, size_type s2) {
+*it = (*it1)*(*it2);
+for (int i=1; i < I; ++i)
+  *it += (*(it1+i*s1)) * (*(it2+i*s2));
+  }
+  template<> inline
+  void reduc_elem_unrolled__<9>(base_tensor::iterator ,
+base_tensor::const_iterator , 
base_tensor::const_iterator ,
+   

[Getfem-commits] [getfem-commits] branch remove-local-superlu updated: Improve configuration without superlu

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

logari81 pushed a commit to branch remove-local-superlu
in repository getfem.

The following commit(s) were added to refs/heads/remove-local-superlu by this 
push:
 new 597d39a0 Improve configuration without superlu
597d39a0 is described below

commit 597d39a04acd25cf137c042c7abe03600ccc7b9d
Author: Konstantinos Poulios 
AuthorDate: Tue Dec 5 14:04:25 2023 +0100

Improve configuration without superlu
---
 configure.ac | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index 16a854de..1ab7d38d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -807,6 +807,7 @@ AC_ARG_WITH(superlu-include-dir,
 CPPFLAGS="$CPPFLAGS $SUPERLUINC"
 
 if test "x$require_superlu" = "xno"; then
+  SUPERLU_LIBS=""
   echo "Building with SuperLU explicitly disabled";
 else
   AC_CHECK_HEADERS(
@@ -834,6 +835,11 @@ else
   SUPERLU_LIBS=""
   LIBS="$save_LIBS"
 fi
+  elif test "x$require_superlu" = "xyes"; then
+AC_MSG_ERROR([SuperLU header files not found but required by the user. 
Aborting configure...]);
+  else
+echo "SuperLU header files not found, building without SuperLU"
+SUPERLU_LIBS=""
   fi
 fi
 



[Getfem-commits] (no subject)

2023-11-30 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit c7c7db695aed8a964521448c1c7eff3f7e16887f
Author: Konstantinos Poulios 
AuthorDate: Sat Nov 18 20:52:37 2023 +0100

Make SuperLU optional
---
 interface/src/getfemint_precond.h | 43 ---
 interface/src/gf_linsolve.cc  |  5 -
 interface/src/gf_precond.cc   |  4 
 src/Makefile.am   |  7 +--
 src/getfem/getfem_config.h|  7 +++
 src/getfem/getfem_model_solvers.h | 18 
 src/getfem/getfem_superlu.h   | 10 -
 tests/laplacian.cc|  4 +++-
 tests/schwarz_additive.cc | 28 +++--
 9 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/interface/src/getfemint_precond.h 
b/interface/src/getfemint_precond.h
index 8af6c79b..7dee1aaa 100644
--- a/interface/src/getfemint_precond.h
+++ b/interface/src/getfemint_precond.h
@@ -52,7 +52,7 @@ namespace getfemint {
 size_type ncols(void) const { return gsp ? gsp->ncols() : ncols_; }
 void set_dimensions(size_type m, size_type n) { nrows_ = m; ncols_ = n; }
 gprecond_base() : nrows_(0), ncols_(0), type(IDENTITY), gsp(0) {}
-const char *name() const { 
+const char *name() const {
   const char *p[] = { "IDENTITY", "DIAG", "ILDLT", "ILDLTT", "ILU", "ILUT",
  "SUPERLU", "GSPARSE" };
   return p[type];
@@ -69,7 +69,9 @@ namespace getfemint {
 std::unique_ptr > ildltt;
 std::unique_ptr > ilu;
 std::unique_ptr > ilut;
+#if defined(GETFEM_USES_SUPERLU)
 std::unique_ptr > superlu;
+#endif
 
 virtual size_type memsize() const {
   size_type sz = sizeof(*this);
@@ -81,10 +83,15 @@ namespace getfemint {
   case ILDLT:   sz += ildlt->memsize(); break;
   case ILDLTT:  sz += ildltt->memsize(); break;
   case SUPERLU:
-   sz += size_type(superlu->memsize()); break;
+#if defined(GETFEM_USES_SUPERLU)
+sz += size_type(superlu->memsize());
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case SPMAT:   sz += gsp->memsize(); break;
   }
-  return sz; 
+  return sz;
 }
   };
 
@@ -120,28 +127,32 @@ namespace gmm {
 switch (precond.type) {
   case getfemint::gprecond_base::IDENTITY: gmm::copy(v,w); break;
   case getfemint::gprecond_base::DIAG:
-   gmm::mult(*precond.diagonal, v, w);
-   break;
-  case getfemint::gprecond_base::ILDLT: 
-if (do_mult) gmm::mult(*precond.ildlt, v, w); 
+gmm::mult(*precond.diagonal, v, w);
+break;
+  case getfemint::gprecond_base::ILDLT:
+if (do_mult) gmm::mult(*precond.ildlt, v, w);
 else gmm::transposed_mult(*precond.ildlt, v, w);
 break;
-  case getfemint::gprecond_base::ILDLTT: 
-if (do_mult) gmm::mult(*precond.ildltt, v, w); 
+  case getfemint::gprecond_base::ILDLTT:
+if (do_mult) gmm::mult(*precond.ildltt, v, w);
 else gmm::transposed_mult(*precond.ildltt, v, w);
 break;
-  case getfemint::gprecond_base::ILU: 
-if (do_mult) gmm::mult(*precond.ilu, v, w); 
+  case getfemint::gprecond_base::ILU:
+if (do_mult) gmm::mult(*precond.ilu, v, w);
 else gmm::transposed_mult(*precond.ilu, v, w);
 break;
-  case getfemint::gprecond_base::ILUT: 
-if (do_mult) gmm::mult(*precond.ilut, v, w); 
+  case getfemint::gprecond_base::ILUT:
+if (do_mult) gmm::mult(*precond.ilut, v, w);
 else gmm::transposed_mult(*precond.ilut, v, w);
 break;
   case getfemint::gprecond_base::SUPERLU:
-   if (do_mult) precond.superlu->solve(w,v);
-   else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
-   break;
+#if defined(GETFEM_USES_SUPERLU)
+if (do_mult) precond.superlu->solve(w,v);
+else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case getfemint::gprecond_base::SPMAT:
precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
 break;
diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index a04adbe5..1b8f42ff 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype,
   else  iterative_gmm_solver(stype, gsp, in, out, 
scalar_type());
 }
 
+#if defined(GETFEM_USES_SUPERLU)
 template  static void
 superlu_solver(gsparse ,
getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) {
@@ -96,6 +97,7 @@ superlu_solver(gsparse ,
   if (out.remaining())
 out.pop().from_scalar(rcond ? 1./rcond : 0.);
 }
+#endif
 
 #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H)
 template  static void
@@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, 
getfemint::mexargs_out& m_out) {
);
 
 
+#if 

[Getfem-commits] [getfem-commits] remove-local-superlu updated (bb988800 -> c7c7db69)

2023-11-30 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

 discard bb988800 Make SuperLU optional
 discard 2ca27bbb Remove local SuperLU copy
 add 517ffd4d Naming, whitespace and simplifications
 add be1bab31 Allow calling adapt() from scripting API for mesh_fem_sum and 
mesh_fem_product
 add 7ff5109e Add missing dependency between fem_global_function and 
context aware global_function instances
 add aa25b585 Update project communication information
 new e0655e02 Remove local SuperLU copy
 new c7c7db69 Make SuperLU optional

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (bb988800)
\
 N -- N -- N   refs/heads/remove-local-superlu (c7c7db69)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.


Summary of changes:
 doc/sphinx/source/lists.rst   |   9 ++-
 interface/src/gf_mesh_fem.cc  |  12 ++--
 interface/src/gf_mesh_fem_set.cc  |  19 --
 src/getfem_fem_global_function.cc |   6 ++
 src/getfem_global_function.cc |  19 +++---
 src/getfem_mesh_fem_product.cc| 120 +++---
 src/getfem_mesh_fem_sum.cc|   3 +-
 7 files changed, 103 insertions(+), 85 deletions(-)



[Getfem-commits] [getfem-commits] branch master updated: Update project communication information

2023-11-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 master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new aa25b585 Update project communication information
aa25b585 is described below

commit aa25b585d7370a5cecbc3502f1b9968607af
Author: Konstantinos Poulios 
AuthorDate: Thu Nov 23 10:01:39 2023 +0100

Update project communication information
---
 doc/sphinx/source/lists.rst | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/doc/sphinx/source/lists.rst b/doc/sphinx/source/lists.rst
index 09763f0b..3d6999f0 100644
--- a/doc/sphinx/source/lists.rst
+++ b/doc/sphinx/source/lists.rst
@@ -8,13 +8,12 @@ GetFEM Mailing Lists
 
 GetFEM is maintened on the `Savannah `_ collaborative 
development platform for free software. See 
https://savannah.nongnu.org/projects/getfem for additional information on 
GetFEM development.
 
+Discussions are now hosted on `the GetFEM discourse forum 
`_.
 
+All kinds of questions or issues about using, installing or improving GetFEM 
can be posted either on `the GetFEM discourse forum 
`_ or the `user mailing list 
`_.
 
-The mailing lists of GetFEM are listed on the page `getfem mailing lists 
`_
+All mailing lists of GetFEM are listed on the page `getfem mailing lists 
`_.
 
-The main mailing list is the `user one 
`_. All kind of 
problems or questions about using, install or improve GetFEM can be posted 
there. Don't forget to register to the list before to post a message.
-
-
-If you make contributions to Getfem, you should register to the 
`getfem-commits mailing list 
`_.
+If you make contributions to GetFEM, you should register to the 
`getfem-commits mailing list 
`_.
 
 



[Getfem-commits] [getfem-commits] master updated (3a323649 -> 7ff5109e)

2023-11-20 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch master.

from 3a323649 Whitespace and other trivial simplifications
 new 517ffd4d Naming, whitespace and simplifications
 new be1bab31 Allow calling adapt() from scripting API for mesh_fem_sum and 
mesh_fem_product
 new 7ff5109e Add missing dependency between fem_global_function and 
context aware global_function instances


Summary of changes:
 interface/src/gf_mesh_fem.cc  |  12 ++--
 interface/src/gf_mesh_fem_set.cc  |  19 --
 src/getfem_fem_global_function.cc |   6 ++
 src/getfem_global_function.cc |  19 +++---
 src/getfem_mesh_fem_product.cc| 120 +++---
 src/getfem_mesh_fem_sum.cc|   3 +-
 6 files changed, 99 insertions(+), 80 deletions(-)



[Getfem-commits] (no subject)

2023-11-20 Thread Konstantinos Poulios via Getfem-commits
branch: master
commit 517ffd4daed62e304c02bee37cd68772b1bdb8fa
Author: Konstantinos Poulios 
AuthorDate: Tue Nov 21 00:04:26 2023 +0100

Naming, whitespace and simplifications
---
 interface/src/gf_mesh_fem.cc   |  12 ++---
 src/getfem_global_function.cc  |  18 +++
 src/getfem_mesh_fem_product.cc | 120 -
 src/getfem_mesh_fem_sum.cc |   3 +-
 4 files changed, 77 insertions(+), 76 deletions(-)

diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc
index 3851f036..cf675d81 100644
--- a/interface/src/gf_mesh_fem.cc
+++ b/interface/src/gf_mesh_fem.cc
@@ -176,21 +176,21 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in,
 sub_command
   ("sum", 1, -1, 0, 1,
std::vector mftab;
-   std::shared_ptr msum;
+   std::shared_ptr mfsum;
while (in.remaining()) {
  getfem::mesh_fem *gfimf = to_meshfem_object(in.pop());
  if (mmf.get() == 0) {
mm = >linked_mesh();
-   msum = std::make_shared(*mm);
-   mmf = msum;
+   mfsum = std::make_shared(*mm);
+   mmf = mfsum;
store_meshfem_object(mmf);
  }
  workspace().set_dependence(mmf.get(), gfimf);
  mftab.push_back(gfimf);
}
-   msum->set_mesh_fems(mftab);
-   msum->adapt();
-   mmf = msum;
+   mfsum->set_mesh_fems(mftab);
+   mfsum->adapt();
+   mmf = mfsum;
);
 
 /*@INIT MF = ('product', @tmf mf1, @tmf mf2)
diff --git a/src/getfem_global_function.cc b/src/getfem_global_function.cc
index 0ed103f4..bcd2e55e 100644
--- a/src/getfem_global_function.cc
+++ b/src/getfem_global_function.cc
@@ -32,7 +32,7 @@ namespace getfem {
   (const fem_interpolation_context ) const {
 base_node pt = c.xreal();
 GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") "
-   << "passed to a global function of dim = "<< dim_ <<".");
+<< "passed to a global function of dim = "<< dim_ <<".");
 return this->val(pt);
   }
 
@@ -40,7 +40,7 @@ namespace getfem {
   (const fem_interpolation_context , base_small_vector ) const {
 base_node pt = c.xreal();
 GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") "
-   << "passed to a global function of dim = "<< dim_ <<".");
+<< "passed to a global function of dim = "<< dim_ <<".");
 this->grad(pt, g);
   }
 
@@ -48,7 +48,7 @@ namespace getfem {
   (const fem_interpolation_context , base_matrix ) const {
 base_node pt = c.xreal();
 GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") "
-   << "passed to a global function of dim = "<< dim_ <<".");
+<< "passed to a global function of dim = "<< dim_ <<".");
 this->hess(pt, h);
   }
 
@@ -717,12 +717,12 @@ namespace getfem {
   if (cv_ != cv) {
 cv=cv_;
 if (lsets.size() == 0) {
- mls_x = ls.mls_of_convex(cv, 1);
- mls_y = ls.mls_of_convex(cv, 0);
+  mls_x = ls.mls_of_convex(cv, 1);
+  mls_y = ls.mls_of_convex(cv, 0);
 } else {
- base_node pt(n);
+  base_node pt(n);
   scalar_type d = scalar_type(-2);
-  for (const auto _ : lsets) {
+  for (const level_set _ : lsets) {
 pmesher_signed_distance mls_xx, mls_yy;
 mls_xx = ls_.mls_of_convex(cv, 1);
 mls_yy = ls_.mls_of_convex(cv, 0);
@@ -806,8 +806,8 @@ namespace getfem {
   GMM_ASSERT1(lsets.size() > 0, "The list of level sets should"
 " contain at least one level set.");
   cv = size_type(-1);
-  for (size_type i = 0; i < lsets.size(); ++i)
-this->add_dependency(lsets[i]);
+  for (const level_set _ : lsets)
+this->add_dependency(ls_);
 }
 
 global_function_on_levelsets_2D_(const level_set _,
diff --git a/src/getfem_mesh_fem_product.cc b/src/getfem_mesh_fem_product.cc
index 33608757..69117915 100644
--- a/src/getfem_mesh_fem_product.cc
+++ b/src/getfem_mesh_fem_product.cc
@@ -23,12 +23,12 @@
 #include "getfem/getfem_mesh_fem_product.h"
 
 namespace getfem {
-
+
   void fem_product::init() {
-
+
 GMM_ASSERT1(pfems[0]->target_dim() == 1, "To be done");
 GMM_ASSERT1(pfems[1]->target_dim() == 1,
-   "The second finite element should be scalar");
+"The second finite element should be scalar");
 
 cvr = pfems[0]->ref_convex(cv);
 dim_ = cvr->structure()->dim();
@@ -40,27 +40,27 @@ namespace getfem {
 nm << "FEM_PRODUCT(" << pfems[0]->debug_name() << ","
<< pfems[1]->debug_name() << "," << cv << ")";
 debug_name_ = nm.str();
-
+
 init_cvs_node();
 for (dal::bv_visitor i(enriched_dof1); !i.finished(); ++i) {
   for (size_type j = 0; j < pfems[1]->nb_dof(cv); ++j)
-   add_node(xfem_dof(pfems[0]->dof_types()[i], xfem_index+j),
-pfems[0]->node_of_dof(cv,i));

[Getfem-commits] (no subject)

2023-11-19 Thread Konstantinos Poulios via Getfem-commits
branch: remove-local-superlu
commit bb9888000da89f9d55f2f474545994e76f4063ae
Author: Konstantinos Poulios 
AuthorDate: Sat Nov 18 20:52:37 2023 +0100

Make SuperLU optional
---
 interface/src/getfemint_precond.h | 43 ---
 interface/src/gf_linsolve.cc  |  5 -
 interface/src/gf_precond.cc   |  4 
 src/Makefile.am   |  7 +--
 src/getfem/getfem_config.h|  7 +++
 src/getfem/getfem_model_solvers.h | 18 
 src/getfem/getfem_superlu.h   | 10 -
 tests/laplacian.cc|  4 +++-
 tests/schwarz_additive.cc | 28 +++--
 9 files changed, 86 insertions(+), 40 deletions(-)

diff --git a/interface/src/getfemint_precond.h 
b/interface/src/getfemint_precond.h
index 8af6c79b..7dee1aaa 100644
--- a/interface/src/getfemint_precond.h
+++ b/interface/src/getfemint_precond.h
@@ -52,7 +52,7 @@ namespace getfemint {
 size_type ncols(void) const { return gsp ? gsp->ncols() : ncols_; }
 void set_dimensions(size_type m, size_type n) { nrows_ = m; ncols_ = n; }
 gprecond_base() : nrows_(0), ncols_(0), type(IDENTITY), gsp(0) {}
-const char *name() const { 
+const char *name() const {
   const char *p[] = { "IDENTITY", "DIAG", "ILDLT", "ILDLTT", "ILU", "ILUT",
  "SUPERLU", "GSPARSE" };
   return p[type];
@@ -69,7 +69,9 @@ namespace getfemint {
 std::unique_ptr > ildltt;
 std::unique_ptr > ilu;
 std::unique_ptr > ilut;
+#if defined(GETFEM_USES_SUPERLU)
 std::unique_ptr > superlu;
+#endif
 
 virtual size_type memsize() const {
   size_type sz = sizeof(*this);
@@ -81,10 +83,15 @@ namespace getfemint {
   case ILDLT:   sz += ildlt->memsize(); break;
   case ILDLTT:  sz += ildltt->memsize(); break;
   case SUPERLU:
-   sz += size_type(superlu->memsize()); break;
+#if defined(GETFEM_USES_SUPERLU)
+sz += size_type(superlu->memsize());
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case SPMAT:   sz += gsp->memsize(); break;
   }
-  return sz; 
+  return sz;
 }
   };
 
@@ -120,28 +127,32 @@ namespace gmm {
 switch (precond.type) {
   case getfemint::gprecond_base::IDENTITY: gmm::copy(v,w); break;
   case getfemint::gprecond_base::DIAG:
-   gmm::mult(*precond.diagonal, v, w);
-   break;
-  case getfemint::gprecond_base::ILDLT: 
-if (do_mult) gmm::mult(*precond.ildlt, v, w); 
+gmm::mult(*precond.diagonal, v, w);
+break;
+  case getfemint::gprecond_base::ILDLT:
+if (do_mult) gmm::mult(*precond.ildlt, v, w);
 else gmm::transposed_mult(*precond.ildlt, v, w);
 break;
-  case getfemint::gprecond_base::ILDLTT: 
-if (do_mult) gmm::mult(*precond.ildltt, v, w); 
+  case getfemint::gprecond_base::ILDLTT:
+if (do_mult) gmm::mult(*precond.ildltt, v, w);
 else gmm::transposed_mult(*precond.ildltt, v, w);
 break;
-  case getfemint::gprecond_base::ILU: 
-if (do_mult) gmm::mult(*precond.ilu, v, w); 
+  case getfemint::gprecond_base::ILU:
+if (do_mult) gmm::mult(*precond.ilu, v, w);
 else gmm::transposed_mult(*precond.ilu, v, w);
 break;
-  case getfemint::gprecond_base::ILUT: 
-if (do_mult) gmm::mult(*precond.ilut, v, w); 
+  case getfemint::gprecond_base::ILUT:
+if (do_mult) gmm::mult(*precond.ilut, v, w);
 else gmm::transposed_mult(*precond.ilut, v, w);
 break;
   case getfemint::gprecond_base::SUPERLU:
-   if (do_mult) precond.superlu->solve(w,v);
-   else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
-   break;
+#if defined(GETFEM_USES_SUPERLU)
+if (do_mult) precond.superlu->solve(w,v);
+else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP);
+#else
+GMM_ASSERT1(false, "GetFEM built without SuperLU support");
+#endif
+break;
   case getfemint::gprecond_base::SPMAT:
precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
 break;
diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index a04adbe5..1b8f42ff 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype,
   else  iterative_gmm_solver(stype, gsp, in, out, 
scalar_type());
 }
 
+#if defined(GETFEM_USES_SUPERLU)
 template  static void
 superlu_solver(gsparse ,
getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) {
@@ -96,6 +97,7 @@ superlu_solver(gsparse ,
   if (out.remaining())
 out.pop().from_scalar(rcond ? 1./rcond : 0.);
 }
+#endif
 
 #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H)
 template  static void
@@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, 
getfemint::mexargs_out& m_out) {
);
 
 
+#if 

[Getfem-commits] [getfem-commits] branch master updated: Whitespace and other trivial simplifications

2023-11-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 3a323649 Whitespace and other trivial simplifications
3a323649 is described below

commit 3a3236490a32cea95fe1b19c744a5dfc09f435c2
Author: Konstantinos Poulios 
AuthorDate: Sun Nov 19 17:03:23 2023 +0100

Whitespace and other trivial simplifications
---
 src/getfem/getfem_mesh_fem_sum.h | 45 +++---
 src/getfem_mesh_fem_level_set.cc | 66 -
 src/getfem_mesh_fem_sum.cc   | 80 
 3 files changed, 95 insertions(+), 96 deletions(-)

diff --git a/src/getfem/getfem_mesh_fem_sum.h b/src/getfem/getfem_mesh_fem_sum.h
index b0391cd3..94db97df 100644
--- a/src/getfem/getfem_mesh_fem_sum.h
+++ b/src/getfem/getfem_mesh_fem_sum.h
@@ -42,35 +42,34 @@
 #include "getfem_mesh_fem.h"
 
 namespace getfem {
-  typedef std::vector dof_enrichments;
-  
+
   /** @internal FEM used in mesh_fem_sum objects. */
   class fem_sum : public virtual_fem {
 std::vector pfems; /* the fems to be summed */
 bool smart_global_dof_linking_;
 size_type cv;
-
+
   public:
 
 size_type index_of_global_dof(size_type cv_, size_type j) const;
 fem_sum(const std::vector , size_type i,
-   bool smart_global_dof_linking)
+bool smart_global_dof_linking)
   : pfems(pfs), smart_global_dof_linking_(smart_global_dof_linking),
-   cv(i) { init(); }
+cv(i) { init(); }
 void init();
 void valid();
 void base_value(const base_node , base_tensor ) const;
 void grad_base_value(const base_node , base_tensor ) const;
 void hess_base_value(const base_node , base_tensor ) const;
 
-void real_base_value(const fem_interpolation_context& c, 
-base_tensor , bool = true) const;
-void real_grad_base_value(const fem_interpolation_context& c, 
- base_tensor , bool = true) const;
-void real_hess_base_value(const fem_interpolation_context& c, 
- base_tensor , bool = true) const;
+void real_base_value(const fem_interpolation_context& c,
+ base_tensor , bool = true) const;
+void real_grad_base_value(const fem_interpolation_context& c,
+  base_tensor , bool = true) const;
+void real_hess_base_value(const fem_interpolation_context& c,
+  base_tensor , bool = true) const;
 void mat_trans(base_matrix , const base_matrix ,
-  bgeot::pgeometric_trans pgt) const;
+   bgeot::pgeometric_trans pgt) const;
   };
 
 
@@ -88,23 +87,23 @@ namespace getfem {
 void clear_build_methods();
 
   public :
-void adapt(void);
-void update_from_context(void) const { is_adapted = false; }
-void clear(void);
-
+void adapt();
+void update_from_context() const { is_adapted = false; }
+void clear();
+
 size_type memsize() const {
   return mesh_fem::memsize(); // + ... ;
 }
-
+
 mesh_fem_sum(const mesh , bool smart_global_dof_linking = false)
   : mesh_fem(me), smart_global_dof_linking_(smart_global_dof_linking)
 { is_adapted = false; }
 void set_mesh_fems(const std::vector )
 { mfs = mefs; adapt(); }
-/** enabled "smart" dof linking between the mesh_fems. 
-   It was introduced for the point-wise matching part of 
-   tests/crack.cc but it does not work with discontinuous global
-   functions... 
+/** enabled "smart" dof linking between the mesh_fems.
+It was introduced for the point-wise matching part of
+tests/crack.cc but it does not work with discontinuous global
+functions...
 */
 void set_smart_global_dof_linking(bool b)
 { smart_global_dof_linking_ = b; }
@@ -113,7 +112,7 @@ namespace getfem {
 void set_mesh_fems(const mesh_fem , const mesh_fem )
 { mfs.clear(); mfs.push_back(); mfs.push_back();  adapt(); }
 void set_mesh_fems(const mesh_fem , const mesh_fem ,
-  const mesh_fem ) {
+   const mesh_fem ) {
   mfs.clear();
   mfs.push_back(); mfs.push_back(); mfs.push_back();
   adapt();
@@ -126,4 +125,4 @@ namespace getfem {
 }  /* end of namespace getfem.*/
 
 #endif
-  
+
diff --git a/src/getfem_mesh_fem_level_set.cc b/src/getfem_mesh_fem_level_set.cc
index 0fa492f6..64677420 100644
--- a/src/getfem_mesh_fem_level_set.cc
+++ b/src/getfem_mesh_fem_level_set.cc
@@ -22,35 +22,35 @@
 #include "getfem/getfem_mesh_fem_level_set.h"
 
 namespace getfem {
-  
+
   void mesh_fem_level_set::clear_build_methods() {
 for (size_type i = 0; i < build_methods.size(); ++i)
   del_stored_object(build_methods[i]);
 build_methods.clear();
   }
-  void 

[Getfem-commits] [getfem-commits] remove-local-superlu updated (2a8b6c8d -> 6f2da65d)

2023-11-17 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

 discard 2a8b6c8d Remove local SuperLU copy
 add ca961cce Fix openmp crash due to concurrency bug
 new 6f2da65d Remove local SuperLU copy

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2a8b6c8d)
\
 N -- N -- N   refs/heads/remove-local-superlu (6f2da65d)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.


Summary of changes:
 src/getfem_models.cc | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)



[Getfem-commits] [getfem-commits] branch consistent_rtree_box_order deleted (was 00ddea3d)

2023-11-17 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch consistent_rtree_box_order.

 was 00ddea3d returning model_pb to the header as it's being used elsewhere

The revisions that were on this branch are still contained in
other references; therefore, this change does not discard any commits
from the repository.



[Getfem-commits] [getfem-commits] branch fixmisspell deleted (was c8ab0c03)

2023-11-17 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch fixmisspell.

 was c8ab0c03 Transifex's Web Application's Domain Change

This change permanently discards the following revisions:

 discard c8ab0c03 Transifex's Web Application's Domain Change
 discard 07809d94 Update code samples from Python2 format to Python3
 discard f2c51973 Fix url of "An Encyclopedia of Cubature Formulas."



[Getfem-commits] [getfem-commits] branch master updated: Remove redundant header includes

2023-11-07 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 03e6c8e2 Remove redundant header includes
03e6c8e2 is described below

commit 03e6c8e291882db3308945556b21b3c70e550d4a
Author: Konstantinos Poulios 
AuthorDate: Tue Nov 7 16:53:39 2023 +0100

Remove redundant header includes
---
 contrib/crack_plate/crack_bilaplacian.cc| 1 -
 contrib/crack_plate/crack_bilaplacian_moment.cc | 1 -
 contrib/crack_plate/crack_bilaplacian_sif.cc| 1 -
 contrib/crack_plate/crack_bilaplacian_tools.cc  | 1 -
 tests/bilaplacian.cc| 1 -
 tests/nonlinear_elastostatic.cc | 1 -
 tests/nonlinear_membrane.cc | 1 -
 7 files changed, 7 deletions(-)

diff --git a/contrib/crack_plate/crack_bilaplacian.cc 
b/contrib/crack_plate/crack_bilaplacian.cc
index 4df30f07..a722d770 100644
--- a/contrib/crack_plate/crack_bilaplacian.cc
+++ b/contrib/crack_plate/crack_bilaplacian.cc
@@ -26,7 +26,6 @@
 #include "getfem/getfem_assembling.h" /* import assembly methods (and norms 
comp.) */
 #include "getfem/getfem_fourth_order.h"
 #include "getfem/getfem_model_solvers.h"
-#include "getfem/getfem_superlu.h"
 
 using std::endl; using std::cout; using std::cerr;
 using std::ends; using std::cin;
diff --git a/contrib/crack_plate/crack_bilaplacian_moment.cc 
b/contrib/crack_plate/crack_bilaplacian_moment.cc
index dcb16d7e..b542ad3e 100644
--- a/contrib/crack_plate/crack_bilaplacian_moment.cc
+++ b/contrib/crack_plate/crack_bilaplacian_moment.cc
@@ -24,7 +24,6 @@
 #include "getfem/getfem_assembling.h"
 #include "getfem/getfem_fourth_order.h"
 #include "getfem/getfem_model_solvers.h"
-#include "getfem/getfem_superlu.h"
 
 using std::endl; using std::cout; using std::cerr;
 using std::ends; using std::cin;
diff --git a/contrib/crack_plate/crack_bilaplacian_sif.cc 
b/contrib/crack_plate/crack_bilaplacian_sif.cc
index 6dda5e0d..8c22e455 100644
--- a/contrib/crack_plate/crack_bilaplacian_sif.cc
+++ b/contrib/crack_plate/crack_bilaplacian_sif.cc
@@ -24,7 +24,6 @@
 #include "getfem/getfem_assembling.h" /* import assembly methods (and norms 
comp.) */
 #include "getfem/getfem_fourth_order.h"
 #include "getfem/getfem_model_solvers.h"
-#include "getfem/getfem_superlu.h"
 #include "getfem/getfem_derivatives.h"
 
 using std::endl; using std::cout; using std::cerr;
diff --git a/contrib/crack_plate/crack_bilaplacian_tools.cc 
b/contrib/crack_plate/crack_bilaplacian_tools.cc
index 79fdf6c1..16f4adb0 100644
--- a/contrib/crack_plate/crack_bilaplacian_tools.cc
+++ b/contrib/crack_plate/crack_bilaplacian_tools.cc
@@ -24,7 +24,6 @@
 #include "getfem/getfem_assembling.h" /* import assembly methods (and norms 
comp.) */
 #include "getfem/getfem_fourth_order.h"
 #include "getfem/getfem_model_solvers.h"
-#include "getfem/getfem_superlu.h"
 
 using std::endl; using std::cout; using std::cerr;
 using std::ends; using std::cin;
diff --git a/tests/bilaplacian.cc b/tests/bilaplacian.cc
index cf0efd65..d2938da8 100644
--- a/tests/bilaplacian.cc
+++ b/tests/bilaplacian.cc
@@ -38,7 +38,6 @@
 #include "getfem/getfem_fourth_order.h"
 #include "getfem/getfem_model_solvers.h"
 #include "gmm/gmm.h"
-#include "getfem/getfem_superlu.h"
 #include "getfem/getfem_derivatives.h"
 #include "gmm/gmm_inoutput.h"
 
diff --git a/tests/nonlinear_elastostatic.cc b/tests/nonlinear_elastostatic.cc
index dfa59c22..2b6a2051 100644
--- a/tests/nonlinear_elastostatic.cc
+++ b/tests/nonlinear_elastostatic.cc
@@ -33,7 +33,6 @@
 #include "getfem/getfem_regular_meshes.h"
 #include "getfem/getfem_model_solvers.h"
 #include "getfem/getfem_nonlinear_elasticity.h"
-#include "getfem/getfem_superlu.h"
 #include "gmm/gmm.h"
 
 using std::endl; using std::cout; using std::cerr;
diff --git a/tests/nonlinear_membrane.cc b/tests/nonlinear_membrane.cc
index 80167f9e..c86d12a2 100644
--- a/tests/nonlinear_membrane.cc
+++ b/tests/nonlinear_membrane.cc
@@ -31,7 +31,6 @@
 #include "getfem/getfem_model_solvers.h"
 #include "getfem/getfem_nonlinear_elasticity.h"
 #include "getfem/getfem_mesh_fem.h"
-#include "getfem/getfem_superlu.h"
 #include "gmm/gmm.h"
 
 using std::endl; using std::cout; using std::cerr;



[Getfem-commits] [getfem-commits] remove-local-superlu updated (bb74a09a -> 64e3a4c2)

2023-11-07 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

 discard bb74a09a Remove local SuperLU copy
 add 38430cf3 minor change
 add 0a9ed217 Adding RT and BDM elements on simplicies for any degree and 
dimension
 add 938c963d Maintain underlying mesh_fem type when cloning mesh_fem 
objects in scripting API
 new 64e3a4c2 Remove local SuperLU copy

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (bb74a09a)
\
 N -- N -- N   refs/heads/remove-local-superlu (64e3a4c2)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.


Summary of changes:
 doc/sphinx/source/userdoc/appendixA.rst   |  43 +-
 interface/src/gf_mesh_fem.cc  |  37 +-
 interface/tests/matlab-octave/check_all_matlab.sh |   2 +-
 interface/tests/matlab-octave/check_all_octave.sh |   2 +-
 src/getfem/getfem_mesh_fem_level_set.h|   9 +-
 src/getfem/getfem_partial_mesh_fem.h  |   2 +
 src/getfem_fem.cc | 487 +++---
 7 files changed, 503 insertions(+), 79 deletions(-)



[Getfem-commits] [getfem-commits] branch master updated: Maintain underlying mesh_fem type when cloning mesh_fem objects in scripting API

2023-11-07 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 938c963d Maintain underlying mesh_fem type when cloning mesh_fem 
objects in scripting API
938c963d is described below

commit 938c963d4f74d80b1f68c2bc7b98d52c67fcb4c9
Author: Konstantinos Poulios 
AuthorDate: Tue Nov 7 13:37:56 2023 +0100

Maintain underlying mesh_fem type when cloning mesh_fem objects in 
scripting API
---
 interface/src/gf_mesh_fem.cc   | 37 +-
 src/getfem/getfem_mesh_fem_level_set.h |  9 +
 src/getfem/getfem_partial_mesh_fem.h   |  2 ++
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc
index 93f33046..3851f036 100644
--- a/interface/src/gf_mesh_fem.cc
+++ b/interface/src/gf_mesh_fem.cc
@@ -134,10 +134,36 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in,
   Create a copy of a @tmf.@*/
 sub_command
   ("clone", 1, 1, 0, 1,
-   
-   getfem::mesh_fem *mmf2 = to_meshfem_object(in.pop());
-   mm = >linked_mesh();
-   mmf = std::make_shared(*mmf2);
+   getfem::mesh_fem *mmf_in = to_meshfem_object(in.pop());
+   mm = _in->linked_mesh();
+   getfem::mesh_fem_sum *mfsum
+ = dynamic_cast(mmf_in);
+   getfem::mesh_fem_product *mfprod
+ = dynamic_cast(mmf_in);
+   getfem::mesh_fem_level_set *mfls
+ = dynamic_cast(mmf_in);
+   getfem::partial_mesh_fem *mfpart
+ = dynamic_cast(mmf_in);
+   getfem::mesh_fem_global_function *mfglob
+ = dynamic_cast(mmf_in);
+   if (mfsum)
+ mmf = std::make_shared(*mfsum);
+   else if (mfprod)
+ mmf = std::make_shared(*mfprod);
+   else if (mfls) {
+ std::shared_ptr mmfls
+   = 
std::make_shared(mfls->linked_mesh_level_set(),
+  
mfls->linked_mesh_fem());
+ mmfls->adapt();
+ mmf = mmfls;
+   } else if (mfpart) {
+ GMM_WARNING1("Cloning a partial_mesh_fem simply clones the underlying"
+ " adapted mesh_fem");
+ mmf = std::make_shared(mfpart->linked_mesh_fem());
+   } else if (mfglob)
+ mmf = std::make_shared(*mfglob);
+   else
+ mmf = std::make_shared(*mmf_in);
);
 
 
@@ -156,7 +182,8 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in,
  if (mmf.get() == 0) {
mm = >linked_mesh();
msum = std::make_shared(*mm);
-   mmf = msum; store_meshfem_object(mmf);
+   mmf = msum;
+   store_meshfem_object(mmf);
  }
  workspace().set_dependence(mmf.get(), gfimf);
  mftab.push_back(gfimf);
diff --git a/src/getfem/getfem_mesh_fem_level_set.h 
b/src/getfem/getfem_mesh_fem_level_set.h
index 1e803b28..c892cbf6 100644
--- a/src/getfem/getfem_mesh_fem_level_set.h
+++ b/src/getfem/getfem_mesh_fem_level_set.h
@@ -59,12 +59,13 @@ namespace getfem {
 void build_method_of_convex(size_type cv);
 
   public :
-void update_from_context(void) const { is_adapted = false; }
-void adapt(void);
-void clear(void); // to be modified
-size_type get_xfem_index(void) const { return xfem_index; }
+void update_from_context() const { is_adapted = false; }
+void adapt();
+void clear(); // to be modified
+size_type get_xfem_index() const { return xfem_index; }
 
 const mesh_level_set _mesh_level_set() const { return mls; }
+const mesh_fem _mesh_fem() const { return mf; }
 
 size_type memsize() const {
   return mesh_fem::memsize(); // + ... ;
diff --git a/src/getfem/getfem_partial_mesh_fem.h 
b/src/getfem/getfem_partial_mesh_fem.h
index c0b7fadb..83ca0a23 100644
--- a/src/getfem/getfem_partial_mesh_fem.h
+++ b/src/getfem/getfem_partial_mesh_fem.h
@@ -98,6 +98,8 @@ namespace getfem {
   "the original fem");
 }
 
+const mesh_fem _mesh_fem() const { return mf; }
+
 ind_dof_ct ind_basic_dof_of_element(size_type cv) const
 { return  mf.ind_basic_dof_of_element(cv); }
 



[Getfem-commits] [getfem-commits] branch improve-expm-performance created (now ee139e69)

2023-10-20 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch improve-expm-performance.

  at ee139e69 Use a Pade approximation for expm, ported from 
Eigen/Unsupported

This branch includes the following new commits:

 new ee139e69 Use a Pade approximation for expm, ported from 
Eigen/Unsupported




[Getfem-commits] (no subject)

2023-10-20 Thread Konstantinos Poulios via Getfem-commits
branch: improve-expm-performance
commit ee139e697b50db9198ef8257e2c492202b037a35
Author: Konstantinos Poulios 
AuthorDate: Fri Oct 20 10:59:42 2023 +0200

Use a Pade approximation for expm, ported from Eigen/Unsupported
---
 src/getfem_plasticity.cc | 472 ++-
 1 file changed, 386 insertions(+), 86 deletions(-)

diff --git a/src/getfem_plasticity.cc b/src/getfem_plasticity.cc
index 5a0ec9c0..69ca66b2 100644
--- a/src/getfem_plasticity.cc
+++ b/src/getfem_plasticity.cc
@@ -46,109 +46,409 @@ namespace getfem {
 { mi.resize(2); mi[0] = mi[1] = N; }
 
 
-  bool expm(const base_matrix _, base_matrix , scalar_type tol=1e-15) {
+  inline void matmul(base_matrix ,base_matrix ,base_matrix )
+{gmm::mult(aa,bb,cc);}
 
-const size_type itmax = 40;
-base_matrix a(a_);
-// scale input matrix a
-int e;
-frexp(gmm::mat_norminf(a), );
-e = std::max(0, std::min(1023, e));
-gmm::scale(a, pow(scalar_type(2),-scalar_type(e)));
-
-base_matrix atmp(a), an(a);
-gmm::copy(a, aexp);
-gmm::add(gmm::identity_matrix(), aexp);
-scalar_type factn(1);
+  bool expm(const base_matrix _, base_matrix ) {
+
+const size_type N = gmm::mat_nrows(a_);
 bool success(false);
-for (size_type n=2; n < itmax; ++n) {
-  factn /= scalar_type(n);
-  gmm::mult(an, a, atmp);
-  gmm::copy(atmp, an);
-  gmm::scale(atmp, factn);
-  gmm::add(atmp, aexp);
-  if (gmm::mat_euclidean_norm(atmp) < tol) {
-success = true;
-break;
-  }
+
+// Pade approximation ported from Eigen/Unsupported
+base_matrix a(a_);
+gmm::clear(aexp.as_vector());
+base_matrix tmp(aexp), v(aexp), u(aexp); // Pade approximant is (v+u)/(v-u)
+const scalar_type l1norm = gmm::mat_norminf(a_);
+int e = 0; // squarings
+if (l1norm < 1.495585217958292e-002) { // matrix_exp_pade3(a, u, v)
+  const static std::array b{120,60,12,1};
+  base_matrix a2(a);
+  matmul(a, a, a2);
+  gmm::copy(gmm::scaled(a2,b[2]), v);   // v = b2*A2 + b0*I
+  gmm::copy(gmm::scaled(a2,b[3]), u);   // u = b3*A2 + b1*I
+  for (size_type ij=0; ij < N; ++ij)
+{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; }
+} else if (l1norm < 2.539398330063230e-001) { // matrix_exp_pade5(a, u, v)
+  const static std::array b{30240,15120,3360,420,30,1};
+  base_matrix a2(a), a4(a);
+  matmul(a, a, a2);
+  matmul(a2, a2, a4);
+  gmm::add(gmm::scaled(a4,b[4]),// v = b4*A4 + b2*A2 + b0*I
+   gmm::scaled(a2,b[2]), v);
+  gmm::add(gmm::scaled(a4,b[5]),// u = b5*A4 + b3*A2 + b1*I
+   gmm::scaled(a2,b[3]), u);
+  for (size_type ij=0; ij < N; ++ij)
+{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; }
+} else if (l1norm < 9.504178996162932e-001) { // matrix_exp_pade7(a, u, v)
+  const static std::array
+b{17297280,8648640,1995840,277200,25200,1512,56,1};
+  base_matrix a2(a), a4(a), a6(a);
+  matmul(a, a, a2);
+  matmul(a2, a2, a4);
+  matmul(a2, a4, a6);
+  gmm::add(gmm::scaled(a6,b[6]),// v = b6*A6 + b4*A4 + b2*A2 + b0*I
+   gmm::scaled(a4,b[4]), v);
+  gmm::add(gmm::scaled(a2,b[2]), v);
+  gmm::add(gmm::scaled(a6,b[7]),// u = b7*A6 + b5*A4 + b3*A2 + b1*I
+   gmm::scaled(a4,b[5]), u);
+  gmm::add(gmm::scaled(a2,b[3]), u);
+  for (size_type ij=0; ij < N; ++ij)
+{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; }
+} else if (l1norm < 2.097847961257068e+000) { // matrix_exp_pade9(a, u, v)
+  const static std::array
+b{17643225600,8821612800,2075673600,302702400,30270240,2162160,
+  110880,3960,90,1};
+  base_matrix a2(a), a4(a), a6(a), a8(a);
+  matmul(a, a, a2);
+  matmul(a2, a2, a4);
+  matmul(a2, a4, a6);
+  matmul(a4, a4, a8);
+  gmm::add(gmm::scaled(a8,b[8]),// v = b8*A8+b6*A6+b4*A4+b2*A2+b0*I
+   gmm::scaled(a6,b[6]), v);
+  gmm::add(gmm::scaled(a4,b[4]), v);
+  gmm::add(gmm::scaled(a2,b[2]), v);
+  gmm::add(gmm::scaled(a8,b[9]),// u = b9*A8+b7*A6+b5*A4+b3*A2+b1*I
+   gmm::scaled(a6,b[7]), u);
+  gmm::add(gmm::scaled(a4,b[5]), u);
+  gmm::add(gmm::scaled(a2,b[3]), u);
+  for (size_type ij=0; ij < N; ++ij)
+{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; }
+} else { // matrix_exp_pade13(a, U, V);
+  const scalar_type maxnorm = 5.371920351148152;
+  frexp(l1norm / maxnorm, );
+  if (e <= 0) e = 0;
+  else for (auto & : a.as_vector()) { val = ldexp(val,-e); }
+   // <==> gmm::scale(a, pow(scalar_type(2),-scalar_type(e)));
+  const static std::array
+b{6476475253248,3238237626624,7771770303897600,
+  1187353796428800,129060195264000,10559470521600,670442572800,
+  33522128640,1323241920,40840800,960960,16380,182,1};
+  base_matrix a2(a), a4(a), a6(a);
+  matmul(a, a, a2);
+  matmul(a2, a2, a4);
+  matmul(a2, a4, a6);
+  

[Getfem-commits] [getfem-commits] branch remove-local-superlu created (now bb74a09a)

2023-10-19 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch remove-local-superlu.

  at bb74a09a Remove local SuperLU copy

This branch includes the following new commits:

 new bb74a09a Remove local SuperLU copy




[Getfem-commits] [getfem-commits] branch master updated: Clean up

2023-10-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 f50e5995 Clean up
f50e5995 is described below

commit f50e5995c0d69f0559fc9f75f8e96e39cfbe6949
Author: Konstantinos Poulios 
AuthorDate: Wed Oct 18 09:58:59 2023 +0200

Clean up

  - remove unused preprocessor macros
  - whitespace
  - include local gmm_dense_lu.h header file
---
 contrib/crack_plate/crack_bilaplacian_sif.cc |   2 +-
 src/dal_backtrace.cc |  17 +-
 src/getfem/getfem_crack_sif.h|   2 +-
 src/getfem_superlu.cc| 167 ---
 src/gmm/gmm_blas_interface.h |   3 +-
 src/gmm/gmm_except.h |   2 +-
 src/gmm/gmm_opt.h|   2 +-
 src/gmm/gmm_superlu_interface.h  | 290 +--
 8 files changed, 241 insertions(+), 244 deletions(-)

diff --git a/contrib/crack_plate/crack_bilaplacian_sif.cc 
b/contrib/crack_plate/crack_bilaplacian_sif.cc
index 3da6139f..6dda5e0d 100644
--- a/contrib/crack_plate/crack_bilaplacian_sif.cc
+++ b/contrib/crack_plate/crack_bilaplacian_sif.cc
@@ -59,7 +59,7 @@ namespace getfem {
   void get_crack_tip_and_orientation_KL(const level_set &/* ls */,
  base_node , 
  base_small_vector , base_small_vector 
) {
-cerr << __PRETTY_FUNCTION__ << " IS TO BE DONE\n";
+cerr << GMM_PRETTY_FUNCTION << " IS TO BE DONE\n";
 /* too lazy to do it now */
 P.resize(2); P[0] = 0.; P[1] = 0;
 T.resize(2); T[0] = 1; T[1] = 0;
diff --git a/src/dal_backtrace.cc b/src/dal_backtrace.cc
index 2f711ffc..464d57ff 100644
--- a/src/dal_backtrace.cc
+++ b/src/dal_backtrace.cc
@@ -32,25 +32,24 @@ namespace dal {
  If you call this function with a non-mangled name (i.e. "main"),
  you will get strange results.
*/
-  std::string demangle(const char *
-#ifdef GETFEM_HAVE_CXXABI_H
-  s
-#endif
-  ) {
 #ifdef GETFEM_HAVE_CXXABI_H
+  std::string demangle(const char *s) {
 int status;
 /* documented in 
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaceabi.html */
 char *sd = abi::__cxa_demangle(s, NULL, NULL, );
 if (sd == NULL || status) {
-  if (sd) free(sd);
+  if (sd)
+free(sd);
   return std::string(""); // + " [could not be demangled]";
 } else {
-  std::string res(sd); free(sd); return res;
+  std::string res(sd);
+  free(sd);
+  return res;
 }
+  }
 #else
-return std::string("");
+  std::string demangle(const char *) { return std::string(""); }
 #endif
-  }
 
 #ifdef GETFEM_HAVE_BACKTRACE
   void dump_glibc_backtrace() {
diff --git a/src/getfem/getfem_crack_sif.h b/src/getfem/getfem_crack_sif.h
index 6d849ba9..4f33d581 100644
--- a/src/getfem/getfem_crack_sif.h
+++ b/src/getfem/getfem_crack_sif.h
@@ -73,7 +73,7 @@ namespace getfem {
   inline void get_crack_tip_and_orientation(const level_set &/* ls */,
  base_node , 
  base_small_vector , base_small_vector 
) {
-cerr << __PRETTY_FUNCTION__ << " IS TO BE DONE\n";
+cerr << GMM_PRETTY_FUNCTION << " IS TO BE DONE\n";
 /* too lazy to do it now */
 P.resize(2); P[0] = .5; P[1] = 0;
 T.resize(2); T[0] = 1; T[1] = 0;
diff --git a/src/getfem_superlu.cc b/src/getfem_superlu.cc
index be113dd5..4e7c3538 100644
--- a/src/getfem_superlu.cc
+++ b/src/getfem_superlu.cc
@@ -45,7 +45,7 @@ namespace SuperLU_C {
 #include "superlu/slu_cdefs.h"
 }
 namespace SuperLU_Z {
-#include "superlu/slu_zdefs.h" 
+#include "superlu/slu_zdefs.h"
 }
 
 
@@ -55,28 +55,28 @@ namespace gmm {
   /*  interface for Create_CompCol_Matrix */
 
   inline void Create_CompCol_Matrix(SuperMatrix *A, int m, int n, int nnz,
-float *a, int *ir, int *jc) {
+float *a, int *ir, int *jc) {
 SuperLU_S::sCreate_CompCol_Matrix(A, m, n, nnz, a, ir, jc,
- SLU_NC, SLU_S, SLU_GE);
+  SLU_NC, SLU_S, SLU_GE);
   }
-  
+
   inline void Create_CompCol_Matrix(SuperMatrix *A, int m, int n, int nnz,
-double *a, int *ir, int *jc) {
+double *a, int *ir, int *jc) {
 SuperLU_D::dCreate_CompCol_Matrix(A, m, n, nnz, a, ir, jc,
- SLU_NC, SLU_D, SLU_GE);
+  SLU_NC, SLU_D, SLU_GE);
   }
-  
+
   inline void Create_CompCol_Matrix(SuperMatrix *A, int m, int n, int nnz,
-std::complex *a, int *ir, int *jc) {
+std::complex *a, int *ir, int *jc) {
 SuperLU_C::cCreate_CompCol_Matrix(A, m, n, nnz, 

[Getfem-commits] [getfem-commits] branch master updated: Enable scripting interface to get and set internal model variables

2023-10-17 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 b3d9703d Enable scripting interface to get and set internal model 
variables
b3d9703d is described below

commit b3d9703d1432d06918e94e25b718b83392d2339c
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 14:43:51 2023 +0200

Enable scripting interface to get and set internal model variables
---
 interface/src/gf_model_get.cc | 11 +++
 interface/src/gf_model_set.cc |  9 ++---
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/interface/src/gf_model_get.cc b/interface/src/gf_model_get.cc
index 7f955eeb..d92408de 100644
--- a/interface/src/gf_model_get.cc
+++ b/interface/src/gf_model_get.cc
@@ -344,17 +344,20 @@ void gf_model_get(getfemint::mexargs_in& m_in,
);
 
 
-/*@GET V = ('from variables')
+/*@GET V = ('from variables'[, @bool with_internal])
   Return the vector of all the degrees of freedom of the model consisting
   of the concatenation of the variables of the model (useful
   to solve your problem with you own solver). @*/
 sub_command
-  ("from variables", 0, 0, 0, 1,
+  ("from variables", 0, 1, 0, 1,
if (!md->is_complex()) {
- std::vector V(md->nb_dof());
- md->from_variables(V);
+ bool with_internal = in.remaining() && in.pop().to_bool();
+ std::vector V(md->nb_dof(with_internal));
+ md->from_variables(V, with_internal);
  out.pop().from_dcvector(V);
} else {
+ GMM_ASSERT1(!in.remaining(),
+ "Not supported argument for complex model");
  std::vector > V(md->nb_dof());
  md->from_variables(V);
  out.pop().from_dcvector(V);
diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc
index 2c90b654..0f4034ea 100644
--- a/interface/src/gf_model_set.cc
+++ b/interface/src/gf_model_set.cc
@@ -409,21 +409,24 @@ void gf_model_set(getfemint::mexargs_in& m_in,
);
 
 
-/*@SET ('to variables', @vec V)
+/*@SET ('to variables', @vec V[, @bool with_internal])
   Set the value of the variables of the model with the vector `V`.
   Typically, the vector `V` results of the solve of the tangent
   linear system (useful to solve your problem with you own solver).@*/
 sub_command
-  ("to variables", 1, 1, 0, 0,
+  ("to variables", 1, 2, 0, 0,
if (!md->is_complex()) {
  darray st = in.pop().to_darray(-1);
  std::vector V;
  V.assign(st.begin(), st.end());
- md->to_variables(V);
+ bool with_internal = in.remaining() && in.pop().to_bool();
+ md->to_variables(V, with_internal);
} else {
  carray st = in.pop().to_carray(-1);
  std::vector > V;
  V.assign(st.begin(), st.end());
+ GMM_ASSERT1(!in.remaining(),
+ "Not supported argument for complex model");
  md->to_variables(V);
}
);



[Getfem-commits] [getfem-commits] branch master updated: Allow to define Lagrange multipliers for contact on integration points

2023-10-17 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 f56fc155 Allow to define Lagrange multipliers for contact on 
integration points
f56fc155 is described below

commit f56fc1552f7508fc3b3d7d2fe6fe35a06540e230
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 14:33:31 2023 +0200

Allow to define Lagrange multipliers for contact on integration points
---
 src/getfem_contact_and_friction_large_sliding.cc | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/getfem_contact_and_friction_large_sliding.cc 
b/src/getfem_contact_and_friction_large_sliding.cc
index de20422c..ab45a51f 100644
--- a/src/getfem_contact_and_friction_large_sliding.cc
+++ b/src/getfem_contact_and_friction_large_sliding.cc
@@ -2334,10 +2334,14 @@ namespace getfem {
   "should share the same mesh");
   if (is_slave) {
 const mesh_fem *mf_l = md.pmesh_fem_of_variable(lambda);
-GMM_ASSERT1(mf, "The multiplier variable should be a f.e.m. one");
-GMM_ASSERT1(&(mf_l->linked_mesh()) == &(mim.linked_mesh()),
-"The displacement variable and the multiplier one "
-"should share the same mesh");
+const im_data *mimd_l = md.pim_data_of_variable(lambda);
+GMM_ASSERT1(mf_l || mimd_l,
+"The multiplier variable should be defined on a "
+"mesh_fem or an im_data");
+GMM_ASSERT1(&(mf_l ? mf_l->linked_mesh() : mimd_l->linked_mesh())
+== &(mim.linked_mesh()),
+"The displacement and the multiplier fields "
+"should be defined on the same mesh");
   }
 
   if (w.size()) {



[Getfem-commits] [getfem-commits] branch master updated: Replace some switches with lookup tables to reduce code duplication

2023-10-17 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 9a57bfb9 Replace some switches with lookup tables to reduce code 
duplication
9a57bfb9 is described below

commit 9a57bfb909e03f74c766301f1ed2bc4eb6a8e517
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 14:27:09 2023 +0200

Replace some switches with lookup tables to reduce code duplication

  - hopefully no performance penalty
---
 src/getfem_generic_assembly_semantic.cc | 306 +---
 1 file changed, 120 insertions(+), 186 deletions(-)

diff --git a/src/getfem_generic_assembly_semantic.cc 
b/src/getfem_generic_assembly_semantic.cc
index 58289d3c..9718838f 100644
--- a/src/getfem_generic_assembly_semantic.cc
+++ b/src/getfem_generic_assembly_semantic.cc
@@ -609,14 +609,14 @@ namespace getfem {
 + ((pnode->node_type == GA_NODE_SECONDARY_DOMAIN) ? 3 : 0)
 + ((pnode->node_type == GA_NODE_XFEM_PLUS)? 4 : 0)
 + ((pnode->node_type == GA_NODE_XFEM_MINUS)   ? 5 : 0);
-std::string op__name =
-  (pnode->node_type == GA_NODE_INTERPOLATE) ? "Interpolation" : ""
-  + (pnode->node_type == GA_NODE_ELEMENTARY) ?
- "Elementary_transformation" : ""
-  + (pnode->node_type == GA_NODE_SECONDARY_DOMAIN) ?
- "Secondary_domain" : ""
-   + (pnode->node_type == GA_NODE_XFEM_PLUS) ? "Xfem_plus" : ""
-  + (pnode->node_type == GA_NODE_XFEM_MINUS) ? "Xfem_minus" : "";
+GMM_ASSERT1(ndt > 0 && ndt < 6, "internal error");
+constexpr std::array
+  op_name_selector{"Interpolation",
+   "Elementary_transformation",
+   "Secondary_domain",
+   "Xfem_plus",
+   "Xfem_minus"};
+std::string op__name = op_name_selector.at(ndt-1);
 
 std::string name = pnode->name;
 size_type prefix_id = ga_parse_prefix_operator(name);
@@ -674,26 +674,53 @@ namespace getfem {
"Invalid null size of variable");
 }
 
+constexpr std::array
+  node_type_selector_val{GA_NODE_INTERPOLATE_VAL,
+ GA_NODE_ELEMENTARY_VAL,
+ GA_NODE_SECONDARY_DOMAIN_VAL,
+ GA_NODE_XFEM_PLUS_VAL,
+ GA_NODE_XFEM_MINUS_VAL},
+  node_type_selector_val_test{GA_NODE_INTERPOLATE_VAL_TEST,
+  GA_NODE_ELEMENTARY_VAL_TEST,
+  GA_NODE_SECONDARY_DOMAIN_VAL_TEST,
+  GA_NODE_XFEM_PLUS_VAL_TEST,
+  GA_NODE_XFEM_MINUS_VAL_TEST},
+  node_type_selector_grad{GA_NODE_INTERPOLATE_GRAD,
+  GA_NODE_ELEMENTARY_GRAD,
+  GA_NODE_SECONDARY_DOMAIN_GRAD,
+  GA_NODE_XFEM_PLUS_GRAD,
+  GA_NODE_XFEM_MINUS_GRAD},
+  node_type_selector_grad_test{GA_NODE_INTERPOLATE_GRAD_TEST,
+   GA_NODE_ELEMENTARY_GRAD_TEST,
+   GA_NODE_SECONDARY_DOMAIN_GRAD_TEST,
+   GA_NODE_XFEM_PLUS_GRAD_TEST,
+   GA_NODE_XFEM_MINUS_GRAD_TEST},
+  node_type_selector_hess{GA_NODE_INTERPOLATE_HESS,
+  GA_NODE_ELEMENTARY_HESS,
+  GA_NODE_SECONDARY_DOMAIN_HESS,
+  GA_NODE_XFEM_PLUS_HESS,
+  GA_NODE_XFEM_MINUS_HESS},
+  node_type_selector_hess_test{GA_NODE_INTERPOLATE_HESS_TEST,
+   GA_NODE_ELEMENTARY_HESS_TEST,
+   GA_NODE_SECONDARY_DOMAIN_HESS_TEST,
+   GA_NODE_XFEM_PLUS_HESS_TEST,
+   GA_NODE_XFEM_MINUS_HESS_TEST},
+  node_type_selector_div{GA_NODE_INTERPOLATE_DIVERG,
+ GA_NODE_ELEMENTARY_DIVERG,
+ GA_NODE_SECONDARY_DOMAIN_DIVERG,
+ GA_NODE_XFEM_PLUS_DIVERG,
+ GA_NODE_XFEM_MINUS_DIVERG},
+  node_type_selector_div_test{GA_NODE_INTERPOLATE_DIVERG_TEST,
+  GA_NODE_ELEMENTARY_DIVERG_TEST,
+  GA_NODE_SECONDARY_DOMAIN_DIVERG_TEST,
+  GA_NODE_XFEM_PLUS_DIVERG_TEST,
+  GA_NODE_XFEM_MINUS_DIVERG_TEST};
+
 switch (prefix_id) {
 case 0: // value
-  

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

2023-10-17 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 31278f3d Fix compilation warnings
31278f3d is described below

commit 31278f3da69321a5619eb9085654d1af10a8a1d3
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 13:12:37 2023 +0200

Fix compilation warnings
---
 contrib/crack_plate/crack_bilaplacian.h   |  2 +-
 contrib/crack_plate/crack_mindlin.cc  |  2 +-
 src/getfem/bgeot_geometric_trans.h|  4 +--
 src/getfem_contact_and_friction_common.cc | 16 +
 src/getfem_nonlinear_elasticity.cc|  5 ++-
 tests/test_mesh.cc| 60 ---
 tests/test_small_vector.cc| 10 +++---
 7 files changed, 54 insertions(+), 45 deletions(-)

diff --git a/contrib/crack_plate/crack_bilaplacian.h 
b/contrib/crack_plate/crack_bilaplacian.h
index 40b08ba9..12c9acf4 100644
--- a/contrib/crack_plate/crack_bilaplacian.h
+++ b/contrib/crack_plate/crack_bilaplacian.h
@@ -264,7 +264,7 @@ void calcul_von_mises(const getfem::mesh_fem _u, const 
VEC1 ,
   getfem::compute_gradient(mf_u, mf_vm, U, DU);
   
   gmm::resize(VM, mf_vm.nb_dof());
-  scalar_type vm_min, vm_max;
+  scalar_type vm_min=0, vm_max=0;
   for (size_type i=0; i < mf_vm.nb_dof(); ++i) {
 VM[i] = 0;
 scalar_type sdiag = 0.;
diff --git a/contrib/crack_plate/crack_mindlin.cc 
b/contrib/crack_plate/crack_mindlin.cc
index ff8056e0..ffbff658 100644
--- a/contrib/crack_plate/crack_mindlin.cc
+++ b/contrib/crack_plate/crack_mindlin.cc
@@ -938,7 +938,7 @@ void calcul_von_mises(const getfem::mesh_fem _u, const 
VEC1 ,
   getfem::compute_gradient(mf_u, mf_vm, U, DU);
   
   gmm::resize(VM, mf_vm.nb_dof());
-  scalar_type vm_min, vm_max;
+  scalar_type vm_min=0, vm_max=0;
   for (size_type i=0; i < mf_vm.nb_dof(); ++i) {
 VM[i] = 0;
 scalar_type sdiag = 0.;
diff --git a/src/getfem/bgeot_geometric_trans.h 
b/src/getfem/bgeot_geometric_trans.h
index edbd4f06..d5ef5590 100644
--- a/src/getfem/bgeot_geometric_trans.h
+++ b/src/getfem/bgeot_geometric_trans.h
@@ -419,7 +419,7 @@ namespace bgeot {
 pgeotrans_precomp pgp_;
 pstored_point_tab pspt_; /** if pgp != 0, it is the same as pgp's one */
 size_type ii_;   /** index of current point in the pgp */
-mutable scalar_type J_, J__; /** Jacobian */
+mutable scalar_type J_=0, J__=0; /** Jacobian */
 mutable base_matrix PC, B_factors;
 mutable base_vector aux1, aux2;
 mutable std::vector ipvt;
@@ -519,7 +519,7 @@ namespace bgeot {
const base_node& xref__,
const base_matrix& G__)
   : xref_(xref__), G_(__), pgt_(pgt__), pgp_(0), pspt_(0),
-  ii_(size_type(-1)),have_J_(false), have_B_(false), have_B3_(false),
+  ii_(size_type(-1)), have_J_(false), have_B_(false), have_B3_(false),
   have_B32_(false), have_K_(false), have_cv_center_(false) {}
   };
 
diff --git a/src/getfem_contact_and_friction_common.cc 
b/src/getfem_contact_and_friction_common.cc
index e1597969..b9a1291d 100644
--- a/src/getfem_contact_and_friction_common.cc
+++ b/src/getfem_contact_and_friction_common.cc
@@ -1031,10 +1031,10 @@ namespace getfem {
 if (!ref_conf)
   slice_vector_on_basic_dof_of_element(mfu, disp_of_boundary(ib),
cv, coeff);
-
 m.points_of_convex(cv, G);
-
-const base_node  = pf_s->ref_convex(cv)->points_of_face(iff)[0];
+// face_pts is of type bgeot::convex<...>::ref_convex_pt_ct
+const auto face_pts = pf_s->ref_convex(cv)->points_of_face(iff);
+const base_node  = face_pts[0];
 fem_interpolation_context ctx(pgt, pf_s, x0, G, cv, iff);
 
 const base_small_vector  = pf_s->ref_convex(cv)->normals()[iff];
@@ -1733,8 +1733,9 @@ namespace getfem {
 //
 
 m_y.points_of_convex(cv_y, G_y);
-const base_node 
-  = pfu_y->ref_convex(cv_y)->points_of_face(face_y)[0];
+// face_pts is of type bgeot::convex<...>::ref_convex_pt_ct
+const auto face_pts = pfu_y->ref_convex(cv_y)->points_of_face(face_y);
+const base_node  = face_pts[0];
 fem_interpolation_context ctx_y(pgt_y, pfu_y, Y0, G_y, cv_y, face_y);
 
 const base_small_vector 
@@ -2162,8 +2163,9 @@ namespace getfem {
 // Classical projection for y by quasi Newton algorithm
 //
 bgeot::vectors_to_base_matrix(G_y, m_y.points_of_convex(cv_y));
-const base_node 
-  = pfu_y->ref_convex(cv_y)->points_of_face(face_y)[0];
+// face_pts is of type bgeot::convex<...>::ref_convex_pt_ct
+const auto face_pts = pfu_y->ref_convex(cv_y)->points_of_face(face_y);
+const base_node  = face_pts[0];
 fem_interpolation_context ctx_y(pgt_y, pfu_y, Y0, G_y, cv_y, face_y);
 
 

[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warnings and coding style

2023-10-17 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 24c096f9 Fix compilation warnings and coding style
24c096f9 is described below

commit 24c096f938f335048d2df8efc8601b93dfd2c90e
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 12:04:43 2023 +0200

Fix compilation warnings and coding style
---
 interface/src/python/getfem_python.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/interface/src/python/getfem_python.c 
b/interface/src/python/getfem_python.c
index 53766e6e..eb9a4641 100644
--- a/interface/src/python/getfem_python.c
+++ b/interface/src/python/getfem_python.c
@@ -483,14 +483,12 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 t->dim.dim_len = PyArray_NDIM((PyArrayObject *)po);
 t->dim.dim_val = (u_int *)gc_alloc(gc, t->dim.dim_len * sizeof(u_int));
 
-int i;
-for (i=0; i < t->dim.dim_len; ++i)
+for (u_int i=0; i < t->dim.dim_len; ++i)
   t->dim.dim_val[i] = (u_int)PyArray_DIM((PyArrayObject *)po,i);
   } else if (PyTuple_Check(o) || PyList_Check(o)) {
 //printf("Tuple or List\n");
 /* python tuples and lists are stored in 'cell arrays'
(i.e. matlab's lists of inhomogeneous elements) */
-int i;
 t->storage.type = GFI_CELL;
 t->dim.dim_len = 1;
 t->dim.dim_val = (cell,len);
@@ -502,7 +500,7 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
   = gc_alloc(gc,sizeof(gfi_array*)*TGFISTORE(cell,len return NULL;
 gfi_array **p = TGFISTORE(cell,val);
 
-for (i=0; i < TGFISTORE(cell,len); ++i) {
+for (u_int i=0; i < TGFISTORE(cell,len); ++i) {
   if (PyTuple_Check(o))
 p[i] = PyObject_to_gfi_array(gc, PyTuple_GET_ITEM(o,i));
   else p[i] = PyObject_to_gfi_array(gc, PyList_GET_ITEM(o,i));
@@ -545,7 +543,7 @@ PyGetfemObject_FromObjId(gfi_object_id id, int in__init__) {
 PyObject *arg;
 if (!(arg = Py_BuildValue("(O)", go))) return NULL;
 //printf("  -> arg= "); PyObject_Print(arg,stdout,0); printf("\n");
-o = PyEval_CallObject(python_factory, arg);
+o = PyObject_CallObject(python_factory, arg);
 Py_DECREF(arg);
   } else o = (PyObject*)go;
   //printf("  -> return "); PyObject_Print(o,stdout,0); printf("\n");
@@ -553,7 +551,7 @@ PyGetfemObject_FromObjId(gfi_object_id id, int in__init__) {
 }
 
 static const gfi_array **
-build_gfi_array_list(gcollect *gc, PyObject *tuple, char **pfunction_name,
+build_gfi_array_list(gcollect *gc, PyObject *tuple, const char 
**pfunction_name,
  int *nb) {
   const gfi_array **l;
   int i, j;
@@ -590,8 +588,7 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
   return PyLong_FromLong(TGFISTORE(int32,val)[0]);
 else {
   npy_intp *dim = PyDimMem_NEW(t->dim.dim_len);
-  int i;
-  for(i=0; i < t->dim.dim_len; i++)
+  for (u_int i=0; i < t->dim.dim_len; i++)
 dim[i] = (npy_intp)t->dim.dim_val[i];
   if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_INT, 1)))
 return NULL;
@@ -610,8 +607,7 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
 return PyFloat_FromDouble(TGFISTORE(double,val)[0]);
   else {
 npy_intp *dim = PyDimMem_NEW(t->dim.dim_len);
-int i;
-for(i=0; i< t->dim.dim_len; i++)
+for (u_int i=0; i < t->dim.dim_len; i++)
   dim[i] = (npy_intp)t->dim.dim_val[i];
 if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_DOUBLE, 1)))
   return NULL;
@@ -623,8 +619,7 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
  TGFISTORE(double,val)[1]);
   else {
 npy_intp *dim = PyDimMem_NEW(t->dim.dim_len);
-int i;
-for(i=0; i< t->dim.dim_len; i++)
+for (u_int i=0; i < t->dim.dim_len; i++)
   dim[i] = (npy_intp)t->dim.dim_val[i];
 if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_CDOUBLE, 1)))
   return NULL;
@@ -642,9 +637,8 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
   } break;
   case GFI_CELL: {
 //printf("GFI_CELL\n");
-unsigned i;
 if (!(o = PyTuple_New(TGFISTORE(cell,len return NULL;
-for (i=0; i < TGFISTORE(cell,len); ++i) {
+for (u_int i=0; i < TGFISTORE(cell,len); ++i) {
   PyObject *to = gfi_array_to_PyObject(TGFISTORE(cell,val)[i], in__init__);
   if (!to) return NULL;
   PyTuple_SET_ITEM(o,i,to);
@@ -657,8 +651,7 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
 #if 0
   /* PyArray_OBJECT is not supported in numarray ... */
   npy_intp *dim = PyDimMem_NEW(t->dim.dim_len);
-  int i;
-  for(i=0; i< t->dim.dim_len; i++)
+  for (u_int i=0; i < t->dim.dim_len; i++)
 dim[i] = (npy_intp)t->dim.dim_val[i];
   if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_OBJECT,1)))
 return NULL;
@@ -715,7 +708,8 @@ 

[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warning, allocate memory for strings passed from Python

2023-10-17 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 77348c0c Fix compilation warning, allocate memory for strings passed 
from Python
77348c0c is described below

commit 77348c0c3ea9082269da468a668eaa236d6e3d1e
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 12:00:24 2023 +0200

Fix compilation warning, allocate memory for strings passed from Python

  - do not use a pointer to cached utf8 version of python string
  - allocate memory and make a copy of the utf8 string instead
---
 interface/src/python/getfem_python.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/interface/src/python/getfem_python.c 
b/interface/src/python/getfem_python.c
index 38abcfd6..53766e6e 100644
--- a/interface/src/python/getfem_python.c
+++ b/interface/src/python/getfem_python.c
@@ -341,14 +341,14 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 //printf("String\n");
 /* for strings, the pointer is shared, no copy */
 int L = (int)(strlen(PyUnicode_AsUTF8(o)));
-char *s = PyUnicode_AsUTF8(o);
-gc_ref(gc, o, 0);
+const char *s = PyUnicode_AsUTF8(o);
 
 t->storage.type = GFI_CHAR;
 t->dim.dim_len = 1;
 t->dim.dim_val = (char,len);
 TGFISTORE(char,len)=L;
-TGFISTORE(char,val)=s;
+if (!(TGFISTORE(char,val)=gc_alloc(gc,L*sizeof(char return NULL;
+memcpy(TGFISTORE(char,val), s, L);
 #if PY_MAJOR_VERSION < 3
   } else if (PyInt_Check(o) || PyLong_Check(o)) {
 #else



[Getfem-commits] [getfem-commits] branch master updated: Whitespace changes

2023-10-17 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 23dfd3c8 Whitespace changes
23dfd3c8 is described below

commit 23dfd3c81580679bf280c3e79f7da5cc01cdd362
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 11:55:35 2023 +0200

Whitespace changes
---
 interface/src/python/getfem_python.c | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/interface/src/python/getfem_python.c 
b/interface/src/python/getfem_python.c
index 634eea1b..38abcfd6 100644
--- a/interface/src/python/getfem_python.c
+++ b/interface/src/python/getfem_python.c
@@ -331,7 +331,8 @@ static gfi_array *
 PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 {
   gfi_object_id id;
-  gfi_array *t = gc_alloc(gc, sizeof(gfi_array)); if (!t) return NULL;
+  gfi_array *t = gc_alloc(gc, sizeof(gfi_array));
+  if (!t) return NULL;
 #define TGFISTORE0(T) t->storage.gfi_storage_u.data_##T
 #define TGFISTORE1(T,field) data_##T##_##field
 #define TGFISTORE(T,field) TGFISTORE0(T).TGFISTORE1(T,field)
@@ -344,7 +345,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 gc_ref(gc, o, 0);
 
 t->storage.type = GFI_CHAR;
-t->dim.dim_len = 1; t->dim.dim_val = (char,len);
+t->dim.dim_len = 1;
+t->dim.dim_val = (char,len);
 TGFISTORE(char,len)=L;
 TGFISTORE(char,val)=s;
 #if PY_MAJOR_VERSION < 3
@@ -364,7 +366,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
"in getfem interface.");
 
 t->storage.type = GFI_INT32;
-t->dim.dim_len = 0; t->dim.dim_val = (int32,len);
+t->dim.dim_len = 0;
+t->dim.dim_val = (int32,len);
 TGFISTORE(int32,len)=1;
 if (!(TGFISTORE(int32,val)=gc_alloc(gc,sizeof(int return NULL;
 TGFISTORE(int32,val)[0] = d;
@@ -373,7 +376,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 /* usual python float */
 double df = PyFloat_AsDouble(o);
 t->storage.type = GFI_DOUBLE;
-t->dim.dim_len = 0; t->dim.dim_val = (double,len);
+t->dim.dim_len = 0;
+t->dim.dim_val = (double,len);
 TGFISTORE(double,len)=1;
 t->storage.gfi_storage_u.data_double.is_complex = 0;
 if (!(TGFISTORE(double,val)=gc_alloc(gc,sizeof(double return NULL;
@@ -384,7 +388,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 double real = PyComplex_RealAsDouble(o);
 double imag = PyComplex_ImagAsDouble(o);
 t->storage.type = GFI_DOUBLE;
-t->dim.dim_len = 0; t->dim.dim_val = (double,len);
+t->dim.dim_len = 0;
+t->dim.dim_val = (double,len);
 TGFISTORE(double,len)=2;
 t->storage.gfi_storage_u.data_double.is_complex = 1;
 if (!(TGFISTORE(double,val)=gc_alloc(gc,sizeof(double)*2))) return NULL;
@@ -487,7 +492,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
(i.e. matlab's lists of inhomogeneous elements) */
 int i;
 t->storage.type = GFI_CELL;
-t->dim.dim_len = 1; t->dim.dim_val = (cell,len);
+t->dim.dim_len = 1;
+t->dim.dim_val = (cell,len);
 
 if (PyTuple_Check(o)) TGFISTORE(cell,len) = 
(unsigned)(PyTuple_GET_SIZE(o));
 else TGFISTORE(cell,len) = (unsigned)(PyList_GET_SIZE(o));
@@ -506,7 +512,8 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o)
 //printf("Object\n");
 /* getfem objects are refered to with a couple (classid, objectid) */
 t->storage.type = GFI_OBJID;
-t->dim.dim_len = 1; t->dim.dim_val = (cell,len);
+t->dim.dim_len = 1;
+t->dim.dim_val = (cell,len);
 t->storage.gfi_storage_u.objid.objid_len = 1;
 if (!(t->storage.gfi_storage_u.objid.objid_val =
   gc_alloc(gc,sizeof(gfi_object_id return NULL;
@@ -586,7 +593,8 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
   int i;
   for(i=0; i < t->dim.dim_len; i++)
 dim[i] = (npy_intp)t->dim.dim_val[i];
-  if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_INT, 1))) return NULL;
+  if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_INT, 1)))
+return NULL;
   PyDimMem_FREE(dim);
 
   npy_intp itemsize = PyArray_ITEMSIZE((PyArrayObject *)o);
@@ -652,8 +660,8 @@ gfi_array_to_PyObject(gfi_array *t, int in__init__) {
   int i;
   for(i=0; i< t->dim.dim_len; i++)
 dim[i] = (npy_intp)t->dim.dim_val[i];
-  if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_OBJECT,1))) return NULL;
-
+  if (!(o = PyArray_EMPTY(t->dim.dim_len, dim, NPY_OBJECT,1)))
+return NULL;
   if (!PyArray_ISFARRAY(PyArray_DATA((PyArrayObject *)o))) {
 // I'm just too lazy to transpose matrices
 PyErr_Format(PyExc_RuntimeError,



  1   2   3   >