Пример #1
0
# License and GCC Runtime Library Exception 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.
#
############################################################################
#
# Contact of a deformable 'wheel' onto a plane deformable obstacle.
#
############################################################################

import numpy as np

import getfem as gf

gf.util('trace level', 1)  # No trace for mesh generation nor for assembly

export_mesh = True
Dirichlet_version = False
# Use a dirichlet condition instead of a global load

#
# Physical parameters
#
E = 21E6  # Young Modulus (N/cm^2)
nu = 0.3  # Poisson ratio
clambda = E * nu / ((1 + nu) * (1 - 2 * nu))  # First Lame coefficient (N/cm^2)
cmu = E / (2 * (1 + nu))  # Second Lame coefficient (N/cm^2)
clambdastar = 2 * clambda * cmu / (clambda + 2 * cmu
                                   )  # Lame coefficient for Plane stress
applied_force = 1E7  # Force at the hole boundary (N)
Пример #2
0
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)
fb2 = mesh.outer_faces_with_direction([0., -1.], 0.01)  # Bottom (Neumann)
fb3 = mesh.outer_faces_in_box([-1., 10.], [101., 101.])
fb4 = mesh.outer_faces_in_box([10., -1.], [101., 101.])
LEFT_BOUND = 1
BOTTOM_BOUND = 2
AUX_BOUND1 = 3
AUX_BOUND2 = 4
mesh.set_region(LEFT_BOUND, fb1)
mesh.set_region(BOTTOM_BOUND, fb2)
Пример #3
0
  if (a[0:3] == 'Hi='):
      Hi = float(a[3:]); print 'Hi set to %g from argv' % Hi; continue
  if (a[0:6] == 'theta='):
      theta = float(a[6:]); print 'theta set to %g from argv' % theta; continue
  if (a[0:12] == 'resultspath='):
      resultspath=a[12:]; print 'resultspath set to %s from argv' % resultspath
      continue
  if (a[0:10] == 'do_export='):
      do_export=int(a[10:]); print 'do_export set to %s from argv' % do_export
      continue
  print "Unknow argument '%s' from the command line, exiting" % a; exit(1);

NY = int(np.ceil(NX * LY / (2 * LX))*2)
DT = T/NT

gf.util('trace_level', 1);


if (do_export >= 2):
    if (not os.path.exists(resultspath)):
        os.makedirs(resultspath)
    print('You can vizualize the optimization steps by launching')
    print('mayavi2 -d %s/von_mises_1.vtk -f WarpVector -m Surface' %resultspath)
    print('mayavi2 -d %s/plast_1.vtk -f WarpVector -m Surface' % resultspath)

if (load_type == 2 and option < 3):
    print('Will not work with this load : will break the body')
    exit(1)

if (load_type == 1):
    f = np.array([0., -1150.]);