Пример #1
0
            'dirichlet': {
                'displacement': [[0., 0.]],
                'regions': [1]
            },
            'neumann': {
                'values': [[0., -1e5]],
                'regions': [2],
                'types': ['cauchy']
            }
        }
    }
}

# First solve the inverse elastostatics problem.
problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem,
                                 fname_disp="results/unloaded_config.pvd")
solver.full_solve()

# Move the mesh using dolfin's ALE functionality
from dolfin import ALE, Mesh
ALE.move(problem.mesh, problem.displacement)
mesh_copy = Mesh(problem.mesh)

# Only need to change relevant entries in config
config['mesh']['mesh_file'] = mesh_copy
config['formulation']['inverse'] = False

# Solve a 'forward' problem.
problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem,
                                 fname_disp="results/loaded_config.pvd")
Пример #2
0
    'element': 'p2-p1',
    'domain': 'lagrangian',
    'bcs': {
        'dirichlet': {
            'displacement': [[0., 0., 0.]],
            'regions': [10],  # Integer ID for base plane
        },
        'neumann': {
            'regions': [20],  # Integer ID for inner surface
            'types': ['pressure'],
            'values': ['10.0*t']
        }
    }
}

# Combine above dictionaries into one.
config = {
    'material': mat_dict,
    'mesh': mesh_dict,
    'formulation': formulation_dict
}

# Create problem and solver objects.
problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem,
                                 fname_disp='results/displacement_output.pvd')
solver.set_parameters(linear_solver="mumps")

# Numerically solve the problem.
solver.full_solve()
Пример #3
0
    'mu': 1.5e6  # Pa
}

mesh_file, boundaries = fm.get_mesh_file_names("unit_domain",
                                               ret_facets=True,
                                               refinements=[20, 20])
mesh = {'mesh_file': mesh_file, 'boundaries': boundaries}

formulation = {
    'element': 'p2-p1',
    'domain': 'lagrangian',
    'bcs': {
        'dirichlet': {
            'displacement': [[0.0, 0.0]],
            'regions': [1],
        },
        'neumann': {
            'values': [[1e6, 0.]],
            'regions': [2],
            'types': ['piola']
        }
    }
}

config = {'material': material, 'mesh': mesh, 'formulation': formulation}

problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem,
                                 fname_disp="results/displacement.pvd")
solver.full_solve()
Пример #4
0
    config['formulation']['bcs']['dirichlet']['velocity'] = [
        dlf.Constant([0.] * args.dim)
    ]
    problem = fm.MechanicsProblem(config)
    solver = fm.MechanicsBlockSolver(problem,
                                     fname_disp=disp_file,
                                     fname_vel=vel_file,
                                     fname_pressure=p_file,
                                     fname_hdf5=hdf5_file,
                                     fname_xdmf=xdmf_file)
    solver.solve(save_freq=save_freq)
else:
    problem = fm.SolidMechanicsProblem(config)
    solver = fm.SolidMechanicsSolver(problem,
                                     fname_disp=disp_file,
                                     fname_pressure=p_file,
                                     fname_hdf5=hdf5_file,
                                     fname_xdmf=xdmf_file)
    solver.full_solve(save_freq=save_freq)

# Compute the final volume
if args.compute_volume:
    W1 = dlf.VectorFunctionSpace(problem.mesh, 'CG', 1)
    xi1 = dlf.TestFunction(W1)
    du1 = dlf.TrialFunction(W1)
    u_move = dlf.Function(W1)
    move_bcs = dlf.DirichletBC(W1, dlf.Constant([0.0] * args.dim),
                               problem.boundaries, CLIP)
    a = dlf.dot(xi1, du1) * dlf.dx
    L = dlf.dot(xi1, problem.displacement) * dlf.dx
    dlf.solve(a == L, u_move, move_bcs)
Пример #5
0
config = {'mesh': mesh, 'material': material, 'formulation': formulation}

if args.incompressible:
    fname_disp = "results/beam-displacement-incompressible.xml.gz"
    fname_pressure = "results/beam-pressure.xml.gz"
    fname_hdf5 = "results/beam-incompressible.h5"
    fname_xdmf = "results/beam-incompressible-viz.xdmf"
else:
    fname_disp = "results/beam-displacement.xml.gz"
    fname_pressure = None
    fname_hdf5 = "results/beam.h5"
    fname_xdmf = "results/beam-viz.xdmf"
problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem, fname_disp=fname_disp,
                                 fname_pressure=fname_pressure,
                                 fname_hdf5=fname_hdf5,
                                 fname_xdmf=fname_xdmf)
solver.full_solve()

rank = dlf.MPI.rank(MPI_COMM_WORLD)
disp_dof = problem.displacement.function_space().dim()
if rank == 0:
    print("DOF(u) = ", disp_dof)

import numpy as np
vals = np.zeros(3)
x = np.array([10., 0.5, 1.])
try:
    problem.displacement.eval(vals, x)
    write_to_file = True
except RuntimeError:
        'mesh_file': mesh_file,
        'boundaries': boundaries
    },
    'formulation': {
        'element': 'p1',
        'domain': 'lagrangian',
        'inverse': False,
        'body_force': body_force,
        'bcs': {
            'dirichlet': {
                'displacement': [dlf.Constant([0., 0., 0.]), twist],
                'regions': [CLIP, TWIST]
            },
            'neumann': {
                'regions': ['everywhere'],
                'types': ['piola'],
                'values': [traction]
            }
        }
    }
}

if args.save:
    result_file = 'results/displacement.pvd'
else:
    result_file = None

problem = fm.SolidMechanicsProblem(config)
solver = fm.SolidMechanicsSolver(problem, fname_disp=result_file)
solver.full_solve()