Update changelog, fix tests-names.
Anton Gladky
10 years ago
0 | getfem++ (4.2.1~beta1~svn4635~dfsg-2) unstable; urgency=medium | |
1 | ||
2 | * [8d1763d] Disable scilab on powerpc and mipsel. | |
3 | * [9dfe279] Add autotests. | |
4 | ||
5 | -- Anton Gladky <gladk@debian.org> Sat, 03 May 2014 10:28:06 +0200 | |
6 | ||
0 | 7 | getfem++ (4.2.1~beta1~svn4635~dfsg-1) unstable; urgency=medium |
1 | 8 | |
2 | 9 | * [b00f6a2] Imported Upstream version 4.2.1~beta1~svn4635~dfsg. |
0 | #!/usr/bin/env python | |
1 | # -*- coding: utf-8 -*- | |
2 | # Python GetFEM++ interface | |
3 | # | |
4 | # Copyright (C) 2009 Luis Saavedra. | |
5 | # | |
6 | # This file is a part of GetFEM++ | |
7 | # | |
8 | # GetFEM++ is free software; you can redistribute it and/or modify it | |
9 | # under the terms of the GNU Lesser General Public License as published | |
10 | # by the Free Software Foundation; either version 2.1 of the License, or | |
11 | # (at your option) any later version. | |
12 | # This program is distributed in the hope that it will be useful, but | |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
15 | # License for more details. | |
16 | # You should have received a copy of the GNU Lesser General Public License | |
17 | # along with this program; if not, write to the Free Software Foundation, | |
18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | # | |
20 | ############################################################################ | |
21 | """ test user global functions. | |
22 | ||
23 | This program is used to check that python-getfem is working. This is | |
24 | also a good example of use of python-getfem.. | |
25 | ||
26 | $Id: check_global_functions.py 4035 2012-02-18 12:21:20Z renard $ | |
27 | """ | |
28 | import numpy as np | |
29 | import getfem as gf | |
30 | import os | |
31 | ||
32 | # mesh fem to export | |
33 | m = gf.Mesh('triangles grid', [-1, -0.5, 0, 0.5, 1], [-1, -0.5, 0, 0.5, 1]) | |
34 | # m = gf.Mesh('import','gmsh','quad.msh') | |
35 | mf = gf.MeshFem(m) | |
36 | mf.set_fem(gf.Fem('FEM_PK(2,1)')) | |
37 | PTs = mf.basic_dof_nodes() | |
38 | ||
39 | # crack: | |
40 | ck0 = gf.GlobalFunction('crack',0) | |
41 | ck1 = gf.GlobalFunction('crack',1) | |
42 | ck2 = gf.GlobalFunction('crack',2) | |
43 | ck3 = gf.GlobalFunction('crack',3) | |
44 | ck4 = gf.GlobalFunction('crack',4) | |
45 | ck5 = gf.GlobalFunction('crack',5) | |
46 | ck6 = gf.GlobalFunction('crack',6) | |
47 | ck7 = gf.GlobalFunction('crack',7) | |
48 | ck8 = gf.GlobalFunction('crack',8) | |
49 | ck9 = gf.GlobalFunction('crack',9) | |
50 | ck10 = gf.GlobalFunction('crack',10) | |
51 | ck11 = gf.GlobalFunction('crack',11) | |
52 | mf.export_to_pos( 'check_global_functions0.pos', ck0(PTs), 'ck0') | |
53 | mf.export_to_pos( 'check_global_functions1.pos', ck1(PTs), 'ck1') | |
54 | mf.export_to_pos( 'check_global_functions2.pos', ck2(PTs), 'ck2') | |
55 | mf.export_to_pos( 'check_global_functions3.pos', ck3(PTs), 'ck3') | |
56 | mf.export_to_pos( 'check_global_functions4.pos', ck4(PTs), 'ck4') | |
57 | mf.export_to_pos( 'check_global_functions5.pos', ck5(PTs), 'ck5') | |
58 | mf.export_to_pos( 'check_global_functions6.pos', ck6(PTs), 'ck6') | |
59 | mf.export_to_pos( 'check_global_functions7.pos', ck7(PTs), 'ck7') | |
60 | mf.export_to_pos( 'check_global_functions8.pos', ck8(PTs), 'ck8') | |
61 | mf.export_to_pos( 'check_global_functions9.pos', ck9(PTs), 'ck9') | |
62 | mf.export_to_pos('check_global_functions10.pos',ck10(PTs),'ck10') | |
63 | mf.export_to_pos('check_global_functions11.pos',ck11(PTs),'ck11') | |
64 | ||
65 | # cutoff: | |
66 | co0 = gf.GlobalFunction('cutoff',-1,0.4,0.01,0.4) | |
67 | co1 = gf.GlobalFunction('cutoff', 0,0.4,0.01,0.4) | |
68 | co2 = gf.GlobalFunction('cutoff', 1,0.4,0.01,0.4) | |
69 | co3 = gf.GlobalFunction('cutoff', 2,0.4,0.01,0.4) | |
70 | mf.export_to_pos('check_global_functions12.pos',co0(PTs),'cutoff -1') | |
71 | mf.export_to_pos('check_global_functions13.pos',co1(PTs),'cutoff 0') | |
72 | mf.export_to_pos('check_global_functions14.pos',co2(PTs),'cutoff 1') | |
73 | mf.export_to_pos('check_global_functions15.pos',co3(PTs),'cutoff 2') | |
74 | ||
75 | # parser: | |
76 | if gf.getfem_env('muParser') == '1': | |
77 | p0 = gf.GlobalFunction('parser','0') | |
78 | p1 = gf.GlobalFunction('parser','1') | |
79 | p2 = gf.GlobalFunction('parser','2') | |
80 | p3 = gf.GlobalFunction('parser','3') | |
81 | p00 = gf.GlobalFunction('parser','x','1;0') | |
82 | p11 = gf.GlobalFunction('parser','y','0;1') | |
83 | 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') | |
84 | 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') | |
85 | mf.export_to_pos('check_global_functions16.pos',p0(PTs),'0') | |
86 | mf.export_to_pos('check_global_functions17.pos',p1(PTs),'1') | |
87 | mf.export_to_pos('check_global_functions18.pos',p2(PTs),'2') | |
88 | mf.export_to_pos('check_global_functions19.pos',p3(PTs),'3') | |
89 | mf.export_to_pos('check_global_functions20.pos',p00(PTs),'x') | |
90 | mf.export_to_pos('check_global_functions21.pos',p11(PTs),'y') | |
91 | mf.export_to_pos('check_global_functions22.pos',p22(PTs),'r') | |
92 | mf.export_to_pos('check_global_functions23.pos',p33(PTs),'theta') | |
93 | mf.export_to_pos('check_global_functions24.pos',p00.grad(PTs),'grad(x)') | |
94 | mf.export_to_pos('check_global_functions25.pos',p11.grad(PTs),'grad(y)') | |
95 | mf.export_to_pos('check_global_functions26.pos',p22.grad(PTs),'grad(r)') | |
96 | mf.export_to_pos('check_global_functions27.pos',p33.grad(PTs),'grad(theta)') | |
97 | ||
98 | # product: | |
99 | p0 = ck0*ck1 | |
100 | p1 = ck1*ck2 | |
101 | p2 = ck2*ck3 | |
102 | mf.export_to_pos('check_global_functions28.pos',p0(PTs),'ck0*ck1') | |
103 | mf.export_to_pos('check_global_functions29.pos',p1(PTs),'ck1*ck2') | |
104 | mf.export_to_pos('check_global_functions30.pos',p2(PTs),'ck2*ck3') | |
105 | ||
106 | # add: | |
107 | ad0 = ck0+ck1 | |
108 | ad1 = ck1+ck2 | |
109 | ad2 = ck2+ck3 | |
110 | mf.export_to_pos('check_global_functions31.pos',ad0(PTs),'ck0+ck1') | |
111 | mf.export_to_pos('check_global_functions32.pos',ad1(PTs),'ck1+ck2') | |
112 | mf.export_to_pos('check_global_functions33.pos',ad2(PTs),'ck2+ck3') | |
113 | ||
114 | for i in range(34): | |
115 | os.remove("check_global_functions%i.pos" % i); |
0 | #!/usr/bin/env python | |
1 | # -*- coding: UTF8 -*- | |
2 | # Python GetFEM++ interface | |
3 | # | |
4 | # Copyright (C) 2004-2009 Yves Renard, Julien Pommier. | |
5 | # | |
6 | # This file is a part of GetFEM++ | |
7 | # | |
8 | # GetFEM++ is free software; you can redistribute it and/or modify it | |
9 | # under the terms of the GNU Lesser General Public License as published | |
10 | # by the Free Software Foundation; either version 2.1 of the License, or | |
11 | # (at your option) any later version. | |
12 | # This program is distributed in the hope that it will be useful, but | |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
15 | # License for more details. | |
16 | # You should have received a copy of the GNU Lesser General Public License | |
17 | # along with this program; if not, write to the Free Software Foundation, | |
18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | # | |
20 | ############################################################################ | |
21 | """ 2D Poisson problem test. | |
22 | ||
23 | This program is used to check that python-getfem is working. This is | |
24 | also a good example of use of GetFEM++. | |
25 | ||
26 | $Id: demo_laplacian.py 4429 2013-10-01 13:15:15Z renard $ | |
27 | """ | |
28 | # import basic modules | |
29 | import getfem as gf | |
30 | import numpy as np | |
31 | ||
32 | ## Parameters | |
33 | NX = 100 # Mesh parameter. | |
34 | Dirichlet_with_multipliers = True # Dirichlet condition with multipliers | |
35 | # or penalization | |
36 | dirichlet_coefficient = 1e10 # Penalization coefficient | |
37 | ||
38 | # creation of a simple cartesian mesh | |
39 | m = gf.Mesh('regular_simplices', np.arange(0,1+1./NX,1./NX), np.arange(0,1+1./NX,1./NX)) | |
40 | ||
41 | # create a MeshFem for u and rhs fields of dimension 1 (i.e. a scalar field) | |
42 | mfu = gf.MeshFem(m, 1) | |
43 | mfrhs = gf.MeshFem(m, 1) | |
44 | # assign the P2 fem to all convexes of the both MeshFem | |
45 | mfu.set_fem(gf.Fem('FEM_PK(2,2)')) | |
46 | mfrhs.set_fem(gf.Fem('FEM_PK(2,2)')) | |
47 | ||
48 | # an exact integration will be used | |
49 | mim = gf.MeshIm(m, gf.Integ('IM_TRIANGLE(4)')) | |
50 | ||
51 | # boundary selection | |
52 | flst = m.outer_faces() | |
53 | fnor = m.normal_of_faces(flst) | |
54 | tleft = abs(fnor[1,:]+1) < 1e-14 | |
55 | ttop = abs(fnor[0,:]-1) < 1e-14 | |
56 | fleft = np.compress(tleft, flst, axis=1) | |
57 | ftop = np.compress(ttop, flst, axis=1) | |
58 | fneum = np.compress(True - ttop - tleft, flst, axis=1) | |
59 | ||
60 | # mark it as boundary | |
61 | DIRICHLET_BOUNDARY_NUM1 = 1 | |
62 | DIRICHLET_BOUNDARY_NUM2 = 2 | |
63 | NEUMANN_BOUNDARY_NUM = 3 | |
64 | m.set_region(DIRICHLET_BOUNDARY_NUM1, fleft) | |
65 | m.set_region(DIRICHLET_BOUNDARY_NUM2, ftop) | |
66 | m.set_region(NEUMANN_BOUNDARY_NUM, fneum) | |
67 | ||
68 | # interpolate the exact solution (Assuming mfu is a Lagrange fem) | |
69 | Ue = mfu.eval('y*(y-1)*x*(x-1)+x*x*x*x*x') | |
70 | ||
71 | # interpolate the source term | |
72 | F1 = mfrhs.eval('-(2*(x*x+y*y)-2*x-2*y+20*x*x*x)') | |
73 | F2 = mfrhs.eval('[y*(y-1)*(2*x-1) + 5*x*x*x*x, x*(x-1)*(2*y-1)]') | |
74 | ||
75 | # model | |
76 | md = gf.Model('real') | |
77 | ||
78 | # main unknown | |
79 | md.add_fem_variable('u', mfu) | |
80 | ||
81 | # laplacian term on u | |
82 | md.add_Laplacian_brick(mim, 'u') | |
83 | ||
84 | # volumic source term | |
85 | md.add_initialized_fem_data('VolumicData', mfrhs, F1) | |
86 | md.add_source_term_brick(mim, 'u', 'VolumicData') | |
87 | ||
88 | # Neumann condition. | |
89 | md.add_initialized_fem_data('NeumannData', mfrhs, F2) | |
90 | md.add_normal_source_term_brick(mim, 'u', 'NeumannData', | |
91 | NEUMANN_BOUNDARY_NUM) | |
92 | ||
93 | # Dirichlet condition on the left. | |
94 | md.add_initialized_fem_data("DirichletData", mfu, Ue) | |
95 | ||
96 | if (Dirichlet_with_multipliers): | |
97 | md.add_Dirichlet_condition_with_multipliers(mim, 'u', mfu, | |
98 | DIRICHLET_BOUNDARY_NUM1, | |
99 | 'DirichletData') | |
100 | else: | |
101 | md.add_Dirichlet_condition_with_penalization(mim, 'u', dirichlet_coefficient, | |
102 | DIRICHLET_BOUNDARY_NUM1, | |
103 | 'DirichletData') | |
104 | ||
105 | # Dirichlet condition on the top. | |
106 | # Two Dirichlet brick in order to test the multiplier | |
107 | # selection in the intersection. | |
108 | if (Dirichlet_with_multipliers): | |
109 | md.add_Dirichlet_condition_with_multipliers(mim, 'u', mfu, | |
110 | DIRICHLET_BOUNDARY_NUM2, | |
111 | 'DirichletData') | |
112 | else: | |
113 | md.add_Dirichlet_condition_with_penalization(mim, 'u', dirichlet_coefficient, | |
114 | DIRICHLET_BOUNDARY_NUM2, | |
115 | 'DirichletData') | |
116 | gf.memstats() | |
117 | # md.listvar() | |
118 | # md.listbricks() | |
119 | ||
120 | # assembly of the linear system and solve. | |
121 | md.solve() | |
122 | ||
123 | # main unknown | |
124 | U = md.variable('u') | |
125 | L2error = gf.compute(mfu, U-Ue, 'L2 norm', mim) | |
126 | H1error = gf.compute(mfu, U-Ue, 'H1 norm', mim) | |
127 | ||
128 | if (H1error > 1e-3): | |
129 | print 'Error in L2 norm : ', L2error | |
130 | print 'Error in H1 norm : ', H1error | |
131 | print 'Error too large !' | |
132 | ||
133 | # export data | |
134 | mfu.export_to_pos('laplacian.pos', Ue,'Exact solution', | |
135 | U,'Computed solution') | |
136 | print 'You can view the solution with (for example):' | |
137 | print 'gmsh laplacian.pos' |
0 | #!/usr/bin/env python | |
1 | # -*- coding: UTF8 -*- | |
2 | # Python GetFEM++ interface | |
3 | # | |
4 | # Copyright (C) 2004-2009 Yves Renard, Julien Pommier. | |
5 | # | |
6 | # This file is a part of GetFEM++ | |
7 | # | |
8 | # GetFEM++ is free software; you can redistribute it and/or modify it | |
9 | # under the terms of the GNU Lesser General Public License as published | |
10 | # by the Free Software Foundation; either version 2.1 of the License, or | |
11 | # (at your option) any later version. | |
12 | # This program is distributed in the hope that it will be useful, but | |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
15 | # License for more details. | |
16 | # You should have received a copy of the GNU Lesser General Public License | |
17 | # along with this program; if not, write to the Free Software Foundation, | |
18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | # | |
20 | ############################################################################ | |
21 | """ Plate problem test. | |
22 | ||
23 | This program is used to check that python-getfem is working. This is | |
24 | also a good example of use of GetFEM++. | |
25 | ||
26 | $Id: demo_plate.py 3809 2011-09-26 20:38:56Z logari81 $ | |
27 | """ | |
28 | from getfem import * | |
29 | from numpy import * | |
30 | ||
31 | NX=10.0 | |
32 | mixed = True | |
33 | thickness = 0.01; | |
34 | ||
35 | m=Mesh('regular simplices', arange(0,1.01,1/NX), arange(0,1.01,1/NX)) | |
36 | mfut = MeshFem(m,2) | |
37 | mfu3 = MeshFem(m,1) | |
38 | mfth = MeshFem(m,2) | |
39 | mfd = MeshFem(m,1) | |
40 | ||
41 | mfut.set_fem(Fem('FEM_PK(2,2)')) | |
42 | mfu3.set_fem(Fem('FEM_PK(2,1)')) | |
43 | mfth.set_fem(Fem('FEM_PK(2,2)')) | |
44 | mfd.set_fem(Fem('FEM_PK(2,2)')) | |
45 | ||
46 | mim = MeshIm(m, Integ('IM_TRIANGLE(5)')) | |
47 | ||
48 | ||
49 | #get the list of faces whose normal is [-1,0] | |
50 | flst = m.outer_faces(); | |
51 | fnor = m.normal_of_faces(flst); | |
52 | fleft = compress(abs(fnor[1,:]+1) < 1e-14, flst, axis=1); | |
53 | fright= compress(abs(fnor[1,:]-1) < 1e-14, flst, axis=1); | |
54 | CLAMPED_BOUNDARY = 1; | |
55 | m.set_region(CLAMPED_BOUNDARY, fleft); | |
56 | SIMPLE_SUPPORT_BOUNDARY = 2 | |
57 | m.set_region(SIMPLE_SUPPORT_BOUNDARY, fright); | |
58 | ||
59 | E=1e3 | |
60 | Nu=0.3 | |
61 | Lambda = E*Nu/((1+Nu)*(1-2*Nu)) | |
62 | Mu =E/(2*(1+Nu)) | |
63 | ||
64 | ||
65 | if not mixed: | |
66 | b0 = MdBrick('isotropic_linearized_plate',mim,mim,mfut,mfu3,mfth,thickness) | |
67 | else: | |
68 | b0 = MdBrick('mixed_isotropic_linearized_plate',mim,mfut,mfu3,mfth,thickness) | |
69 | ||
70 | b1 = MdBrick('plate_source_term', b0) | |
71 | b1.set('param', 'M', mfd, mfd.eval('[0, y*y/1000]')) | |
72 | ||
73 | b2 = MdBrick('plate clamped support', b1, CLAMPED_BOUNDARY, 'augmented'); | |
74 | ||
75 | b3 = MdBrick('plate simple support', b2, SIMPLE_SUPPORT_BOUNDARY, 'augmented'); | |
76 | ||
77 | b4 = b3 | |
78 | if mixed: | |
79 | b4 = MdBrick('plate closing', b3) | |
80 | ||
81 | mds=MdState(b4) | |
82 | print 'running solve...' | |
83 | b4.solve(mds, 'noisy', 'lsolver','superlu') | |
84 | print 'solve done!' | |
85 | ||
86 | ||
87 | U=mds.state() | |
88 | nut = mfut.nbdof() | |
89 | nu3 = mfu3.nbdof() | |
90 | nth = mfth.nbdof() | |
91 | ut=U[0:nut] | |
92 | u3=U[nut:(nut+nu3)] | |
93 | th=U[(nut+nu3):(nut+nu3+nth)] | |
94 | ||
95 | ||
96 | sl=Slice(('none',), mfu3, 4) | |
97 | sl.export_to_vtk('plate.vtk', mfu3, u3, 'Displacement') | |
98 | sl.export_to_pos('plate.pos', mfu3, u3,'Displacement') | |
99 | ||
100 | print 'You can view the solution with (for example):' | |
101 | print 'mayavi -d ./plate.vtk -f WarpScalar -m BandedSurfaceMap' | |
102 | print 'or' | |
103 | print 'mayavi2 -d plate.vtk -f WarpScalar -m Surface' | |
104 | print 'or' | |
105 | print 'gmsh plate.pos' |