[getfem] 03/03: Update changelog, fix tests-names.

Anton Gladky gladk at moszumanska.debian.org
Sat May 3 13:32:12 UTC 2014


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

gladk pushed a commit to branch master
in repository getfem.

commit bce6a9575d8713fe0dd790c9d09ca6ba6f036460
Author: Anton Gladky <gladk at debian.org>
Date:   Sat May 3 13:50:05 2014 +0200

    Update changelog, fix tests-names.
---
 debian/changelog                     |   7 ++
 debian/tests/checkGlobalFunctions.py | 116 +++++++++++++++++++++++++++++
 debian/tests/control                 |   2 +
 debian/tests/demoLaplacian.py        | 138 +++++++++++++++++++++++++++++++++++
 debian/tests/demoPlate.py            | 106 +++++++++++++++++++++++++++
 5 files changed, 369 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 95ac14b..c861b50 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+getfem++ (4.2.1~beta1~svn4635~dfsg-2) unstable; urgency=medium
+
+  * [8d1763d] Disable scilab on powerpc and mipsel.
+  * [9dfe279] Add autotests.
+
+ -- Anton Gladky <gladk at debian.org>  Sat, 03 May 2014 10:28:06 +0200
+
 getfem++ (4.2.1~beta1~svn4635~dfsg-1) unstable; urgency=medium
 
   * [b00f6a2] Imported Upstream version 4.2.1~beta1~svn4635~dfsg. 
diff --git a/debian/tests/checkGlobalFunctions.py b/debian/tests/checkGlobalFunctions.py
new file mode 100755
index 0000000..fc53f48
--- /dev/null
+++ b/debian/tests/checkGlobalFunctions.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Python GetFEM++ interface
+#
+# Copyright (C) 2009 Luis Saavedra.
+#
+# 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 2.1 of the License,  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 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.
+#
+############################################################################
+"""  test user global functions.
+
+  This program is used to check that python-getfem is working. This is
+  also a good example of use of python-getfem..
+
+  $Id: check_global_functions.py 4035 2012-02-18 12:21:20Z renard $
+"""
+import numpy as np
+import getfem as gf
+import os
+
+# mesh fem to export
+m = gf.Mesh('triangles grid', [-1, -0.5, 0, 0.5, 1], [-1, -0.5, 0, 0.5, 1])
+# m = gf.Mesh('import','gmsh','quad.msh')
+mf = gf.MeshFem(m)
+mf.set_fem(gf.Fem('FEM_PK(2,1)'))
+PTs = mf.basic_dof_nodes()
+
+# crack:
+ck0  = gf.GlobalFunction('crack',0)
+ck1  = gf.GlobalFunction('crack',1)
+ck2  = gf.GlobalFunction('crack',2)
+ck3  = gf.GlobalFunction('crack',3)
+ck4  = gf.GlobalFunction('crack',4)
+ck5  = gf.GlobalFunction('crack',5)
+ck6  = gf.GlobalFunction('crack',6)
+ck7  = gf.GlobalFunction('crack',7)
+ck8  = gf.GlobalFunction('crack',8)
+ck9  = gf.GlobalFunction('crack',9)
+ck10 = gf.GlobalFunction('crack',10)
+ck11 = gf.GlobalFunction('crack',11)
+mf.export_to_pos( 'check_global_functions0.pos', ck0(PTs), 'ck0')
+mf.export_to_pos( 'check_global_functions1.pos', ck1(PTs), 'ck1')
+mf.export_to_pos( 'check_global_functions2.pos', ck2(PTs), 'ck2')
+mf.export_to_pos( 'check_global_functions3.pos', ck3(PTs), 'ck3')
+mf.export_to_pos( 'check_global_functions4.pos', ck4(PTs), 'ck4')
+mf.export_to_pos( 'check_global_functions5.pos', ck5(PTs), 'ck5')
+mf.export_to_pos( 'check_global_functions6.pos', ck6(PTs), 'ck6')
+mf.export_to_pos( 'check_global_functions7.pos', ck7(PTs), 'ck7')
+mf.export_to_pos( 'check_global_functions8.pos', ck8(PTs), 'ck8')
+mf.export_to_pos( 'check_global_functions9.pos', ck9(PTs), 'ck9')
+mf.export_to_pos('check_global_functions10.pos',ck10(PTs),'ck10')
+mf.export_to_pos('check_global_functions11.pos',ck11(PTs),'ck11')
+
+# cutoff:
+co0 = gf.GlobalFunction('cutoff',-1,0.4,0.01,0.4)
+co1 = gf.GlobalFunction('cutoff', 0,0.4,0.01,0.4)
+co2 = gf.GlobalFunction('cutoff', 1,0.4,0.01,0.4)
+co3 = gf.GlobalFunction('cutoff', 2,0.4,0.01,0.4)
+mf.export_to_pos('check_global_functions12.pos',co0(PTs),'cutoff -1')
+mf.export_to_pos('check_global_functions13.pos',co1(PTs),'cutoff  0')
+mf.export_to_pos('check_global_functions14.pos',co2(PTs),'cutoff  1')
+mf.export_to_pos('check_global_functions15.pos',co3(PTs),'cutoff  2')
+
+# parser:
+if gf.getfem_env('muParser') == '1':
+ p0 = gf.GlobalFunction('parser','0')
+ p1 = gf.GlobalFunction('parser','1')
+ p2 = gf.GlobalFunction('parser','2')
+ p3 = gf.GlobalFunction('parser','3')
+ p00 = gf.GlobalFunction('parser','x','1;0')
+ p11 = gf.GlobalFunction('parser','y','0;1')
+ p22 = gf.GlobalFunction('parser','r','x/r;y/r;','y^2/r^3;-x*y/r^3;-x*y/r^3;x^2/r^3')
+ p33 = gf.GlobalFunction('parser','theta','-y/(r^2);x/(r^2)','2*x*y/r^4;(y^2-x^2)/r^4;(y^2-x^2)/r^4;-2*x*y/r^4')
+ mf.export_to_pos('check_global_functions16.pos',p0(PTs),'0')
+ mf.export_to_pos('check_global_functions17.pos',p1(PTs),'1')
+ mf.export_to_pos('check_global_functions18.pos',p2(PTs),'2')
+ mf.export_to_pos('check_global_functions19.pos',p3(PTs),'3')
+ mf.export_to_pos('check_global_functions20.pos',p00(PTs),'x')
+ mf.export_to_pos('check_global_functions21.pos',p11(PTs),'y')
+ mf.export_to_pos('check_global_functions22.pos',p22(PTs),'r')
+ mf.export_to_pos('check_global_functions23.pos',p33(PTs),'theta')
+ mf.export_to_pos('check_global_functions24.pos',p00.grad(PTs),'grad(x)')
+ mf.export_to_pos('check_global_functions25.pos',p11.grad(PTs),'grad(y)')
+ mf.export_to_pos('check_global_functions26.pos',p22.grad(PTs),'grad(r)')
+ mf.export_to_pos('check_global_functions27.pos',p33.grad(PTs),'grad(theta)')
+
+# product:
+p0 = ck0*ck1
+p1 = ck1*ck2
+p2 = ck2*ck3
+mf.export_to_pos('check_global_functions28.pos',p0(PTs),'ck0*ck1')
+mf.export_to_pos('check_global_functions29.pos',p1(PTs),'ck1*ck2')
+mf.export_to_pos('check_global_functions30.pos',p2(PTs),'ck2*ck3')
+
+# add:
+ad0 = ck0+ck1
+ad1 = ck1+ck2
+ad2 = ck2+ck3
+mf.export_to_pos('check_global_functions31.pos',ad0(PTs),'ck0+ck1')
+mf.export_to_pos('check_global_functions32.pos',ad1(PTs),'ck1+ck2')
+mf.export_to_pos('check_global_functions33.pos',ad2(PTs),'ck2+ck3')
+
+for i in range(34):
+  os.remove("check_global_functions%i.pos" % i);
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..b4dcefd
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: checkGlobalFunctions.py demoLaplacian.py demoPlate.py
+Depends: python-getfem++
diff --git a/debian/tests/demoLaplacian.py b/debian/tests/demoLaplacian.py
new file mode 100755
index 0000000..230f3e9
--- /dev/null
+++ b/debian/tests/demoLaplacian.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+# -*- coding: UTF8 -*-
+# Python GetFEM++ interface
+#
+# Copyright (C) 2004-2009 Yves Renard, Julien Pommier.
+#
+# 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 2.1 of the License,  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 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.
+#
+############################################################################
+"""  2D Poisson problem test.
+
+  This program is used to check that python-getfem is working. This is
+  also a good example of use of GetFEM++.
+
+  $Id: demo_laplacian.py 4429 2013-10-01 13:15:15Z renard $
+"""
+# import basic modules
+import getfem as gf
+import numpy as np
+
+## Parameters
+NX = 100                           # Mesh parameter.
+Dirichlet_with_multipliers = True  # Dirichlet condition with multipliers
+                                   # or penalization
+dirichlet_coefficient = 1e10       # Penalization coefficient
+
+# creation of a simple cartesian mesh
+m = gf.Mesh('regular_simplices', np.arange(0,1+1./NX,1./NX), np.arange(0,1+1./NX,1./NX))
+
+# create a MeshFem for u and rhs fields of dimension 1 (i.e. a scalar field)
+mfu   = gf.MeshFem(m, 1)
+mfrhs = gf.MeshFem(m, 1)
+# assign the P2 fem to all convexes of the both MeshFem
+mfu.set_fem(gf.Fem('FEM_PK(2,2)'))
+mfrhs.set_fem(gf.Fem('FEM_PK(2,2)'))
+
+# an exact integration will be used
+mim = gf.MeshIm(m, gf.Integ('IM_TRIANGLE(4)'))
+
+# boundary selection
+flst  = m.outer_faces()
+fnor  = m.normal_of_faces(flst)
+tleft = abs(fnor[1,:]+1) < 1e-14
+ttop  = abs(fnor[0,:]-1) < 1e-14
+fleft = np.compress(tleft, flst, axis=1)
+ftop  = np.compress(ttop, flst, axis=1)
+fneum = np.compress(True - ttop - tleft, flst, axis=1)
+
+# mark it as boundary
+DIRICHLET_BOUNDARY_NUM1 = 1
+DIRICHLET_BOUNDARY_NUM2 = 2
+NEUMANN_BOUNDARY_NUM = 3
+m.set_region(DIRICHLET_BOUNDARY_NUM1, fleft)
+m.set_region(DIRICHLET_BOUNDARY_NUM2, ftop)
+m.set_region(NEUMANN_BOUNDARY_NUM, fneum)
+
+# interpolate the exact solution (Assuming mfu is a Lagrange fem)
+Ue = mfu.eval('y*(y-1)*x*(x-1)+x*x*x*x*x')
+
+# interpolate the source term
+F1 = mfrhs.eval('-(2*(x*x+y*y)-2*x-2*y+20*x*x*x)')
+F2 = mfrhs.eval('[y*(y-1)*(2*x-1) + 5*x*x*x*x, x*(x-1)*(2*y-1)]')
+
+# model
+md = gf.Model('real')
+
+# main unknown
+md.add_fem_variable('u', mfu)
+
+# laplacian term on u
+md.add_Laplacian_brick(mim, 'u')
+
+# volumic source term
+md.add_initialized_fem_data('VolumicData', mfrhs, F1)
+md.add_source_term_brick(mim, 'u', 'VolumicData')
+
+# Neumann condition.
+md.add_initialized_fem_data('NeumannData', mfrhs, F2)
+md.add_normal_source_term_brick(mim, 'u', 'NeumannData',
+                                NEUMANN_BOUNDARY_NUM)
+
+# Dirichlet condition on the left.
+md.add_initialized_fem_data("DirichletData", mfu, Ue)
+
+if (Dirichlet_with_multipliers):
+  md.add_Dirichlet_condition_with_multipliers(mim, 'u', mfu,
+                                              DIRICHLET_BOUNDARY_NUM1,
+                                              'DirichletData')
+else:
+  md.add_Dirichlet_condition_with_penalization(mim, 'u', dirichlet_coefficient,
+                                               DIRICHLET_BOUNDARY_NUM1,
+                                               'DirichletData')
+
+# Dirichlet condition on the top.
+# Two Dirichlet brick in order to test the multiplier
+# selection in the intersection.
+if (Dirichlet_with_multipliers):
+  md.add_Dirichlet_condition_with_multipliers(mim, 'u', mfu,
+                                              DIRICHLET_BOUNDARY_NUM2,
+                                              'DirichletData')
+else:
+  md.add_Dirichlet_condition_with_penalization(mim, 'u', dirichlet_coefficient,
+                                               DIRICHLET_BOUNDARY_NUM2,
+                                               'DirichletData')
+gf.memstats()
+# md.listvar()
+# md.listbricks()
+
+# assembly of the linear system and solve.
+md.solve()
+
+# main unknown
+U = md.variable('u')
+L2error = gf.compute(mfu, U-Ue, 'L2 norm', mim)
+H1error = gf.compute(mfu, U-Ue, 'H1 norm', mim)
+
+if (H1error > 1e-3):
+    print 'Error in L2 norm : ', L2error
+    print 'Error in H1 norm : ', H1error
+    print 'Error too large !'
+
+# export data
+mfu.export_to_pos('laplacian.pos', Ue,'Exact solution',
+                                    U,'Computed solution')
+print 'You can view the solution with (for example):'
+print 'gmsh laplacian.pos'
diff --git a/debian/tests/demoPlate.py b/debian/tests/demoPlate.py
new file mode 100755
index 0000000..07ee6f0
--- /dev/null
+++ b/debian/tests/demoPlate.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+# -*- coding: UTF8 -*-
+# Python GetFEM++ interface
+#
+# Copyright (C) 2004-2009 Yves Renard, Julien Pommier.
+#
+# 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 2.1 of the License,  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 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.
+#
+############################################################################
+"""  Plate problem test.
+
+  This program is used to check that python-getfem is working. This is
+  also a good example of use of GetFEM++.
+
+  $Id: demo_plate.py 3809 2011-09-26 20:38:56Z logari81 $
+"""
+from getfem import *
+from numpy import *
+
+NX=10.0
+mixed = True
+thickness = 0.01;
+
+m=Mesh('regular simplices', arange(0,1.01,1/NX), arange(0,1.01,1/NX))
+mfut = MeshFem(m,2)
+mfu3 = MeshFem(m,1)
+mfth = MeshFem(m,2)
+mfd  = MeshFem(m,1)
+
+mfut.set_fem(Fem('FEM_PK(2,2)'))
+mfu3.set_fem(Fem('FEM_PK(2,1)'))
+mfth.set_fem(Fem('FEM_PK(2,2)'))
+mfd.set_fem(Fem('FEM_PK(2,2)'))
+
+mim = MeshIm(m, Integ('IM_TRIANGLE(5)'))
+
+
+#get the list of faces whose normal is [-1,0]
+flst = m.outer_faces();
+fnor = m.normal_of_faces(flst);
+fleft = compress(abs(fnor[1,:]+1) < 1e-14, flst, axis=1);
+fright= compress(abs(fnor[1,:]-1) < 1e-14, flst, axis=1);
+CLAMPED_BOUNDARY = 1;
+m.set_region(CLAMPED_BOUNDARY, fleft);
+SIMPLE_SUPPORT_BOUNDARY = 2
+m.set_region(SIMPLE_SUPPORT_BOUNDARY, fright);
+
+E=1e3
+Nu=0.3
+Lambda = E*Nu/((1+Nu)*(1-2*Nu))
+Mu =E/(2*(1+Nu))
+
+
+if not mixed:
+    b0 = MdBrick('isotropic_linearized_plate',mim,mim,mfut,mfu3,mfth,thickness)
+else:
+    b0 = MdBrick('mixed_isotropic_linearized_plate',mim,mfut,mfu3,mfth,thickness)
+
+b1 = MdBrick('plate_source_term', b0)
+b1.set('param', 'M', mfd, mfd.eval('[0, y*y/1000]'))
+
+b2 = MdBrick('plate clamped support', b1, CLAMPED_BOUNDARY, 'augmented');
+
+b3 = MdBrick('plate simple support', b2, SIMPLE_SUPPORT_BOUNDARY, 'augmented');
+
+b4 = b3
+if mixed:
+    b4 = MdBrick('plate closing', b3)
+
+mds=MdState(b4)
+print 'running solve...'
+b4.solve(mds, 'noisy', 'lsolver','superlu')
+print 'solve done!'
+
+
+U=mds.state()
+nut = mfut.nbdof()
+nu3 = mfu3.nbdof()
+nth = mfth.nbdof()
+ut=U[0:nut]
+u3=U[nut:(nut+nu3)]
+th=U[(nut+nu3):(nut+nu3+nth)]
+
+
+sl=Slice(('none',), mfu3, 4)
+sl.export_to_vtk('plate.vtk', mfu3, u3, 'Displacement')
+sl.export_to_pos('plate.pos', mfu3, u3,'Displacement')
+
+print 'You can view the solution with (for example):'
+print 'mayavi -d ./plate.vtk -f WarpScalar -m BandedSurfaceMap'
+print 'or'
+print 'mayavi2 -d plate.vtk -f WarpScalar -m Surface'
+print 'or'
+print 'gmsh plate.pos'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/getfem.git



More information about the debian-science-commits mailing list