Ejemplo n.º 1
0
  $Id: demo_laplacian_aposteriori.py 4429 2013-10-01 13:15:15Z renard $
"""
import numpy as np

# Import basic modules
import getfem as gf

## Parameters
h = 4.  # Mesh parameter.
Dirichlet_with_multipliers = True  # Dirichlet condition with multipliers
# or penalization
dirichlet_coefficient = 1e10  # Penalization coefficient
export_mesh = True  # Draw the mesh after mesh generation or not

# Create a mesh
mo1 = gf.MesherObject('rectangle', [0., 50.], [100., 100.])
mo2 = gf.MesherObject('rectangle', [50., 0.], [100., 100.])
mo3 = gf.MesherObject('union', mo1, mo2)
mo4 = gf.MesherObject('ball', [25., 75], 8.)
mo5 = gf.MesherObject('ball', [75., 25.], 8.)
mo6 = gf.MesherObject('ball', [75., 75.], 8.)
mo7 = gf.MesherObject('union', mo4, mo5, mo6)
mo = gf.MesherObject('set minus', mo3, mo7)

gf.util('trace level', 2)  # No trace for mesh generation
mesh = gf.Mesh('generate', mo, h, 3)

#
# Boundary selection
#
fb1 = mesh.outer_faces_with_direction([-1., 0.], 0.01)  # Left   (Dirichlet)
Ejemplo n.º 2
0
T0 = 20.           # Reference temperature in oC.
rho_0 = 1.754E-8   # Resistance temperature coefficient at T0 = 20oC
alpha = 0.0039     # Second resistance temperature coefficient.

#
# Numerical parameters
#
h = 2.                     # Approximate mesh size
elements_degree = 2        # Degree of the finite element methods
export_mesh = True         # Draw the mesh after mesh generation or not
solve_in_two_steps = True  # Solve the elasticity problem separately or not

#
# Mesh generation. Meshes can also been imported from several formats.
#
mo1 = gf.MesherObject('rectangle', [0., 0.], [100., 25.])
mo2 = gf.MesherObject('ball', [25., 12.5], 8.)
mo3 = gf.MesherObject('ball', [50., 12.5], 8.)
mo4 = gf.MesherObject('ball', [75., 12.5], 8.)
mo5 = gf.MesherObject('union', mo2, mo3, mo4)
mo  = gf.MesherObject('set minus', mo1, mo5)

print 'Mesh generation';
gf.util('trace level', 2)   # No trace for mesh generation
mesh = gf.Mesh('generate', mo, h, 2)

#
# Boundary selection
#
fb1 = mesh.outer_faces_in_box([1., 1.], [99., 24.])    # Boundary of the holes
fb2 = mesh.outer_faces_with_direction([ 1., 0.], 0.01) # Right boundary
Ejemplo n.º 3
0
clambdastar = 2 * clambda * cmu / (clambda + 2 * cmu
                                   )  # Lame coefficient for Plane stress
applied_force = 1E7  # Force at the hole boundary (N)

#
# Numerical parameters
#
h = 1  # Approximate mesh size
elements_degree = 2  # Degree of the finite element methods
gamma0 = 1. / E
# Augmentation parameter for the augmented Lagrangian

#
# Mesh generation. Meshes can also been imported from several formats.
#
mo1 = gf.MesherObject('ball', [0., 15.], 15.)
mo2 = gf.MesherObject('ball', [0., 15.], 8.)
mo3 = gf.MesherObject('set minus', mo1, mo2)

print('Meshes generation')
mesh1 = gf.Mesh('generate', mo3, h, 2)
mesh2 = gf.Mesh(
    'import', 'structured',
    'GT="GT_PK(2,1)";SIZES=[30,10];NOISED=0;NSUBDIV=[%d,%d];' %
    (int(30 / h) + 1, int(10 / h) + 1))
mesh2.translate([-15., -10.])

if (export_mesh):
    mesh1.export_to_vtk('mesh1.vtk')
    mesh2.export_to_vtk('mesh2.vtk')
    print('\nYou can view the meshes for instance with')
Ejemplo n.º 4
0
"""  2D Poisson problem test in unit disk \Omega.
  -\Delta u=1 in \Omega, u=0 on \delta\Omega

  This program is used to check that python-getfem is working. This is
  also a good example of use of GetFEM++.

  $Id$
"""
# Import basic modules
import getfem as gf

## Parameters
h = 0.1  # approximate diameter of the elements.

# Create a unit disk mesh
mo = gf.MesherObject('ball', [1.0, 1.0], 1.0)
mesh = gf.Mesh('generate', mo, h, 2)
mesh.translate([-1.0, -1.0])

# Create a MeshFem for u and rhs fields of dimension 1 (i.e. a scalar field)
mfu = gf.MeshFem(mesh, 1)
mfrhs = gf.MeshFem(mesh, 1)
# assign the Classical Fem
elements_degree = 2
mfu.set_classical_fem(elements_degree)
mfrhs.set_classical_fem(elements_degree)

#  Integration method used
mim = gf.MeshIm(mesh, pow(elements_degree, 2))

# Boundary selection