Пример #1
0
###################################################
###     Simple linear-elastic cantilever beam   ###
###################################################

mesh_file = amfe_dir('meshes/gmsh/simple_beam_gmsh/simple_beam_gmsh.msh')
mesh = ui.import_mesh_from_file(mesh_file)

model = ui.create_structural_component(mesh)

material = ui.create_material('Kirchhoff',
                              E=210E9,
                              nu=0.3,
                              rho=1E4,
                              plane_stress=True)

ui.assign_material_by_group(model, material, 'material')

ui.set_dirichlet_by_group(model, 'dirichlet', ('ux'), 'Dirichlet_x')
ui.set_dirichlet_by_nodeids(model, [1], ('uy'), 'Dirichlet_y')

F = constant_force(5E7)
ui.set_neumann_by_group(model, 'neumann', np.array([0.0, -1.0]), 'Load', F)

solution_writer = ui.solve_linear_static(model)

ui.write_results_to_paraview(solution_writer, model,
                             amfe_dir('results/gmsh/ui_example_beam_linear'))

###################################################
###  Nonlinear heterogeneous cantilever beam    ###
###################################################
of ``surface2partition`` to ``True`` when reading the mesh.
"""

# Reading the .msh file and defining a structural component
reader = GmshAsciiMeshReader(input_file)
converter = AmfeMeshConverter()
reader.parse(converter, surface2partition=True)
my_mesh = converter.return_mesh()
my_component = StructuralComponent(my_mesh)
"""
We proceed by assigning the material properties and
mapping the global degrees of freedom for the Dirichlet boundary conditions.
"""

# Assigning material properties on physical group called "material"
ui.assign_material_by_group(my_component, my_material, 'material')

# Mapping the degrees of freedom for nodes belonging to the physical group called "dirichlet"
glo_dofs_x = my_component.mapping.get_dofs_by_nodeids(
    my_component.mesh.get_nodeids_by_groups(['dirichlet']), 'ux')
glo_dofs_y = my_component.mapping.get_dofs_by_nodeids(
    my_component.mesh.get_nodeids_by_groups(['dirichlet']), 'uy')
glo_dofs_z = my_component.mapping.get_dofs_by_nodeids(
    my_component.mesh.get_nodeids_by_groups(['dirichlet']), 'uz')

my_composite = MeshComponentComposite(my_component)
"""
We define a structural composite object with the help of the tree builder
that manages the substructures and the connections between them.
"""