[Getfem-commits] [getfem-commits] branch master updated: Convert the planetary gear example to GWFL
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 4e663f5 Convert the planetary gear example to GWFL 4e663f5 is described below commit 4e663f5855112c36bd3f916cc20ffc89cd18491c Author: Konstantinos Poulios AuthorDate: Fri Jan 22 20:23:59 2021 +0100 Convert the planetary gear example to GWFL --- .../static_contact_planetary.py| 571 + 1 file changed, 252 insertions(+), 319 deletions(-) diff --git a/contrib/static_contact_gears/static_contact_planetary.py b/contrib/static_contact_gears/static_contact_planetary.py index 91307e7..1dc4553 100644 --- a/contrib/static_contact_gears/static_contact_planetary.py +++ b/contrib/static_contact_gears/static_contact_planetary.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Python GetFEM++ interface # -# Copyright (C) 2010-2020 Konstantinos Poulios. +# Copyright (C) 2010-2021 Konstantinos Poulios. # # This file is a part of GetFEM++ # @@ -26,16 +26,10 @@ This program is used to check that python-getfem is working. This is also a good example of use of GetFEM++. """ -from math import cos, pi, sin - -from getfem import * - -# mesh import -m_1 = Mesh('import', 'gmsh', './static_contact_planetary_1.msh') -m_2 = Mesh('import', 'gmsh', './static_contact_planetary_2.msh') -m_p1 = Mesh('import', 'gmsh', './static_contact_planetary_3.msh') -m_p2 = Mesh('import', 'gmsh', './static_contact_planetary_4.msh') -m_p3 = Mesh('import', 'gmsh', './static_contact_planetary_5.msh') +import getfem as gf +from math import sin,cos,pi +gf.util_trace_level(1) +gf.util_warning_level(1) z_1 = 20 z_2 = -64 @@ -46,331 +40,270 @@ R_i = 31. #rot_angle = 2e-2 torsion = 1000.e3 +steps = 10 +anglestep = 2*pi/abs(z_2)/float(steps) Lambda = 1.18e5 Mu = 0.83e5 -qdim = 2 -degree = 1 +f_coeff = 0. -contact_algo = 1 +disp_fem_order = 2 +mult_fem_order = 1 # but discontinuous -# displacement meshfems -mfu_1 = MeshFem(m_1, qdim) -mfu_2 = MeshFem(m_2, qdim) -mfu_p1 = MeshFem(m_p1, qdim) -mfu_p2 = MeshFem(m_p2, qdim) -mfu_p3 = MeshFem(m_p3, qdim) - -mfu_1.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfu_2.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfu_p1.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfu_p2.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfu_p3.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) +integration_degree = 4 # 9 gauss points per quad +integration_contact_degree = 10 # 6 gauss points per face -# rhs meshfems -mfrhs_1 = MeshFem(m_1, 1) -mfrhs_2 = MeshFem(m_2, 1) -mfrhs_p1 = MeshFem(m_p1, 1) -mfrhs_p2 = MeshFem(m_p2, 1) -mfrhs_p3 = MeshFem(m_p3, 1) - -mfrhs_1.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfrhs_2.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfrhs_p1.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfrhs_p2.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) -mfrhs_p3.set_fem(Fem('FEM_QK(2,%d)' % (degree,))) - -# integration methods -mim_1 = MeshIm(m_1, Integ('IM_QUAD(2)')) -mim_2 = MeshIm(m_2, Integ('IM_QUAD(2)')) -mim_p1 = MeshIm(m_p1, Integ('IM_QUAD(2)')) -mim_p2 = MeshIm(m_p2, Integ('IM_QUAD(2)')) -mim_p3 = MeshIm(m_p3, Integ('IM_QUAD(2)')) +# mesh import +m_1 = gf.Mesh('import', 'gmsh', './static_contact_planetary_1.msh') +m_2 = gf.Mesh('import', 'gmsh', './static_contact_planetary_2.msh') +m_p1 = gf.Mesh('import', 'gmsh', './static_contact_planetary_3.msh') +m_p2 = gf.Mesh('import', 'gmsh', './static_contact_planetary_4.msh') +m_p3 = gf.Mesh('import', 'gmsh', './static_contact_planetary_5.msh') # regions definitions for boundary conditions RG_NEUMANN_1 = 1 -RG_NEUMANN_2 = 2 -RG_NEUMANN_p1 = 3 -RG_NEUMANN_p2 = 4 -RG_NEUMANN_p3 = 5 - -RG_DIRICHLET_1 = 10 -RG_DIRICHLET_2 = 20 -RG_CONTACT_p1 = 30 -RG_CONTACT_p2 = 40 -RG_CONTACT_p3 = 50 - -RG_CONTACT_1_p1 = 13 -RG_CONTACT_1_p2 = 14 -RG_CONTACT_1_p3 = 15 - -RG_CONTACT_2_p1 = 23 -RG_CONTACT_2_p2 = 24 -RG_CONTACT_2_p3 = 25 - -RG_CONTACT_p1_1 = 31 -RG_CONTACT_p1_2 = 32 - -RG_CONTACT_p2_1 = 41 -RG_CONTACT_p2_2 = 42 - -RG_CONTACT_p3_1 = 51 -RG_CONTACT_p3_2 = 52 +RG_DIRICHLET_2 = 2 +RG_CONTACT_1 = 3 +RG_CONTACT_2 = 4 +RG_CONTACT_p1_out = 5 +RG_CONTACT_p2_out = 6 +RG_CONTACT_p3_out = 7 +RG_CONTACT_p1_in = 8 +RG_CONTACT_p2_in = 9 +RG_CONTACT_p3_in = 10 +RG_CONTACT_p1 = 11 +RG_CONTACT_p2 = 12 +RG_CONTACT_p3 = 13 for i in range(1, z_1 + 1): - m_1.set_region(RG_NEUMANN_1, m_1.region(100043+100*i)) - m_1.set_region(RG_NEUMANN_1, m_1.region(100083+100*i)) + m_1.region_merge(RG_NEUMANN_1, 100043+100*i) + m_1.region_merge(RG_NEUMANN_1, 100083+100*i) + m_1.region_merge(RG_CONTACT_1, 100013+100*i) + m_1.region_merge(RG_CONTACT_1, 100053+100*i) for i in range(1, abs(z_2) + 1): - m_2.set_region(RG_DIRICHLET_2, m_2.region(200043+100*i)) - m_2.set_region(RG_DIRICHLET_2, m_2.region(200083+100*i)) + m_2.region_merge(RG_DIRICHLET_2, 200043+100*i) + m_2.region_merge(RG_DIRICHLET_2, 200083+100*i) +
[Getfem-commits] [getfem-commits] branch master updated: Add projected_fem::projected_target_region() function
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 05989af Add projected_fem::projected_target_region() function 05989af is described below commit 05989af44c2e90fade549070462b3201e59e6a6e Author: Andriy Andreykiv AuthorDate: Wed Mar 10 16:59:10 2021 +0100 Add projected_fem::projected_target_region() function --- src/getfem/getfem_projected_fem.h | 4 src/getfem_projected_fem.cc | 22 ++ 2 files changed, 26 insertions(+) diff --git a/src/getfem/getfem_projected_fem.h b/src/getfem/getfem_projected_fem.h index ae216b9..840362f 100644 --- a/src/getfem/getfem_projected_fem.h +++ b/src/getfem/getfem_projected_fem.h @@ -141,6 +141,10 @@ namespace getfem { /** return the list of convexes of the projected mesh_fem which * contain at least one gauss point (should be all convexes)! */ dal::bit_vector projected_convexes() const; + +/** faces and convexes from the target region + * that contain at least one Gauss point that is projected by the source */ +mesh_region projected_target_region() const; /** return the min/max/mean number of gauss points in the convexes * of the projected mesh_fem */ diff --git a/src/getfem_projected_fem.cc b/src/getfem_projected_fem.cc index fa73548..a5f0d68 100644 --- a/src/getfem_projected_fem.cc +++ b/src/getfem_projected_fem.cc @@ -795,6 +795,28 @@ namespace getfem { return bv; } + mesh_region projected_fem::projected_target_region() const { +context_check(); +mesh_region projected_target; +for (mr_visitor v(rg_target); !v.finished(); ++v) { + pintegration_method pim = mim_target.int_method_of_element(v.cv()); + papprox_integration pai = pim->approx_method(); + size_type start_pt = v.is_face() ? pai->ind_first_point_on_face(v.f()) : 0; + size_type nb_pts = v.is_face() ? pai->nb_points_on_face(v.f()) + : pai->nb_points_on_convex(); + bool isProjectedOn = false; + for (size_type ip = 0; ip != nb_pts; ++ip) { +auto _data = elements.at(v.cv()).gausspt[start_pt + ip]; +if (proj_data.iflags) { + isProjectedOn = true; + break; +} + } + if (isProjectedOn) projected_target.add(v.cv(), v.f()); +} +return projected_target; + } + void projected_fem::gauss_pts_stats(unsigned , unsigned , scalar_type ) const { std::vector v(mf_source.linked_mesh().nb_allocated_convex());
Re: [Getfem-commits] merge request for touched_region_for_projected_fem
Hi Andriy, Sorry for the delay. I hadn't noticed your previous reply. Your commits have been rebased/squashed/merged. All of your changes should be in the current master. If you confirm this, you can delete the touched_region_for_projected_fem branch yourself. Thanks for the useful new function. Best regards Kostas On Tue, Mar 9, 2021 at 9:37 AM Andriy Andreykiv wrote: > Kostas, hi, > > Did you have a chance to review my latest commits? > Thanks, > Andriy > > On Fri, 5 Mar 2021 at 09:27, Konstantinos Poulios > wrote: > >> Thanks. I see your point about "intersected". I think >> "projected_target_region" is a good name. >> >> If you do this change I can squash and merge your commits. >> >> Best regards >> Kostas >> >> On Thu, Mar 4, 2021 at 2:06 PM Andriy Andreykiv < >> andriy.andrey...@gmail.com> wrote: >> >>> Hi Konstantinos, >>> >>> Replaced almost all the auto's. Regarding intersected_target_region, >>> that could be, but for me the word intersected would be appropriate if it >>> was interpolated_fem where the regions intersect. >>> Physically it feels like touch, but I agree that we have touch() in >>> context_dependencies which might be confusing. >>> Here I feel a need for the concept of projection. I personally need a >>> name that condenses the sentence "region that contains part of the target >>> where the source is projected on". Can we say >>> projected_target_region? We can also go with supported_target_region()? >>> >>> Let me know what you think, >>> Andriy >>> >>> >>> >>> On Thu, 4 Mar 2021 at 12:38, Konstantinos Poulios < >>> logar...@googlemail.com> wrote: >>> should we also briefly discuss the name of the function? In mathematical terms I would call it support_region But a more popularized name might be easier to understand in general. However, I do not like "touched" because "touch" is typically used in programming for denoting change in state, so your current name I understand it as a region that has state A and changes to state B. We could instead call it intersected_target_region or something similar. Other ideas? In general I think we should spend some effort in good names because once a name is in the API it is more difficult to remove. Best regards Kostas On Thu, Mar 4, 2021 at 12:31 PM Konstantinos Poulios < logar...@googlemail.com> wrote: > Hi Andriy, > > Thanks, I see how it can be useful. Could I ask you to reduce the use > of auto for this commit? For example it does not make much sense to use > auto for bool. In general my preference for the GetFEM codebase is to use > auto only if some type is particularly long and makes the code > significantly less readable. Otherwise the type of the variables is useful > information for people that will read and try to understand the code > later. > > There is also a typo in a comment. It should be "Gauss". > > Best regards > Kostas > > On Thu, Mar 4, 2021 at 11:32 AM Andriy Andreykiv < > andriy.andrey...@gmail.com> wrote: > >> Dear Yves and Konstantinus, >> >> Kind request to review and merge touched_region_for_projected_fem >> branch. >> It introduces a method for projected_fem that extracts a region from >> the target that is actually touched by the source. >> I use this region to integrate my mortar terms on. >> >> Best regards, >> Andriy >> >> >>
Re: [Getfem-commits] merge request for touched_region_for_projected_fem
Hi Andriy, Thanks, I see how it can be useful. Could I ask you to reduce the use of auto for this commit? For example it does not make much sense to use auto for bool. In general my preference for the GetFEM codebase is to use auto only if some type is particularly long and makes the code significantly less readable. Otherwise the type of the variables is useful information for people that will read and try to understand the code later. There is also a typo in a comment. It should be "Gauss". Best regards Kostas On Thu, Mar 4, 2021 at 11:32 AM Andriy Andreykiv wrote: > Dear Yves and Konstantinus, > > Kind request to review and merge touched_region_for_projected_fem branch. > It introduces a method for projected_fem that extracts a region from the > target that is actually touched by the source. > I use this region to integrate my mortar terms on. > > Best regards, > Andriy > > >
Re: [Getfem-commits] merge request for touched_region_for_projected_fem
should we also briefly discuss the name of the function? In mathematical terms I would call it support_region But a more popularized name might be easier to understand in general. However, I do not like "touched" because "touch" is typically used in programming for denoting change in state, so your current name I understand it as a region that has state A and changes to state B. We could instead call it intersected_target_region or something similar. Other ideas? In general I think we should spend some effort in good names because once a name is in the API it is more difficult to remove. Best regards Kostas On Thu, Mar 4, 2021 at 12:31 PM Konstantinos Poulios < logar...@googlemail.com> wrote: > Hi Andriy, > > Thanks, I see how it can be useful. Could I ask you to reduce the use of > auto for this commit? For example it does not make much sense to use auto > for bool. In general my preference for the GetFEM codebase is to use auto > only if some type is particularly long and makes the code significantly > less readable. Otherwise the type of the variables is useful information > for people that will read and try to understand the code later. > > There is also a typo in a comment. It should be "Gauss". > > Best regards > Kostas > > On Thu, Mar 4, 2021 at 11:32 AM Andriy Andreykiv < > andriy.andrey...@gmail.com> wrote: > >> Dear Yves and Konstantinus, >> >> Kind request to review and merge touched_region_for_projected_fem branch. >> It introduces a method for projected_fem that extracts a region from the >> target that is actually touched by the source. >> I use this region to integrate my mortar terms on. >> >> Best regards, >> Andriy >> >> >>
Re: [Getfem-commits] merge request for touched_region_for_projected_fem
Thanks. I see your point about "intersected". I think "projected_target_region" is a good name. If you do this change I can squash and merge your commits. Best regards Kostas On Thu, Mar 4, 2021 at 2:06 PM Andriy Andreykiv wrote: > Hi Konstantinos, > > Replaced almost all the auto's. Regarding intersected_target_region, that > could be, but for me the word intersected would be appropriate if it was > interpolated_fem where the regions intersect. > Physically it feels like touch, but I agree that we have touch() in > context_dependencies which might be confusing. > Here I feel a need for the concept of projection. I personally need a > name that condenses the sentence "region that contains part of the target > where the source is projected on". Can we say > projected_target_region? We can also go with supported_target_region()? > > Let me know what you think, > Andriy > > > > On Thu, 4 Mar 2021 at 12:38, Konstantinos Poulios > wrote: > >> should we also briefly discuss the name of the function? In mathematical >> terms I would call it >> >> support_region >> >> But a more popularized name might be easier to understand in general. >> However, I do not like "touched" because "touch" is typically used in >> programming for denoting change in state, so your current name I understand >> it as a region that has state A and changes to state B. We could instead >> call it >> >> intersected_target_region >> >> or something similar. Other ideas? >> >> In general I think we should spend some effort in good names because once >> a name is in the API it is more difficult to remove. >> >> Best regards >> Kostas >> >> On Thu, Mar 4, 2021 at 12:31 PM Konstantinos Poulios < >> logar...@googlemail.com> wrote: >> >>> Hi Andriy, >>> >>> Thanks, I see how it can be useful. Could I ask you to reduce the use of >>> auto for this commit? For example it does not make much sense to use auto >>> for bool. In general my preference for the GetFEM codebase is to use auto >>> only if some type is particularly long and makes the code significantly >>> less readable. Otherwise the type of the variables is useful information >>> for people that will read and try to understand the code later. >>> >>> There is also a typo in a comment. It should be "Gauss". >>> >>> Best regards >>> Kostas >>> >>> On Thu, Mar 4, 2021 at 11:32 AM Andriy Andreykiv < >>> andriy.andrey...@gmail.com> wrote: >>> Dear Yves and Konstantinus, Kind request to review and merge touched_region_for_projected_fem branch. It introduces a method for projected_fem that extracts a region from the target that is actually touched by the source. I use this region to integrate my mortar terms on. Best regards, Andriy
Re: [Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash
Dear Tetsuo, Could I get you to update some uses of the old pstress and pstrain brick names in the following files? model_linear_elasticity.rst demo_elasticity.m I hope I haven't missed any other affected files. Otherwise if all tests run successfully, then it is fine for me to merge the branch. Best regards Kostas On Fri, Apr 16, 2021 at 1:29 PM Tetsuo Koyama wrote: > Dear Yves and Kostas > > Thanks for your comments. > I updated the method names. > Please review it. > > Best regards, > > Tetsuo > > 2021年4月16日(金) 17:37 Yves Renard : > >> >> >> Dear Tetsuo, >> >> I also think that these name changes are convenient. >> >> Best regards, >> >> Yves >> >> On 10/04/2021 06:57, Tetsuo Koyama wrote: >> >> Dear Kostas and Yves >> >> @Kostas Thank you for your comment. It is a good point. >> I am a fan of adding brick at the end of the methods. >> >> add_isotropic_linearized_elasticity_pstrain_brick >> add_isotropic_linearized_elasticity_pstrain_brick >> add_lumped_mass_for_first_order_brick >> >> If you don't mind I will fix the name of these methods in this branch. >> >> Best regards Tetsuo >> >> 2021年4月10日(土) 4:24 Konstantinos Poulios : >> >>> Dear Tetsuo and Yves >>> >>> @Tetsuo thanks for this interface functions. I would like to use this >>> opportunity to discuss about the word "brick" in the naming of our >>> functions adding PDE term matrices. Traditionally, "brick" was only used at >>> the end of the function name. More recently, Yves started skipping "brick" >>> from some of the newer terms, which I think is fine. Now we have a mix with >>> names including "brick" and some without. Apart from that, there are 3 >>> functions that do not follow the old naming convention at all: >>> >>> add_isotropic_linearized_elasticity_brick_pstrainadd_isotropic_linearized_elasticity_brick_pstrainadd_lumped_mass_brick_for_first_order >>> >>> I would like to avoid this kind of inconsistencies in the naming so that >>> all functions for adding a PDE matrix either have "brick" at the end of >>> their name or that they do not include it at all. >>> >>> For Tetsuo's function I would suggest one of >>> add_lumped_mass_matrix_for_first_order >>> add_lumped_mass_for_first_order_brick >>> >>> Both in c++ and the interfaces. >>> >>> What do you think? >>> >>> Best regards >>> Kostas >>> >>> On Fri, Apr 9, 2021 at 11:23 AM Tetsuo Koyama >>> wrote: >>> Dear GetFEM project I added the lumped mass for first order to the python interface. Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ? BR Tetsuo >>> >> -- >> >> Yves Renard (yves.ren...@insa-lyon.fr) tel : (33) 04.72.43.87.08 >> INSA-Lyon >> 20, rue Albert Einstein >> 69621 Villeurbanne Cedex, FRANCE >> http://math.univ-lyon1.fr/~renard >> >> - >> >>
Re: [Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash
Dear Tetsuo and Yves @Tetsuo thanks for this interface functions. I would like to use this opportunity to discuss about the word "brick" in the naming of our functions adding PDE term matrices. Traditionally, "brick" was only used at the end of the function name. More recently, Yves started skipping "brick" from some of the newer terms, which I think is fine. Now we have a mix with names including "brick" and some without. Apart from that, there are 3 functions that do not follow the old naming convention at all: add_isotropic_linearized_elasticity_brick_pstrain add_isotropic_linearized_elasticity_brick_pstrain add_lumped_mass_brick_for_first_order I would like to avoid this kind of inconsistencies in the naming so that all functions for adding a PDE matrix either have "brick" at the end of their name or that they do not include it at all. For Tetsuo's function I would suggest one of add_lumped_mass_matrix_for_first_order add_lumped_mass_for_first_order_brick Both in c++ and the interfaces. What do you think? Best regards Kostas On Fri, Apr 9, 2021 at 11:23 AM Tetsuo Koyama wrote: > Dear GetFEM project > > I added the lumped mass for first order to the python interface. > Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ? > > BR Tetsuo >
[Getfem-commits] [getfem-commits] branch master updated: Add quasi-linear viscoelasticity example (finite strain)
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 2b5bbe3 Add quasi-linear viscoelasticity example (finite strain) 2b5bbe3 is described below commit 2b5bbe33723168066f400170ca795b4c2e9894db Author: Konstantinos Poulios AuthorDate: Sun Aug 15 17:51:49 2021 +0200 Add quasi-linear viscoelasticity example (finite strain) (de Pascalis, Abrahams, Parnell 2014) --- contrib/continuum_mechanics/QLV_viscoelasticity.py | 196 + 1 file changed, 196 insertions(+) diff --git a/contrib/continuum_mechanics/QLV_viscoelasticity.py b/contrib/continuum_mechanics/QLV_viscoelasticity.py new file mode 100644 index 000..6c22f0d --- /dev/null +++ b/contrib/continuum_mechanics/QLV_viscoelasticity.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python3 +# -*- coding: UTF8 -*- +# Python GetFEM interface +# +# Copyright (C) 2021-2021 Konstantinos Poulios. +# +# This file is a part of GetFEM +# +# GetFEM is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version along with the GCC Runtime Library +# Exception either version 3.1 or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License and GCC Runtime Library Exception for more details. +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +# + + +""" +This example provides an implementation of large strain quasilinear +viscoelasticity according to (de Pascalis, Abrahams, Parnell 2014). It +implements the compressible case with the Horgan-Murphy law from the paper, +as well as a neo-Hookean law from (Simo, Taylor, Pister 1985). The +implementation only covers Prony stress relaxation functions, which allow +a much simpler time integration, requiring storage of data at only one +previous time step. +""" + +import getfem as gf + +gf.util_trace_level(1) +gf.util_warning_level(1) + +# Material parameters under high strain rate +E = 1e2# Young's modulus [Pa] +nu = 0.49 # Poisson's ratio [-] +kappa = E/(3*(1-2*nu)) +mu = E/(2*(1+nu)) +MAT_LAW = ('neohookean-Simo','Horgan-Murphy')[1] +gamma = 1./6. # only used for Horgan-Murphy + +# Viscoelastic material constants +tauH = 1e-3 +tauD = 1e-3 +rH = 0.5 # the low strain rate bulk modulus is rH*kappa +rD = 0.5 # the low strain rate shear modulus is rD*mu + +# Dimensions [mm] +W = 0.5 # Block width +H = 2 # Block height +T = 0.5 # Block thikness + +# Time +t_max = 28e-3 + +# Numerical parameters +N_W = 1 +N_H = 1 +N_T = 1 +steps = 112 +fem_order = 2 + +# Mesh +m = gf.Mesh("import", +"structured","GT='GT_QK(3,2)'; ORG=[0,0,0]; SIZES=[%f,%f,%f]; NSUBDIV=[%i,%i,%i]" +% (W, H, T, N_W, N_H, N_T)) + +# Boundaries +RG_LEFT = 11 +RG_BOTTOM = 12 +RG_BACK = 13 +RG_TOP = 14 +m.set_region(RG_LEFT, m.outer_faces_in_box([-1e-5,-1e-5,-1e-5], [1e-5,H+1e-5,T+1e-5])) +m.set_region(RG_BOTTOM, m.outer_faces_in_box([-1e-5,-1e-5,-1e-5], [W+1e-5,1e-5,T+1e-5])) +m.set_region(RG_BACK, m.outer_faces_in_box([-1e-5,-1e-5,-1e-5], [W+1e-5,H+1e-5,1e-5])) +m.set_region(RG_TOP, m.outer_faces_in_box([-1e-5,H-1e-5,-1e-5], [W+1e-5,H+1e-5,T+1e-5])) + + +mfu_ = gf.MeshFem(m, 3) +mfu_.set_classical_fem(fem_order) + +kept_dofs = list(range(mfu_.nbdof())) +# remove x-dofs on RG_LEFT, y-dofs on RG_BOTTOM, and z-dofs on RG_BACK +for skipped_dof, RG in enumerate((RG_LEFT,RG_BOTTOM,RG_BACK)): + for dof in mfu_.basic_dof_on_region(RG): +if dof % 3 == skipped_dof: + kept_dofs.remove(dof) +mfu = gf.MeshFem('partial', mfu_, kept_dofs) + +mfmult = gf.MeshFem(m, 1) +mfmult.set_classical_fem(fem_order) + +mfout = gf.MeshFem(m, 1) +mfout.set_classical_discontinuous_fem(2) + +mim = gf.MeshIm(m, 5) + +# Model +md = gf.Model('real') +md.add_fem_variable('u', mfu) + +mimd3x3 = gf.MeshImData(mim, -1, [3,3]) + +md.add_initialized_data('epsYY', 0) + +md.add_initialized_data('kappa', kappa) +md.add_initialized_data('mu', mu) + +md.add_initialized_data('tauH', tauH) +md.add_initialized_data('tauD', tauD) +md.add_initialized_data('rH', rH) +md.add_initialized_data('rD', rD) + +dt = t_max/steps +md.add_initialized_data('dt', dt) + +md.add_im_data("SeHprev", mimd3x3) # Elastic hydrostatic stress at previous timestep +md.add_im_data("SeDprev", mimd3x3) # Elastic
[Getfem-commits] [getfem-commits] master updated (c41f5b8 -> bc309aa)
logari81 pushed a change to branch master. from c41f5b8 MPI fixes for affine and linear terms in nonlinear model residual add bc309aa Fix the compile error of nbp in ubuntu20.04 No new revisions were added by this update. Summary of changes: src/getfem_models.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
[Getfem-commits] [getfem-commits] master updated (11c409f -> c41f5b8)
logari81 pushed a change to branch master. from 11c409f Change in the web site upload new 066eb84 Just code style changes new afd2d94 MPI fixes form model residual assembly new c41f5b8 MPI fixes for affine and linear terms in nonlinear model residual Summary of changes: src/getfem/getfem_models.h | 9 +- src/getfem_models.cc | 217 - 2 files changed, 121 insertions(+), 105 deletions(-)
[Getfem-commits] (no subject)
branch: master commit afd2d94d80b702a128a5c577b631a2c906b4899d Author: Konstantinos Poulios AuthorDate: Sun May 23 14:38:53 2021 +0200 MPI fixes form model residual assembly --- src/getfem_models.cc | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/getfem_models.cc b/src/getfem_models.cc index fbbd361..40ff2e8 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -2845,7 +2845,9 @@ namespace getfem { } if (version & BUILD_RHS) { - approx_external_load_ = MPI_SUM_SCALAR(approx_external_load_); + // some contributions are added only in the master process + // send the correct result to all other processes + MPI_BCAST0_SCALAR(approx_external_load_); } #if GETFEM_PARA_LEVEL > 1 @@ -3281,10 +3283,14 @@ namespace getfem { gmm::clear(vecl[0]); if (expr.size()) { +const mesh_im = *mims[0]; +mesh_region rg(region); +mim.linked_mesh().intersect_with_mpi_region(rg); + // reenables disabled variables ga_workspace workspace(md, ga_workspace::inherit::ALL); GMM_TRACE2(name << ": generic source term assembly"); -workspace.add_expression(expr, *(mims[0]), region, 1, secondary_domain); +workspace.add_expression(expr, mim, rg, 1, secondary_domain); workspace.assembly(1); const auto =workspace.assembled_vector(); for (size_type i = 0; i < vl_test1.size(); ++i) {
[Getfem-commits] (no subject)
branch: master commit 066eb8423836f3d2f11ebc0b39e5d2e869d8de8c Author: Konstantinos Poulios AuthorDate: Sun May 23 14:32:50 2021 +0200 Just code style changes --- src/getfem/getfem_models.h | 9 ++-- src/getfem_models.cc | 123 +++-- 2 files changed, 57 insertions(+), 75 deletions(-) diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h index d875ace..9707404 100644 --- a/src/getfem/getfem_models.h +++ b/src/getfem/getfem_models.h @@ -241,9 +241,12 @@ namespace getfem { return 0; } - size_type size() const // Should control that the variable is - // indeed initialized by actualize_sizes() ... - { return is_complex ? complex_value[0].size() : real_value[0].size(); } + size_type size() const { // Should control that the variable is + // indeed initialized by actualize_sizes() ... +return is_complex ? complex_value[0].size() + : real_value[0].size(); + } + inline bool is_enabled() const { return !is_disabled; } void set_size(); }; // struct var_description diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 9e08ad1..fbbd361 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -247,7 +247,7 @@ namespace getfem { bool model::is_internal_variable(const std::string ) const { if (is_old(name)) return false; const auto _descr = variable_description(name); -return var_descr.is_internal && !var_descr.is_disabled; +return var_descr.is_internal && var_descr.is_enabled(); } bool model::is_affine_dependent_variable(const std::string ) const { @@ -318,7 +318,7 @@ namespace getfem { size_type primary_size = full_size; for (auto & : variables) - if (v.second.is_internal && !v.second.is_disabled) { // is_internal_variable() + if (v.second.is_internal && v.second.is_enabled()) { // is_internal_variable() v.second.I = gmm::sub_interval(full_size, v.second.size()); full_size += v.second.size(); } @@ -2411,166 +2411,145 @@ namespace getfem { if (cplx) { // complex term in complex model if (term.is_matrix_term && (version & BUILD_MATRIX) && !isprevious - && (isg || (!(var1->is_disabled) && !(var2->is_disabled { + && (isg || (var1->is_enabled() && var2->is_enabled( { gmm::add(gmm::scaled(brick.cmatlist[j], alpha), gmm::sub_matrix(cTM, I1, I2)); -if (term.is_symmetric && I1.first() != I2.first()) { +if (term.is_symmetric && I1.first() != I2.first()) gmm::add(gmm::scaled(gmm::transposed(brick.cmatlist[j]), alpha), gmm::sub_matrix(cTM, I2, I1)); -} } if (version & BUILD_RHS) { -if (isg || !(var1->is_disabled)) { - if (brick.pdispatch) { +if (isg || var1->is_enabled()) { + if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.cveclist[k][j], brick.coeffs[k]), gmm::sub_vector(crhs, I1)); - } - else { + else gmm::add(gmm::scaled(brick.cveclist[0][j], complex_type(alpha1)), gmm::sub_vector(crhs, I1)); - } } if (term.is_matrix_term && brick.pbr->is_linear() && is_linear()) { - if (var2->is_affine_dependent - && !(var1->is_disabled)) + if (var2->is_affine_dependent && var1->is_enabled()) gmm::mult_add(brick.cmatlist[j], gmm::scaled(var2->affine_complex_value, complex_type(-alpha1)), gmm::sub_vector(crhs, I1)); if (term.is_symmetric && I1.first() != I2.first() - && var1->is_affine_dependent - && !(var2->is_disabled)) { + && var1->is_affine_dependent && var2->is_enabled()) gmm::mult_add(gmm::conjugated(brick.cmatlist[j]), gmm::scaled(var1->affine_complex_value, complex_type(-alpha2)), gmm::sub_vector(crhs, I2)); - } } if (term.is_matrix_term && brick.pbr->is_linear() -&& (!is_linear() || (version & BUILD_WITH_LIN))) { - if (!(var1->is_disabled)) -gmm::mult_add(brick.cmatlist[j], - gmm::scaled(var2->complex_value[0], - complex_type(-alpha1)), - gmm::sub_vector(crhs, I1)); -
[Getfem-commits] (no subject)
branch: master commit c41f5b87f0b2d18e7ec2509d5e2dae1459aac034 Author: Konstantinos Poulios AuthorDate: Sun May 23 14:43:21 2021 +0200 MPI fixes for affine and linear terms in nonlinear model residual --- src/getfem_models.cc | 86 ++-- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 40ff2e8..c9eedf8 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -2339,6 +2339,9 @@ namespace getfem { "Invalid assembly version BUILD_WITH_INTERNAL"); #if GETFEM_PARA_LEVEL > 1 double t_ref = MPI_Wtime(); +int rk=0, nbp=1; +MPI_Comm_rank(MPI_COMM_WORLD, ); +MPI_Comm_size(MPI_COMM_WORLD, ); #endif context_check(); if (act_size_to_be_done) actualize_sizes(); @@ -2419,6 +2422,7 @@ namespace getfem { gmm::sub_matrix(cTM, I2, I1)); } if (version & BUILD_RHS) { +//FIXME MPI_SUM_VECTOR(crhs) if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) @@ -2479,6 +2483,7 @@ namespace getfem { gmm::sub_matrix(cTM, I2, I1)); } if (version & BUILD_RHS) { +//FIXME MPI_SUM_VECTOR(crhs) if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) @@ -2539,54 +2544,77 @@ namespace getfem { } if (version & BUILD_RHS) { // Contributions to interval I1 of var1 +auto vec_out1 = gmm::sub_vector(rrhs, I1); if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.rveclist[k][j], brick.coeffs[k]), - gmm::sub_vector(rrhs, I1)); + vec_out1); else gmm::add(gmm::scaled(brick.rveclist[0][j], alpha1), - gmm::sub_vector(rrhs, I1)); + vec_out1); } -if (var1->is_enabled()) { - // Contributions from affine dependent variables - if (term.is_matrix_term && brick.pbr->is_linear() && is_linear() - && var2->is_affine_dependent) -gmm::mult_add(brick.rmatlist[j], - gmm::scaled(var2->affine_real_value, -alpha1), - gmm::sub_vector(rrhs, I1)); - // Contributions from linear terms - if (term.is_matrix_term && brick.pbr->is_linear() - && (!is_linear() || (version & BUILD_WITH_LIN))) -gmm::mult_add(brick.rmatlist[j], - gmm::scaled(var2->real_value[0], -alpha1), - gmm::sub_vector(rrhs, I1)); +if (var1->is_enabled() +&& term.is_matrix_term && brick.pbr->is_linear()) { + bool affine_contrib(is_linear() && var2->is_affine_dependent); + bool linear_contrib(!is_linear() || (version & BUILD_WITH_LIN)); + const auto = brick.rmatlist[j]; + const auto vec_affine2 = gmm::scaled(var2->affine_real_value, + -alpha1); + const auto vec_linear2 = gmm::scaled(var2->real_value[0], + -alpha1); + if (nbp > 1) { +model_real_plain_vector vec_tmp1(I1.size(), 0.); +if (affine_contrib) // Affine dependent variable contribution + gmm::mult(matj, vec_affine2, vec_tmp1); +if (linear_contrib) // Linear term contribution + gmm::mult_add(matj, vec_linear2, vec_tmp1); +MPI_SUM_VECTOR(vec_tmp1); +gmm::add(vec_tmp1, vec_out1); + } else { // nbp == 1 +if (affine_contrib) // Affine dependent variable contribution + gmm::mult_add(matj, vec_affine2, vec_out1); +if (linear_contrib) // Linear term contribution + gmm::mult_add(matj, vec_linear2, vec_out1); + } } // Contributions to interval I2 of var2 due to symmetric terms if (term.is_symmetric && I1.first() != I2.first() && var2->is_enabled()) { + auto vec_out2 = gmm::sub_vector(rrhs, I2); if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.rveclist_sym[k][j], brick.coeffs[k]), - gmm::sub_vector(rrhs, I2)); + vec_out2); else
Re: [Getfem-commits] (no subject)
Dear Yves, Another thing that seems illogical to me is that geotrans_inv_convex::invert() returns convergence information, both as a return value and through a boolean argument "converged", with two possibly different values. Shouldn't we simplify this? The reason that I am looking into this is because I am experiencing some geometric inversion failures which are due to too strict checks with IN_EPS/100. But I don't want to just change the threshold value, I would like to improve the robustness of this quite central function in general. Best regards Kostas On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios wrote: > Dear Yves, > > I assume this change > [image: image.png] > was not intentional, right? I cannot imagine why one would use a factor > equal to 2. > > Best regards > Kostas > > On Fri, Jun 15, 2018 at 5:14 PM Yves Renard > wrote: > >> branch: master >> commit 93ea20ccf0e03d841f600d928764a694a0047ab8 >> Author: Yves Renard >> Date: Fri Jun 15 16:34:52 2018 +0200 >> >> fix a problem in inverting transformation for pyramids >> --- >> src/bgeot_geotrans_inv.cc | 10 +++ >> src/getfem/getfem_generic_assembly_tree.h | 5 >> src/getfem_generic_assembly_compile_and_exec.cc | 35 >> ++--- >> 3 files changed, 29 insertions(+), 21 deletions(-) >> >> diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc >> index f87e9df..f3fb9d0 100644 >> --- a/src/bgeot_geotrans_inv.cc >> +++ b/src/bgeot_geotrans_inv.cc >> @@ -227,6 +227,7 @@ namespace bgeot >> } >> >> if (res < res0) copy(storage.x_ref, x); >> +x *= 0.999888783; // For pyramid element to avoid the singularity >>} >> >> >> @@ -242,12 +243,11 @@ namespace bgeot >> auto res = vect_norm2(nonlinear_storage.diff); >> auto res0 = std::numeric_limits::max(); >> double factor = 1.0; >> -auto cnt = 0; >> >> while (res > IN_EPS) { >>if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { >> -converged = false; >> -return point_in_convex(*pgt, x, res, IN_EPS); >> + converged = false; >> + return point_in_convex(*pgt, x, res, IN_EPS); >>} >> >>if (res > res0) { >> @@ -258,10 +258,9 @@ namespace bgeot >> factor *= 0.5; >>} >>else { >> -if (factor < 1.0) factor *= 2.0; >> +if (factor < 1.0-IN_EPS) factor = 2.0; >> res0 = res; >>} >> - >>pgt->poly_vector_grad(x, pc); >>update_B(); >>mult(transposed(B), nonlinear_storage.diff, >> nonlinear_storage.x_ref); >> @@ -271,7 +270,6 @@ namespace bgeot >>add(nonlinear_storage.x_real, scaled(xreal, -1.0), >>nonlinear_storage.diff); >>res = vect_norm2(nonlinear_storage.diff); >> - ++cnt; >> } >> >> return point_in_convex(*pgt, x, res, IN_EPS); >> diff --git a/src/getfem/getfem_generic_assembly_tree.h >> b/src/getfem/getfem_generic_assembly_tree.h >> index 9ca3bd9..18682c0 100644 >> --- a/src/getfem/getfem_generic_assembly_tree.h >> +++ b/src/getfem/getfem_generic_assembly_tree.h >> @@ -54,11 +54,6 @@ extern "C"{ >> } >> #endif >> >> -// #define GA_USES_BLAS // not so interesting, at least for debian blas >> - >> -// #define GA_DEBUG_INFO(a) { cout << a << endl; } >> -#define GA_DEBUG_INFO(a) >> - >> #define GA_DEBUG_ASSERT(a, b) GMM_ASSERT1(a, b) >> // #define GA_DEBUG_ASSERT(a, b) >> >> diff --git a/src/getfem_generic_assembly_compile_and_exec.cc >> b/src/getfem_generic_assembly_compile_and_exec.cc >> index 3212b25..5a77635 100644 >> --- a/src/getfem_generic_assembly_compile_and_exec.cc >> +++ b/src/getfem_generic_assembly_compile_and_exec.cc >> @@ -25,6 +25,13 @@ >> #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_DEBUG_INFO(a) { cout << a << endl; } >> +#define GA_DEBUG_INFO(a) >> + >> + >> + >> namespace getfem { >> >> >> @@ -766,6 +773,7 @@ namespace getfem { >> virtual int exec() { >>GA_DEBUG_INFO("Instruction: value of test functions"); >>if (qdim == 1) { >> + GA_DEBUG_ASSERT(t.size() == Z.size(), "Wrong size for base >> vector"); >> std::copy(Z.begin(), Z.end(), t.begin()); >>} else { >> size_type target_dim = Z.sizes()[1]; >> @@ -3781,7 +3789,7 @@ namespace getfem { >>if (inin.pt_type) { >> if (cv != size_type(-1)) { >>inin.m->points_of_convex(cv, inin.G); >> - inin.ctx.change((inin.m)->trans_of_convex(cv), >> + inin.ctx.change((inin.m)->trans_of_convex(cv), >>0, P_ref, inin.G, cv, face_num); >>inin.has_ctx = true; >>if (face_num != short_type(-1)) { >> @@ -3826,7 +3834,7 @@ namespace getfem { >> >> virtual int exec() { >>bool cancel_optimization = false; >> -
Re: [Getfem-commits] (no subject)
Dear Yves, I assume this change [image: image.png] was not intentional, right? I cannot imagine why one would use a factor equal to 2. Best regards Kostas On Fri, Jun 15, 2018 at 5:14 PM Yves Renard wrote: > branch: master > commit 93ea20ccf0e03d841f600d928764a694a0047ab8 > Author: Yves Renard > Date: Fri Jun 15 16:34:52 2018 +0200 > > fix a problem in inverting transformation for pyramids > --- > src/bgeot_geotrans_inv.cc | 10 +++ > src/getfem/getfem_generic_assembly_tree.h | 5 > src/getfem_generic_assembly_compile_and_exec.cc | 35 > ++--- > 3 files changed, 29 insertions(+), 21 deletions(-) > > diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc > index f87e9df..f3fb9d0 100644 > --- a/src/bgeot_geotrans_inv.cc > +++ b/src/bgeot_geotrans_inv.cc > @@ -227,6 +227,7 @@ namespace bgeot > } > > if (res < res0) copy(storage.x_ref, x); > +x *= 0.999888783; // For pyramid element to avoid the singularity >} > > > @@ -242,12 +243,11 @@ namespace bgeot > auto res = vect_norm2(nonlinear_storage.diff); > auto res0 = std::numeric_limits::max(); > double factor = 1.0; > -auto cnt = 0; > > while (res > IN_EPS) { >if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { > -converged = false; > -return point_in_convex(*pgt, x, res, IN_EPS); > + converged = false; > + return point_in_convex(*pgt, x, res, IN_EPS); >} > >if (res > res0) { > @@ -258,10 +258,9 @@ namespace bgeot > factor *= 0.5; >} >else { > -if (factor < 1.0) factor *= 2.0; > +if (factor < 1.0-IN_EPS) factor = 2.0; > res0 = res; >} > - >pgt->poly_vector_grad(x, pc); >update_B(); >mult(transposed(B), nonlinear_storage.diff, > nonlinear_storage.x_ref); > @@ -271,7 +270,6 @@ namespace bgeot >add(nonlinear_storage.x_real, scaled(xreal, -1.0), >nonlinear_storage.diff); >res = vect_norm2(nonlinear_storage.diff); > - ++cnt; > } > > return point_in_convex(*pgt, x, res, IN_EPS); > diff --git a/src/getfem/getfem_generic_assembly_tree.h > b/src/getfem/getfem_generic_assembly_tree.h > index 9ca3bd9..18682c0 100644 > --- a/src/getfem/getfem_generic_assembly_tree.h > +++ b/src/getfem/getfem_generic_assembly_tree.h > @@ -54,11 +54,6 @@ extern "C"{ > } > #endif > > -// #define GA_USES_BLAS // not so interesting, at least for debian blas > - > -// #define GA_DEBUG_INFO(a) { cout << a << endl; } > -#define GA_DEBUG_INFO(a) > - > #define GA_DEBUG_ASSERT(a, b) GMM_ASSERT1(a, b) > // #define GA_DEBUG_ASSERT(a, b) > > diff --git a/src/getfem_generic_assembly_compile_and_exec.cc > b/src/getfem_generic_assembly_compile_and_exec.cc > index 3212b25..5a77635 100644 > --- a/src/getfem_generic_assembly_compile_and_exec.cc > +++ b/src/getfem_generic_assembly_compile_and_exec.cc > @@ -25,6 +25,13 @@ > #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_DEBUG_INFO(a) { cout << a << endl; } > +#define GA_DEBUG_INFO(a) > + > + > + > namespace getfem { > > > @@ -766,6 +773,7 @@ namespace getfem { > virtual int exec() { >GA_DEBUG_INFO("Instruction: value of test functions"); >if (qdim == 1) { > + GA_DEBUG_ASSERT(t.size() == Z.size(), "Wrong size for base > vector"); > std::copy(Z.begin(), Z.end(), t.begin()); >} else { > size_type target_dim = Z.sizes()[1]; > @@ -3781,7 +3789,7 @@ namespace getfem { >if (inin.pt_type) { > if (cv != size_type(-1)) { >inin.m->points_of_convex(cv, inin.G); > - inin.ctx.change((inin.m)->trans_of_convex(cv), > + inin.ctx.change((inin.m)->trans_of_convex(cv), >0, P_ref, inin.G, cv, face_num); >inin.has_ctx = true; >if (face_num != short_type(-1)) { > @@ -3826,7 +3834,7 @@ namespace getfem { > > virtual int exec() { >bool cancel_optimization = false; > - GA_DEBUG_INFO("Instruction: call interpolate transformation"); > + GA_DEBUG_INFO("Instruction: call interpolate neighbour > transformation"); >if (ipt == 0) { > if (!(ctx.have_pgp()) || !pai || pai->is_built_on_the_fly() > || cancel_optimization) { > @@ -3873,7 +3881,7 @@ namespace getfem { >gic.init(m.points_of_convex(adj_face.cv), gpc.pgt2); >size_type first_ind = pai->ind_first_point_on_face(f); >const bgeot::stored_point_tab > - = *(pai->pintegration_points()); > += *(pai->pintegration_points()); >base_matrix G; >m.points_of_convex(cv, G); >fem_interpolation_context ctx_x(gpc.pgt1, 0, spt[0], G, cv, > f); >
[Getfem-commits] [getfem-commits] branch master updated: Minor changes
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 7b9740ef Minor changes 7b9740ef is described below commit 7b9740efee89a87ac219048291ad634e7c0b3f74 Author: Konstantinos Poulios AuthorDate: Tue Apr 5 22:08:53 2022 +0200 Minor changes --- src/bgeot_geotrans_inv.cc | 26 +- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index 2de17449..04b0e007 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -27,15 +27,6 @@ namespace bgeot { - - bool point_in_convex(const geometric_trans , - const base_node , - scalar_type res, - scalar_type IN_EPS) { -// Test un peu sev�re peut-�tre en ce qui concerne res. -return (geoTrans.convex_ref()->is_in(x) < IN_EPS) && (res < IN_EPS); - } - void project_into_convex(base_node , const pgeometric_trans pgt) { for (auto : x) { @@ -96,7 +87,8 @@ namespace bgeot y = pgt->transform(n_ref, G); add(gmm::scaled(n, -1.0), y); -return point_in_convex(*pgt, n_ref, gmm::vect_norm2(y), IN_EPS); +return (pgt->convex_ref()->is_in(n_ref) < IN_EPS) && + (gmm::vect_norm2(y) < IN_EPS); } void geotrans_inv_convex::update_B() { @@ -192,7 +184,7 @@ namespace bgeot bool project_into_element) { converged = true; base_node x0_ref(P), diff(N); - + { // find initial guess x0_ref = pgt->geometric_nodes()[0]; scalar_type res = gmm::vect_dist2(mat_col(G, 0), xreal); @@ -221,15 +213,15 @@ namespace bgeot } add(pgt->transform(x, G), gmm::scaled(xreal, -1.0), diff); -auto res = gmm::vect_norm2(diff); -auto res0 = std::numeric_limits::max(); -double factor = 1.0; +scalar_type res = gmm::vect_norm2(diff); +scalar_type res0 = std::numeric_limits::max(); +scalar_type factor = 1.0; base_node x0_real(N); while (res > IN_EPS/100.) { if ((gmm::abs(res - res0) < IN_EPS/100.) || (factor < IN_EPS)) { converged = false; -return point_in_convex(*pgt, x, res, IN_EPS); +return (pgt->convex_ref()->is_in(x) < IN_EPS) && (res < IN_EPS); } if (res > res0) { add(gmm::scaled(x0_ref, factor), x); @@ -244,13 +236,13 @@ namespace bgeot pgt->poly_vector_grad(x, pc); update_B(); mult(transposed(B), diff, x0_ref); - add(gmm::scaled(x0_ref, -1.0 * factor), x); + add(gmm::scaled(x0_ref, -factor), x); if (project_into_element) project_into_convex(x, pgt); x0_real = pgt->transform(x, G); add(x0_real, gmm::scaled(xreal, -1.0), diff); res = gmm::vect_norm2(diff); } -return point_in_convex(*pgt, x, res, IN_EPS); +return (pgt->convex_ref()->is_in(x) < IN_EPS) && (res < IN_EPS); } } /* end of namespace bgeot. */
[Getfem-commits] [getfem-commits] branch master updated: More informative error messages
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 0e4a5740 More informative error messages 0e4a5740 is described below commit 0e4a5740dff2994cb28899508cb0481b6e611a68 Author: Konstantinos Poulios AuthorDate: Tue Apr 5 21:36:25 2022 +0200 More informative error messages --- src/getfem/getfem_generic_assembly.h | 6 +++--- src/getfem_generic_assembly_workspace.cc | 6 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/getfem/getfem_generic_assembly.h b/src/getfem/getfem_generic_assembly.h index f9d3951c..43d269de 100644 --- a/src/getfem/getfem_generic_assembly.h +++ b/src/getfem/getfem_generic_assembly.h @@ -591,9 +591,9 @@ namespace getfem { enum class inherit { NONE, ENABLED, ALL }; explicit ga_workspace(const getfem::model _, - const inherit var_inherit=inherit::ENABLED); -explicit ga_workspace(const ga_workspace ,// compulsory 2nd arg to avoid - const inherit var_inherit); // conflict with copy constructor + const inherit var_inherit=inherit::ENABLED); +explicit ga_workspace(const ga_workspace ,// compulsory 2nd arg to avoid + const inherit var_inherit); // conflict with copy constructor ga_workspace(); ~ga_workspace(); diff --git a/src/getfem_generic_assembly_workspace.cc b/src/getfem_generic_assembly_workspace.cc index 38f36efc..f9c8d233 100644 --- a/src/getfem_generic_assembly_workspace.cc +++ b/src/getfem_generic_assembly_workspace.cc @@ -837,7 +837,8 @@ namespace getfem { if (order == 1 || (order == 2 && condensation)) { if (order == 2 && condensation) { -GMM_ASSERT1(V->size() == nb_tot_dof, "Wrong size"); +GMM_ASSERT1(V->size() == nb_tot_dof, +"Wrong size of assembled vector in workspace"); gmm::resize(cached_V, nb_tot_dof); gmm::copy(*V, cached_V); // current residual is used in condensation gmm::fill(*V, scalar_type(0)); @@ -845,7 +846,8 @@ namespace getfem { gmm::clear(*V); gmm::resize(*V, nb_tot_dof); } else -GMM_ASSERT1(V->size() == nb_tot_dof, "Wrong size"); +GMM_ASSERT1(V->size() == nb_tot_dof, +"Wrong size of assembled vector in workspace"); gmm::clear(unreduced_V); gmm::resize(unreduced_V, nb_tmp_dof); }
[Getfem-commits] [getfem-commits] branch master updated: Fixing mistake introduced in SHA: 93ea20ccf0e03d841f600d928764a694a0047ab8
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 31df9dba Fixing mistake introduced in SHA: 93ea20ccf0e03d841f600d928764a694a0047ab8 31df9dba is described below commit 31df9dbab2eff9127142a291de51029fd59b983d Author: Konstantinos Poulios AuthorDate: Tue Apr 5 21:58:07 2022 +0200 Fixing mistake introduced in SHA: 93ea20ccf0e03d841f600d928764a694a0047ab8 --- src/bgeot_geotrans_inv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index 3f0ff7e8..2de17449 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -238,7 +238,7 @@ namespace bgeot factor *= 0.5; } else { -if (factor < 1.0-IN_EPS) factor = 2.0; +if (factor < 1.0-IN_EPS) factor *= 2.0; res0 = res; } pgt->poly_vector_grad(x, pc);
Re: [Getfem-commits] (no subject)
Dear Yves, Thanks for the feedback. Still the check if the point lies in the convex is combined with a convergence check in the returned value. And this convergence check is less strict than the convergence result returned in the "converged" flag. So we have two different convergence criteria which is a bit confusing. Anyway, at some point, you had reduced the convergence threshold from IN_EPS to IN_EPS/1000 and then you increased it to the current value of IN_EPS/100. Do you remember the motivation for reducing the threshold? The problem is that the current threshold value works well for elements that are 1x1x1 or smaller and they are placed relatively close to the origin of the coordinates. If one needs to work with large elements e.g. 100x100x100, or small elements 1x1x1, which are far away from the origin, let's say at a distance of 1000 from (0,0,0), then the requested precision can never be achieved because of floating point arithmetics. Ideally, the geometric inversion should be done with the real element moved to the origin and normalized, but this would require quite some changes in this function. Another quick fix would be to multiply the convergence threshold with gmm::mat_maxnorm(G). I will think a bit about it. Best regards Kostas On Mon, Apr 4, 2022 at 3:18 PM Renard Yves wrote: > > Dear Kostas, > > > You are right of course. This change has been done after experiencing some > difficulties of convergence for the pyramid element. I think the test > (factor < 1.0-IN-EPS) does not change a lot of things but may be it is > slightly more robust in some situations, but the change "factor *= 2.0" in > "factor = 2.0" is simply a nonsense. > > Concerning the returned value and the convergence flag it has a different > meaning : the inversion is sometimes used for extrapolation outside the > element. The returned value indicates only if the point is inside the > element (with possibly a successful convergence) and the flag returns > whether or not the convergence was successful. > > This portion of code can probably be improved, yes ! > > > Best regards, > > > Yves > > > > Le 03/04/2022 à 11:05, Konstantinos Poulios a écrit : > > Dear Yves, > > Another thing that seems illogical to me is that > geotrans_inv_convex::invert() returns convergence information, both as a > return value and through a boolean argument "converged", with two possibly > different values. Shouldn't we simplify this? > > The reason that I am looking into this is because I am experiencing some > geometric inversion failures which are due to too strict checks with > IN_EPS/100. But I don't want to just change the threshold value, I would > like to improve the robustness of this quite central function in general. > > Best regards > Kostas > > On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios < > logar...@googlemail.com> wrote: > >> Dear Yves, >> >> I assume this change >> [image: image.png] >> was not intentional, right? I cannot imagine why one would use a factor >> equal to 2. >> >> Best regards >> Kostas >> >> On Fri, Jun 15, 2018 at 5:14 PM Yves Renard >> wrote: >> >>> branch: master >>> commit 93ea20ccf0e03d841f600d928764a694a0047ab8 >>> Author: Yves Renard >>> Date: Fri Jun 15 16:34:52 2018 +0200 >>> >>> fix a problem in inverting transformation for pyramids >>> --- >>> src/bgeot_geotrans_inv.cc | 10 +++ >>> src/getfem/getfem_generic_assembly_tree.h | 5 >>> src/getfem_generic_assembly_compile_and_exec.cc | 35 >>> ++--- >>> 3 files changed, 29 insertions(+), 21 deletions(-) >>> >>> diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc >>> index f87e9df..f3fb9d0 100644 >>> --- a/src/bgeot_geotrans_inv.cc >>> +++ b/src/bgeot_geotrans_inv.cc >>> @@ -227,6 +227,7 @@ namespace bgeot >>> } >>> >>> if (res < res0) copy(storage.x_ref, x); >>> +x *= 0.999888783; // For pyramid element to avoid the singularity >>>} >>> >>> >>> @@ -242,12 +243,11 @@ namespace bgeot >>> auto res = vect_norm2(nonlinear_storage.diff); >>> auto res0 = std::numeric_limits::max(); >>> double factor = 1.0; >>> -auto cnt = 0; >>> >>> while (res > IN_EPS) { >>>if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { >>> -converged = false; >>> -return point_in_convex(*pgt, x, res, IN_EPS); >>> + converged = false; >>> + return point_in_convex(*pgt, x, res, IN_EPS); >>>} >>> >>>if (res > res0) { >>> @@ -258,10 +258,9 @@ namespace bgeot >>> factor *= 0.5; >>>} >>>else { >>> -if (factor < 1.0) factor *= 2.0; >>> +if (factor < 1.0-IN_EPS) factor = 2.0; >>> res0 = res; >>>} >>> - >>>pgt->poly_vector_grad(x, pc); >>>update_B(); >>>mult(transposed(B), nonlinear_storage.diff, >>> nonlinear_storage.x_ref); >>> @@ -271,7 +270,6 @@ namespace bgeot >>>add(nonlinear_storage.x_real, scaled(xreal, -1.0), >>>
[Getfem-commits] [getfem-commits] branch master updated: Coding style and documentation improvements
This is an automated email from the git hooks/post-receive script. logari81 pushed a commit to branch master in repository getfem. The following commit(s) were added to refs/heads/master by this push: new e895f1ff Coding style and documentation improvements e895f1ff is described below commit e895f1ffa9ab92c4ff305f9469b5687c7f386ac6 Author: Konstantinos Poulios AuthorDate: Sun Sep 17 00:55:39 2023 +0200 Coding style and documentation improvements --- interface/src/gf_spmat.cc | 4 +- src/getfem/getfem_continuation.h| 76 + src/getfem/getfem_models.h | 41 - src/getfem/getfem_omp.h | 2 +- src/getfem_generic_assembly_compile_and_exec.cc | 5 +- src/getfem_generic_assembly_semantic.cc | 11 +++- src/getfem_plasticity.cc| 2 +- src/gmm/gmm_sub_vector.h| 27 - 8 files changed, 107 insertions(+), 61 deletions(-) diff --git a/interface/src/gf_spmat.cc b/interface/src/gf_spmat.cc index f0e8f601..be62254a 100644 --- a/interface/src/gf_spmat.cc +++ b/interface/src/gf_spmat.cc @@ -189,8 +189,8 @@ void gf_spmat(getfemint::mexargs_in& m_in, gsp->allocate(m, n, gsparse::WSCMAT, gsparse::REAL); ); -/*@INIT SM = ('copy', @mat K [, @PYTHON{@list} I [, @PYTHON{@list} J]]) - Duplicate a matrix `K` (which might be a @tsp@MATLAB{ or a native matlab +/*@INIT SM = ('copy', @mat K [, @PYTHON{@list} I [, @PYTHON{@list} J=I]]) + Duplicate a matrix `K` (which might be an @tsp@MATLAB{ or a native matlab sparse matrix}). If index `I` and/or `J` are given, the matrix will be a submatrix of `K`. For example:: diff --git a/src/getfem/getfem_continuation.h b/src/getfem/getfem_continuation.h index 6b4da63f..5d69add2 100644 --- a/src/getfem/getfem_continuation.h +++ b/src/getfem/getfem_continuation.h @@ -232,7 +232,8 @@ namespace getfem { double test_function_bp(const MAT , const VECT , const VECT , double tgamma) { - VECT v_x(g); double v_gamma; + VECT v_x(g); + double v_gamma; return test_function_bp(A, g, tx, tgamma, v_x, v_gamma); } @@ -249,7 +250,8 @@ namespace getfem { double test_function_bp(const VECT , double gamma, const VECT , double tgamma) { - VECT v_x(x); double v_gamma; + VECT v_x(x); + double v_gamma; return test_function_bp(x, gamma, tx, tgamma, v_x, v_gamma); } @@ -801,39 +803,39 @@ namespace getfem { public: // Misc. for accessing private data -int noisy(void) const { return noisy_; } -double h_init(void) const { return h_init_; } -double h_min(void) const { return h_min_; } -double h_max(void) const { return h_max_; } -double h_dec(void) const { return h_dec_; } -double h_inc(void) const { return h_inc_; } -size_type maxit(void) const { return maxit_; } -size_type thrit(void) const { return thrit_; } -double maxres(void) const { return maxres_; } -double maxdiff(void) const { return maxdiff_; } -double mincos(void) const { return mincos_; } -double delta_max(void) const { return delta_max_; } -double delta_min(void) const { return delta_min_; } -double thrvar(void) const { return thrvar_; } -size_type nbdir(void) const { return nbdir_; } -size_type nbspan(void) const { return nbspan_; } +int noisy() const { return noisy_; } +double h_init() const { return h_init_; } +double h_min() const { return h_min_; } +double h_max() const { return h_max_; } +double h_dec() const { return h_dec_; } +double h_inc() const { return h_inc_; } +size_type maxit() const { return maxit_; } +size_type thrit() const { return thrit_; } +double maxres() const { return maxres_; } +double maxdiff() const { return maxdiff_; } +double mincos() const { return mincos_; } +double delta_max() const { return delta_max_; } +double delta_min() const { return delta_min_; } +double thrvar() const { return thrvar_; } +size_type nbdir() const { return nbdir_; } +size_type nbspan() const { return nbspan_; } void set_tau_lp(double tau) { tau_lp = tau; } -double get_tau_lp(void) const { return tau_lp; } +double get_tau_lp() const { return tau_lp; } void set_tau_bp_1(double tau) { tau_bp_1 = tau; } -double get_tau_bp_1(void) const { return tau_bp_1; } +double get_tau_bp_1() const { return tau_bp_1; } void set_tau_bp_2(double tau) { tau_bp_2 = tau; } -double get_tau_bp_2(void) const { return tau_bp_2; } -void clear_tau_bp_currentstep(void) { +double get_tau_bp_2() const { return tau_bp_2; } +void clear_tau_bp_currentstep() { tau_bp_graph.clear(); } -void init_tau_bp_graph(void) { tau_bp_graph[0.] = tau_bp_2; } +void init_tau_bp_graph() { tau_bp_graph[0.] = tau_bp_2; } void
[Getfem-commits] [getfem-commits] branch master updated: Remove erroneous J^-2/3 factor from finite strain plasticity examples
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 1910cb6e Remove erroneous J^-2/3 factor from finite strain plasticity examples 1910cb6e is described below commit 1910cb6ee6f72ffe2f819bdb054097aa6f830898 Author: Konstantinos Poulios AuthorDate: Sat Sep 16 22:18:46 2023 +0200 Remove erroneous J^-2/3 factor from finite strain plasticity examples + coding style improvements --- ...ticity_fin_strain_lin_hardening_axisymmetric.py | 32 +-- ...ticity_fin_strain_lin_hardening_plane_strain.py | 64 -- ...ty_finite_strain_linear_hardening_tension_3D.py | 34 ++-- 3 files changed, 55 insertions(+), 75 deletions(-) diff --git a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py index 7969b238..f24d1db5 100644 --- a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py +++ b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py @@ -2,7 +2,7 @@ # -*- coding: UTF8 -*- # Python GetFEM interface # -# Copyright (C) 2020-2020 Konstantinos Poulios. +# Copyright (C) 2020-2023 Konstantinos Poulios. # # This file is a part of GetFEM # @@ -68,7 +68,7 @@ resultspath = "./results" if not os.path.exists(resultspath): os.makedirs(resultspath) -tee = subprocess.Popen(["tee", "%s/tension_axisymmetric.log" % resultspath], +tee = subprocess.Popen(["tee", f"{resultspath}/tension_axisymmetric.log"], stdin=subprocess.PIPE) sys.stdout.flush() os.dup2(tee.stdin.fileno(), sys.stdout.fileno()) @@ -86,8 +86,7 @@ ymin = 0. dx = L/2 dy = H/2 mesh = gf.Mesh("import", "structured", - "GT='%s';ORG=[%f,%f];SIZES=[%f,%f];NSUBDIV=[%i,%i]" - % (geotrans, xmin, ymin, dx, dy, N_L, N_H)) + f"GT='{geotrans}';ORG=[{xmin},{ymin}];SIZES=[{dx},{dy}];NSUBDIV=[{N_L},{N_H}]") N = mesh.dim() outer_faces = mesh.outer_faces() @@ -119,7 +118,7 @@ if dH > 0: pts[1,i] -= (y*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L)) mesh.set_pts(pts) -mesh.export_to_vtu("%s/mesh.vtu" % resultspath) +mesh.export_to_vtu(f"{resultspath}/mesh.vtu") # FEM mfN = gf.MeshFem(mesh, N) @@ -171,12 +170,12 @@ md.add_macro("invCp0", "[[[1,0,0],[0,0,0],[0,0,0]],"+\ md.add_macro("devlogbetr", "Deviator(Logm(F3d*invCp0*F3d'))") md.add_macro("Y0","{A}+{B}*gamma0".format(A=np.sqrt(2./3.)*pl_sigma_0, B=2./3.*pl_H)) md.add_macro("ksi", - "(1-1/max(1,mu*pow(J,-5/3)*Norm(devlogbetr)/Y0))/(2+{B}/(mu*pow(J,-5/3)))" + "(1-1/max(1,mu/J*Norm(devlogbetr)/Y0))/(2+{B}/(mu/J))" .format(B=2./3.*pl_H)) md.add_macro("gamma", "gamma0+ksi*Norm(devlogbetr)") md.add_macro("devlogbe", "(1-2*ksi)*devlogbetr") -md.add_macro("tauD2d", "mu*pow(J,-2/3)*[1,0,0;0,1,0]*devlogbe*[1,0;0,1;0,0]") -md.add_macro("tauD33", "mu*pow(J,-2/3)*devlogbe(3,3)") +md.add_macro("tauD2d", "mu*[1,0,0;0,1,0]*devlogbe*[1,0;0,1;0,0]") +md.add_macro("tauD33", "mu*devlogbe(3,3)") md.add_nonlinear_generic_assembly_brick\ (mim, "2*pi*X(2)*(((tauH*Id(2)+tauD2d)*Inv(F')):Grad_Test_u+(tauH+tauD33)/(X(2)+u(2))*Test_u(2))") @@ -190,22 +189,21 @@ md.add_macro("invCp", "(Inv(F3d)*Expm(-ksi*devlogbetr)*(F3d))*invCp0"\ md.add_filtered_fem_variable("dirmult", mfmult, XP_RG) md.add_nonlinear_generic_assembly_brick(mim, "2*pi*X(2)*(disp-u(1))*dirmult", XP_RG) -print("Model dofs: %i" % md.nbdof()) -print("Displacement fem dofs: %i" % mfu.nbdof()) +print(f"Model dofs: {md.nbdof()}\nDisplacement fem dofs: {mfu.nbdof()}") print("Dirichlet mult dofs: %i" % md.mesh_fem_of_variable("dirmult").nbdof()) shutil.copyfile(os.path.abspath(sys.argv[0]),resultspath+"/"+sys.argv[0]) starttime_overall = time.process_time() -with open("%s/tension_axisymmetric.dat" % resultspath, "w") as f1: +with open(f"{resultspath}/tension_axisymmetric.dat", "w") as f1: for step in range(steps_t+1): md.set_variable("disp", disp*step/float(steps_t)) print('STEP %i: Solving with disp = %g' % (step, md.variable("disp"))) starttime = time.process_time() - md.solve('noisy', 'max_iter', 25, 'max_res', 1e-10, - 'lsearch', 'simplest', 'alpha max ratio', 100, 'alpha min', 0.2, 'alpha mult', 0.6, - 'alpha threshold res', 1e9) - print('STEP %i COMPLETED IN %f SEC' % (step, time.process_time()-starttime)) + md.solve("noisy", "max_iter", 25, "max_res", 1e-10, + "lsearch", "simplest", "alpha max ratio", 100, "alpha min", 0.2, "alpha mult", 0.6, + "alpha threshold res", 1e9) + print("STEP %i COMPLETED IN %f SEC" % (step, time.process_time()-starttime)) F = gf.asm_generic(mim, 0, "2*pi*X(2)*dirmult", XP_RG, md) print("Displacement %g, total force %g" %
[Getfem-commits] [getfem-commits] branch master updated: Split parent assignment out of ga_tree::copy_node
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 37870199 Split parent assignment out of ga_tree::copy_node 37870199 is described below commit 378701998a665bc3491362c1702c7c2ea80c91d6 Author: Konstantinos Poulios AuthorDate: Sun Sep 17 09:34:24 2023 +0200 Split parent assignment out of ga_tree::copy_node --- src/getfem/getfem_generic_assembly_tree.h | 12 ++- src/getfem_generic_assembly_semantic.cc | 162 -- src/getfem_generic_assembly_tree.cc | 39 --- src/getfem_generic_assembly_workspace.cc | 3 +- 4 files changed, 122 insertions(+), 94 deletions(-) diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index b3d2405b..711cddf2 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -401,6 +401,11 @@ namespace getfem { inline void adopt_child(pga_tree_node new_child) { children.push_back(new_child); children.back()->parent = this; } +inline void accept_child(size_type i) { + GMM_ASSERT1(i < children.size(), "Internal error"); + children[i]->parent = this; +} + inline void replace_child(pga_tree_node oldchild, pga_tree_node newchild) { bool found = false; @@ -453,8 +458,7 @@ namespace getfem { void clear() { clear_node_rec(root); root = current_node = nullptr; } void clear_children(pga_tree_node pnode); void replace_node_by_child(pga_tree_node pnode, size_type i); -void copy_node(pga_tree_node pnode, pga_tree_node parent, - pga_tree_node ); +void copy_node(pga_tree_node pnode, pga_tree_node _new); void duplicate_with_operation(pga_tree_node pnode, GA_TOKEN_TYPE op_type); void duplicate_with_addition(pga_tree_node pnode) { duplicate_with_operation(pnode, GA_PLUS); } @@ -475,14 +479,14 @@ namespace getfem { secondary_domain(tree.secondary_domain) { if (tree.root) -copy_node(tree.root, nullptr, root); +copy_node(tree.root, root); } ga_tree =(const ga_tree ) { clear(); secondary_domain = tree.secondary_domain; if (tree.root) -copy_node(tree.root, nullptr, root); +copy_node(tree.root, root); return *this; } diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 302f7688..134eec8c 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -199,7 +199,7 @@ namespace getfem { bool need_hess = (pnode->node_type == GA_NODE_HESS_TEST); if (need_grad && grad_expr.root == nullptr) { -tree.copy_node(pexpr, nullptr, grad_expr.root); +tree.copy_node(pexpr, grad_expr.root); if (ga_node_mark_tree_for_grad(grad_expr.root, workspace)) { ga_node_grad(grad_expr, workspace, me, grad_expr.root); ga_node_analysis(grad_expr, workspace, grad_expr.root, me, @@ -215,7 +215,7 @@ namespace getfem { } if (need_hess && hess_expr.root == nullptr) { -tree.copy_node(grad_expr.root, nullptr, hess_expr.root); +tree.copy_node(grad_expr.root, hess_expr.root); if (ga_node_mark_tree_for_grad(hess_expr.root, workspace)) { ga_node_grad(hess_expr, workspace, me, hess_expr.root); ga_node_analysis(hess_expr, workspace, hess_expr.root, me, @@ -237,18 +237,20 @@ namespace getfem { { pga_tree_node pnode_new = nullptr; if (pnode->node_type == GA_NODE_VAL_TEST) -tree.copy_node(pexpr, parent, pnode_new); // allocates new +tree.copy_node(pexpr, pnode_new); // allocates new else if (pnode->node_type == GA_NODE_GRAD_TEST || pnode->node_type == GA_NODE_DIVERG_TEST) -tree.copy_node(grad_expr.root, parent, pnode_new); // allocates new +tree.copy_node(grad_expr.root, pnode_new); // allocates new else if (pnode->node_type == GA_NODE_HESS_TEST) -tree.copy_node(hess_expr.root, parent, pnode_new); // allocates new +tree.copy_node(hess_expr.root, pnode_new); // allocates new + pnode_new->parent = parent; parent->replace_child(pnode, pnode_new); if (pnode->node_type == GA_NODE_DIVERG_TEST) { tree.insert_node(pnode_new, GA_NODE_OP); pnode_new->parent->op_type = GA_TRACE; } - delete pnode; pnode = nullptr;// deallocates old + delete pnode; // deallocates old + pnode = nullptr; } break; case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST: @@ -598,15 +600,15 @@
[Getfem-commits] [getfem-commits] branch master updated: Use short names of functions for adding linear and nonlinear terms
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 2c046b66 Use short names of functions for adding linear and nonlinear terms 2c046b66 is described below commit 2c046b668bbeff4eddd8a259d8fe712be0b05fa8 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 13:37:51 2023 +0200 Use short names of functions for adding linear and nonlinear terms --- contrib/continuum_mechanics/QLV_viscoelasticity.py | 4 +-- ...ticity_fin_strain_lin_hardening_axisymmetric.py | 4 +-- ...ticity_fin_strain_lin_hardening_plane_strain.py | 4 +-- ...ty_finite_strain_linear_hardening_tension_3D.py | 4 +-- .../static_contact_planetary.py| 10 +++--- doc/sphinx/source/tutorial/basic_usage.rst | 4 +-- interface/tests/matlab-octave/demo_wheel_contact.m | 6 ++-- interface/tests/python/check_mixed_mesh.py | 2 +- src/getfem_contact_and_friction_integral.cc| 4 +-- src/getfem_linearized_plates.cc| 36 +++--- src/getfem_models.cc | 2 +- src/getfem_nonlinear_elasticity.cc | 4 +-- src/getfem_plasticity.cc | 6 ++-- tests/test_condensation.cc | 20 ++-- tests/test_internal_variables.cc | 12 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/contrib/continuum_mechanics/QLV_viscoelasticity.py b/contrib/continuum_mechanics/QLV_viscoelasticity.py index 6c22f0de..b6cd9480 100644 --- a/contrib/continuum_mechanics/QLV_viscoelasticity.py +++ b/contrib/continuum_mechanics/QLV_viscoelasticity.py @@ -155,7 +155,7 @@ md.add_macro("SvD", "exp(-dt/tauD)*SvDprev" #"-(1-rD)*(1-tauD/dt*(1-exp(-dt/tauD)))*(SeD-SeDprev)") # Virtual work expression -md.add_nonlinear_generic_assembly_brick(mim, "(F*(SeH+SvH+SeD+SvD)):Grad_Test_u") +md.add_nonlinear_term(mim, "(F*(SeH+SvH+SeD+SvD)):Grad_Test_u") # Cauchy and von Mises definitions md.add_macro("Cauchy", "(F*(SeH+SvH+SeD+SvD)*F')/Det(F)") @@ -163,7 +163,7 @@ md.add_macro("VM", "sqrt(1.5)*Norm(Deviator(F*(SeH+SvH+SeD+SvD)*F'))/Det(F)") # Dirichlet condition md.add_filtered_fem_variable("dirmult", mfmult, RG_TOP) -md.add_linear_generic_assembly_brick(mim, "(epsYY*X(2)-u(2))*dirmult", RG_TOP) +md.add_linear_term(mim, "(epsYY*X(2)-u(2))*dirmult", RG_TOP) Vol = gf.asm_generic(mim, 0, "1", -1, md) with open("QLV_viscoelasticity_results.dat", "w") as f: diff --git a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py index f24d1db5..2e08eb19 100644 --- a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py +++ b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_axisymmetric.py @@ -177,7 +177,7 @@ md.add_macro("devlogbe", "(1-2*ksi)*devlogbetr") md.add_macro("tauD2d", "mu*[1,0,0;0,1,0]*devlogbe*[1,0;0,1;0,0]") md.add_macro("tauD33", "mu*devlogbe(3,3)") -md.add_nonlinear_generic_assembly_brick\ +md.add_nonlinear_term\ (mim, "2*pi*X(2)*(((tauH*Id(2)+tauD2d)*Inv(F')):Grad_Test_u+(tauH+tauD33)/(X(2)+u(2))*Test_u(2))") md.add_macro("sigmaD", "(mu*pow(J,-5/3)*devlogbe)") @@ -187,7 +187,7 @@ md.add_macro("invCp", "(Inv(F3d)*Expm(-ksi*devlogbetr)*(F3d))*invCp0"\ # Dirichlet condition md.add_filtered_fem_variable("dirmult", mfmult, XP_RG) -md.add_nonlinear_generic_assembly_brick(mim, "2*pi*X(2)*(disp-u(1))*dirmult", XP_RG) +md.add_nonlinear_term(mim, "2*pi*X(2)*(disp-u(1))*dirmult", XP_RG) print(f"Model dofs: {md.nbdof()}\nDisplacement fem dofs: {mfu.nbdof()}") print("Dirichlet mult dofs: %i" % md.mesh_fem_of_variable("dirmult").nbdof()) diff --git a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_plane_strain.py b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_plane_strain.py index 20bc6c79..30ab2bc4 100644 --- a/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_plane_strain.py +++ b/contrib/continuum_mechanics/plasticity_fin_strain_lin_hardening_plane_strain.py @@ -175,7 +175,7 @@ md.add_macro("gamma", "gamma0+ksi*Norm(devlogbetr)") md.add_macro("devlogbe", "(1-2*ksi)*devlogbetr") md.add_macro("tauD2d", "mu*[1,0,0;0,1,0]*devlogbe*[1,0;0,1;0,0]") -md.add_nonlinear_generic_assembly_brick\ +md.add_nonlinear_term\ (mim, "((tauH*Id(2)+tauD2d)*Inv(F')):Grad_Test_u") md.add_macro("sigmaD", "(mu/J*devlogbe)") @@ -185,7 +185,7 @@ md.add_macro("invCp", "(Inv(F3d)*Expm(-ksi*devlogbetr)*(F3d))*invCp0"\ # Dirichlet condition md.add_filtered_fem_variable("dirmult", mfmult, XP_RG) -md.add_nonlinear_generic_assembly_brick(mim, "(disp-u(1))*dirmult", XP_RG) +md.add_nonlinear_term(mim, "(disp-u(1))*dirmult", XP_RG) print(f"Model dofs: {md.nbdof()}\nDisplacement
[Getfem-commits] (no subject)
branch: master commit f8fda6e8ce084f6414854ce7b633dc5561a46509 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:04:42 2023 +0200 Fix segfault when internal variables are used inside an explicit matrix expression --- src/getfem_generic_assembly_semantic.cc | 35 ++--- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 134eec8c..3504a724 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -1609,23 +1609,34 @@ namespace getfem { } } int to_add = int(pnode->nb_test_functions() + pnode->nbc1) - - int(pnode->tensor().sizes().size()); -GMM_ASSERT1(to_add >= 0 && to_add <=2, "Internal error"); + - int(pnode->tensor().sizes().size()); +GMM_ASSERT1(to_add >= 0 && to_add <= 2, "Internal error"); if (to_add) { mi = pnode->tensor().sizes(); mi.resize(pnode->nbc1+pnode->nb_test_functions()); for (int i = int(mi.size()-1); i >= to_add; --i) mi[i] = mi[i-to_add]; - for (int i = 0; i < to_add; ++i) mi[i] = 2; - if (pnode->test_function_type & 1 && - !(workspace.associated_mf(pnode->name_test1)) - && !(workspace.associated_im_data(pnode->name_test1))) -mi[0] = gmm::vect_size(workspace.value(pnode->name_test1)); - if (pnode->test_function_type & 2 && - !(workspace.associated_mf(pnode->name_test2)) - && !(workspace.associated_im_data(pnode->name_test2))) -mi[(pnode->test_function_type & 1) ? 1 : 0] - = gmm::vect_size(workspace.value(pnode->name_test2)); + for (int i = 0; i < to_add; ++i) +mi[i] = 2; + + if (pnode->test_function_type & 1) { +const mesh_fem *mf1 = workspace.associated_mf(pnode->name_test1); +const im_data *imd1 = workspace.associated_im_data(pnode->name_test1); +if (mf1 == 0 && imd1 == 0) // global variable + mi[0] = gmm::vect_size(workspace.value(pnode->name_test1)); +else if (imd1) // im_data variable + mi[0] = workspace.qdim(pnode->name_test1); // == 1 because of all_sc = true + } + if (pnode->test_function_type & 2) { +const mesh_fem *mf2 = workspace.associated_mf(pnode->name_test2); +const im_data *imd2 = workspace.associated_im_data(pnode->name_test2); +if (mf2 == 0 && imd2 == 0) // global variable + mi[(pnode->test_function_type & 1) ? 1 : 0] += gmm::vect_size(workspace.value(pnode->name_test2)); // == 1 because of all_sc = true +else if (imd2) // im_data variable + mi[(pnode->test_function_type & 1) ? 1 : 0] += workspace.qdim(pnode->name_test2); + } pnode->tensor().adjust_sizes(mi); }
[Getfem-commits] [getfem-commits] master updated (2c046b66 -> f8fda6e8)
logari81 pushed a change to branch master. from 2c046b66 Use short names of functions for adding linear and nonlinear terms new 1b1001e4 Add unit test for filtered internal variables new c8922031 Add unit test for internal variables that leads to segfault new f8fda6e8 Fix segfault when internal variables are used inside an explicit matrix expression Summary of changes: src/getfem_generic_assembly_semantic.cc | 35 ++--- tests/test_internal_variables.cc| 22 + 2 files changed, 45 insertions(+), 12 deletions(-)
[Getfem-commits] (no subject)
branch: master commit c89220316f6f84fa991e8f9b01bb568132e0e862 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:03:02 2023 +0200 Add unit test for internal variables that leads to segfault --- tests/test_internal_variables.cc | 9 + 1 file changed, 9 insertions(+) diff --git a/tests/test_internal_variables.cc b/tests/test_internal_variables.cc index 228e0427..e5c22f7d 100644 --- a/tests/test_internal_variables.cc +++ b/tests/test_internal_variables.cc @@ -124,6 +124,15 @@ int main(int argc, char *argv[]) { getfem::add_nonlinear_term(md3, mim, "(p-exp(p+2)+10)*Test_p", 201); iter.init(); getfem::standard_solve(md3, iter); + + if (!DIFFICULTY) { +getfem::model md4; +md4.add_im_variable("f33", mimd); +gmm::fill(md4.set_real_variable("f33"), 1); +getfem::add_nonlinear_term(md4, mim, "Det([1,0,0;0,1,0;0,0,f33])*Test_f33"); +md4.assembly(getfem::model::BUILD_MATRIX); + } + GETFEM_MPI_FINALIZE; return gmm::vect_dist2(md1.real_variable("u"), md2.real_variable("u")) < 1e-9 ? 0 : 1;
[Getfem-commits] (no subject)
branch: master commit 1b1001e476d207a24bed8f6f2f94438853fcada1 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:02:13 2023 +0200 Add unit test for filtered internal variables --- tests/test_internal_variables.cc | 13 + 1 file changed, 13 insertions(+) diff --git a/tests/test_internal_variables.cc b/tests/test_internal_variables.cc index 6fe57be0..228e0427 100644 --- a/tests/test_internal_variables.cc +++ b/tests/test_internal_variables.cc @@ -53,6 +53,8 @@ int main(int argc, char *argv[]) { m.region(100) = getfem::select_faces_of_normal(m, outer_faces, base_node(-1, 0), 0.001); m.region(101) = getfem::select_faces_of_normal(m, outer_faces, base_node(1, 0), 0.001); m.region(102) = getfem::mesh_region::merge(m.region(100), m.region(101)); + m.region(201) = getfem::select_convexes_in_box(m, base_node(-1e-3, -1e-3), +base_node(1+1e-3, 0.5+1e-3)); dim_type N(2); getfem::mesh_fem mf(m, N), mf_intern(m); @@ -66,6 +68,10 @@ int main(int argc, char *argv[]) { getfem::im_data mimd(mim); if (DIFFICULTY) mimd.set_tensor_size(bgeot::multi_index(3,4)); + getfem::im_data mimd_filtered(mim); + mimd_filtered.set_region(201); + + getfem::model md1, md2; md1.add_fem_variable("u", mf); md2.add_fem_variable("u", mf); @@ -111,6 +117,13 @@ int main(int argc, char *argv[]) { std::cout << "Total dofs of model 1: " << md1.nb_dof() << std::endl; std::cout << "Total dofs of model 2: " << md2.nb_dof() << std::endl; + + getfem::model md3; + md3.add_im_variable("p", mimd_filtered); + + getfem::add_nonlinear_term(md3, mim, "(p-exp(p+2)+10)*Test_p", 201); + iter.init(); + getfem::standard_solve(md3, iter); GETFEM_MPI_FINALIZE; return gmm::vect_dist2(md1.real_variable("u"), md2.real_variable("u")) < 1e-9 ? 0 : 1;
[Getfem-commits] (no subject)
branch: master commit 88a69becf3d33fa2b55d083a76e88a5033bbaab4 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:37:11 2023 +0200 Whitespace changes --- src/getfem_mesh_im_level_set.cc | 694 1 file changed, 347 insertions(+), 347 deletions(-) diff --git a/src/getfem_mesh_im_level_set.cc b/src/getfem_mesh_im_level_set.cc index 00edc831..11eae1b6 100644 --- a/src/getfem_mesh_im_level_set.cc +++ b/src/getfem_mesh_im_level_set.cc @@ -39,12 +39,12 @@ namespace getfem { mesh_im::clear(); clear_build_methods(); is_adapted = false; - } + } - void mesh_im_level_set::init_with_mls(mesh_level_set , - int integrate_where_, - pintegration_method reg, - pintegration_method sing) { + void mesh_im_level_set::init_with_mls(mesh_level_set , +int integrate_where_, +pintegration_method reg, +pintegration_method sing) { init_with_mesh(me.linked_mesh()); cut_im.init_with_mesh(me.linked_mesh()); mls = @@ -55,9 +55,9 @@ namespace getfem { } mesh_im_level_set::mesh_im_level_set(mesh_level_set , - int integrate_where_, - pintegration_method reg, - pintegration_method sing) { + int integrate_where_, + pintegration_method reg, + pintegration_method sing) { mls = 0; init_with_mls(me, integrate_where_, reg, sing); } @@ -66,14 +66,14 @@ namespace getfem { { mls = 0; is_adapted = false; } - pintegration_method + pintegration_method mesh_im_level_set::int_method_of_element(size_type cv) const { if (!is_adapted) const_cast(this)->adapt(); -if (cut_im.convex_index().is_in(cv)) - return cut_im.int_method_of_element(cv); +if (cut_im.convex_index().is_in(cv)) + return cut_im.int_method_of_element(cv); else { if (ignored_im.is_in(cv)) //integrate_where == INTEGRATE_BOUNDARY) - return getfem::im_none(); +return getfem::im_none(); return mesh_im::int_method_of_element(cv); } @@ -91,16 +91,16 @@ namespace getfem { for (unsigned i = 0; i < mls->nb_level_sets(); ++i) { isin = isin && ((*(mesherls0[i]))(P) < 0); if (gmm::abs((*(mesherls0[i]))(P)) < 1e-7) - isbin = i+1; +isbin = i+1; if (mls->get_level_set(i)->has_secondary()) - isin = isin && ((*(mesherls1[i]))(P) < 0); +isin = isin && ((*(mesherls1[i]))(P) < 0); } -bool2 b; +bool2 b; b.in = ((integrate_where & INTEGRATE_OUTSIDE)) ? !isin : isin; b.bin = isbin; return b; } - + /* very rustic set operations evaluator */ struct is_in_eval { @@ -110,77 +110,77 @@ namespace getfem { bool2 do_expr(const char *) { bool2 r; if (*s == '(') { - r = do_expr(++s); - GMM_ASSERT1(*s++ == ')', - "expecting ')' in csg expression at '" << s-1 << "'"); +r = do_expr(++s); +GMM_ASSERT1(*s++ == ')', +"expecting ')' in csg expression at '" << s-1 << "'"); } else if (*s == '!') { // complementary - r = do_expr(++s); r.in = !r.in; +r = do_expr(++s); r.in = !r.in; } else if (*s >= 'a' && *s <= 'z') { - unsigned idx = (*s) - 'a'; - r.in = in.is_in(idx); - r.bin = bin.is_in(idx) ? idx+1 : 0; - ++s; - } else - GMM_ASSERT1(false, "parse error in csg expression at '" << s << "'"); +unsigned idx = (*s) - 'a'; +r.in = in.is_in(idx); +r.bin = bin.is_in(idx) ? idx+1 : 0; +++s; + } else +GMM_ASSERT1(false, "parse error in csg expression at '" << s << "'"); if (*s == '+') { // Union - //cerr << "s = " << s << ", r = " << r << "\n"; - bool2 a = r, b = do_expr(++s); - //cerr << "->b = " << b << "\n"; - r.in = b.in || a.in; - if (b.bin && !a.in) r.bin = b.bin; - else if (a.bin && !b.in) r.bin = a.bin; - else r.bin = 0; +//cerr << "s = " << s << ", r = " << r << "\n"; +bool2 a = r, b = do_expr(++s); +//cerr << "->b = " << b << "\n"; +r.in = b.in || a.in; +if (b.bin && !a.in) r.bin = b.bin; +else if (a.bin && !b.in) r.bin = a.bin; +else r.bin = 0; } else if (*s == '-') { // Set difference - bool2 a = r, b = do_expr(++s); - r.in = a.in && !b.in; - if (a.bin && !b.in) r.bin = a.bin; - else if (a.in && b.bin) r.bin = b.bin; - else r.bin = 0; +bool2 a = r, b = do_expr(++s); +r.in = a.in && !b.in; +if (a.bin && !b.in) r.bin =
[Getfem-commits] (no subject)
branch: master commit 0d05415881685c1cf8cf6ad4ff308b22d582ac9f Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:19:48 2023 +0200 Minor changes in python demo --- interface/tests/python/demo_nonlinear_elasticity.py | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/tests/python/demo_nonlinear_elasticity.py b/interface/tests/python/demo_nonlinear_elasticity.py index 4a8074a6..66425da3 100644 --- a/interface/tests/python/demo_nonlinear_elasticity.py +++ b/interface/tests/python/demo_nonlinear_elasticity.py @@ -85,17 +85,17 @@ if (not(explicit_potential)): md.add_finite_strain_elasticity_brick(mim, lawname, 'u', 'params') else: print("Explicit elastic potential") -K = 1.2; mu = 3.0; -md.add_macro('F_', '(Id(meshdim)+Grad_u)') -md.add_macro('J_', 'Det(F_)') -md.add_macro('be_', 'Left_Cauchy_Green(F_)') -md.add_initialized_data('K', [K]) -md.add_initialized_data('mu', [mu]) +K = 1.2 +mu = 3.0 +md.add_macro('F', 'Id(meshdim)+Grad_u') +md.add_macro('J', 'Det(F)') +md.add_macro('be', 'Left_Cauchy_Green(F)') +md.add_initialized_data('K', K) +md.add_initialized_data('mu', mu) md.add_initialized_data('paramsIMR', [1,1,2]) -_expr_1 = "(K/2)*sqr(log(J_))+(mu/2)*(Matrix_j1(be_)-3)"; -_expr_2 = "(K/2)*sqr(log(J_))+(mu/2)*(pow(Det(be_),-1./3.)*Trace(be_)-3)" -_expr_3 = "paramsIMR(1)*(Matrix_j1(Right_Cauchy_Green(F_))-3)+ paramsIMR(2)*(Matrix_j2(Right_Cauchy_Green(F_)) - 3)+paramsIMR(3)*sqr(J_-1)" -md.add_nonlinear_term(mim, _expr_3); +#md.add_nonlinear_term(mim, "(K/2)*sqr(log(J))+(mu/2)*(Matrix_j1(be)-3)") +#md.add_nonlinear_term(mim, "(K/2)*sqr(log(J))+(mu/2)*(pow(Det(be),-1./3.)*Trace(be)-3)") +md.add_nonlinear_term(mim, "paramsIMR(1)*(Matrix_j1(Right_Cauchy_Green(F))-3)+ paramsIMR(2)*(Matrix_j2(Right_Cauchy_Green(F)) - 3)+paramsIMR(3)*sqr(J-1)"); # md.add_nonlinear_term(mim, 'sqr(Trace(Green_Lagrangian(Id(meshdim)+Grad_u)))/8 + Norm_sqr(Green_Lagrangian(Id(meshdim)+Grad_u))/4') # md.add_nonlinear_term(mim, '((Id(meshdim)+Grad_u)*(params(1)*Trace(Green_Lagrangian(Id(meshdim)+Grad_u))*Id(meshdim)+2*params(2)*Green_Lagrangian(Id(meshdim)+Grad_u))):Grad_Test_u')
[Getfem-commits] (no subject)
branch: master commit 888391bb931bf1bcf56027664a02159356b78954 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:16:02 2023 +0200 Code readability --- src/getfem_generic_assembly_compile_and_exec.cc | 3 +- src/getfem_generic_assembly_semantic.cc | 3 +- src/getfem_generic_assembly_tree.cc | 38 - 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index e09d46ff..71793f6a 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -5366,7 +5366,8 @@ namespace getfem { // Produce a resize instruction which is stored if no equivalent node is // detected and if the mesh is not uniform. -pnode->t.set_to_original(); pnode->t.set_sparsity(0, 0); +pnode->t.set_to_original(); +pnode->t.set_sparsity(0, 0); bool is_uniform = false; if (pnode->test_function_type == 1) { if (mf1 || mfg1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 3504a724..714c4d19 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -2257,7 +2257,8 @@ namespace getfem { else if (pnode->children.size() == 5) { ind[0] = 2; ind[1] = 4; } else if (pnode->children.size() == 7) { - ind.resize(4); indsize.resize(4); + ind.resize(4); + indsize.resize(4); ind[0] = 2; ind[1] = 3; ind[2] = 5; ind[3] = 6; } diff --git a/src/getfem_generic_assembly_tree.cc b/src/getfem_generic_assembly_tree.cc index 9ba538ea..3dee62a8 100644 --- a/src/getfem_generic_assembly_tree.cc +++ b/src/getfem_generic_assembly_tree.cc @@ -542,12 +542,12 @@ namespace getfem { return false; break; case GA_NODE_C_MATRIX: - if (pnode1->children.size() != pnode2->children.size()) return false; - if (pnode1->nb_test_functions() != pnode2->nb_test_functions()) + if (pnode1->children.size() != pnode2->children.size() || + pnode1->nb_test_functions() != pnode2->nb_test_functions() || + pnode1->t.sizes().size() != pnode2->t.sizes().size()) return false; - if (pnode1->t.sizes().size() != pnode2->t.sizes().size()) return false; for (size_type i=pnode1->nb_test_functions(); - it.sizes().size(); ++i) + i < pnode1->t.sizes().size(); ++i) if (pnode1->t.sizes()[i] != pnode2->t.sizes()[i]) return false; if (pnode1->nbc1 != pnode2->nbc1) return false; break; @@ -1951,7 +1951,8 @@ namespace getfem { mi.pop_back(); sub_tree.root->tensor().adjust_sizes(mi); } -if (!nb_comp) mii = sub_tree.root->tensor().sizes(); +if (!nb_comp) + mii = sub_tree.root->tensor().sizes(); else { const bgeot::multi_index =sub_tree.root->tensor().sizes(); bool cmp = true; @@ -2034,23 +2035,32 @@ namespace getfem { } while (r_type != GA_RBRACKET); bgeot::multi_index mi; - nbc1 = tree.current_node->nbc1; nbc2 = tree.current_node->nbc2; + nbc1 = tree.current_node->nbc1; + nbc2 = tree.current_node->nbc2; nbc3 = tree.current_node->nbc3; size_type nbl = tree.current_node->children.size() / (nbc2 * nbc1 * nbc3); switch(tensor_order) { case 1: -/* mi.push_back(1); */ mi.push_back(nbc1); break; +// mi.push_back(1); +mi.push_back(nbc1); +break; case 2: -mi.push_back(nbl); if (nbc1 > 1) mi.push_back(nbc1); break; +mi.push_back(nbl); +if (nbc1 > 1) + mi.push_back(nbc1); +break; case 3: -mi.push_back(nbl); mi.push_back(nbc2); +mi.push_back(nbl); +mi.push_back(nbc2); mi.push_back(nbc1); break; case 4: -mi.push_back(nbl); mi.push_back(nbc3); -mi.push_back(nbc2); mi.push_back(nbc1); +mi.push_back(nbl); +mi.push_back(nbc3); +mi.push_back(nbc2); +mi.push_back(nbc1); break; default: GMM_ASSERT1(false, "Internal error"); } @@ -2080,10 +2090,12 @@ namespace getfem { case GA_COLON: case GA_DOT: case GA_DOTMULT: case GA_DOTDIV: case GA_TMULT: tree.add_op(t_type, token_pos, expr); - state = 1; break; + state = 1; + break; case GA_QUOTE: tree.add_op(t_type, token_pos, expr); - state = 2; break; +
[Getfem-commits] [getfem-commits] master updated (f8fda6e8 -> f818f6b6)
logari81 pushed a change to branch master. from f8fda6e8 Fix segfault when internal variables are used inside an explicit matrix expression new 888391bb Code readability new 0d054158 Minor changes in python demo new 88a69bec Whitespace changes new f818f6b6 Fix compilation warnings Summary of changes: .../tests/python/demo_nonlinear_elasticity.py | 20 +- src/getfem_generic_assembly_compile_and_exec.cc| 3 +- src/getfem_generic_assembly_semantic.cc| 3 +- src/getfem_generic_assembly_tree.cc| 38 +- src/getfem_mesh_fem.cc | 3 +- src/getfem_mesh_im_level_set.cc| 694 ++--- 6 files changed, 387 insertions(+), 374 deletions(-)
[Getfem-commits] (no subject)
branch: master commit f818f6b6fe4bb6128a37fabe3d2436f706880a37 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 15:05:25 2023 +0200 Fix compilation warnings --- src/getfem_mesh_fem.cc | 3 +-- src/getfem_mesh_im_level_set.cc | 26 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/getfem_mesh_fem.cc b/src/getfem_mesh_fem.cc index d26ad8ce..62df084d 100644 --- a/src/getfem_mesh_fem.cc +++ b/src/getfem_mesh_fem.cc @@ -360,8 +360,7 @@ namespace getfem { if (fe_convex.is_in(cv)) { gmm::copy(linked_mesh().points_of_convex(cv)[0], bmin); gmm::copy(bmin, bmax); -for (size_type i = 0; i < linked_mesh().nb_points_of_convex(cv); ++i) { - const base_node = linked_mesh().points_of_convex(cv)[i]; +for (const base_node : linked_mesh().points_of_convex(cv)) { for (size_type d = 1; d < bmin.size(); ++d) { bmin[d] = std::min(bmin[d], pt[d]); bmax[d] = std::max(bmax[d], pt[d]); diff --git a/src/getfem_mesh_im_level_set.cc b/src/getfem_mesh_im_level_set.cc index 11eae1b6..3772d936 100644 --- a/src/getfem_mesh_im_level_set.cc +++ b/src/getfem_mesh_im_level_set.cc @@ -337,11 +337,9 @@ namespace getfem { if (integrate_where == INTEGRATE_BOUNDARY) { bool lisin = true; - for (unsigned ipt = 0; ipt < - pgt2->structure()->nb_points_of_face(f); ++ipt) { -const base_node = msh.points_of_face_of_convex(i, f)[ipt]; -isin = is_point_in_selected_area(mesherls0, mesherls1, P).bin; -//cerr << P << ":" << isin << " "; + for (const base_node : msh.points_of_face_of_convex(i, f)) { +isin = is_point_in_selected_area(mesherls0, mesherls1, pt).bin; +//cerr << pt << ":" << isin << " "; if (!isin) { lisin = false; break; } } if (!lisin) continue; @@ -591,10 +589,12 @@ namespace getfem { bgeot::geotrans_interpolation_context cc(linked_mesh().trans_of_convex(cv), base_node(n), G2); + mesh::ref_mesh_pt_ct cvpts = msh.points_of_convex(i); + dal::bit_vector ptinter; for (short_type k = 0; k < n; ++k) { size_type ipt = msh.structure_of_convex(i)->ind_dir_points()[k]; -const base_node = msh.points_of_convex(i)[ipt]; +const base_node = cvpts[ipt]; if (is_point_in_intersection(mesherls0, mesherls1, P)) ptinter.add(ipt); } @@ -605,7 +605,7 @@ namespace getfem { size_type ipt = msh.structure_of_convex(i)->ind_dir_points()[k]; if (ptinter.is_in(ipt)) { -const base_node = msh.points_of_convex(i)[ipt]; +const base_node = cvpts[ipt]; cc.set_xref(P); if (global_intersection.search_point(cc.xreal()) @@ -626,8 +626,8 @@ namespace getfem { size_type ipt2=msh.structure_of_convex(i)->ind_dir_points()[k2]; if (ptinter.is_in(ipt1) && ptinter.is_in(ipt2)) { -const base_node = msh.points_of_convex(i)[ipt1]; -const base_node = msh.points_of_convex(i)[ipt2]; +const base_node = cvpts[ipt1]; +const base_node = cvpts[ipt2]; cc.set_xref(P1); base_node PR1 = cc.xreal(); cc.set_xref(P2); @@ -651,10 +651,10 @@ namespace getfem { for (bgeot::rtree::pbox_set::const_iterator it=boxlst.begin(); it != boxlst.end(); ++it) { -const base_node - = global_intersection.points_of_convex((*it)->id)[0]; -const base_node - = global_intersection.points_of_convex((*it)->id)[1]; +mesh::ref_mesh_pt_ct intersect_cvpts + = global_intersection.points_of_convex((*it)->id); +const base_node = intersect_cvpts[0]; +const base_node = intersect_cvpts[1]; if (is_edges_intersect(PP1, PP2, PR1, PR2)) { found_intersect = true; break; } }
[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warnings
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 warning, allocate memory for strings passed from Python
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
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,
[Getfem-commits] [getfem-commits] branch master updated: Fix inconsistent argument in C extension python type initialization
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 0b85c037 Fix inconsistent argument in C extension python type initialization 0b85c037 is described below commit 0b85c0370e454931519b17ec4d30e922e37b46cd Author: Konstantinos Poulios AuthorDate: Tue Oct 17 11:34:17 2023 +0200 Fix inconsistent argument in C extension python type initialization --- interface/src/python/getfem_python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/python/getfem_python.c b/interface/src/python/getfem_python.c index beeb0cc8..2c67ae29 100644 --- a/interface/src/python/getfem_python.c +++ b/interface/src/python/getfem_python.c @@ -139,7 +139,7 @@ static PyTypeObject PyGetfemObject_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ #if PY_MAJOR_VERSION >= 3 -GetfemObject_compare, /* tp_compare, necessary for dictionary*/ +0, /* tp_as_async */ #else (cmpfunc)GetfemObject_compare, /* tp_compare, necessary for dictionary*/ #endif
[Getfem-commits] [getfem-commits] branch master updated: Default to Python 3 function naming in the C extension implementation
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 f8076b95 Default to Python 3 function naming in the C extension implementation f8076b95 is described below commit f8076b953cbe6e1b4abe22b753427b7b2d6a51e6 Author: Konstantinos Poulios AuthorDate: Tue Oct 17 11:50:37 2023 +0200 Default to Python 3 function naming in the C extension implementation --- interface/src/python/getfem_python.c | 71 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/interface/src/python/getfem_python.c b/interface/src/python/getfem_python.c index 2c67ae29..634eea1b 100644 --- a/interface/src/python/getfem_python.c +++ b/interface/src/python/getfem_python.c @@ -34,15 +34,13 @@ #include "getfem_arch_config.h" #include -#if PY_MAJOR_VERSION >= 3 -#define PyString_AsString(o) PyUnicode_AsUTF8(o) -#define PyString_FromFormat(a,b,c) PyUnicode_FromFormat(a,b,c) -#define PyString_Check(o) PyUnicode_Check(o) -#define PyInt_Check(o) PyLong_Check(o) -#define PyInt_AsLong(o) PyLong_AsLong(o) -#define PyString_FromString(o) PyUnicode_FromString(o) -#define PyString_FromStringAndSize(o,l) PyUnicode_FromStringAndSize(o,l) -#define PyInt_FromLong(o) PyLong_FromLong(o) +#if PY_MAJOR_VERSION < 3 +#define PyUnicode_AsUTF8(o) PyString_AsString(o) +#define PyUnicode_FromFormat(a,b,c) PyString_FromFormat(a,b,c) +#define PyUnicode_Check(o) PyString_Check(o) +#define PyUnicode_FromString(o) PyString_FromString(o) +#define PyUnicode_FromStringAndSize(o,l) PyString_FromStringAndSize(o,l) +#define PyLong_FromLong(o) PyInt_FromLong(o) #endif static PyObject *call_getfem(PyObject *self, PyObject *args); @@ -63,8 +61,8 @@ typedef struct PyGetfemObject { static PyObject * GetfemObject_name(PyGetfemObject *self) { - return PyString_FromFormat("getfem.GetfemObject(classid=%d,objid=%d)", - self->classid, self->objid); + return PyUnicode_FromFormat("getfem.GetfemObject(classid=%d,objid=%d)", + self->classid, self->objid); } static int @@ -338,21 +336,29 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o) #define TGFISTORE1(T,field) data_##T##_##field #define TGFISTORE(T,field) TGFISTORE0(T).TGFISTORE1(T,field) PyErr_Clear(); - if (PyString_Check(o)) { + if (PyUnicode_Check(o)) { //printf("String\n"); /* for strings, the pointer is shared, no copy */ -int L = (int)(strlen(PyString_AsString(o))); -char *s = PyString_AsString(o); +int L = (int)(strlen(PyUnicode_AsUTF8(o))); +char *s = PyUnicode_AsUTF8(o); gc_ref(gc, o, 0); 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 PY_MAJOR_VERSION < 3 } else if (PyInt_Check(o) || PyLong_Check(o)) { +#else + } else if (PyLong_Check(o)) { +#endif //printf("Int or Long\n"); /* usual python integer */ +#if PY_MAJOR_VERSION < 3 int d = (int)PyInt_AsLong(o); +#else +int d = (int)PyLong_AsLong(o); +#endif if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_OverflowError)) return (gfi_array *)PyErr_Format(PyExc_OverflowError, "in getfem interface."); @@ -464,7 +470,7 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o) default: { PyObject *sdtype =PyObject_Str((PyObject*)PyArray_DescrFromType(dtype)); PyErr_Format(PyExc_RuntimeError, "invalid numeric dtype: %s", - PyString_AsString(sdtype)); + PyUnicode_AsUTF8(sdtype)); Py_DECREF(sdtype); return NULL; } @@ -511,7 +517,7 @@ PyObject_to_gfi_array(gcollect *gc, PyObject *o) PyObject *sdtype = PyObject_Str((PyObject*)PyArray_DescrFromType(dtype)); PyErr_Format(PyExc_RuntimeError, "unhandled argument (type, dtype): (%s, %s)", - PyString_AsString(stype), PyString_AsString(sdtype)); + PyUnicode_AsUTF8(stype), PyUnicode_AsUTF8(sdtype)); Py_DECREF(stype); Py_DECREF(sdtype); return NULL; @@ -547,11 +553,11 @@ build_gfi_array_list(gcollect *gc, PyObject *tuple, char **pfunction_name, if (PyTuple_GET_SIZE(tuple) == 0) { PyErr_SetString(PyExc_RuntimeError, "missing function name"); return NULL; } - if (!PyString_Check(PyTuple_GET_ITEM(tuple,0))) { + if (!PyUnicode_Check(PyTuple_GET_ITEM(tuple,0))) { PyErr_SetString(PyExc_RuntimeError, "expecting function name as a string"); return NULL; } - *pfunction_name = PyString_AsString(PyTuple_GET_ITEM(tuple,0)); + *pfunction_name = PyUnicode_AsUTF8(PyTuple_GET_ITEM(tuple,0)); *nb = (int)(PyTuple_GET_SIZE(tuple) - 1); if (!(l = gc_alloc(gc, sizeof(gfi_array*) * *nb))) return NULL; for (i=0, j = 0; i < *nb; ++i) { @@ -573,7 +579,8 @@ gfi_array_to_PyObject(gfi_array
[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warnings and coding style
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: Whitespace and coding style changes
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 33ac2baf Whitespace and coding style changes 33ac2baf is described below commit 33ac2baf7dad2322668309dcdef116671b94f370 Author: Konstantinos Poulios AuthorDate: Tue Oct 17 11:29:25 2023 +0200 Whitespace and coding style changes --- interface/src/gfi_array.c | 78 ++- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/interface/src/gfi_array.c b/interface/src/gfi_array.c index 43269e48..f6ee6a48 100644 --- a/interface/src/gfi_array.c +++ b/interface/src/gfi_array.c @@ -41,22 +41,31 @@ void* gfi_calloc(size_t n, size_t m) { void gfi_free(void *p) { /*printf("gfi_free (%p)\n", p);*/ - if (p) free(p); + if (p) free(p); } #define FREE(p) { /*printf("%s@%d ", __FILE__, __LINE__); fflush(stdout); */gfi_free(p); p = NULL; } gfi_array* -gfi_array_create(int ndim, int *dims, +gfi_array_create(int ndim, int *dims, gfi_type_id type, gfi_complex_flag is_complex) { - int i,sz; - gfi_array *t = gfi_calloc(1, sizeof(gfi_array)); if (t == NULL) return NULL; + gfi_array *t = gfi_calloc(1, sizeof(gfi_array)); + if (!t) +return NULL; t->dim.dim_len = ndim; - t->dim.dim_val = gfi_calloc(ndim, sizeof(int)); if ( t->dim.dim_val == NULL) { gfi_free(t); return NULL; } + t->dim.dim_val = gfi_calloc(ndim, sizeof(int)); + if (t->dim.dim_val == NULL) { +gfi_free(t); +return NULL; + } /*printf("gfi_array_create(ndim = %d, type = %d, @%p %p\n", ndim, type, t, t->dim.dim_val);*/ - for (i=0,sz=1; i < ndim; ++i) { t->dim.dim_val[i] = dims[i]; sz *= dims[i]; } + int sz=1; + for (int i=0; i < ndim; ++i) { +t->dim.dim_val[i] = dims[i]; +sz *= dims[i]; + } t->storage.type = type; switch (t->storage.type) { case GFI_CHAR: { @@ -87,13 +96,13 @@ gfi_array_create(int ndim, int *dims, } break; case GFI_OBJID: { t->storage.gfi_storage_u.objid.objid_len = sz; -t->storage.gfi_storage_u.objid.objid_val = gfi_calloc(sz, sizeof(gfi_object_id)); +t->storage.gfi_storage_u.objid.objid_val = gfi_calloc(sz, sizeof(gfi_object_id)); if (t->storage.gfi_storage_u.objid.objid_val == NULL) goto not_enough_mem; } break; default: { -printf("internal error"); return NULL; +printf("internal error"); return NULL; } break; - } + } return t; not_enough_mem: gfi_array_destroy(t); gfi_free(t); return NULL; @@ -118,9 +127,9 @@ gfi_array_create_2(int M, int N, gfi_type_id type, gfi_complex_flag is_complex) gfi_array* gfi_array_from_string(const char *s) { - gfi_array*t; + gfi_array *t; int n = (int)strlen(s); - t = gfi_array_create_1(n,GFI_CHAR, GFI_REAL); + t = gfi_array_create_1(n, GFI_CHAR, GFI_REAL); if (t) memcpy(gfi_char_get_data(t), s, n); return t; } @@ -128,14 +137,14 @@ gfi_array_from_string(const char *s) { gfi_array* gfi_create_sparse(int m, int n, int nzmax, gfi_complex_flag is_complex) { gfi_array *t = gfi_calloc(1, sizeof(gfi_array)); - t->dim.dim_len = 2; - t->dim.dim_val = gfi_calloc(2, sizeof(int)); + t->dim.dim_len = 2; + t->dim.dim_val = gfi_calloc(2, sizeof(int)); t->dim.dim_val[0] = m; t->dim.dim_val[1] = n; t->storage.type = GFI_SPARSE; t->storage.gfi_storage_u.sp.is_complex = is_complex; t->storage.gfi_storage_u.sp.ir.ir_len = nzmax; t->storage.gfi_storage_u.sp.ir.ir_val = gfi_calloc(nzmax,sizeof(int)); t->storage.gfi_storage_u.sp.jc.jc_len = n+1; t->storage.gfi_storage_u.sp.jc.jc_val = gfi_calloc(n+1,sizeof(int)); - t->storage.gfi_storage_u.sp.pr.pr_len = nzmax * (is_complex ? 2 : 1); + t->storage.gfi_storage_u.sp.pr.pr_len = nzmax * (is_complex ? 2 : 1); t->storage.gfi_storage_u.sp.pr.pr_val = gfi_calloc(nzmax,sizeof(double) * (is_complex ? 2 : 1)); if ((nzmax && (t->storage.gfi_storage_u.sp.ir.ir_val == NULL || t->storage.gfi_storage_u.sp.pr.pr_val == NULL)) || @@ -145,14 +154,13 @@ gfi_create_sparse(int m, int n, int nzmax, gfi_complex_flag is_complex) { /* gfi_array* gfi_create_objid(int nid, unsigned *ids, unsigned cid) { - int i; gfi_array *t = gfi_calloc(1, sizeof(gfi_array)); - t->dim.dim_len = nid; + t->dim.dim_len = nid; t->dim.dim_val = gfi_calloc(1, sizeof(int)); t->dim.dim_val[0]=1; t->storage.type = GFI_OBJID; t->storage.gfi_storage_u.objid.objid_len = nid; t->storage.gfi_storage_u.objid.objid_val = gfi_calloc(nid, sizeof(gfi_object_id)); - for (i=0; i < nid; ++i) { + for (int i=0; i < nid; ++i) { t->storage.gfi_storage_u.objid.objid_val[i].id = ids[i]; t->storage.gfi_storage_u.objid.objid_val[i].cid = cid; } @@ -161,7 +169,7 @@ gfi_create_objid(int nid, unsigned *ids, unsigned cid) { */ /* - destruction */ -void +void gfi_array_destroy(gfi_array *t) { if (t == NULL)
[Getfem-commits] [getfem-commits] branch master updated: Enable scripting interface to get and set internal model variables
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: Fix compilation warnings
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: Replace some switches with lookup tables to reduce code duplication
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: Allow to define Lagrange multipliers for contact on integration points
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 remove-local-superlu created (now bb74a09a)
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] remove-local-superlu updated (bb74a09a -> 64e3a4c2)
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
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 master updated: Remove redundant header includes
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] branch master updated: Clean up
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] (no subject)
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 improve-expm-performance created (now ee139e69)
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] [getfem-commits] branch master updated: Remove redundant state flag member from var_description classes
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 35b4bf52 Remove redundant state flag member from var_description classes 35b4bf52 is described below commit 35b4bf52c75a3c977d5575793bb180d25b37a1ac Author: Konstantinos Poulios AuthorDate: Mon Oct 16 09:01:55 2023 +0200 Remove redundant state flag member from var_description classes --- src/getfem/getfem_generic_assembly.h | 3 +-- src/getfem/getfem_models.h | 6 ++--- src/getfem_generic_assembly_workspace.cc | 6 ++--- src/getfem_models.cc | 43 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/getfem/getfem_generic_assembly.h b/src/getfem/getfem_generic_assembly.h index 43d269de..1eb582eb 100644 --- a/src/getfem/getfem_generic_assembly.h +++ b/src/getfem/getfem_generic_assembly.h @@ -272,7 +272,6 @@ namespace getfem { struct var_description { const bool is_variable; - const bool is_fem_dofs; const mesh_fem *mf; const im_data *imd; gmm::sub_interval I; @@ -291,7 +290,7 @@ namespace getfem { var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_, gmm::sub_interval I_, const model_real_plain_vector *V_, size_type Q, bool is_intern_=false) -: is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_), +: is_variable(is_var), mf(mf_), imd(imd_), I(I_), V(V_), qdims(1), is_internal(is_intern_) { GMM_ASSERT1(Q > 0, "Bad dimension"); diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h index 1c06b424..9bee4ce9 100644 --- a/src/getfem/getfem_models.h +++ b/src/getfem/getfem_models.h @@ -158,7 +158,6 @@ namespace getfem { // to another variable. bool is_internal; // An internal variable defined on integration // points, condensed out of the global system. - bool is_fem_dofs; // The variable is the dofs of a fem size_type n_iter; // Number of versions of the variable stored. size_type n_temp_iter;// Number of additional temporary versions size_type default_iter; // default iteration number. @@ -206,7 +205,6 @@ namespace getfem { mesh_im const *filter_mim_ = 0) : is_variable(is_var), is_disabled(false), is_complex(is_compl), is_affine_dependent(false), is_internal(false), - is_fem_dofs(mf_ != 0), n_iter(std::max(size_type(1), n_it)), n_temp_iter(0), default_iter(0), ptsc(0), filter(filter_), filter_region(filter_reg), filter_var(filter_var_), @@ -230,12 +228,12 @@ namespace getfem { void clear_temporaries(); const mesh_fem _mf() const { -GMM_ASSERT1(is_fem_dofs, "This variable is not linked to a fem"); +GMM_ASSERT1(mf, "This variable is not linked to a fem"); return (filter == VDESCRFILTER_NO) ? *mf : *partial_mf; } const mesh_fem *passociated_mf() const { -if (is_fem_dofs) +if (mf) return (filter == VDESCRFILTER_NO || partial_mf.get() == 0) ? mf : partial_mf.get(); return 0; diff --git a/src/getfem_generic_assembly_workspace.cc b/src/getfem_generic_assembly_workspace.cc index fd3d6c75..9f652a9e 100644 --- a/src/getfem_generic_assembly_workspace.cc +++ b/src/getfem_generic_assembly_workspace.cc @@ -241,7 +241,7 @@ namespace getfem { ga_workspace::associated_mf(const std::string ) const { VAR_SET::const_iterator it = variables.find(name); if (it != variables.end()) - return it->second.is_fem_dofs ? it->second.mf : 0; + return it->second.mf; if (md && md->variable_exists(name)) return md->pmesh_fem_of_variable(name); if (parent_workspace && parent_workspace->variable_exists(name)) @@ -266,7 +266,7 @@ namespace getfem { size_type ga_workspace::qdim(const std::string ) const { VAR_SET::const_iterator it = variables.find(name); if (it != variables.end()) { - const mesh_fem *mf = it->second.is_fem_dofs ? it->second.mf : 0; + const mesh_fem *mf = it->second.mf; const im_data *imd = it->second.imd; size_type n = it->second.qdim(); if (mf) { @@ -289,7 +289,7 @@ namespace getfem { ga_workspace::qdims(const std::string ) const { VAR_SET::const_iterator it = variables.find(name); if (it != variables.end()) { - const mesh_fem *mf = it->second.is_fem_dofs ? it->second.mf : 0; + const mesh_fem *mf = it->second.mf; const im_data *imd = it->second.imd; size_type n = it->second.qdim(); if (mf) { diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 3ae1927d..c56b02e7 100644 --- a/src/getfem_models.cc
[Getfem-commits] [getfem-commits] branch master updated: Fix failing tests due to superlu on some systems
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 a46b1e84 Fix failing tests due to superlu on some systems a46b1e84 is described below commit a46b1e847fe64fa344a962f9b0a3dba593ee5f45 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 08:49:28 2023 +0200 Fix failing tests due to superlu on some systems --- contrib/level_set_contact/test_contact.cpp | 5 - tests/plasticity.cc| 4 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/level_set_contact/test_contact.cpp b/contrib/level_set_contact/test_contact.cpp index 977c25d2..e3906dcf 100644 --- a/contrib/level_set_contact/test_contact.cpp +++ b/contrib/level_set_contact/test_contact.cpp @@ -165,8 +165,11 @@ int main(int argc, char *argv[]) //actual step solving level_set_contact::solve_with_contact(standard_solve, model, +#ifdef GMM_USES_MUMPS +iter_newton, iter_contact, "mumps", line_search); +#else iter_newton, iter_contact, "superlu", line_search); - +#endif GMM_ASSERT1(iter_contact.converged(), "ERROR: contact algorithm did not converge"); std::cout << "update" << std::endl; diff --git a/tests/plasticity.cc b/tests/plasticity.cc index b32233d6..78f54d8c 100644 --- a/tests/plasticity.cc +++ b/tests/plasticity.cc @@ -332,7 +332,11 @@ bool elastoplasticity_problem::solve(plain_vector ) { // getfem::simplest_newton_line_search ls; gmm::iteration iter(residual, 2, 4); getfem::standard_solve(model, iter, +#ifdef GMM_USES_MUMPS + getfem::rselect_linear_solver(model, "mumps"), ls); +#else getfem::rselect_linear_solver(model, "superlu"), ls); +#endif getfem::small_strain_elastoplasticity_next_iter (model, mim, "Prandtl Reuss", getfem::DISPLACEMENT_ONLY,
[Getfem-commits] [getfem-commits] branch master updated: Fix compilation warnings
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:
[Getfem-commits] [getfem-commits] branch master updated: Enable use of multithreaded GetGEM (openmp) from Python
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 6c37f3e6 Enable use of multithreaded GetGEM (openmp) from Python 6c37f3e6 is described below commit 6c37f3e67c8663c7d5fbc0f1e7ec65e23303522d Author: Konstantinos Poulios AuthorDate: Sun Aug 27 15:55:56 2023 +0200 Enable use of multithreaded GetGEM (openmp) from Python * new scripting interface function: util_set_num_threads(int) --- interface/src/gf_util.cc | 58 +++- interface/src/python/Makefile.am | 2 +- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/interface/src/gf_util.cc b/interface/src/gf_util.cc index e37a22ed..4fed4dab 100644 --- a/interface/src/gf_util.cc +++ b/interface/src/gf_util.cc @@ -38,7 +38,7 @@ using namespace getfemint; struct sub_gf_util : 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) = 0; + getfemint::mexargs_out& out) = 0; }; typedef std::shared_ptr psub_command; @@ -47,15 +47,15 @@ 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_util { \ - virtual void run(getfemint::mexargs_in& in, \ - getfemint::mexargs_out& out) \ - { 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_util { \ + virtual void run(getfemint::mexargs_in& in, \ + getfemint::mexargs_out& out) \ + { 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; \ } @@ -82,15 +82,15 @@ void gf_util(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { else THROW_BADARG("unknown sparse matrix file-format : " << fmt); std::string fname = in.pop().to_string(); if (!in.front().is_complex()) { -gf_real_sparse_csc_const_ref H; in.pop().to_sparse(H); -gmm::csc_matrix cscH; gmm::copy(H,cscH); -if (ifmt == 0) gmm::Harwell_Boeing_save(fname.c_str(), cscH); -else gmm::MatrixMarket_save(fname.c_str(), cscH); + gf_real_sparse_csc_const_ref H; in.pop().to_sparse(H); + gmm::csc_matrix cscH; gmm::copy(H,cscH); + if (ifmt == 0) gmm::Harwell_Boeing_save(fname.c_str(), cscH); + else gmm::MatrixMarket_save(fname.c_str(), cscH); } else { -gf_cplx_sparse_csc_const_ref H; in.pop().to_sparse(H); -gmm::csc_matrix cscH; gmm::copy(H,cscH); -if (ifmt == 0) gmm::Harwell_Boeing_save(fname.c_str(), cscH); -else gmm::MatrixMarket_save(fname.c_str(), cscH); + gf_cplx_sparse_csc_const_ref H; in.pop().to_sparse(H); + gmm::csc_matrix cscH; gmm::copy(H,cscH); + if (ifmt == 0) gmm::Harwell_Boeing_save(fname.c_str(), cscH); + else gmm::MatrixMarket_save(fname.c_str(), cscH); } ); @@ -113,9 +113,9 @@ void gf_util(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { sub_command ("trace level", 0, 1, 0, 1, if (in.remaining()) -gmm::set_traces_level(in.pop().to_integer(0, 100)); + gmm::set_traces_level(in.pop().to_integer(0, 100)); else -out.pop().from_integer(int(gmm::traces_level::level())); + out.pop().from_integer(int(gmm::traces_level::level())); ); @@ -127,9 +127,17 @@ void gf_util(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { sub_command ("warning level", 0, 1, 0, 1, if (in.remaining()) -gmm::set_warning_level(in.pop().to_integer(0, 100)); + gmm::set_warning_level(in.pop().to_integer(0, 100)); else -out.pop().from_integer(int(gmm::warning_level::level())); +
[Getfem-commits] (no subject)
branch: devel-logari81-interpolate-element-matrices commit 4bb1fd6ee30846fa8ea582358de0b39518b8df56 Author: Konstantinos Poulios AuthorDate: Fri May 27 11:20:27 2022 +0200 Avoid passing unused references --- src/getfem_generic_assembly_compile_and_exec.cc | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index 14da914f..a875de3f 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -3982,7 +3982,7 @@ namespace getfem { ga_instruction_set::interpolate_info pinterpolate_transformation trans; fem_interpolation_context -base_small_vector +base_small_vector dummy_normal; const mesh size_type papprox_integration @@ -4077,9 +4077,10 @@ namespace getfem { size_type cv; short_type face_num; gmm::clear(inin.Normal); -inin.pt_type = trans->transform(workspace, m, ctx, Normal, &(inin.m), -cv, face_num, P_ref, inin.Normal, -inin.derivatives, false); +inin.pt_type = trans->transform(workspace, m, ctx, dummy_normal, +&(inin.m), cv, face_num, P_ref, +dummy_normal, inin.derivatives, +false); if (inin.pt_type) { if (cv != size_type(-1)) { inin.m->points_of_convex(cv, inin.G); @@ -4111,10 +4112,10 @@ namespace getfem { ga_instruction_neighbor_transformation_call (const ga_workspace , ga_instruction_set::interpolate_info , pinterpolate_transformation t, fem_interpolation_context , - base_small_vector , const mesh , size_type _, - papprox_integration _, bgeot::geotrans_precomp_pool _pool_, + const mesh , size_type _, papprox_integration _, + bgeot::geotrans_precomp_pool _pool_, std::map _corresp_) - : workspace(w), inin(i), trans(t), ctx(ctxx), Normal(No), m(mm), + : workspace(w), inin(i), trans(t), ctx(ctxx), m(mm), ipt(ipt_), pai(pai_), gp_pool(gp_pool_), neighbor_corresp(neighbor_corresp_) {} }; @@ -7257,8 +7258,7 @@ namespace getfem { pgai = std::make_shared (workspace, rmi.interpolate_infos[transname], workspace.interpolate_transformation(transname), gis.ctx, - gis.Normal, m, gis.ipt, gis.pai, gis.gp_pool, - gis.neighbor_corresp); + m, gis.ipt, gis.pai, gis.gp_pool, gis.neighbor_corresp); } else { pgai = std::make_shared (workspace, rmi.interpolate_infos[transname],
[Getfem-commits] (no subject)
branch: devel-logari81-interpolate-element-matrices commit 5f88efb4b1be63caceb0193d4db7b256cad80726 Author: Konstantinos Poulios AuthorDate: Fri May 27 11:22:29 2022 +0200 Support element_K and element_B interpolates in GWFL --- src/getfem/getfem_generic_assembly_tree.h | 2 ++ src/getfem_generic_assembly_compile_and_exec.cc | 15 + src/getfem_generic_assembly_semantic.cc | 42 - src/getfem_generic_assembly_tree.cc | 14 +++-- 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 0d9ad00a..9c9ba7ac 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -158,6 +158,8 @@ namespace getfem { GA_NODE_INTERPOLATE_HESS_TEST, GA_NODE_INTERPOLATE_DIVERG_TEST, GA_NODE_INTERPOLATE_X, +GA_NODE_INTERPOLATE_ELT_K, +GA_NODE_INTERPOLATE_ELT_B, GA_NODE_INTERPOLATE_NORMAL, GA_NODE_INTERPOLATE_DERIVATIVE, GA_NODE_ELEMENTARY, diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index a875de3f..7b1260e5 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -5577,6 +5577,21 @@ namespace getfem { rmi.instructions.push_back(std::move(pgai)); break; +case GA_NODE_INTERPOLATE_ELT_K: +case GA_NODE_INTERPOLATE_ELT_B: + GMM_ASSERT1(!function_case, + "No use of Interpolate is allowed in functions"); + if (pnode->node_type == GA_NODE_INTERPOLATE_ELT_K) +pgai = std::make_shared + (pnode->tensor(), +rmi.interpolate_infos[pnode->interpolate_name].ctx); + else if (pnode->node_type == GA_NODE_INTERPOLATE_ELT_B) +pgai = std::make_shared + (pnode->tensor(), +rmi.interpolate_infos[pnode->interpolate_name].ctx); + rmi.instructions.push_back(std::move(pgai)); + break; + case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: { diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 6522ba69..a9b5ac31 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -99,6 +99,8 @@ namespace getfem { pnode->node_type == GA_NODE_INTERPOLATE_HESS_TEST || pnode->node_type == GA_NODE_INTERPOLATE_DIVERG_TEST || pnode->node_type == GA_NODE_INTERPOLATE_X || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_K || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_B || pnode->node_type == GA_NODE_INTERPOLATE_NORMAL) { workspace.interpolate_transformation(pnode->interpolate_name) ->extract_variables(workspace, vars, ignore_data, m, @@ -160,6 +162,8 @@ namespace getfem { if (interpolate_node || interpolate_test_node || pnode->node_type == GA_NODE_INTERPOLATE_X || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_K || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_B || pnode->node_type == GA_NODE_INTERPOLATE_NORMAL) { std::set vars; workspace.interpolate_transformation(pnode->interpolate_name) @@ -381,7 +385,9 @@ namespace getfem { case GA_NODE_XFEM_MINUS_HESS_TEST: case GA_NODE_XFEM_MINUS_DIVERG_TEST: c += 1.33*(1.22+ga_hash_code(pnode->name)); break; -case GA_NODE_INTERPOLATE_X: case GA_NODE_INTERPOLATE_NORMAL: +case GA_NODE_INTERPOLATE_X: +case GA_NODE_INTERPOLATE_ELT_K: case GA_NODE_INTERPOLATE_ELT_B: +case GA_NODE_INTERPOLATE_NORMAL: case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: c += M_PI*1.33*ga_hash_code(pnode->interpolate_name); break; @@ -450,6 +456,7 @@ namespace getfem { case GA_NODE_RESHAPE: case GA_NODE_CROSS_PRODUCT: case GA_NODE_IND_MOVE_LAST: case GA_NODE_SWAP_IND: case GA_NODE_CONTRACT: case GA_NODE_INTERPOLATE_X: +case GA_NODE_INTERPOLATE_ELT_K: case GA_NODE_INTERPOLATE_ELT_B: case GA_NODE_INTERPOLATE_NORMAL: case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: pnode->test_function_type = 0; break; @@ -584,6 +591,23 @@ namespace getfem { } break; } + if (pnode->name.compare("element_K") == 0) { +if (pnode->node_type == GA_NODE_INTERPOLATE) { + pnode->node_type = GA_NODE_INTERPOLATE_ELT_K; + if (ref_elt_dim == 1) +pnode->init_vector_tensor(meshdim); + else +pnode->init_matrix_tensor(meshdim, ref_elt_dim); +} +break; + } + if (pnode->name.compare("element_B") == 0) { +if (pnode->node_type == GA_NODE_INTERPOLATE) { + pnode->node_type = GA_NODE_INTERPOLATE_ELT_B; + pnode->init_matrix_tensor(ref_elt_dim, meshdim); +} +break; +
[Getfem-commits] [getfem-commits] branch devel-logari81-interpolate-element-matrices created (now 5f88efb4)
logari81 pushed a change to branch devel-logari81-interpolate-element-matrices. at 5f88efb4 Support element_K and element_B interpolates in GWFL This branch includes the following new commits: new 71eeed57 Minor changes new 4bb1fd6e Avoid passing unused references new 5f88efb4 Support element_K and element_B interpolates in GWFL
Re: [Getfem-commits] [getfem-commits] branch devel-logari81-interpolate-element-matrices created (now 5f88efb4)
Dear Yves, Could you please have a look at these commits, especially the last two, and merge/delete this branch? Kostas On Fri, May 27, 2022 at 11:23 AM Konstantinos Poulios via Getfem-commits < getfem-commits@nongnu.org> wrote: > logari81 pushed a change to branch > devel-logari81-interpolate-element-matrices. > > at 5f88efb4 Support element_K and element_B interpolates in GWFL > > This branch includes the following new commits: > > new 71eeed57 Minor changes > new 4bb1fd6e Avoid passing unused references > new 5f88efb4 Support element_K and element_B interpolates in GWFL > > >
[Getfem-commits] [getfem-commits] branch master updated: Fix typos
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 df62d419 Fix typos df62d419 is described below commit df62d419e989fe639d82fda45936da9254327f82 Author: Konstantinos Poulios AuthorDate: Thu Jun 23 10:09:02 2022 +0200 Fix typos --- src/getfem_generic_assembly_compile_and_exec.cc | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index 7b1260e5..b2f629c5 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -5660,7 +5660,7 @@ namespace getfem { "Wrong context for elementary transformation"); GMM_ASSERT1(&(mfo->linked_mesh()) == &(m), "The finite element of variable " << pnode->name -<< " has to be defined on the same mesh than the " +<< " has to be defined on the same mesh as the " << "integration method or interpolation used"); } @@ -5679,7 +5679,7 @@ namespace getfem { GMM_ASSERT1(&(mf->linked_mesh()) == &(m), "The finite element of variable " << (is_elementary ? pnode->elementary_target : pnode->name) -<< " has to be defined on the same mesh than the " +<< " has to be defined on the same mesh as the " << "integration method or interpolation used"); // An instruction for extracting local dofs of the variable. @@ -5949,7 +5949,7 @@ namespace getfem { GMM_ASSERT1(mf, "Internal error"); GMM_ASSERT1(&(mf->linked_mesh()) == &(psd->mim().linked_mesh()), "The finite element of variable " << pnode->name << - " has to be defined on the same mesh than the " + " has to be defined on the same mesh as the " "integration method or interpolation used on the " "secondary domain"); @@ -6121,13 +6121,13 @@ namespace getfem { "Wrong context for elementary transformation"); GMM_ASSERT1(&(mfo->linked_mesh()) == &(m), "The finite element of variable " << pnode->name - << " has to be defined on the same mesh than the " + << " has to be defined on the same mesh as the " << "integration method or interpolation used"); } if (mf) { GMM_ASSERT1(&(mf->linked_mesh()) == &(m), - "The finite element of variable " << pnode->name << + "The finite element of variable " << (is_elementary ? pnode->elementary_target : pnode->name) << " and the applied integration method have to be" << " defined on the same mesh");
[Getfem-commits] [getfem-commits] branch master updated: Python version 3 in auxiliary scripts
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 89e50dbd Python version 3 in auxiliary scripts 89e50dbd is described below commit 89e50dbdfe6dbd752fc90abcf2559d5a41e143fe Author: Konstantinos Poulios AuthorDate: Wed Jun 22 13:52:19 2022 +0200 Python version 3 in auxiliary scripts --- bin/extract_doc | 2 +- bin/split_cmdref | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/extract_doc b/bin/extract_doc index e0f72c68..0619560c 100755 --- a/bin/extract_doc +++ b/bin/extract_doc @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # -*- python -*- # # Copyright (C) 2004-2022 Yves Renard, Julien Pommier. diff --git a/bin/split_cmdref b/bin/split_cmdref index bcc7dca4..5e8c2e34 100755 --- a/bin/split_cmdref +++ b/bin/split_cmdref @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # -*- python -*- # # Copyright (C) 2004-2020 Yves Renard.
[Getfem-commits] [getfem-commits] branch master updated: Fix issue from #89e50dbd
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 76a75614 Fix issue from #89e50dbd 76a75614 is described below commit 76a75614e9b60c603334cb7e5a637d0eedd78495 Author: Konstantinos Poulios AuthorDate: Tue Jun 28 14:42:23 2022 +0200 Fix issue from #89e50dbd --- bin/extract_doc | 2 +- bin/split_cmdref | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/extract_doc b/bin/extract_doc index 0619560c..d444e652 100755 --- a/bin/extract_doc +++ b/bin/extract_doc @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- python -*- # # Copyright (C) 2004-2022 Yves Renard, Julien Pommier. diff --git a/bin/split_cmdref b/bin/split_cmdref index 5e8c2e34..db36a2e3 100755 --- a/bin/split_cmdref +++ b/bin/split_cmdref @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- python -*- # # Copyright (C) 2004-2020 Yves Renard.
[Getfem-commits] [getfem-commits] devel-logari81 updated (d87054dd -> d9bcc35a)
logari81 pushed a change to branch devel-logari81. from d87054dd Merge branch 'master' into devel-logari81 add 2b08ba6a Terminate loop, if less than two elements are left. add d45990de minor fix add 0b739c65 Merge branch 'master' of git.sv.gnu.org:/srv/git/getfem add cebc94af Add additional info (actual tensor size) to the im_data. add 6f87ba2a Add link with the pre-compiled getfem packages of J.F. Barthelemy for Windows add 0dbd1586 bug fix in second derivative of Det() add 7bb62680 Final fix in second derivative of Det() add 180025ae t merge origin/Merge branch 'master' of ssh://git.sv.gnu.org:/srv/git/getfem add 2b961a64 small fix add a0603978 fix spell mistake add a77686cb minor fix add 0c10151a Fix typo add fcd9ea92 minor change add 6fe32efe fix misspell add a7257c5f Fix typo in docs add e78fd734 Fix typo in docs add 6ca55987 Fix typo in docs add 92d31205 Fix typo in docs add b183b46f Fix typo in docs add c443a396 Fix typo in docs add cd097984 Fix typo in docs add 8cd2e7bf Fix typo in docs add 2687aaaf Fix typo in docs add 9aba30b6 Fix typo in docs add f43840f6 Merge remote-tracking branch 'origin/fixmisspell' add 578da9c1 'PK2' instead of -sigma in hyper elastic law names add e14de6ab minor change add 8dcd729f Ensure compatibility of the python interface to python 3.x, --enable-python3 of the configure script enable the interface with python 3.x add 6e477933 Merge remote-tracking branch 'origin/devel-tetsuo-fix_test_error' add 55ac4dd5 [fix] test error in numpy Version: 1.14.5 add aa4d3e16 minor modification for compatibility with xcode 10.0, mac add d3d1d625 [add] modification for translation add f56a6938 Merge branch 'master' of ssh://git.sv.gnu.org:/srv/git/getfem into devel-tetsuo-translation add 55df88eb update config file add 6187a32a add content "Localization(L10N)" add 0dc4111b Fix by review add f157fa05 fix Warning: this 'for' clause does not guard add 1d789aa3 documentation improvements add ab95e5c6 optimizing gmm::add for small vectors add 98b56a36 adding the scaled case add f56e01a6 comparing pconvex_structure by keys everywhere add e9270a80 further refining comparison for convex_structure pointers add 45c3f1ba Add a ball shell structured mesh generator (tested in 2D and 3D) add a14b31c7 Code clean up add f0541858 Let the tolerance sign determine if added points to a mesh are merged with existing ones or not add b4627083 Add merge_convexes_from_mesh method to the mesh object add 3e2655bc New implementation of project_into_convex as a geotrans class function add 5e91d088 Fix projected_fem add 4001a790 Fix copyright header add aa91194a Add format option to GMM's vecsave add 5b0ebffc Fix vecsave format option add 11638ff8 Avoid creation of some temporary objects. add 3326ae35 minor fix add 4fe9963c Fix python script by 2to3 add 18bcf868 Add initial support for gmsh mesh format version 4 add d33eb662 Merge branch 'master' of ssh://git.sv.gnu.org:/srv/git/getfem into devel-tetsuo-2to3check add c7b7ac1d minor change add f88ba527 minor change add b3bf69ba [update] svn -> git add e26a31ff Fix typo in docs add 980a9c84 Fix typo in docs add f6061239 Fix typo in docs add 3fcba5a0 Fix typo in docs add 366dceea Fix typo in docs add 4d22c9a7 Merge remote-tracking branch 'origin/fixmisspell' add d4e6de7b Add getfem_tutorial.pdf add e68cc961 Merge remote-tracking branch 'origin/devel-tetsuo-add-tutorial-pdf' add 11244915 Fix bug add 7db9249a fixed SEH exceptions created by a wrong optimization by the INTEL c++ 2019 compiler add 59ae1324 Merge remote-tracking branch 'origin/devel-tunc_bahcecioglu_intel2019_fix' add 407e1d86 Macro that encapsulates the parallel Open MP run add 059c2017 Merge branch 'master' of git.sv.gnu.org:/srv/git/getfem into consistent_partitioning_for_open_mp add df435160 Besides doing some basic clean up in the Open MP related partitioning and global storage the main purpose is to make region and subsequently assembly partitioning independent from the number of parallel threads being used. For instance, if we choose to partition the whole calculation into 8 partitions, but use only 2 parallel threads, then each thread will be looping through 4 independent partitions. This way, no matter how many threads we choose we partition the regions [...] add 69ba6429 Adaptations for Scilab 6.0 add 9770d9d3 Some small fixes for consistent partionning for open_mp add f217241b fixing segmentation fault caused by the fact that omp_distribute for singletons was destroyed before the objects from it were deleted. Fixed by creating it dynamically and deleting only when its content was emptied add
[Getfem-commits] (no subject)
branch: devel-logari81 commit d9bcc35a3e49db2d14ec7b9cd4249c6072d9e6cc Merge: d87054dd 20c315d5 Author: Konstantinos Poulios AuthorDate: Fri Jun 24 14:40:02 2022 +0200 Merge branch 'master' into devel-logari81 # Conflicts: # src/getfem/getfem_mesh_region.h # src/getfem_mesh_region.cc .codecov.yml | 25 + .gitignore | 69 +- .travis.yml| 48 + ChangeLog | 697 +--- INSTALL|2 +- Makefile.am|7 +- NEWS | 113 +- README |8 +- autogen.sh |2 +- bin/Makefile.am|6 +- bin/ansys2getfem_mesh |6 +- bin/createmp |6 +- bin/dr2dgnuplot|6 +- bin/extract_doc| 560 +++- bin/fig2eps|6 +- bin/file_dependencies |8 +- bin/makeheadfile | 20 +- bin/mesh_matlab_to_getfem |6 +- bin/rst_to_xml.py | 18 +- bin/sc2dgnuplot|6 +- bin/split_cmdref | 10 +- bin/test_dist |6 +- bin/upload_documentation |6 +- bin/upload_html| 13 +- bin/upload_misc|6 +- bin/upload_version |6 +- bin/word_count |6 +- configure.ac | 1208 +++ contrib/Makefile.am|9 +- contrib/aposteriori/Makefile.am|8 +- contrib/aposteriori/aposteriori.cc | 12 +- contrib/aposteriori/aposteriori.m |2 +- contrib/aposteriori/aposteriori.param |2 +- contrib/aposteriori/aposteriori.pl |2 +- contrib/aposteriori/aposteriori_laplacian.cc | 14 +- contrib/aposteriori/aposteriori_laplacian.param|2 +- contrib/aposteriori/aposteriori_laplacian.pl |2 +- contrib/aposteriori/bimaterial_crack_test.param|2 +- contrib/bimaterial_crack_test/Makefile.am |8 +- .../bimaterial_crack_test/bimaterial_crack_test.cc | 10 +- .../bimaterial_crack_test.param|2 +- .../bimaterial_crack_test/bimaterial_crack_test.pl |2 +- contrib/bimaterial_crack_test/crack.cc |8 +- contrib/bimaterial_crack_test/crack.param |2 +- contrib/bimaterial_crack_test/crack.pl |2 +- .../bimaterial_crack_test/crack_exact_solution.cc |6 +- .../bimaterial_crack_test/crack_exact_solution.h |8 +- contrib/bimaterial_crack_test/getfem_Xfem.cc |6 +- contrib/bimaterial_crack_test/getfem_Xfem.h|6 +- contrib/bimaterial_crack_test/getfem_spider_fem.h |6 +- .../Makefile.am| 13 +- contrib/continuum_mechanics/QLV_viscoelasticity.py | 196 ++ ...ty_finite_strain_linear_hardening_tension_3D.py | 249 ++ ...strain_linear_hardening_tension_axisymmetric.py | 238 ++ ...strain_linear_hardening_tension_plane_strain.py | 236 ++ contrib/crack_plate/Makefile.am|8 +- contrib/crack_plate/crack_bilaplacian.cc |8 +- contrib/crack_plate/crack_bilaplacian.h|8 +- contrib/crack_plate/crack_bilaplacian.param|2 +- contrib/crack_plate/crack_bilaplacian_mixed.param |2 +- contrib/crack_plate/crack_bilaplacian_moment.cc|6 +- contrib/crack_plate/crack_bilaplacian_problem.cc |6 +- contrib/crack_plate/crack_bilaplacian_sif.cc |6 +- .../crack_plate/crack_bilaplacian_singularities.cc |6 +- contrib/crack_plate/crack_bilaplacian_tools.cc |6 +- contrib/crack_plate/crack_mindlin.cc | 10 +- contrib/crack_plate/crack_mindlin.param|2 +- contrib/crack_plate/crack_mindlin.pl |2 +- contrib/crack_plate/crack_panel.cc |8 +- contrib/crack_plate/crack_panel.param |2 +- contrib/crack_plate/demi_plaque.mesh |2 +- contrib/crack_plate/serie.pl |2 +- contrib/delaminated_crack/Makefile.am |8 +- contrib/delaminated_crack/delaminated_crack.cc |8 +- contrib/delaminated_crack/delaminated_crack.param |2 +-
[Getfem-commits] [getfem-commits] branch devel-logari81 updated: Fix wrong point size in mesh method
This is an automated email from the git hooks/post-receive script. logari81 pushed a commit to branch devel-logari81 in repository getfem. The following commit(s) were added to refs/heads/devel-logari81 by this push: new 60d7d962 Fix wrong point size in mesh method 60d7d962 is described below commit 60d7d962e77f6d582ac4d01c3897212f687ea7bd Author: Konstantinos Poulios AuthorDate: Fri Jun 24 14:45:06 2022 +0200 Fix wrong point size in mesh method --- src/getfem_mesh.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/getfem_mesh.cc b/src/getfem_mesh.cc index 4c631a38..d6e25378 100644 --- a/src/getfem_mesh.cc +++ b/src/getfem_mesh.cc @@ -1150,7 +1150,7 @@ namespace getfem { pgp = bgeot::geotrans_precomp(pgt, pspt, 0); } -base_node pt(n); +base_node pt(dim()); ipt.resize(pspt->size()); for (size_type ip = 0; ip < pspt->size(); ++ip) { pgp->transform(points_of_convex(i), ip, pt); @@ -1229,6 +1229,7 @@ namespace getfem { else return icc; } else if (ref) Bank_refine_normal_convex(i); + return size_type(-1); } @@ -1283,7 +1284,7 @@ namespace getfem { bgeot::pgeotrans_precomp pgp = bgeot::geotrans_precomp(pgt1, pspt1, 0); std::vector ipt1(pspt1->size()); -base_node pt(n); +base_node pt(dim()); for (size_type i = 0; i < pspt1->size(); ++i) { pgp->transform(mesh2.points_of_convex(ic1), i, pt); ipt1[i] = mesh2.add_point(pt);
[Getfem-commits] [getfem-commits] branch devel-tetsuo-fix-aclocal-python deleted (was a105a274)
logari81 pushed a change to branch devel-tetsuo-fix-aclocal-python. was a105a274 Fix m4/ac_python_devel.m4 for Python3.10 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 devel-tetsuo-fix-error-in-ubuntu20.04 deleted (was bc309aa0)
logari81 pushed a change to branch devel-tetsuo-fix-error-in-ubuntu20.04. was bc309aa0 Fix the compile error of nbp in ubuntu20.04 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] (no subject)
branch: master commit a499492ecdb32c9b73e83148541d79297b9cdbae Author: Konstantinos Poulios AuthorDate: Thu Sep 29 13:16:47 2022 +0200 Add const attribute to class member function --- src/getfem/getfem_generic_assembly_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 9c9ba7ac..4384b9fd 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -235,7 +235,7 @@ namespace getfem { void set_sparsity(int sp, size_type q) { sparsity_ = sp; qdim_ = q; } -size_type qdim() { return is_copied ? tensor_copied->qdim() : qdim_; } +size_type qdim() const { return is_copied ? tensor_copied->qdim() : qdim_; } int sparsity() const { return is_copied ? tensor_copied->sparsity() : sparsity_; }
[Getfem-commits] [getfem-commits] master updated (49aedfae -> f50e3cba)
logari81 pushed a change to branch master. from 49aedfae fix a problem with a non adaptation of mim to mesh change new a499492e Add const attribute to class member function new 8cfa3b3b Typo fix and documentation improvements new f50e3cba Allow integration point variables for GWFL assembly in the scripting interface Summary of changes: doc/sphinx/source/replaces.txt| 2 +- doc/sphinx/source/userdoc/bfem.rst| 50 +++ doc/sphinx/source/userdoc/bmesh.rst | 2 +- doc/web/index.php | 4 +-- interface/src/gf_asm.cc | 6 ++-- src/getfem/getfem_generic_assembly_tree.h | 2 +- src/gmm/gmm_dense_matrix_functions.h | 2 +- 7 files changed, 35 insertions(+), 33 deletions(-)
[Getfem-commits] [getfem-commits] branch master updated: Relax convergence threshold for inverse geometric transformation
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 2a1dd105 Relax convergence threshold for inverse geometric transformation 2a1dd105 is described below commit 2a1dd1059ed54a3dfceb5662f7e542132a774c99 Author: Konstantinos Poulios AuthorDate: Thu Sep 29 14:50:01 2022 +0200 Relax convergence threshold for inverse geometric transformation - convergence criterion depending on size and position of the real element --- src/bgeot_geotrans_inv.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index 04b0e007..f6301fdb 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -220,7 +220,9 @@ namespace bgeot base_node x0_real(N); while (res > IN_EPS/100.) { if ((gmm::abs(res - res0) < IN_EPS/100.) || (factor < IN_EPS)) { -converged = false; +// relaxed convergence criterion depending on the size and position +// of the real element +converged = (res < gmm::mat_maxnorm(G) * IN_EPS/100.); return (pgt->convex_ref()->is_in(x) < IN_EPS) && (res < IN_EPS); } if (res > res0) {
[Getfem-commits] (no subject)
branch: master commit f50e3cbab06ca59e87decb0aea6f4fdfa1cf1b4c Author: Konstantinos Poulios AuthorDate: Thu Sep 29 14:15:54 2022 +0200 Allow integration point variables for GWFL assembly in the scripting interface --- interface/src/gf_asm.cc | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/gf_asm.cc b/interface/src/gf_asm.cc index a223b15e..1824fe01 100644 --- a/interface/src/gf_asm.cc +++ b/interface/src/gf_asm.cc @@ -488,7 +488,9 @@ static void do_high_level_generic_assembly(mexargs_in& in, mexargs_out& out) { nbdof += mf->nb_dof(); workspace.add_fem_variable(varname, *mf, I, vectors[varname]); } else if (mimd) { - THROW_BADARG("Data defined on integration points can not be a variable"); + gmm::sub_interval I(nbdof, mimd->nb_filtered_index()); + nbdof += mimd->nb_filtered_index(); + workspace.add_im_variable(varname, *mimd, I, vectors[varname]); } else { gmm::sub_interval I(nbdof, U.size()); nbdof += U.size(); @@ -604,7 +606,7 @@ static void do_expression_analysis(mexargs_in& in, mexargs_out& out) { if (mf) workspace.add_fem_variable(varname, *mf, dummy_I, dummy_V); else if (mimd) { -THROW_BADARG("Data defined on integration points can not be a variable"); +workspace.add_im_variable(varname, *mimd, dummy_I, dummy_V); } else workspace.add_fixed_size_variable(varname, dummy_I, dummy_V); }
[Getfem-commits] [getfem-commits] branch master updated: Replace deprecated distutils with setuptools
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 108702a6 Replace deprecated distutils with setuptools 108702a6 is described below commit 108702a617220c8052fac4b17a9523680478be0e Author: Konstantinos Poulios AuthorDate: Wed Oct 5 17:23:55 2022 +0200 Replace deprecated distutils with setuptools --- configure.ac | 4 +- interface/src/python/setup.py.in | 2 +- m4/ac_python_devel.m4| 185 - m4/ax_python_devel.m4| 416 +++ 4 files changed, 419 insertions(+), 188 deletions(-) diff --git a/configure.ac b/configure.ac index 84d685bd..e9e18671 100644 --- a/configure.ac +++ b/configure.ac @@ -450,7 +450,7 @@ if test "x$usepython" = "xYES"; then echo "Building with python ($PYTHON) support (use --enable-python=no to disable it) " echo "You will need the python-numpy and python-scipy packages." dnl AM_PATH_PYTHON(2.2) - AC_PYTHON_DEVEL + AX_PYTHON_DEVEL ac_python_numpy=`$PYTHON -c 'import numpy; print("YES")' 2>/dev/null` if test "x$ac_python_numpy" != "xYES"; then usepython=NO @@ -474,7 +474,7 @@ dnl AM_PATH_PYTHON(2.2) WARNING_MSG="$WARNING_MSG\n$MSG" fi fi - PYTHON_SO=`$PYTHON -c "import distutils.sysconfig, sys; get = distutils.sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or get('SO') or '.so');"` + PYTHON_SO=`$PYTHON -c "import sysconfig, sys; get = sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or get('SO') or '.so');"` AC_SUBST(PYTHON_SO) fi diff --git a/interface/src/python/setup.py.in b/interface/src/python/setup.py.in index 6a8445bf..22b9feed 100644 --- a/interface/src/python/setup.py.in +++ b/interface/src/python/setup.py.in @@ -22,7 +22,7 @@ """This is the getfem-python-interface module. """ -from distutils.core import setup, Extension +from setuptools import setup, Extension import os try: diff --git a/m4/ac_python_devel.m4 b/m4/ac_python_devel.m4 deleted file mode 100644 index 479aad7e.. --- a/m4/ac_python_devel.m4 +++ /dev/null @@ -1,185 +0,0 @@ -dnl @synopsis AC_PYTHON_DEVEL([version]) -dnl -dnl Checks for Python and tries to get the include path to 'Python.h'. -dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output -dnl variables. Also exports $(PYTHON_EXTRA_LIBS) and -dnl $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. -dnl -dnl You can search for some particular version of Python by passing a -dnl parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". -dnl Please note that you *have* to pass also an operator along with the -dnl version to match, and pay special attention to the single quotes -dnl surrounding the version number. -dnl -dnl If the user wants to employ a particular version of Python, she can -dnl now pass to configure the PYTHON_VERSION environment variable. This -dnl is only limited by the macro parameter set by the packager. -dnl -dnl This macro should work for all versions of Python >= 2.1.0. You can -dnl disable the check for the python version by setting the -dnl PYTHON_NOVERSIONCHECK environment variable to something else than -dnl the empty string. -dnl -dnl If you need to use this macro for an older Python version, please -dnl contact the authors. We're always open for feedback. -dnl -dnl @category InstalledPackages -dnl @author Sebastian Huber -dnl @author Alan W. Irwin -dnl @author Rafael Laboissiere -dnl @author Andrew Collier -dnl @author Matteo Settenvini -dnl @version 2006-02-05 -dnl @license GPLWithACException - -AC_DEFUN([AC_PYTHON_DEVEL],[ - # - # Allow the use of a (user set) custom python version - # - AC_ARG_VAR([PYTHON_VERSION],[The installed Python - version to use, for example '2.3'. This string - will be appended to the Python interpreter - canonical name.]) - - AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) - if test -z "$PYTHON"; then - AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) - fi - - # - # Check for a version of Python >= 2.1.0 - # - AC_MSG_CHECKING([for a version of Python >= '2.1.0']) - ac_supports_python_ver=`$PYTHON -c "import sys, string; \ - ver =(sys.version.split())[[0]]; \ - print(int(ver >= '2.1.0'))"` - if test "$ac_supports_python_ver" != "1"; then - if test -z "$PYTHON_NOVERSIONCHECK"; then - AC_MSG_RESULT([no]) - AC_MSG_FAILURE([ -This version of the AC@@_PYTHON_DEVEL macro -doesn't work properly with versions of Python before -2.1.0. You may need to re-run configure, setting the -variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, -PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
[Getfem-commits] [getfem-commits] branch master updated: Fix GWFL bug in ga_node_grad for elementary transformations
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 c49e989c Fix GWFL bug in ga_node_grad for elementary transformations c49e989c is described below commit c49e989c150d76ea7dad74d6f5f49ed88af35c5c Author: Konstantinos Poulios AuthorDate: Fri Jan 6 16:08:32 2023 +0100 Fix GWFL bug in ga_node_grad for elementary transformations --- src/getfem_generic_assembly_semantic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index a9b5ac31..039ff551 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -4209,7 +4209,7 @@ namespace getfem { pnode->t.adjust_sizes(mi); break; case GA_NODE_ELEMENTARY_GRAD: case GA_NODE_ELEMENTARY_GRAD_TEST: - if (pnode->node_type == GA_NODE_ELEMENTARY_VAL) + if (pnode->node_type == GA_NODE_ELEMENTARY_GRAD) pnode->node_type = GA_NODE_ELEMENTARY_HESS; else pnode->node_type = GA_NODE_ELEMENTARY_HESS_TEST;
[Getfem-commits] [getfem-commits] branch master updated: Just white space changes
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 5dd7219d Just white space changes 5dd7219d is described below commit 5dd7219dc0afa468310c2911f638a69c8c3567d0 Author: Konstantinos Poulios AuthorDate: Fri Jan 13 14:02:56 2023 +0100 Just white space changes --- interface/src/getfemint.h | 140 ++--- src/getfem_generic_assembly_compile_and_exec.cc | 2 +- src/getfem_generic_assembly_semantic.cc | 98 --- src/getfem_global_function.cc | 2 +- src/gmm/gmm_sub_vector.h| 160 ++-- 5 files changed, 216 insertions(+), 186 deletions(-) diff --git a/interface/src/getfemint.h b/interface/src/getfemint.h index 4e75dcce..b88f5876 100644 --- a/interface/src/getfemint.h +++ b/interface/src/getfemint.h @@ -51,25 +51,25 @@ namespace getfemint { Do not forget to modify also 'name_of_getfemint_class_id' just after */ typedef enum { CONT_STRUCT_CLASS_ID, -CVSTRUCT_CLASS_ID, -ELTM_CLASS_ID, -FEM_CLASS_ID, -GEOTRANS_CLASS_ID, -GLOBAL_FUNCTION_CLASS_ID, -INTEG_CLASS_ID, -LEVELSET_CLASS_ID, -MESH_CLASS_ID, -MESHFEM_CLASS_ID, -MESHIM_CLASS_ID, -MESHIMDATA_CLASS_ID, -MESH_LEVELSET_CLASS_ID, -MESHER_OBJECT_CLASS_ID, -MODEL_CLASS_ID, -PRECOND_CLASS_ID, -SLICE_CLASS_ID, -SPMAT_CLASS_ID, -POLY_CLASS_ID,/* Not fully interfaced. Remain at the end */ -GETFEMINT_NB_CLASS } getfemint_class_id; + CVSTRUCT_CLASS_ID, + ELTM_CLASS_ID, + FEM_CLASS_ID, + GEOTRANS_CLASS_ID, + GLOBAL_FUNCTION_CLASS_ID, + INTEG_CLASS_ID, + LEVELSET_CLASS_ID, + MESH_CLASS_ID, + MESHFEM_CLASS_ID, + MESHIM_CLASS_ID, + MESHIMDATA_CLASS_ID, + MESH_LEVELSET_CLASS_ID, + MESHER_OBJECT_CLASS_ID, + MODEL_CLASS_ID, + PRECOND_CLASS_ID, + SLICE_CLASS_ID, + SPMAT_CLASS_ID, + POLY_CLASS_ID,/* Not fully interfaced. Remain at the end */ + GETFEMINT_NB_CLASS } getfemint_class_id; /* Associate the class ID found in the matlab structures referencing @@ -83,17 +83,17 @@ namespace getfemint { /* exception-throwing version of the allocation functions of gfi_array.h */ gfi_array* checked_gfi_array_create(int ndim, const int *dims, - gfi_type_id type, - gfi_complex_flag is_complex = GFI_REAL); + gfi_type_id type, + gfi_complex_flag is_complex = GFI_REAL); gfi_array* checked_gfi_array_create_0(gfi_type_id type, - gfi_complex_flag is_complex = GFI_REAL); +gfi_complex_flag is_complex = GFI_REAL); gfi_array* checked_gfi_array_create_1(int M, gfi_type_id type, - gfi_complex_flag is_complex = GFI_REAL); +gfi_complex_flag is_complex = GFI_REAL); gfi_array* checked_gfi_array_create_2(int M, int N, gfi_type_id type, - gfi_complex_flag is_complex = GFI_REAL); +gfi_complex_flag is_complex = GFI_REAL); gfi_array* checked_gfi_array_from_string(const char*s); gfi_array* checked_gfi_create_sparse(int m, int n, int nzmax, - gfi_complex_flag is_complex); + gfi_complex_flag is_complex); typedef bgeot::dim_type dim_type; typedef bgeot::scalar_type scalar_type; @@ -114,12 +114,12 @@ namespace getfemint { typedef gmm::row_matrix > gf_real_sparse_by_row; typedef gmm::col_matrix > gf_real_sparse_by_col; typedef gmm::csc_matrix_ref + const unsigned int *> gf_real_sparse_csc_const_ref; typedef gmm::row_matrix > gf_cplx_sparse_by_row; typedef gmm::col_matrix > gf_cplx_sparse_by_col; typedef gmm::csc_matrix_ref + const unsigned int *> gf_cplx_sparse_csc_const_ref; class gsparse; @@ -204,7 +204,7 @@ namespace getfemint { return (data.get())[unsigned(i+j*getm()+k*getm()*getn())]; } const value_type& operator()(size_type i, size_type j, -size_type k=0) const { +
[Getfem-commits] [getfem-commits] branch master updated: Fix broken lapack interface on BigEndian architectures
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 42188b7a Fix broken lapack interface on BigEndian architectures 42188b7a is described below commit 42188b7a3958f0de611d30bbfb275034b42ed1c0 Author: Konstantinos Poulios AuthorDate: Mon Dec 5 09:15:57 2022 +0100 Fix broken lapack interface on BigEndian architectures Closes bug #63413 --- src/gmm/gmm_lapack_interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmm/gmm_lapack_interface.h b/src/gmm/gmm_lapack_interface.h index 37bc48f5..fa38addf 100644 --- a/src/gmm/gmm_lapack_interface.h +++ b/src/gmm/gmm_lapack_interface.h @@ -105,7 +105,7 @@ namespace gmm { size_type lu_factor(dense_matrix , lapack_ipvt ){ \ GMMLAPACK_TRACE("getrf_interface"); \ BLAS_INT m = BLAS_INT(mat_nrows(A)), n = BLAS_INT(mat_ncols(A)), lda(m); \ -long info(-1L); \ +BLAS_INT info(-1); \ if (m && n) lapack_name(, , (0,0), , ipvt.pfirst(), );\ if ((sizeof(BLAS_INT) == 4) ||\ ((info & 0xL) && !(info & 0xL))) \
[Getfem-commits] [getfem-commits] branch master updated: White space, typos and coding style
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 c6b5391e White space, typos and coding style c6b5391e is described below commit c6b5391e8914baf6cb11e165fda2e6d88cb4208c Author: Konstantinos Poulios AuthorDate: Mon Dec 19 00:47:14 2022 +0100 White space, typos and coding style --- interface/src/gf_mesh_fem.cc | 94 +- src/getfem/dal_static_stored_objects.h | 2 +- src/getfem/getfem_global_function.h| 2 +- src/getfem_context.cc | 79 ++-- src/gmm/gmm_blas_interface.h | 2 +- 5 files changed, 90 insertions(+), 89 deletions(-) diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc index 4fd49809..7cc1b6a0 100644 --- a/interface/src/gf_mesh_fem.cc +++ b/interface/src/gf_mesh_fem.cc @@ -41,10 +41,10 @@ using namespace getfemint; struct sub_gf_mf : 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, - const getfem::mesh *mm, - std::shared_ptr , - unsigned q_dim) = 0; + getfemint::mexargs_out& out, + const getfem::mesh *mm, + std::shared_ptr , + unsigned q_dim) = 0; }; typedef std::shared_ptr psub_command; @@ -53,19 +53,19 @@ 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_mf { \ - virtual void run(getfemint::mexargs_in& in, \ - getfemint::mexargs_out& out, \ - const getfem::mesh *mm, \ - std::shared_ptr , \ - unsigned q_dim) \ - { dummy_func(in); dummy_func(out); dummy_func(mm); \ - dummy_func(q_dim); 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_mf {\ + virtual void run(getfemint::mexargs_in& in, \ + getfemint::mexargs_out& out, \ + const getfem::mesh *mm, \ + std::shared_ptr , \ + unsigned q_dim) \ + { dummy_func(in); dummy_func(out); dummy_func(mm);\ +dummy_func(q_dim); 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; \ } /*@INIT MF = ('.mesh', @tmesh m[, @int Qdim1=1[, @int Qdim2=1, ...]]) @@ -78,7 +78,7 @@ template static inline void dummy_func(T &) {} Returns the handle of the created object. @*/ void gf_mesh_fem(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; @@ -94,15 +94,15 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in, ("load", 1, 2, 0, 1, std::string fname = in.pop().to_string(); if (in.remaining()) { -mm = extract_mesh_object(in.pop()); -mmf = std::make_shared(*mm, q_dim); + mm = extract_mesh_object(in.pop()); + mmf = std::make_shared(*mm, q_dim); } else { -auto m = std::make_shared(); -m->read_from_file(fname); -store_mesh_object(m); -mm = m.get(); -mmf = std::make_shared(*mm, q_dim); -workspace().add_hidden_object(store_meshfem_object(mmf), m); + auto m = std::make_shared(); + m->read_from_file(fname); + store_mesh_object(m); + mm = m.get(); + mmf = std::make_shared(*mm, q_dim); + workspace().add_hidden_object(store_meshfem_object(mmf), m); }
[Getfem-commits] (no subject)
branch: lapack-interface-simplifications commit b8f8a7f2548ef0de60b0ac5bb24b5e37b4ae30dc Author: Konstantinos Poulios AuthorDate: Sun Dec 18 22:53:01 2022 +0100 Drop runtime handling of int64 lapack and fix lapack type at compile time --- src/gmm/gmm_dense_lu.h | 68 +++--- src/gmm/gmm_lapack_interface.h | 14 - src/gmm/gmm_opt.h | 2 +- 3 files changed, 24 insertions(+), 60 deletions(-) diff --git a/src/gmm/gmm_dense_lu.h b/src/gmm/gmm_dense_lu.h index 33fbbcb1..dd3470e2 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(void) const {} -void begin(void) {} -void end(void) const {} -void end(void) {} - - 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_LAPACK) || defined(GMM_USES_ATLAS) + typedef std::vector lapack_ipvt; +#else + typedef std::vector lapack_ipvt; +#endif /** LU Factorization of a general (dense) matrix (real or complex). @@ -125,23 +89,24 @@ 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)); size_type NN = std::min(M, N); 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)); @@ -151,7 +116,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; } @@ -165,7 +130,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.*/ @@ -193,7 +158,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 = pvector.get(i-1)-1; // permutations stored in 1's offset + size_type perm = size_type(pvector[i-1]-1); // permutations stored in 1's offset if(i-1 != perm) { T aux = x[i-1]; x[i-1] = x[perm]; x[perm] = aux; } } } @@ -263,11 +228,12 @@ namespace gmm { typename linalg_traits::value_type lu_det(const DenseMatrixLU& LU, const Pvector ) { typedef typename linalg_traits::value_type T; +typedef typename linalg_traits::value_type INT;
[Getfem-commits] [getfem-commits] branch lapack-interface-simplifications created (now b8f8a7f2)
logari81 pushed a change to branch lapack-interface-simplifications. at b8f8a7f2 Drop runtime handling of int64 lapack and fix lapack type at compile time This branch includes the following new commits: new b8f8a7f2 Drop runtime handling of int64 lapack and fix lapack type at compile time
[Getfem-commits] [getfem-commits] branch master updated: Implement bspline basis functions for mesh_fem in 2D
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 e7f75a1f Implement bspline basis functions for mesh_fem in 2D e7f75a1f is described below commit e7f75a1f61aae4dbad4a1104bea142c3866535df Author: Konstantinos Poulios AuthorDate: Mon Dec 19 01:02:37 2022 +0100 Implement bspline basis functions for mesh_fem in 2D --- src/getfem/getfem_global_function.h | 5 + src/getfem/getfem_mesh_fem_global_function.h | 11 + src/getfem_global_function.cc| 556 ++- src/getfem_mesh_fem_global_function.cc | 61 ++- 4 files changed, 629 insertions(+), 4 deletions(-) diff --git a/src/getfem/getfem_global_function.h b/src/getfem/getfem_global_function.h index 45ddd562..75fe122a 100644 --- a/src/getfem/getfem_global_function.h +++ b/src/getfem/getfem_global_function.h @@ -320,6 +320,11 @@ namespace getfem { global_function_on_level_sets(const std::vector , const pxy_function ); + pglobal_function + global_function_bspline(scalar_type , scalar_type , + scalar_type , scalar_type , + size_type , + size_type , size_type ); } /* end of namespace getfem.*/ diff --git a/src/getfem/getfem_mesh_fem_global_function.h b/src/getfem/getfem_mesh_fem_global_function.h index e4686c77..65982de4 100644 --- a/src/getfem/getfem_mesh_fem_global_function.h +++ b/src/getfem/getfem_mesh_fem_global_function.h @@ -62,6 +62,17 @@ namespace getfem { virtual ~mesh_fem_global_function() { clear(); } }; + /** This function will generate bspline basis functions in an NX x NY + rectilinear grid. The generated basis spans the entire bounding + box of the mesh linked by mf. The function will finally set the + generated bspline basis functions as the basis of mf. + In case mim is provided, this integration method will be used to + determine the support of he basis functions. + */ + void define_bspline_basis_functions_for_mesh_fem + (mesh_fem_global_function , + size_type NX, size_type NY, size_type order, + const mesh_im =dummy_mesh_im()); } /* end of namespace getfem.*/ diff --git a/src/getfem_global_function.cc b/src/getfem_global_function.cc index d552e188..e96503c6 100644 --- a/src/getfem_global_function.cc +++ b/src/getfem_global_function.cc @@ -1,7 +1,7 @@ /*=== - Copyright (C) 2004-2020 Yves Renard - Copyright (C) 2016-2020 Konstantinos Poulios + Copyright (C) 2004-2022 Yves Renard + Copyright (C) 2016-2022 Konstantinos Poulios This file is a part of GetFEM @@ -831,6 +831,558 @@ namespace getfem { return std::make_shared(ls, fn); } + + + + // Global function for bspline basis + const scalar_type eps(1e-12); + + // order k = 3 + scalar_type bsp3_01(scalar_type t) { +return (t >= -eps && t < 1) ? pow(1.-t,2) +: 0; + } + scalar_type bsp3_01_der(scalar_type t) { +return (t >= -eps && t < 1) ? 2.*t-2. +: 0; + } + scalar_type bsp3_01_der2(scalar_type t) { +return (t >= eps && t <= 1.-eps) ? 2. + : 0; + } + scalar_type bsp3_01_der2_with_hint(scalar_type t, scalar_type t_hint) { +return (t > -eps && t < 1.+eps && t_hint > 0 && t_hint < 1) ? 2. +: 0; + } + scalar_type bsp3_02(scalar_type t) { +if (t >= -eps) { + if (t < 1) +return (-1.5*t+2.)*t; + else if (t < 2) +return 0.5*pow(2.-t,2); +} +return 0; + } + scalar_type bsp3_02_der(scalar_type t) { +if (t >= -eps) { + if (t < 1) +return -3.*t+2.; + else if (t < 2) +return t-2.; +} +return 0; + } + scalar_type bsp3_02_der2(scalar_type t) { +if (t >= eps) { + if (t < 1.-eps) +return -3.; + else if (t < 1.+eps) +return 0; + else if (t <= 2.-eps) +return 1.; +} +return 0; + } + scalar_type bsp3_03(scalar_type t) { +if (t >= -eps) { + if (t < 1) { +return 0.5*t*t; + } else if (t < 2) { +t -= 1.; +return t*(1-t)+0.5; + } else if (t < 3) { +t = 3.-t; +return 0.5*t*t; + } +} +return 0; + } + scalar_type bsp3_03_der(scalar_type t) { +if (t >= -eps) { + if (t < 1) { +return t; + } else if (t < 2) { +t -= 1.; +return 1.-2.*t; + } else if (t < 3) { +return t-3.; + } +} +return 0; + } + scalar_type bsp3_03_der2(scalar_type t) { +if (t >= -eps) { + if (t < eps) +return 0; + else if
[Getfem-commits] [getfem-commits] branch master updated: Add scripting interface for creating mesh_fem with bspline basis functions
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 e4c954d0 Add scripting interface for creating mesh_fem with bspline basis functions e4c954d0 is described below commit e4c954d07f5184de4fd00f82c7055150c7ba069d Author: Konstantinos Poulios AuthorDate: Mon Dec 19 01:03:59 2022 +0100 Add scripting interface for creating mesh_fem with bspline basis functions --- interface/src/gf_mesh_fem.cc | 18 ++ 1 file changed, 18 insertions(+) diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc index 7cc1b6a0..6b245acf 100644 --- a/interface/src/gf_mesh_fem.cc +++ b/interface/src/gf_mesh_fem.cc @@ -226,6 +226,24 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in, ); +/*@INIT MF = ('bspline', @tmesh m, @int NX, @int NY, @int order) + Create a @tmf on mesh `m`, whose basis functions are global functions + corresponding to bspline basis of order `order`, in an NX x NY grid + that spans the entire bounding box of `m`. @*/ +sub_command + ("bspline", 3, 4, 0, 1, + mm = extract_mesh_object(in.pop()); + size_type NX = in.pop().to_integer(1,1000); + size_type NY = in.pop().to_integer(1,1000); + size_type order = in.pop().to_integer(3,5); + + auto mfgf = std::make_shared(*mm); + mfgf->set_qdim(1.); + define_bspline_basis_functions_for_mesh_fem(*mfgf, NX, NY, order); + mmf = mfgf; + ); + + /*@INIT MF = ('partial', @tmf mf, @ivec DOFs[, @ivec RCVs]) Build a restricted @tmf by keeping only a subset of the degrees of freedom of `mf`.
[Getfem-commits] [getfem-commits] branch master updated: Fix incompatibility with older versions of the qhull header files
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 fc7187f3 Fix incompatibility with older versions of the qhull header files fc7187f3 is described below commit fc7187f3947075068d2679bd6ef89d837768ff88 Author: Konstantinos Poulios AuthorDate: Wed Jan 25 00:17:21 2023 +0100 Fix incompatibility with older versions of the qhull header files --- src/bgeot_convex_ref.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bgeot_convex_ref.cc b/src/bgeot_convex_ref.cc index 8047203c..5bf6f581 100644 --- a/src/bgeot_convex_ref.cc +++ b/src/bgeot_convex_ref.cc @@ -38,7 +38,9 @@ namespace bgeot { } # else + extern "C" { // old versions of this header lack a __cplusplus guard # include + } void qhull_delaunay(const std::vector , gmm::dense_matrix& simplexes) {
[Getfem-commits] [getfem-commits] branch master updated: Improve implementation of uniform bspline mesh_fem and add a unit test
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 e2bec5f1 Improve implementation of uniform bspline mesh_fem and add a unit test e2bec5f1 is described below commit e2bec5f19452db681c12ecf69c306369f3501aa9 Author: Konstantinos Poulios AuthorDate: Sun Jan 15 23:50:10 2023 +0100 Improve implementation of uniform bspline mesh_fem and add a unit test --- interface/src/gf_mesh_fem.cc | 82 ++- interface/tests/python/Makefile.am | 2 + interface/tests/python/check_bspline_mesh_fem.py | 162 src/getfem/getfem_global_function.h | 12 +- src/getfem/getfem_mesh_fem_global_function.h | 44 +++- src/getfem_global_function.cc| 98 +++- src/getfem_mesh_fem_global_function.cc | 298 +++ 7 files changed, 632 insertions(+), 66 deletions(-) diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc index 6b245acf..93f33046 100644 --- a/interface/src/gf_mesh_fem.cc +++ b/interface/src/gf_mesh_fem.cc @@ -213,33 +213,95 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in, if (in.remaining() && in.front().is_integer()) q_dim = in.pop().to_integer(1,256); - std::vector vfunc(size_type(in_gf.narg())); - for (size_type i = 0; i < vfunc.size(); ++i) { + std::vector vfuncs(size_type(in_gf.narg())); + for (auto : vfuncs) { getfem::pxy_function s = to_global_function_object(in_gf.pop()); - vfunc[i] = getfem::global_function_on_level_set(*pls, s); + vfunc = getfem::global_function_on_level_set(*pls, s); } auto mfgf = std::make_shared(*mm); mfgf->set_qdim(dim_type(q_dim)); - mfgf->set_functions(vfunc); + mfgf->set_functions(vfuncs); mmf = mfgf; ); -/*@INIT MF = ('bspline', @tmesh m, @int NX, @int NY, @int order) - Create a @tmf on mesh `m`, whose basis functions are global functions +/*@INIT MF = ('bspline_uniform', @tmesh m, @int NX[, @int NY,] @int order[, @str bcX_low[, @str bcY_low[, @str bcX_high][, @str bcY_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 - that spans the entire bounding box of `m`. @*/ + (just NX in 1s) 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'. @*/ sub_command - ("bspline", 3, 4, 0, 1, + ("bspline_uniform", 3, 8, 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"); size_type NX = in.pop().to_integer(1,1000); - size_type NY = 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 order = in.pop().to_integer(3,5); + std::string bcx_low("free"); + std::string bcy_low("free"); + std::string bcx_high(""); + std::string bcy_high(""); + if (in.remaining()) bcx_low = in.pop().to_string(); + if (dim == 2 && in.remaining()) bcy_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"); + getfem::bspline_boundary bcX_low(getfem::bspline_boundary::FREE); + getfem::bspline_boundary bcY_low(getfem::bspline_boundary::FREE); + getfem::bspline_boundary bcX_high(getfem::bspline_boundary::FREE); + getfem::bspline_boundary bcY_high(getfem::bspline_boundary::FREE); + if (bcx_low == "periodic") + bcX_high = bcX_low = getfem::bspline_boundary::PERIODIC; + else if (bcx_low == "symmetry") + bcX_high = bcX_low = getfem::bspline_boundary::SYMMETRY; + else if (bcx_low != "free") + THROW_ERROR("Unknown boundary condition " << bcx_low); + + if (bcy_low == "periodic") + bcY_high = bcY_low = getfem::bspline_boundary::PERIODIC; + else if (bcy_low == "symmetry") + bcY_high = bcY_low = getfem::bspline_boundary::SYMMETRY; + else if (bcy_low != "free") + THROW_ERROR("Unknown boundary condition " << bcy_low); + + if (!bcx_high.empty()) { + if (bcx_high == "periodic") + bcX_high = getfem::bspline_boundary::PERIODIC; + else if (bcx_high ==
[Getfem-commits] [getfem-commits] fixmisspell updated (ed420f9d -> f6bfdffd)
logari81 pushed a change to branch fixmisspell. from ed420f9d Merge remote-tracking branch 'origin/master' into fixmisspell add c6524253 towards release 5.4.2 add e29c6e03 towards release 5.4.2 add 0256e321 towards release 5.4.2 add 084f9aed towards release 5.4.2 add 89e50dbd Python version 3 in auxiliary scripts add f903c1ee work in progress add df62d419 Fix typos add 20c315d5 minor fix add 3a613b80 towards release 5.4.2 add 76a75614 Fix issue from #89e50dbd add 7a26ce81 small improvment add 494de109 fix bug in simplexification of pyramid elements add 63276e89 Merge branch 'master' into devel-logari81 add ea6f2828 Cosmetic changes and typo fix add d36b1a36 Stricter checks in the use of mesh regions add 5df388a5 Remove unused mesh_region option add 537a96f6 Minor improvements in finite strain plasticity brick and new demos add 5f31268e Merge branch 'master' into devel-logari81 add d87054dd Merge branch 'master' into devel-logari81 add d9bcc35a Merge branch 'master' into devel-logari81 add 60d7d962 Fix wrong point size in mesh method add ac2c3acb Merge remote-tracking branch 'origin/devel-logari81' add 287ad65e little fix on ga_instruction_contraction_switch add 52929dd8 minor modifications for 5.4.2 release add 59601b43 an intermediary working version add 82a1d106 minor modification add e6e0fc4a removing GMM_USES_BLAS_INTERFACE add 134e0599 small add add 3ca72e10 towards release 5.4.2 add c42e6d2e minor fixes add 49aedfae fix a problem with a non adaptation of mim to mesh change add a499492e Add const attribute to class member function add 8cfa3b3b Typo fix and documentation improvements add f50e3cba Allow integration point variables for GWFL assembly in the scripting interface add 2a1dd105 Relax convergence threshold for inverse geometric transformation add 108702a6 Replace deprecated distutils with setuptools add 42188b7a Fix broken lapack interface on BigEndian architectures add c6b5391e White space, typos and coding style add e7f75a1f Implement bspline basis functions for mesh_fem in 2D add e4c954d0 Add scripting interface for creating mesh_fem with bspline basis functions add c49e989c Fix GWFL bug in ga_node_grad for elementary transformations add 5dd7219d Just white space changes add e2bec5f1 Improve implementation of uniform bspline mesh_fem and add a unit test add f6bfdffd Fix some compilation warning No new revisions were added by this update. Summary of changes: INSTALL| 24 +- README |2 +- bin/extract_doc|6 +- bin/split_cmdref |2 +- configure.ac | 24 +- contrib/continuum_mechanics/Makefile.am| 12 +- ...icity_fin_strain_lin_hardening_axisymmetric.py} |0 ...icity_fin_strain_lin_hardening_plane_strain.py} | 36 +- doc/doxygen/Doxyfile |2 +- doc/sphinx/Makefile.am |2 +- doc/sphinx/source/.templates/download.html |6 +- doc/sphinx/source/.templates/indexcontent.html |2 +- doc/sphinx/source/replaces.txt |6 +- doc/sphinx/source/userdoc/bfem.rst | 50 +- doc/sphinx/source/userdoc/bmesh.rst|2 +- doc/sphinx/source/whatsnew/5.4.2.rst | 17 + doc/sphinx/source/whatsnew/index.rst |1 + doc/web/index.php |4 +- extract_gmm++ |7 +- interface/src/getfemint.h | 140 +- interface/src/gf_asm.cc| 13 +- interface/src/gf_mesh_fem.cc | 180 +- interface/src/python/Makefile.am |2 +- interface/src/python/getfem_python.c |4 +- interface/src/python/setup.py.in |6 +- interface/tests/matlab-octave/check_all_octave.sh |2 +- interface/tests/matlab-octave/demo_refine.m|2 +- interface/tests/python/Makefile.am |8 +- interface/tests/python/check_bspline_mesh_fem.py | 162 + .../python/demo_fluide_structure_interaction.py| 205 +- interface/tests/python/demo_laplacian.py | 42 +- m4/ac_python_devel.m4 | 185 - m4/ax_python_devel.m4 | 416 ++ src/bgeot_geotrans_inv.cc |4 +- src/getfem/dal_static_stored_objects.h |2 +- src/getfem/getfem_config.h |2 +- src/getfem/getfem_derivatives.h|2 +- src/getfem/getfem_generic_assembly_tree.h |2 +-
[Getfem-commits] [getfem-commits] branch master updated: Fix some compilation warning
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 f6bfdffd Fix some compilation warning f6bfdffd is described below commit f6bfdffdcde67b724b80480c813267b841a61821 Author: Konstantinos Poulios AuthorDate: Mon Jan 16 00:44:10 2023 +0100 Fix some compilation warning --- interface/src/gf_asm.cc | 7 ++-- src/getfem_assembling_tensors.cc| 4 +-- src/getfem_generic_assembly_semantic.cc | 62 + src/getfem_generic_assembly_tree.cc | 15 +--- src/gmm/gmm_MUMPS_interface.h | 4 +++ tests/cyl_slicer.cc | 4 +++ tests/test_mesh.cc | 34 +- 7 files changed, 75 insertions(+), 55 deletions(-) diff --git a/interface/src/gf_asm.cc b/interface/src/gf_asm.cc index 1824fe01..7a4da996 100644 --- a/interface/src/gf_asm.cc +++ b/interface/src/gf_asm.cc @@ -1368,8 +1368,11 @@ void gf_asm(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { mf_coeff = to_meshfem_object(argin); vec_coeff = in.pop().to_darray(); in.last_popped().check_trailing_dimension(int(mf_coeff->nb_dof())); - } else - vec_coeff = darray(new double(argin.to_scalar()), 1); + } else { + auto coeff = std::make_shared_array(1); + *coeff = argin.to_scalar(); + vec_coeff = darray(coeff.get(), 1); + } int option = in.remaining() ? in.pop().to_integer() : 1; double alpha = in.remaining() ? in.pop().to_scalar() : 1; darray vec_W; diff --git a/src/getfem_assembling_tensors.cc b/src/getfem_assembling_tensors.cc index d8a15d3a..6327ad9f 100644 --- a/src/getfem_assembling_tensors.cc +++ b/src/getfem_assembling_tensors.cc @@ -27,8 +27,8 @@ namespace getfem { size_type vdim_specif_list::nb_mf() const { -return std::count_if(begin(),end(), - std::mem_fun_ref(_specif::is_mf_ref)); +return std::count_if(begin(), end(), + std::mem_fn(_specif::is_mf_ref)); } size_type vdim_specif_list::nbelt() const { size_type sz = 1; diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index b6619f1a..ec3571a2 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -262,46 +262,39 @@ namespace getfem { break; case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST: case GA_NODE_INTERPOLATE_HESS_TEST: case GA_NODE_INTERPOLATE_DIVERG_TEST: -if (pexpr->node_type == GA_NODE_VAL_TEST) { - pnode->name = pexpr->name; -} else { - GMM_ASSERT1(false, - "Sorry, directional derivative do not work for the " - "moment with interpolate transformations. Future work."); -} +GMM_ASSERT1(pexpr->node_type == GA_NODE_VAL_TEST, +"Sorry, directional derivative does not work for the " +"moment with interpolate transformations. Future work."); +pnode->name = pexpr->name; +break; case GA_NODE_ELEMENTARY_VAL_TEST: case GA_NODE_ELEMENTARY_GRAD_TEST: case GA_NODE_ELEMENTARY_HESS_TEST: case GA_NODE_ELEMENTARY_DIVERG_TEST: -if (pexpr->node_type == GA_NODE_VAL_TEST) { - pnode->name = pexpr->name; -} else { - GMM_ASSERT1(false, - "Sorry, directional derivative do not work for the " - "moment with elementary transformations. Future work."); -} +GMM_ASSERT1(pexpr->node_type == GA_NODE_VAL_TEST, +"Sorry, directional derivative does not work for the " +"moment with elementary transformations. Future work."); +pnode->name = pexpr->name; +break; case GA_NODE_SECONDARY_DOMAIN_VAL_TEST: case GA_NODE_SECONDARY_DOMAIN_GRAD_TEST: case GA_NODE_SECONDARY_DOMAIN_HESS_TEST: case GA_NODE_SECONDARY_DOMAIN_DIVERG_TEST: -if (pexpr->node_type == GA_NODE_VAL_TEST) { - pnode->name = pexpr->name; -} else { - GMM_ASSERT1(false, - "Sorry, directional derivative do not work for the " - "moment with secondary domains. Future work."); -} +GMM_ASSERT1(pexpr->node_type == GA_NODE_VAL_TEST, +"Sorry, directional derivative does not work for the " +"moment with secondary domains. Future work."); +pnode->name = pexpr->name; +break; case GA_NODE_XFEM_PLUS_VAL_TEST: case GA_NODE_XFEM_PLUS_GRAD_TEST: case GA_NODE_XFEM_PLUS_HESS_TEST: case GA_NODE_XFEM_PLUS_DIVERG_TEST: case GA_NODE_XFEM_MINUS_VAL_TEST: case
[Getfem-commits] [getfem-commits] branch master updated: Fix bug in assembly with integration point variables on element faces
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 26c9792a Fix bug in assembly with integration point variables on element faces 26c9792a is described below commit 26c9792a39828f654f126b4d28810161d8686e57 Author: Konstantinos Poulios AuthorDate: Mon Jan 23 22:27:30 2023 +0100 Fix bug in assembly with integration point variables on element faces --- src/getfem_generic_assembly_compile_and_exec.cc | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index a7ec2bd5..e5517f49 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -4214,7 +4214,7 @@ namespace getfem { virtual int exec() { GA_DEBUG_INFO("Instruction: vector term assembly for im_data variable"); size_type cv = ctx.convex_num(); - size_type i = t.size() * imd.filtered_index_of_point(cv, ipt); + size_type i = t.size() * imd.filtered_index_of_point(cv, ctx.ii()); GMM_ASSERT1(i+t.size() <= I.size(), "Internal error "first(); - if (imd1) ifirst1 += s1 * imd1->filtered_index_of_point(cv1, ipt); + if (imd1) ifirst1 += s1 * imd1->filtered_index_of_point(cv1, ctx1.ii()); populate_contiguous_dofs_vector(dofs1, s1, ifirst1); // --> dofs1 size_type qmult2 = mf2->get_qdim(); @@ -4743,7 +4743,7 @@ namespace getfem { size_type s1 = t.sizes()[0], s2 = t.sizes()[1]; size_type cv1 = ctx1.convex_num(), cv2 = ctx2.convex_num(); size_type ifirst1 = I1->first(), ifirst2 = I2->first(); - if (imd2) ifirst2 += s2 * imd2->filtered_index_of_point(cv2, ipt); + if (imd2) ifirst2 += s2 * imd2->filtered_index_of_point(cv2, ctx2.ii()); size_type qmult1 = mf1->get_qdim(); if (qmult1 > 1) qmult1 /= mf1->fem_of_element(cv1)->target_dim(); @@ -4803,9 +4803,9 @@ namespace getfem { size_type s1 = t.sizes()[0], s2 = t.sizes()[1]; size_type ifirst1 = I1.first(), ifirst2 = I2.first(); if (imd1) -ifirst1 += s1 * imd1->filtered_index_of_point(ctx1.convex_num(), ipt); +ifirst1 += s1 * imd1->filtered_index_of_point(ctx1.convex_num(), ctx1.ii()); if (imd2) -ifirst2 += s2 * imd2->filtered_index_of_point(ctx2.convex_num(), ipt); +ifirst2 += s2 * imd2->filtered_index_of_point(ctx2.convex_num(), ctx2.ii()); populate_contiguous_dofs_vector(dofs2, s2, ifirst2); add_elem_matrix_contiguous_rows(K, ifirst1, s1, dofs2, elem, ninf*1E-14);
[Getfem-commits] [getfem-commits] branch master updated: Switch to reentrant qhull library interface (patch by Stefan Brüns)
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 264c7c5c Switch to reentrant qhull library interface (patch by Stefan Brüns) 264c7c5c is described below commit 264c7c5cef54b63ce199c4f245702625c2b8b03b Author: Konstantinos Poulios AuthorDate: Wed Jan 18 23:59:45 2023 +0100 Switch to reentrant qhull library interface (patch by Stefan Brüns) --- configure.ac| 8 src/bgeot_convex_ref.cc | 29 + 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index e9e18671..018bfd86 100644 --- a/configure.ac +++ b/configure.ac @@ -910,14 +910,14 @@ save_LIBS="$LIBS"; if test "x$useQHULL" = "xno"; then echo "Building with libqhull explicitly disabled"; else - AC_CHECK_LIB(qhull, qh_new_qhull, [QHULL_LIBS="-lqhull"], + AC_CHECK_LIB(qhull_r, qh_new_qhull, [QHULL_LIBS="-lqhull_r"], [ -AC_CHECK_LIB(qhullstatic, qh_new_qhull,[QHULL_LIBS="-lqhullstatic"],[QHULL_LIBS=""]) +AC_CHECK_LIB(qhullstatic_r, qh_new_qhull,[QHULL_LIBS="-lqhullstatic_r"],[QHULL_LIBS=""]) ]) - AC_CHECK_HEADERS(libqhull/qhull_a.h,[useQHULL="yes"], + AC_CHECK_HEADERS(libqhull_r/qhull_ra.h,[useQHULL="yes"], [ if test "x$useQHULL" = "xyes"; then - AC_MSG_ERROR([header files libqhull/qhull_a.h not found. Use --enable-qhull=no flag]); + AC_MSG_ERROR([header files libqhull_r/qhull_ra.h not found. Use --enable-qhull=no flag]); useQHULL="no" fi; ]) diff --git a/src/bgeot_convex_ref.cc b/src/bgeot_convex_ref.cc index 28e1776e..8047203c 100644 --- a/src/bgeot_convex_ref.cc +++ b/src/bgeot_convex_ref.cc @@ -30,7 +30,7 @@ namespace bgeot { //Interface with qhull // ** -# ifndef GETFEM_HAVE_LIBQHULL_QHULL_A_H +# if !defined(GETFEM_HAVE_LIBQHULL_R_QHULL_RA_H) void qhull_delaunay(const std::vector &, gmm::dense_matrix&) { GMM_ASSERT1(false, "Qhull header files not installed. " @@ -38,20 +38,7 @@ namespace bgeot { } # else - extern "C" { -// #ifdef _MSC_VER -# include -// #else -// # include -// # include -// # include -// # include -// # include -// # include -// # include -// # include -// #endif - } +# include void qhull_delaunay(const std::vector , gmm::dense_matrix& simplexes) { @@ -79,7 +66,9 @@ namespace bgeot { facetT *facet; /* set by FORALLfacets */ int curlong, totlong; /* memory remaining after qh_memfreeshort */ vertexT *vertex, **vertexp; -exitcode = qh_new_qhull (int(dim), int(pts.size()), [0], ismalloc, +qhT context = {}; +qhT* qh = +exitcode = qh_new_qhull (qh, int(dim), int(pts.size()), [0], ismalloc, flags, outfile, errfile); if (!exitcode) { /* if no error */ size_type nbf=0; @@ -92,14 +81,14 @@ namespace bgeot { size_type s=0; FOREACHvertex_(facet->vertices) { assert(s < (unsigned)(dim+1)); -simplexes(s++,nbf) = qh_pointid(vertex->point); +simplexes(s++,nbf) = qh_pointid(qh, vertex->point); } nbf++; } } } -qh_freeqhull(!qh_ALL); -qh_memfreeshort (, ); +qh_freeqhull(qh, !qh_ALL); +qh_memfreeshort(qh, , ); if (curlong || totlong) cerr << "qhull internal warning (main): did not free " << totlong << " bytes of long memory (" << curlong << " pieces)\n"; @@ -132,7 +121,7 @@ namespace bgeot { m.add_simplex(n, ipts.begin()); } }else { -# ifdef GETFEM_HAVE_LIBQHULL_QHULL_A_H +# if defined(GETFEM_HAVE_LIBQHULL_R_QHULL_RA_H) gmm::dense_matrix t; qhull_delaunay(cvr->points(), t); for (size_type nc = 0; nc < gmm::mat_ncols(t); ++nc) {
[Getfem-commits] [getfem-commits] branch master updated: Fix segmentation fault in Diff operator and add unit test
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 e74deb32 Fix segmentation fault in Diff operator and add unit test e74deb32 is described below commit e74deb32b28c27d032f6c57b25aeccfdc21c9db2 Author: Konstantinos Poulios AuthorDate: Fri Mar 10 18:43:46 2023 +0100 Fix segmentation fault in Diff operator and add unit test --- interface/tests/python/check_asm.py | 5 + src/getfem_generic_assembly_semantic.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/tests/python/check_asm.py b/interface/tests/python/check_asm.py index 21519427..fdd05c63 100644 --- a/interface/tests/python/check_asm.py +++ b/interface/tests/python/check_asm.py @@ -242,3 +242,8 @@ str = "Hess(u)"; print('\nAssembly string "%s" gives:' % str) res = gf.asm('expression analysis', str, mim, 1, md) if (res != "(Hess_u)"): print("Should be Hess_u"); exit(1) + +str = "Diff(u*Div(w),w,3*w)"; print('\nAssembly string "%s" gives:' % str) +res = gf.asm_expression_analysis(str, mim, md) +if (res != "(u*((3*Grad_w):[[1,0],[0,1]]))"): + print("Wrong Diff result"); exit(1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index ec3571a2..3106703e 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -182,7 +182,7 @@ namespace getfem { static void ga_node_expand_expression_in_place_of_test (ga_tree , const ga_workspace , - pga_tree_node , const std::string , + pga_tree_node pnode, const std::string , pga_tree_node pexpr, ga_tree _expr, ga_tree _expr, size_type order, const mesh , size_type ref_elt_dim, bool eval_fixed_size, bool ignore_X, int option) {
[Getfem-commits] [getfem-commits] branch master updated: Fix regression in the directional differentiation operator
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 b0e8b299 Fix regression in the directional differentiation operator b0e8b299 is described below commit b0e8b2992641f91306e8e470ff5b3337815c01a4 Author: Konstantinos Poulios AuthorDate: Thu Mar 23 00:04:10 2023 +0100 Fix regression in the directional differentiation operator --- interface/tests/python/check_asm.py | 9 +++-- src/getfem_generic_assembly_semantic.cc | 35 + 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/interface/tests/python/check_asm.py b/interface/tests/python/check_asm.py index fdd05c63..ccec3b15 100644 --- a/interface/tests/python/check_asm.py +++ b/interface/tests/python/check_asm.py @@ -244,6 +244,11 @@ if (res != "(Hess_u)"): print("Should be Hess_u"); exit(1) str = "Diff(u*Div(w),w,3*w)"; print('\nAssembly string "%s" gives:' % str) -res = gf.asm_expression_analysis(str, mim, md) -if (res != "(u*((3*Grad_w):[[1,0],[0,1]]))"): +res = gf.asm_expression_analysis(str, mim, 0, md) +if (res != "(u*(Trace((3*Grad_w"): + print("Wrong Diff result"); exit(1) + +str = "Diff((Grad_w+Grad_w'-Id(2)*u):Grad(w),u,Norm(v))"; print('\nAssembly string "%s" gives:' % str) +res = gf.asm_expression_analysis(str, mim, 0, md) +if (res != "((-([[1,0],[0,1]]*Norm(v))):Grad_w)"): print("Wrong Diff result"); exit(1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 3106703e..a770b139 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -233,31 +233,24 @@ namespace getfem { } switch(pnode->node_type) { case GA_NODE_VAL_TEST: -delete pnode; pnode = nullptr; -tree.copy_node(pexpr, parent, pnode); -break; case GA_NODE_GRAD_TEST: -delete pnode; pnode = nullptr; -tree.copy_node(grad_expr.root, parent, pnode); -break; case GA_NODE_HESS_TEST: -delete pnode; pnode = nullptr; -tree.copy_node(hess_expr.root, parent, pnode); -break; case GA_NODE_DIVERG_TEST: { - delete pnode; pnode = nullptr; - tree.copy_node(grad_expr.root, parent, pnode); - tree.insert_node(pnode, GA_NODE_OP); - pnode->parent->op_type = GA_COLON; - tree.add_child(pnode->parent, GA_NODE_PARAMS); - pga_tree_node pid = pnode->parent->children[1]; - tree.add_child(pid); - tree.add_child(pid); - pid->children[0]->node_type = GA_NODE_NAME; - pid->children[0]->name = "Id"; - pid->children[1]->node_type = GA_NODE_CONSTANT; - pid->children[1]->init_scalar_tensor(me.dim()); + pga_tree_node pnode_new = nullptr; + if (pnode->node_type == GA_NODE_VAL_TEST) +tree.copy_node(pexpr, parent, pnode_new); // allocates new + else if (pnode->node_type == GA_NODE_GRAD_TEST || + pnode->node_type == GA_NODE_DIVERG_TEST) +tree.copy_node(grad_expr.root, parent, pnode_new); // allocates new + else if (pnode->node_type == GA_NODE_HESS_TEST) +tree.copy_node(hess_expr.root, parent, pnode_new); // allocates new + parent->replace_child(pnode, pnode_new); + if (pnode->node_type == GA_NODE_DIVERG_TEST) { +tree.insert_node(pnode_new, GA_NODE_OP); +pnode_new->parent->op_type = GA_TRACE; + } + delete pnode; pnode = nullptr;// deallocates old } break; case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST:
[Getfem-commits] [getfem-commits] branch master updated: Just aesthetic changes
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 1c6decca Just aesthetic changes 1c6decca is described below commit 1c6deccaa278e2665d42f85ecc2b581fcd761913 Author: Konstantinos Poulios AuthorDate: Thu Mar 23 00:20:44 2023 +0100 Just aesthetic changes --- interface/tests/python/check_asm.py | 2 +- src/getfem/getfem_generic_assembly_tree.h | 18 ++ src/getfem_generic_assembly_semantic.cc | 55 --- src/getfem_generic_assembly_tree.cc | 26 +++ 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/interface/tests/python/check_asm.py b/interface/tests/python/check_asm.py index ccec3b15..e18b4038 100644 --- a/interface/tests/python/check_asm.py +++ b/interface/tests/python/check_asm.py @@ -33,7 +33,7 @@ import getfem as gf NX = 4 m = gf.Mesh('triangles grid', np.arange(0,1+1./NX,1./NX), -np.arange(0,1+1./NX,1./NX)) # Structured mesh + np.arange(0,1+1./NX,1./NX)) # Structured mesh fem = gf.Fem('FEM_PK(2,1)') mfu = gf.MeshFem(m, 1); mfu.set_fem(fem)# Lagrange P1 scalar fem mfv = gf.MeshFem(m, 3); mfv.set_fem(fem)# Lagrange P1 vector fem diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 4384b9fd..b3d2405b 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -470,14 +470,19 @@ namespace getfem { ga_tree() : root(nullptr), current_node(nullptr), secondary_domain() {} -ga_tree(const ga_tree ) : root(nullptr), current_node(nullptr), - secondary_domain(tree.secondary_domain) -{ if (tree.root) copy_node(tree.root, nullptr, root); } +ga_tree(const ga_tree ) + : root(nullptr), current_node(nullptr), +secondary_domain(tree.secondary_domain) +{ + if (tree.root) +copy_node(tree.root, nullptr, root); +} ga_tree =(const ga_tree ) { - clear(); secondary_domain = tree.secondary_domain; + clear(); + secondary_domain = tree.secondary_domain; if (tree.root) -copy_node(tree.root,nullptr,root); +copy_node(tree.root, nullptr, root); return *this; } @@ -494,8 +499,7 @@ namespace getfem { // Transform the expression of a node and its sub-nodes in the equivalent // assembly string sent to ostream str - void ga_print_node(const pga_tree_node pnode, - std::ostream ); + void ga_print_node(const pga_tree_node pnode, std::ostream ); // The same for the whole tree, the result is a std::string std::string ga_tree_to_string(const ga_tree ); diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index a770b139..8e75e3a7 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -119,8 +119,8 @@ namespace getfem { const std::string , const std::string , bool any_trans = false) { bool marked = false; -for (size_type i = 0; i < pnode->children.size(); ++i) - if (ga_node_mark_tree_for_variable(pnode->children[i], workspace, m, +for (pga_tree_node : pnode->children) + if (ga_node_mark_tree_for_variable(child, workspace, m, varname, interpolatename, any_trans)) marked = true; @@ -169,12 +169,10 @@ namespace getfem { workspace.interpolate_transformation(pnode->interpolate_name) ->extract_variables(workspace, vars, true, m, pnode->interpolate_name); - for (std::set::iterator it=vars.begin(); - it != vars.end(); ++it) { -if (it->varname.compare(varname) == 0 && -(any_trans || - it->transname.compare(interpolatename) == 0)) marked = true; - } + for (const var_trans_pair : vars) +if (pair.varname.compare(varname) == 0 && +(any_trans || pair.transname.compare(interpolatename) == 0)) + marked = true; } pnode->marked = marked; return marked; @@ -187,9 +185,9 @@ namespace getfem { size_type order, const mesh , size_type ref_elt_dim, bool eval_fixed_size, bool ignore_X, int option) { pga_tree_node parent = pnode->parent; -for (size_type i = 0; i < pnode->children.size(); ++i) +for (pga_tree_node : pnode->children) ga_node_expand_expression_in_place_of_test -(tree, workspace, pnode->children[i], varname, pexpr, grad_expr, +(tree, workspace, child, varname, pexpr, grad_expr, hess_expr, order, me, ref_elt_dim, eval_fixed_size, ignore_X, option); const std::string = pnode->name; size_type loc_order = pnode->test_function_type; @@ -253,14 +251,14 @@ namespace getfem { delete pnode; pnode = nullptr;
[Getfem-commits] [getfem-commits] branch master updated: Whitespace only
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 57d84b08 Whitespace only 57d84b08 is described below commit 57d84b087d1e2a0927f18016a00923ee1d1a2ab7 Author: Konstantinos Poulios AuthorDate: Thu Mar 23 20:11:18 2023 +0100 Whitespace only --- src/gmm/gmm_blas.h | 409 + src/gmm/gmm_dense_lu.h | 48 ++--- src/gmm/gmm_lapack_interface.h | 24 +-- 3 files changed, 248 insertions(+), 233 deletions(-) diff --git a/src/gmm/gmm_blas.h b/src/gmm/gmm_blas.h index e41b5da1..4426bb7d 100644 --- a/src/gmm/gmm_blas.h +++ b/src/gmm/gmm_blas.h @@ -45,14 +45,14 @@ namespace gmm { /* */ - /* */ - /* Generic algorithms*/ - /* */ + /* */ + /*Generic algorithms*/ + /* */ /* */ /* */ - /* Miscellaneous */ + /*Miscellaneous */ /* */ /** clear (fill with zeros) a vector or matrix. */ @@ -78,7 +78,7 @@ namespace gmm { template inline size_type nnz(const L& l, abstract_matrix) { return nnz(l, typename principal_orientation_type::sub_orientation>::potype()); + linalg_traits::sub_orientation>::potype()); } template inline size_type nnz(const L& l, row_major) { @@ -113,16 +113,16 @@ namespace gmm { template inline // to be optimized for dense vectors ... void fill(L& l, typename gmm::linalg_traits::value_type x, - abstract_vector) { +abstract_vector) { for (size_type i = 0; i < vect_size(l); ++i) l[i] = x; } template inline // to be optimized for dense matrices ... void fill(L& l, typename gmm::linalg_traits::value_type x, - abstract_matrix) { +abstract_matrix) { for (size_type i = 0; i < mat_nrows(l); ++i) for (size_type j = 0; j < mat_ncols(l); ++j) - l(i,j) = x; +l(i,j) = x; } /** fill a vector or matrix with random value (uniform [-1,1]). */ @@ -132,7 +132,7 @@ namespace gmm { ///@cond DOXY_SHOW_ALL_FUNCTIONS template inline void fill_random(const L& l) { fill_random(linalg_const_cast(l), - typename linalg_traits::linalg_type()); +typename linalg_traits::linalg_type()); } template inline void fill_random(L& l, abstract_vector) { @@ -143,7 +143,7 @@ namespace gmm { template inline void fill_random(L& l, abstract_matrix) { for (size_type i = 0; i < mat_nrows(l); ++i) for (size_type j = 0; j < mat_ncols(l); ++j) - l(i,j) = gmm::random(typename linalg_traits::value_type()); +l(i,j) = gmm::random(typename linalg_traits::value_type()); } ///@endcond @@ -157,19 +157,19 @@ namespace gmm { template inline void fill_random(const L& l, double cfill) { fill_random(linalg_const_cast(l), cfill, - typename linalg_traits::linalg_type()); +typename linalg_traits::linalg_type()); } template inline void fill_random(L& l, double cfill, abstract_vector) { typedef typename linalg_traits::value_type T; size_type ntot = std::min(vect_size(l), - size_type(double(vect_size(l))*cfill) + 1); + size_type(double(vect_size(l))*cfill) + 1); for (size_type nb = 0; nb < ntot;) { size_type i = gmm::irandom(vect_size(l)); if (l[i] == T(0)) { - l[i] = gmm::random(typename linalg_traits::value_type()); - ++nb; +l[i] = gmm::random(typename linalg_traits::value_type()); +++nb; } } } @@ -177,7 +177,7 @@ namespace gmm { template inline void fill_random(L& l, double cfill, abstract_matrix) { fill_random(l, cfill, typename principal_orientation_type::sub_orientation>::potype()); +linalg_traits::sub_orientation>::potype()); } template inline @@ -253,7 +253,7 @@ namespace gmm { /* */ - /* Scalar product*/ + /*Scalar product*/
[Getfem-commits] [getfem-commits] branch simplify-Div-derivative created (now 7b3338cb)
logari81 pushed a change to branch simplify-Div-derivative. at 7b3338cb Simplify directional derivative of Div This branch includes the following new commits: new 7b3338cb Simplify directional derivative of Div
[Getfem-commits] (no subject)
branch: simplify-Div-derivative commit 7b3338cb0f118cc9f318fd334bafaac1d210b2f7 Author: Konstantinos Poulios AuthorDate: Fri Mar 10 19:32:13 2023 +0100 Simplify directional derivative of Div --- interface/tests/python/check_asm.py | 2 +- src/getfem_generic_assembly_semantic.cc | 10 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/interface/tests/python/check_asm.py b/interface/tests/python/check_asm.py index fdd05c63..c2ef06c7 100644 --- a/interface/tests/python/check_asm.py +++ b/interface/tests/python/check_asm.py @@ -245,5 +245,5 @@ if (res != "(Hess_u)"): str = "Diff(u*Div(w),w,3*w)"; print('\nAssembly string "%s" gives:' % str) res = gf.asm_expression_analysis(str, mim, md) -if (res != "(u*((3*Grad_w):[[1,0],[0,1]]))"): +if (res != "(u*(Trace((3*Grad_w"): print("Wrong Diff result"); exit(1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 3106703e..11fa0dc2 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -249,15 +249,7 @@ namespace getfem { delete pnode; pnode = nullptr; tree.copy_node(grad_expr.root, parent, pnode); tree.insert_node(pnode, GA_NODE_OP); - pnode->parent->op_type = GA_COLON; - tree.add_child(pnode->parent, GA_NODE_PARAMS); - pga_tree_node pid = pnode->parent->children[1]; - tree.add_child(pid); - tree.add_child(pid); - pid->children[0]->node_type = GA_NODE_NAME; - pid->children[0]->name = "Id"; - pid->children[1]->node_type = GA_NODE_CONSTANT; - pid->children[1]->init_scalar_tensor(me.dim()); + pnode->parent->op_type = GA_TRACE; } break; case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST:
[Getfem-commits] [getfem-commits] branch master updated: Fix non-UTF8 file encodings
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 e41de9db Fix non-UTF8 file encodings e41de9db is described below commit e41de9dbc9a1172ad6b2025ecfee860c0e90e327 Author: Konstantinos Poulios AuthorDate: Wed Jun 14 20:55:13 2023 +0200 Fix non-UTF8 file encodings --- src/bgeot_geotrans_inv.cc| 4 ++-- src/getfem/bgeot_sparse_tensors.h| 38 src/getfem/getfem_assembling_tensors.h | 2 +- src/getfem/getfem_mesher.h | 6 ++--- src/getfem_contact_and_friction_nodal.cc | 2 +- src/getfem_error_estimate.cc | 4 ++-- src/getfem_mat_elem.cc | 4 ++-- src/getfem_mesh_slicers.cc | 2 +- src/gmm/gmm_solver_idgmres.h | 32 +-- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index f6301fdb..175fbfb0 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -99,8 +99,8 @@ namespace bgeot gmm::mult(K, CS, B); } else { - // L'inversion peut �tre optimis�e par le non calcul global de B - // et la resolution d'un syst�me lin�aire. + // L'inversion peut être optimisée par le non calcul global de B + // et la resolution d'un système linéaire. base_matrix KT(K.nrows(), K.ncols()); pgt->compute_K_matrix(G, pc, KT); gmm::copy(gmm::transposed(KT), K); diff --git a/src/getfem/bgeot_sparse_tensors.h b/src/getfem/bgeot_sparse_tensors.h index d2283811..768f9b92 100644 --- a/src/getfem/bgeot_sparse_tensors.h +++ b/src/getfem/bgeot_sparse_tensors.h @@ -76,7 +76,7 @@ namespace bgeot { typedef gmm::uint32_type index_type; - typedef gmm::int32_type stride_type; /* sign�! */ + typedef gmm::int32_type stride_type; /* signé! */ // typedef std::vector tensor_ranges; class tensor_ranges : public std::vector { @@ -313,7 +313,7 @@ namespace bgeot { tensor_mask_container masks_; /* verifie si un masque est completement vide, - si c'est le cas alors tous les autres masques sont vid�s + si c'est le cas alors tous les autres masques sont vidés (le tenseur est identiquement nul) */ void check_empty_mask() { if (card() == 0) { @@ -506,13 +506,13 @@ namespace bgeot { update_idx2mask(); } -/* forme d'une tranche (c'est la forme qu'on applique � un tenseur pour +/* forme d'une tranche (c'est la forme qu'on applique à un tenseur pour en extraire la tranche) */ tensor_shape slice_shape(tensor_mask::Slice slice) const { assert(slice.dim < ndim() && slice.i0 < dim(slice.dim)); tensor_shape ts(ndim()); ts.push_mask(tensor_mask(dim(slice.dim), slice)); - ts.merge(*this); /* le masque peut se retrouver brutalement vid� si on a tranch� au mauvais endroit! */ + ts.merge(*this); /* le masque peut se retrouver brutalement vidé si on a tranché au mauvais endroit! */ return ts; } @@ -548,8 +548,8 @@ namespace bgeot { */ class tensor_ref : public tensor_shape { std::vector< tensor_strides > strides_; -TDIter *pbase_; /* pointeur sur un pointeur qui designe les donn�es - �a permet de changer la base pour toute une serie +TDIter *pbase_; /* pointeur sur un pointeur qui designe les données + ça permet de changer la base pour toute une serie de tensor_ref en un coup */ stride_type base_shift_; @@ -578,7 +578,7 @@ namespace bgeot { -/* s'assure que le stride du premier indice est toujours bien �gal � z�ro */ +/* s'assure que le stride du premier indice est toujours bien égal à zéro */ void ensure_0_stride() { for (index_type i=0; i < strides_.size(); ++i) { if (strides_[i].size() >= 1 && strides_[i][0] != 0) { @@ -589,8 +589,8 @@ namespace bgeot { } } -/* constructeur � partir d'une forme : ATTENTION ce constructeur n'alloue pas la - m�moire n�cessaire pour les donn�es !! */ +/* constructeur à partir d'une forme : ATTENTION ce constructeur n'alloue pas la + mémoire nécessaire pour les données !! */ explicit tensor_ref(const tensor_shape& ts) : tensor_shape(ts), pbase_(0), base_shift_(0) { strides_.reserve(16); init_strides(); @@ -614,8 +614,8 @@ namespace bgeot { void set_sub_tensor(const tensor_ref& tr, const tensor_shape& sub); -/* constructeur � partir d'un sous-tenseur � partir d'un tenseur et d'une forme - hypothese: la forme 'sub' doit �tre un sous-ensemble de la forme du tenseur +/* constructeur à partir d'un sous-tenseur à partir d'un tenseur et d'une forme + hypothese: la forme 'sub' doit être un sous-ensemble de la forme du tenseur */
[Getfem-commits] [getfem-commits] branch master updated: Improve input check in scripting interface, fix broken link
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 72735599 Improve input check in scripting interface, fix broken link 72735599 is described below commit 727355998c9eaf10de1854a90a13cffea80b6c69 Author: Konstantinos Poulios AuthorDate: Wed Jun 14 18:59:26 2023 +0200 Improve input check in scripting interface, fix broken link --- doc/sphinx/source/links.rst | 4 ++-- interface/src/gf_model_get.cc | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/sphinx/source/links.rst b/doc/sphinx/source/links.rst index db5d9916..2f77430a 100644 --- a/doc/sphinx/source/links.rst +++ b/doc/sphinx/source/links.rst @@ -12,8 +12,8 @@ Some related links Jean Garrigues courses (in french) -- -.. |link1| replace:: http://jgarrigues.perso.egim-mrs.fr/ef.html -.. _link1: http://jgarrigues.perso.egim-mrs.fr/ef.html +.. |link1| replace:: http://jean.garrigues.perso.centrale-marseille.fr +.. _link1: http://jean.garrigues.perso.centrale-marseille.fr |link1|_ diff --git a/interface/src/gf_model_get.cc b/interface/src/gf_model_get.cc index cf79d783..7f955eeb 100644 --- a/interface/src/gf_model_get.cc +++ b/interface/src/gf_model_get.cc @@ -259,6 +259,8 @@ void gf_model_get(getfemint::mexargs_in& m_in, } else { darray st = in.pop().to_darray(); std::vector PTS(st.begin(), st.end()); + GMM_ASSERT1(in.remaining() && is_mesh_object(in.front()), + "Expecting mesh object after points for interpolation"); const getfem::mesh *m = extract_mesh_object(in.pop()); size_type N = m->dim(); size_type nbpoints = gmm::vect_size(PTS) / N;
[Getfem-commits] [getfem-commits] branch cleanup-mesh-import created (now 69884dd4)
logari81 pushed a change to branch cleanup-mesh-import. at 69884dd4 Change default treatment of overlapping nodes and cleanup of mesh import This branch includes the following new commits: new 69884dd4 Change default treatment of overlapping nodes and cleanup of mesh import
[Getfem-commits] (no subject)
branch: cleanup-mesh-import commit 69884dd486e8e68d7bcdb502f2843c5131c5a91e Author: Konstantinos Poulios AuthorDate: Wed Aug 2 23:14:40 2023 +0200 Change default treatment of overlapping nodes and cleanup of mesh import --- src/getfem/getfem_import.h | 62 --- src/getfem_import.cc | 439 ++--- 2 files changed, 248 insertions(+), 253 deletions(-) diff --git a/src/getfem/getfem_import.h b/src/getfem/getfem_import.h index 10210207..cad32fd0 100644 --- a/src/getfem/getfem_import.h +++ b/src/getfem/getfem_import.h @@ -76,9 +76,9 @@ namespace getfem { parametrization of the mesh in Gmsh .geo file must assign a different number to each region, the problem exists because in Gmsh can coexist, for example, "Physical Surface (200)" and - "Physical Line (200)", as they are different "types of regions" - in Gmsh, that which does not occur in GetFEM since there is - only one "type of region". + "Physical Line (200)", as they are different types of regions + in Gmsh, which cannot occur in GetFEM since there is only one + type of region. - "cdb" for meshes generated by ANSYS (in blocked format). @@ -103,11 +103,19 @@ namespace getfem { - "am_fmt" for 2D meshes from emc2 [http://pauillac.inria.fr/cdrom/prog/unix/emc2/eng.htm] + + For all mesh formats, overlapping nodes are preserved by default. + In order to merge overlapping nodes during the import, add + ":merge_overlapping_nodes" to the format specifier. + For example: +"gmsh:merge_overlapping_nodes" +"cdb:merge_overlapping_nodes" +"cdb:3:merge_overlapping_nodes" */ void import_mesh(const std::string& filename, const std::string& format, - mesh& m); + mesh& m); void import_mesh(std::istream& f, const std::string& format, - mesh& m); + mesh& m); void import_mesh(const std::string& filename, mesh& m); /** Import a mesh file in format generated by Gmsh. @@ -140,38 +148,42 @@ namespace getfem { be tested. */ void import_mesh_gmsh(const std::string& filename, mesh& m, -std::map _map, +bool add_all_element_type = false, +std::set *lower_dim_convex_rg = nullptr, +std::map *region_map = nullptr, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - - void import_mesh_gmsh(std::istream& f, mesh& m, +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false); + void import_mesh_gmsh(const std::string& filename, mesh& m, std::map _map, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - - void import_mesh_gmsh(const std::string& filename, mesh& m, +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false) { +import_mesh_gmsh(filename, m, false, nullptr, _map, + remove_last_dimension, nodal_map, merge_overlapping_nodes); + } + void import_mesh_gmsh(std::istream& f, mesh& m, bool add_all_element_type = false, -std::set *lower_dim_convex_rg = NULL, -std::map *region_map = NULL, +std::set *lower_dim_convex_rg = nullptr, +std::map *region_map = nullptr, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false); void import_mesh_gmsh(std::istream& f, mesh& m, -bool add_all_element_type = false, -std::set *lower_dim_convex_rg = NULL, -std::map *region_map = NULL, +std::map _map, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false) { +import_gmsh_mesh(f, m, false, nullptr, _map, + remove_last_dimension, nodal_map, merge_overlapping_nodes); + } /** for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh the z-component of nodes should be removed */ void maybe_remove_last_dimension(mesh ); /** for gmsh meshes, create table
[Getfem-commits] [getfem-commits] branch cleanup-mesh-import updated: Fix compilation errors
This is an automated email from the git hooks/post-receive script. logari81 pushed a commit to branch cleanup-mesh-import in repository getfem. The following commit(s) were added to refs/heads/cleanup-mesh-import by this push: new d2c0af5a Fix compilation errors d2c0af5a is described below commit d2c0af5acc7e58902193d883fac273eae26ccd3a Author: Konstantinos Poulios AuthorDate: Thu Aug 3 15:17:31 2023 +0200 Fix compilation errors --- src/getfem/getfem_import.h | 2 +- src/getfem_import.cc | 55 +- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/getfem/getfem_import.h b/src/getfem/getfem_import.h index cad32fd0..ac24051f 100644 --- a/src/getfem/getfem_import.h +++ b/src/getfem/getfem_import.h @@ -174,7 +174,7 @@ namespace getfem { bool remove_last_dimension = true, std::map> *nodal_map = nullptr, bool merge_overlapping_nodes = false) { -import_gmsh_mesh(f, m, false, nullptr, _map, +import_mesh_gmsh(f, m, false, nullptr, _map, remove_last_dimension, nodal_map, merge_overlapping_nodes); } diff --git a/src/getfem_import.cc b/src/getfem_import.cc index 13cf1414..0272eaf5 100644 --- a/src/getfem_import.cc +++ b/src/getfem_import.cc @@ -289,13 +289,13 @@ namespace getfem { for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh if remove_last_dimension == true the z-component of nodes will be removed */ - static void import_gmsh_mesh(std::istream& f, mesh& m, - bool add_all_element_type, - std::set *lower_dim_convex_rg, - std::map *region_map, - bool remove_last_dimension, - std::map> *nodal_map, - bool merge_overlapping_nodes) + void import_mesh_gmsh(std::istream& f, mesh& m, +bool add_all_element_type, +std::set *lower_dim_convex_rg, +std::map *region_map, +bool remove_last_dimension, +std::map> *nodal_map, +bool merge_overlapping_nodes) { gmm::stream_standard_locale sl(f); // /* print general warning */ @@ -653,12 +653,12 @@ namespace getfem { for (auto i : ci.nodes) (*nodal_map)[ci.region].insert(i); if (!cvok) { // if the convex is not part of the face of others - if (is_node) + if (is_node) { if (nodal_map == nullptr) GMM_WARNING2("gmsh import ignored a node id: " << ci.id << " region :" << ci.region << " point is not added explicitly as an element."); - else if (add_all_element_type) { + } else if (add_all_element_type) { size_type ic = m.add_convex(ci.pgt, ci.nodes.begin()); m.region(ci.region).add(ic); cvok = true; @@ -690,7 +690,7 @@ namespace getfem { GMM_ASSERT1(f.good(), "can't open file " << filename); /* throw exceptions when an error occurs */ f.exceptions(std::ifstream::badbit | std::ifstream::failbit); - import_gmsh_mesh(f, m, add_all_element_type, lower_dim_convex_rg, region_map, + import_mesh_gmsh(f, m, add_all_element_type, lower_dim_convex_rg, region_map, remove_last_dimension, nodal_map, merge_overlapping_nodes); f.close(); } @@ -715,7 +715,7 @@ namespace getfem { supports linear and quadratic elements (quadrilaterals, use 9(or 27)-noded elements) */ - static void import_gid_mesh(std::istream& f, mesh& m, + static void import_mesh_gid(std::istream& f, mesh& m, bool merge_overlapping_nodes=false) { gmm::stream_standard_locale sl(f); /* read the node list */ @@ -874,7 +874,7 @@ namespace getfem { cdwrite,db,filename,cdb */ - static void import_cdb_mesh(std::istream& f, mesh& m, + static void import_mesh_cdb(std::istream& f, mesh& m, size_type imat_filt=size_type(-1), bool merge_overlapping_nodes=false) { std::map cdb_node_2_getfem_node; @@ -1360,7 +1360,7 @@ namespace getfem { /* mesh file from noboite [http://www.distene.com/fr/corp/newsroom16.html] */ - static void import_noboite_mesh(std::istream& f, mesh& m) + static void import_mesh_noboite(std::istream& f, mesh& m) { using namespace std; gmm::stream_standard_locale sl(f); @@ -1444,10 +1444,10 @@ namespace getfem { else // sinon cerr << "Erreur à l'ouverture !" << endl; -// appeler subroutine import_gid_mesh +// appeler subroutine import_mesh_gid //import_mesh(const std::string&
[Getfem-commits] [getfem-commits] branch cleanup-mesh-import updated: Inline helper functions
This is an automated email from the git hooks/post-receive script. logari81 pushed a commit to branch cleanup-mesh-import in repository getfem. The following commit(s) were added to refs/heads/cleanup-mesh-import by this push: new c6e288f7 Inline helper functions c6e288f7 is described below commit c6e288f738b68d5dbd4aceca5bd116220a6e8e28 Author: Konstantinos Poulios AuthorDate: Mon Aug 7 13:01:11 2023 +0200 Inline helper functions --- src/getfem/getfem_import.h | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/getfem/getfem_import.h b/src/getfem/getfem_import.h index ac24051f..dad7792b 100644 --- a/src/getfem/getfem_import.h +++ b/src/getfem/getfem_import.h @@ -154,11 +154,12 @@ namespace getfem { bool remove_last_dimension = true, std::map> *nodal_map = nullptr, bool merge_overlapping_nodes = false); - void import_mesh_gmsh(const std::string& filename, mesh& m, -std::map _map, -bool remove_last_dimension = true, -std::map> *nodal_map = nullptr, -bool merge_overlapping_nodes = false) { + inline void + import_mesh_gmsh(const std::string& filename, mesh& m, + std::map _map, + bool remove_last_dimension = true, + std::map> *nodal_map = nullptr, + bool merge_overlapping_nodes = false) { import_mesh_gmsh(filename, m, false, nullptr, _map, remove_last_dimension, nodal_map, merge_overlapping_nodes); } @@ -169,11 +170,12 @@ namespace getfem { bool remove_last_dimension = true, std::map> *nodal_map = nullptr, bool merge_overlapping_nodes = false); - void import_mesh_gmsh(std::istream& f, mesh& m, -std::map _map, -bool remove_last_dimension = true, -std::map> *nodal_map = nullptr, -bool merge_overlapping_nodes = false) { + inline void + import_mesh_gmsh(std::istream& f, mesh& m, + std::map _map, + bool remove_last_dimension = true, + std::map> *nodal_map = nullptr, + bool merge_overlapping_nodes = false) { import_mesh_gmsh(f, m, false, nullptr, _map, remove_last_dimension, nodal_map, merge_overlapping_nodes); }
[Getfem-commits] [getfem-commits] branch simplify-Div-derivative deleted (was 7b3338cb)
logari81 pushed a change to branch simplify-Div-derivative. was 7b3338cb Simplify directional derivative of Div This change permanently discards the following revisions: discard 7b3338cb Simplify directional derivative of Div
[Getfem-commits] [getfem-commits] branch master updated: Add hardcoded matmult for small matrices and possibility of BLAS gemm for larger ones
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); -