In [1]:
from getfem import Mesh, MeshFem, Fem, MeshIm, Integ, Model
from numpy import arange
In [2]:
m = Mesh('cartesian', arange(0,1.1,0.1), arange(0,1.1,0.1))
In [3]:
mf = MeshFem(m, 1)
In [4]:
mf.set_fem(Fem('FEM_QK(2,2)'))
In [5]:
print Fem('FEM_QK(2,2)').poly_str()
In [6]:
mim = MeshIm(m, Integ('IM_EXACT_PARALLELEPIPED(2)'))
In [7]:
border = m.outer_faces()
In [8]:
m.set_region(42, border)
In [9]:
md = Model('real')
In [10]:
md.add_fem_variable('u', mf)
In [11]:
md.add_Laplacian_brick(mim, 'u');
In [12]:
g = mf.eval('x*(x-1) - y*(y-1)')
md.add_initialized_fem_data('DirichletData', mf, g)
md.add_Dirichlet_condition_with_multipliers(mim, 'u', mf, 42, 'DirichletData')
Out[12]:
In [13]:
md.solve()
Out[13]:
In [14]:
u = md.variable('u')
In [15]:
mf.export_to_pos('u.pos',u,'Computed solution')
In [16]:
%%writefile gscript
Print "A_step-by-step_basic_example_python_image1.png";
Exit;
In [17]:
!cat gscript
In [18]:
!gmsh u.pos gscript
In [19]:
from IPython.core.display import Image
In [20]:
Image('A_step-by-step_basic_example_python_image1.png')
Out[20]:
In [21]:
f = mf.eval('5')
md.add_initialized_fem_data('VolumicData', mf, f)
md.add_source_term_brick(mim, 'u', 'VolumicData')
Out[21]:
In [22]:
md.solve()
u = md.variable('u')
mf.export_to_pos('u.pos',u,'Computed solution')
In [23]:
%%writefile gscript
Print "A_step-by-step_basic_example_python_image2.png";
Exit;
In [24]:
!gmsh u.pos gscript
In [25]:
Image('A_step-by-step_basic_example_python_image2.png')
Out[25]:
In [ ]: