[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5102 - in /trunk/getfem: doc/sphinx/source/userdoc/ in
From: |
logari81 |
Subject: |
[Getfem-commits] r5102 - in /trunk/getfem: doc/sphinx/source/userdoc/ interface/tests/matlab/ interface/tests/python/ tests/ |
Date: |
Sun, 18 Oct 2015 18:20:29 -0000 |
Author: logari81
Date: Sun Oct 18 20:20:28 2015
New Revision: 5102
URL: http://svn.gna.org/viewcvs/getfem?rev=5102&view=rev
Log:
update the python version of demo_crack + some typo fixes
Modified:
trunk/getfem/doc/sphinx/source/userdoc/model_time_integration.rst
trunk/getfem/interface/tests/matlab/demo_crack.m
trunk/getfem/interface/tests/python/demo_crack.py
trunk/getfem/tests/heat_equation.cc
trunk/getfem/tests/laplacian.cc
trunk/getfem/tests/laplacian_with_bricks.cc
trunk/getfem/tests/wave_equation.cc
Modified: trunk/getfem/doc/sphinx/source/userdoc/model_time_integration.rst
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/doc/sphinx/source/userdoc/model_time_integration.rst?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/doc/sphinx/source/userdoc/model_time_integration.rst
(original)
+++ trunk/getfem/doc/sphinx/source/userdoc/model_time_integration.rst Sun Oct
18 20:20:28 2015
@@ -116,7 +116,7 @@
model.perform_init_time_derivative(ddt);
standard_solve(model, iter);
-allows to perform automatically the approximation of the initial time
derivative. The parameter `ddt` corresponds to the small time step used to
perform the aproximation. Typically, `dtt = dt/20` could be used where `dt` is
the time step used to approximate the transient problem (see the exemple below).
+allows to perform automatically the approximation of the initial time
derivative. The parameter `ddt` corresponds to the small time step used to
perform the aproximation. Typically, `dtt = dt/20` could be used where `dt` is
the time step used to approximate the transient problem (see the example below).
The implicit theta-method for second-order problems
***************************************************
Modified: trunk/getfem/interface/tests/matlab/demo_crack.m
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/matlab/demo_crack.m?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/interface/tests/matlab/demo_crack.m (original)
+++ trunk/getfem/interface/tests/matlab/demo_crack.m Sun Oct 18 20:20:28 2015
@@ -25,14 +25,14 @@
variant = 4;
% variant : 1 : a single crack with cutoff enrichement
% 2 : a single crack with a fixed size area Xfem enrichment
-% 3 : a suppl?mentary crossing crack with a fixed size area
+% 3 : a supplementary crossing crack with a fixed size area
% Xfem enrichment
% 4 : variant 3 with the second crack closed by a penalisation of
-% the jump (exemple of use of xfem_plus and xfem_minus).
+% the jump (example of use of xfem_plus and xfem_minus).
% 5 : variant 3 with the first crack closed by a penalisation of
-% the jump (exemple of use of xfem_plus and xfem_minus).
+% the jump (example of use of xfem_plus and xfem_minus).
% 6 : variant 3 with the two cracks closed by a penalisation of
-% the jump (exemple of use of xfem_plus and xfem_minus).
+% the jump (example of use of xfem_plus and xfem_minus).
gf_workspace('clear all');
@@ -43,17 +43,25 @@
Lambda = 1.25e10; % Lame coefficient
Mu = 1.875e10; % Lame coefficient
-% Mesh in definition:
+% Mesh definition:
m = gf_mesh('regular_simplices', -0.5:1.0/nx:0.5+1.0/nx,
-0.5:1.0/nx:0.5+1.0/nx);
% m = gf_mesh('import','gmsh','quad.msh')
-% boundary set:
+% Boundary set:
gf_mesh_set(m, 'region', DIRICHLET, gf_mesh_get(m,'outer_faces'));
-% Basic mesh_fem without enrichment
-mf_pre_u = gf_mesh_fem(m);
-gf_mesh_fem_set(mf_pre_u,'fem',gf_fem('FEM_PK(2,1)'));
-
+% Global functions for asymptotic enrichment:
+ck0 = gf_global_function('crack',0);
+ck1 = gf_global_function('crack',1);
+ck2 = gf_global_function('crack',2);
+ck3 = gf_global_function('crack',3);
+if (variant == 1) % Cutoff enrichement
+ coff = gf_global_function('cutoff',2,0.4,0.01,0.4);
+ ckoff0 = gf_global_function('product', ck0, coff);
+ ckoff1 = gf_global_function('product', ck1, coff);
+ ckoff2 = gf_global_function('product', ck2, coff);
+ ckoff3 = gf_global_function('product', ck3, coff);
+end
% Levelset(s) definition
ls = gf_levelset(m,1,'y','x');
@@ -65,22 +73,14 @@
end
gf_mesh_levelset_set(mls,'adapt');
-
-% Global Functions for asymptotic enrichment
-ck0 = gf_global_function('crack',0);
-ck1 = gf_global_function('crack',1);
-ck2 = gf_global_function('crack',2);
-ck3 = gf_global_function('crack',3);
+% Basic mesh_fem without enrichment
+mf_pre_u = gf_mesh_fem(m);
+gf_mesh_fem_set(mf_pre_u,'fem',gf_fem('FEM_PK(2,1)'));
% Definition of the enriched finite element method
mfls_u = gf_mesh_fem('levelset',mls,mf_pre_u);
if (variant == 1) % Cutoff enrichement
- coff = gf_global_function('cutoff',2,0.4,0.01,0.4);
- ckoff0 = gf_global_function('product', ck0, coff);
- ckoff1 = gf_global_function('product', ck1, coff);
- ckoff2 = gf_global_function('product', ck2, coff);
- ckoff3 = gf_global_function('product', ck3, coff);
mf_sing_u = gf_mesh_fem('global function',m,ls,
{ckoff0,ckoff1,ckoff2,ckoff3},1);
mf_u = gf_mesh_fem('sum',mf_sing_u,mfls_u);
else
@@ -106,9 +106,16 @@
mf_u = gf_mesh_fem('sum', mf_xfem_sing, mf_xfem_sing2, mfls_u);
end
end
-
+
gf_mesh_fem_set(mf_u,'qdim',2);
-% Exact solution for a single crack
+
+% MeshIm definition:
+mim = gf_mesh_im('levelset', mls, 'all', ...
+ gf_integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),3)'), ...
+
gf_integ('IM_STRUCTURED_COMPOSITE(IM_GAUSS_PARALLELEPIPED(2,6),9)'), ...
+ gf_integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),5)'));
+
+% Exact solution for a single crack:
mf_ue = gf_mesh_fem('global function',m,ls,{ck0,ck1,ck2,ck3});
A = 2+2*Mu/(Lambda+2*Mu);
B = -2*(Lambda+Mu)/(Lambda+2*Mu);
@@ -119,12 +126,8 @@
Ue(1,4) = 0; Ue(2,4) = B; % cos(theta/2)*cos(theta)
Ue = Ue / 2*pi;
Ue=reshape(Ue,1,8);
-% MeshIm in action:
-mim = gf_mesh_im('levelset', mls, 'all', ...
- gf_integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),3)'), ...
-
gf_integ('IM_STRUCTURED_COMPOSITE(IM_GAUSS_PARALLELEPIPED(2,6),9)'), ...
- gf_integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),5)'));
-% Model in action:
+
+% Model definition:
md = gf_model('real');
gf_model_set(md,'add_fem_variable', 'u', mf_u);
% data
@@ -145,7 +148,7 @@
gf_model_set(md, 'add linear generic assembly brick', mim_bound2,
'1e17*(Xfem_plus(u)-Xfem_minus(u)).(Xfem_plus(Test_u)-Xfem_minus(Test_u))');
end
-% assembly of the linear system and solve:
+% Assembly of the linear system and solve:
gf_model_get(md,'solve');
U = gf_model_get(md,'variable','u');
@@ -154,10 +157,11 @@
mfv = gf_mesh_fem(cut_mesh,2);
gf_mesh_fem_set(mfv,'classical_discontinuous_fem',2,0.001);
gf_mesh_fem_set(mf_ue,'qdim',2);
+
V = gf_compute(mf_u,U,'interpolate_on',mfv);
Ve = gf_compute(mf_ue,Ue,'interpolate_on',mfv);
-% computation of the Von Mises stress
+% Computation of the Von Mises stress
mfvm = gf_mesh_fem(cut_mesh);
gf_mesh_fem_set(mfvm,'classical_discontinuous_fem',2,0.001);
gf_model_set(md,'add initialized fem data', 'u_cut', mfv, V);
Modified: trunk/getfem/interface/tests/python/demo_crack.py
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/python/demo_crack.py?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/interface/tests/python/demo_crack.py (original)
+++ trunk/getfem/interface/tests/python/demo_crack.py Sun Oct 18 20:20:28 2015
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# Python GetFEM++ interface
#
-# Copyright (C) 2009-2010 Luis Saavedra, Yves Renard.
+# Copyright (C) 2009-2015 Luis Saavedra, Yves Renard.
#
# This file is a part of GetFEM++
#
@@ -38,6 +38,18 @@
import numpy as np
import math
+variant = 4
+# variant : 1 : a single crack with cutoff enrichement
+# 2 : a single crack with a fixed size area Xfem enrichment
+# 3 : a supplementary crossing crack with a fixed size area
+# Xfem enrichment
+# 4 : variant 3 with the second crack closed by a penalisation of
+# the jump (example of use of xfem_plus and xfem_minus).
+# 5 : variant 3 with the first crack closed by a penalisation of
+# the jump (example of use of xfem_plus and xfem_minus).
+# 6 : variant 3 with the two cracks closed by a penalisation of
+# the jump (example of use of xfem_plus and xfem_minus).
+
# Parameters: ######################
nx = 20 #
#
@@ -47,57 +59,81 @@
Mu = 1.875E10 # Lame coefficient #
#####################################
-# Global Functions: ###############################
-ck0 = gf.GlobalFunction('crack',0) #
-ck1 = gf.GlobalFunction('crack',1) #
-ck2 = gf.GlobalFunction('crack',2) #
-ck3 = gf.GlobalFunction('crack',3) #
- #
-coff = gf.GlobalFunction('cutoff',2,0.4,0.01,0.4) #
- #
-ckoff0 = ck0*coff #
-ckoff1 = ck1*coff #
-ckoff2 = ck2*coff #
-ckoff3 = ck3*coff #
-###################################################
-
-# Mesh in action:
-m = gf.Mesh('regular_simplices', np.arange(-0.5,.5+1./nx,1./nx),
np.arange(-.5,.5+1./nx,1./nx))
+# Mesh definition:
+m = gf.Mesh('regular_simplices', -0.5+np.arange(nx+1)/float(nx),
+ -0.5+np.arange(nx+1)/float(nx))
#m = gf.Mesh('import','gmsh','quad.msh')
-# boundary set:
+# Boundary set:
m.set_region(DIRICHLET, m.outer_faces())
-# MeshFem in action:
-mf_pre_u = gf.MeshFem(m)
-mf_pre_u.set_fem(gf.Fem('FEM_PK(2,1)'))
+# Global functions for asymptotic enrichment:
+ck0 = gf.GlobalFunction('crack',0)
+ck1 = gf.GlobalFunction('crack',1)
+ck2 = gf.GlobalFunction('crack',2)
+ck3 = gf.GlobalFunction('crack',3)
+if variant == 1: # Cutoff enrichement
+ coff = gf.GlobalFunction('cutoff',2,0.4,0.01,0.4)
+ ckoff0 = ck0*coff # gf.GlobalFunction('product',ck0,coff)
+ ckoff1 = ck1*coff
+ ckoff2 = ck2*coff
+ ckoff3 = ck3*coff
-# Levelset in action:
+# Levelset definition:
ls = gf.LevelSet(m,1,'y','x')
mls = gf.MeshLevelSet(m)
mls.add(ls)
+if variant > 2:
+ ls2 = gf.LevelSet(m,1,'x+0.125','abs(y)-0.375')
+ mls.add(ls2);
mls.adapt()
-# MeshFemLevelSet:
+# Basic mesh_fem without enrichment:
+mf_pre_u = gf.MeshFem(m)
+mf_pre_u.set_fem(gf.Fem('FEM_PK(2,1)'))
+
+# Definition of the enriched finite element method (MeshFemLevelSet):
mfls_u = gf.MeshFem('levelset',mls,mf_pre_u)
-# MeshFemGlobalFunction:
-mf_sing_u = gf.MeshFem('global function',m,ls,[ckoff0,ckoff1,ckoff2,ckoff3])
+if variant == 1: # Cutoff enrichement
+ # MeshFemGlobalFunction:
+ mf_sing_u = gf.MeshFem('global
function',m,ls,[ckoff0,ckoff1,ckoff2,ckoff3],1)
+ # MeshFemDirectSum:
+ mf_u = gf.MeshFem('sum',mf_sing_u,mfls_u)
+else:
+ mf_sing_u = gf.MeshFem('global function',m,ls,[ck0,ck1,ck2,ck3],1)
+ mf_part_unity = gf.MeshFem(m)
+ mf_part_unity.set_classical_fem(1)
+ DOFpts = mf_part_unity.basic_dof_nodes()
+ # Search the dofs to be enriched with the asymptotic displacement.
+ Idofs_center = np.nonzero(np.square(DOFpts[0,:]) +
+ np.square(DOFpts[1,:]) <= 0.1**2)[0]
+ mf_xfem_sing = gf.MeshFem('product', mf_part_unity, mf_sing_u)
+ mf_xfem_sing.set_enriched_dofs(Idofs_center)
+ if variant > 2:
+ Idofs_up = np.nonzero(np.square(DOFpts[0,:]+0.125) +
+ np.square(DOFpts[1,:]-0.375) <= 0.1**2)[0]
+ Idofs_down = np.nonzero(np.square(DOFpts[0,:]+0.125) +
+ np.square(DOFpts[1,:]+0.375) <= 0.1**2)[0]
+ mf_sing_u2 = gf.MeshFem('global function',m,ls2,[ck0,ck1,ck2,ck3],1)
+ mf_xfem_sing2 = gf.MeshFem('product', mf_part_unity, mf_sing_u2)
+ mf_xfem_sing2.set_enriched_dofs(np.union1d(Idofs_up, Idofs_down))
+ if variant == 2:
+ mf_u = gf.MeshFem('sum', mf_xfem_sing, mfls_u)
+ else:
+ mf_u = gf.MeshFem('sum', mf_xfem_sing, mf_xfem_sing2, mfls_u)
-# MeshImLevelSet:
+mf_u.set_qdim(2)
+
+# MeshIm definition (MeshImLevelSet):
mim = gf.MeshIm('levelset', mls, 'all',
gf.Integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),3)'),
gf.Integ('IM_STRUCTURED_COMPOSITE(IM_GAUSS_PARALLELEPIPED(2,6),9)'),
gf.Integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),5)'))
-# MeshFemDirectSum:
-mf_u = gf.MeshFem('sum',mf_sing_u,mfls_u)
-mf_u.set_qdim(2)
-
-# exact solution:
+# Exact solution for a single crack:
mf_ue = gf.MeshFem('global function',m,ls,[ck0,ck1,ck2,ck3])
-
A = 2+2*Mu/(Lambda+2*Mu); B=-2*(Lambda+Mu)/(Lambda+2*Mu)
Ue = np.zeros([2,4])
Ue[0,0] = 0; Ue[1,0] = A-B # sin(theta/2)
@@ -107,32 +143,35 @@
Ue /= 2*np.pi
Ue = Ue.T.reshape(1,8)
-# Model in action:
+# Model definition:
md = gf.Model('real')
md.add_fem_variable('u', mf_u)
-
# data
md.add_initialized_data('lambda', [Lambda])
md.add_initialized_data('mu', [Mu])
md.add_isotropic_linearized_elasticity_brick(mim,'u','lambda','mu')
-
-# il fault!!!
-#md.add_variable('mult_spec',6)
-#BB = gf.Spmat('empty',6,mf_u.nbdof())
-#md.add_constraint_with_multipliers('u','mult_spec',BB,plain_vector(6))
-
md.add_initialized_fem_data("DirichletData", mf_ue, Ue)
md.add_Dirichlet_condition_with_penalization(mim,'u', 1e12, DIRICHLET,
'DirichletData')
-# assembly of the linear system and solve:
+if variant == 5 or variant == 6: # Penalisation of the jump over the first
crack
+ mim_bound1 = gf.MeshIm('levelset', mls, 'boundary(a)',
+
gf.Integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),3)'))
+ #gf.asm_generic(mim_bound1, 0, '1', -1) # length of the crack
+ md.add_linear_generic_assembly_brick\
+ (mim_bound1,
'1e17*(Xfem_plus(u)-Xfem_minus(u)).(Xfem_plus(Test_u)-Xfem_minus(Test_u))')
+
+if variant == 4 or variant == 6: # Penalisation of the jump over the second
crack
+ mim_bound2 = gf.MeshIm('levelset', mls, 'boundary(b)',
+
gf.Integ('IM_STRUCTURED_COMPOSITE(IM_TRIANGLE(6),3)'))
+ md.add_linear_generic_assembly_brick\
+ (mim_bound2,
'1e17*(Xfem_plus(u)-Xfem_minus(u)).(Xfem_plus(Test_u)-Xfem_minus(Test_u))')
+
+# Assembly of the linear system and solve:
md.solve()
-
U = md.variable('u')
-
-
-# export to pos
-cut_mesh = mls.cut_mesh();
+# Interpolation of the solution on a cut mesh for the drawing purpose
+cut_mesh = mls.cut_mesh()
mfv = gf.MeshFem(cut_mesh, 2)
mfv.set_classical_discontinuous_fem(2, 0.001)
mf_ue.set_qdim(2)
@@ -140,10 +179,11 @@
V = gf.compute_interpolate_on(mf_u, U, mfv)
Ve = gf.compute_interpolate_on(mf_ue, Ue, mfv)
-mfvm = gf.MeshFem(cut_mesh);
-mfvm.set_classical_discontinuous_fem(2, 0.001);
-md.add_initialized_fem_data('u_cut', mfv, V);
-VM = md.compute_isotropic_linearized_Von_Mises_or_Tresca('u_cut', 'lambda',
'mu', mfvm);
+# Computation of the Von Mises stress
+mfvm = gf.MeshFem(cut_mesh)
+mfvm.set_classical_discontinuous_fem(2, 0.001)
+md.add_initialized_fem_data('u_cut', mfv, V)
+VM = md.compute_isotropic_linearized_Von_Mises_or_Tresca('u_cut', 'lambda',
'mu', mfvm)
mfv.export_to_pos('crack.pos', V, 'V', Ve, 'Ve', mfvm, VM, 'Von Mises')
Modified: trunk/getfem/tests/heat_equation.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/heat_equation.cc?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/tests/heat_equation.cc (original)
+++ trunk/getfem/tests/heat_equation.cc Sun Oct 18 20:20:28 2015
@@ -27,7 +27,7 @@
This program is used to check that getfem++ is working. This is
also a good example of use of GetFEM++. This program does not use the
- model bricks intentionally in order to serve as an exemple of solving
+ model bricks intentionally in order to serve as an example of solving
a pde directly with the assembly procedures.
*/
Modified: trunk/getfem/tests/laplacian.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/laplacian.cc?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/tests/laplacian.cc (original)
+++ trunk/getfem/tests/laplacian.cc Sun Oct 18 20:20:28 2015
@@ -27,7 +27,7 @@
This program is used to check that getfem++ is working. This is
also a good example of use of GetFEM++. This program does not use the
- model bricks intentionally in order to serve as an exemple of solving
+ model bricks intentionally in order to serve as an example of solving
a pde directly with the assembly procedures.
*/
Modified: trunk/getfem/tests/laplacian_with_bricks.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/laplacian_with_bricks.cc?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/tests/laplacian_with_bricks.cc (original)
+++ trunk/getfem/tests/laplacian_with_bricks.cc Sun Oct 18 20:20:28 2015
@@ -27,7 +27,7 @@
This program is used to check that getfem++ is working. This is
also a good example of use of GetFEM++. This program does not use the
- model bricks intentionally in order to serve as an exemple of solving
+ model bricks intentionally in order to serve as an example of solving
a pde directly with the assembly procedures.
*/
Modified: trunk/getfem/tests/wave_equation.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/wave_equation.cc?rev=5102&r1=5101&r2=5102&view=diff
==============================================================================
--- trunk/getfem/tests/wave_equation.cc (original)
+++ trunk/getfem/tests/wave_equation.cc Sun Oct 18 20:20:28 2015
@@ -29,7 +29,7 @@
This program is used to check that getfem++ is working. This is
also a good example of use of GetFEM++. This program does not use the
- model bricks intentionally in order to serve as an exemple of solving
+ model bricks intentionally in order to serve as an example of solving
a pde directly with the assembly procedures.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5102 - in /trunk/getfem: doc/sphinx/source/userdoc/ interface/tests/matlab/ interface/tests/python/ tests/,
logari81 <=