[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 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 8f534996 Fix compilation warnings
8f534996 is described below

commit 8f5349968d918271bfeb001a2d32fd1686fa42b6
Author: Konstantinos Poulios 
AuthorDate: Tue Oct 17 11:05:52 2023 +0200

Fix compilation warnings
---
 src/getfem_generic_assembly_interpolation.cc |  8 
 src/getfem_plasticity.cc | 13 -
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/getfem_generic_assembly_interpolation.cc 
b/src/getfem_generic_assembly_interpolation.cc
index 2f45470f..5fb43322 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -593,10 +593,10 @@ namespace getfem {
 box_to_convexes.clear();
 element_boxes.clear();
 base_node bmin(N), bmax(N);
+const mesh_region  = target_mesh.region(target_region);
 const dal::bit_vector&
   convex_index = (target_region == mesh_region::all_convexes().id())
-   ? target_mesh.convex_index()
-   : target_mesh.region(target_region).index();
+   ? target_mesh.convex_index() : mr.index();
 for (dal::bv_visitor cv(convex_index); !cv.finished(); ++cv) {
 
   bgeot::pgeometric_trans pgt = target_mesh.trans_of_convex(cv);
@@ -609,10 +609,10 @@ namespace getfem {
 gmm::clear(bmin);
 gmm::clear(bmax);
   }
+  mesh::ref_mesh_pt_ct cvpts = target_mesh.points_of_convex(cv);
   for (short_type ip = 1; ip < nbd_t; ++ip) {
 // size_type ind = target_mesh.ind_points_of_convex(cv)[ip];
-const base_node  = target_mesh.points_of_convex(cv)[ip];
-
+const base_node  = cvpts[ip];
 for (size_type k = 0; k < N; ++k) {
   bmin[k] = std::min(bmin[k], pt[k]);
   bmax[k] = std::max(bmax[k], pt[k]);
diff --git a/src/getfem_plasticity.cc b/src/getfem_plasticity.cc
index 79166277..5a0ec9c0 100644
--- a/src/getfem_plasticity.cc
+++ b/src/getfem_plasticity.cc
@@ -2193,15 +2193,10 @@ namespace getfem {
 
 pbrick pbr = std::make_shared(ACP);
 
-model::termlist tl;
-tl.push_back(model::term_description
- (varname, varname, true));
-model::varnamelist dl(1, datalambda);
-dl.push_back(datamu);
-dl.push_back(datathreshold);
-dl.push_back(datasigma);
-dl.push_back(data_previous_disp);
-model::varnamelist vl(1, varname);
+model::termlist tl{model::term_description(varname, varname, true)};
+model::varnamelist
+  dl{datalambda, datamu, datathreshold, datasigma, data_previous_disp},
+  vl{varname};
 
 return md.add_brick(pbr, vl, dl, tl,
 model::mimlist(1,), region);



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

2023-10-16 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 d174e60a Fix compilation warnings
d174e60a is described below

commit d174e60ae00fc250435e16948ff07eada1d32591
Author: Konstantinos Poulios 
AuthorDate: Mon Oct 16 13:29:42 2023 +0200

Fix compilation warnings
---
 src/getfem_mesh.cc| 4 ++--
 src/gmm/gmm_feedback_management.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/getfem_mesh.cc b/src/getfem_mesh.cc
index d6e25378..ecaba792 100644
--- a/src/getfem_mesh.cc
+++ b/src/getfem_mesh.cc
@@ -324,9 +324,9 @@ namespace getfem {
 GMM_ASSERT1(rg == size_type(-1) || msource.region(rg).is_only_convexes(),
 "The provided mesh region should only contain convexes");
 
+const mesh_region  = msource.region(rg);
 const dal::bit_vector  = (rg == size_type(-1))
-? msource.convex_index()
-: msource.region(rg).index();
+? msource.convex_index() : mr.index();
 std::vector old2new(msource.points_index().last()+1, 
size_type(-1));
 for (dal::bv_visitor cv(convexes); !cv.finished(); ++cv) {
 
diff --git a/src/gmm/gmm_feedback_management.h 
b/src/gmm/gmm_feedback_management.h
index f445b16d..84ef3222 100644
--- a/src/gmm/gmm_feedback_management.h
+++ b/src/gmm/gmm_feedback_management.h
@@ -135,8 +135,8 @@ public:
 // Depending on action either gets, sets or replaces feedback handler. Setting 
handler to null resets
 // it to gmm::default_feedback_handler.
 inline base_feedback_handler* feedback_manager::manage(enum Action action, 
base_feedback_handler *pHandler) {
-  static std::unique_ptr pHandler_ =
-std::move(std::unique_ptr(new 
default_feedback_handler));
+  static std::unique_ptr
+pHandler_ = std::make_unique();
   base_feedback_handler *rethandler = nullptr;
   switch(action) {
 case SET: