def _default_config(class_name, unsteady=False): import fenicsmechanics as fm mat_dict = { 'incompressible': True, 'density': 10.0, } mesh_file, boundaries_file = fm.get_mesh_file_names("unit_domain", ret_facets=True, refinements=[12] * 3) mesh_dict = {'mesh_file': mesh_file, 'boundaries': boundaries_file} formulation_dict = { 'element': "p2-p0", 'bcs': { 'dirichlet': { 'displacement': [[0.0] * 3], 'velocity': [[0.0] * 3], 'regions': [1], 'components': ["all"] }, 'neumann': { 'values': ["30.0*t", [0.0, 1.0, 0.0]], 'regions': [2, 2], 'types': ["pressure", "cauchy"] } } } if class_name == "FluidMechanicsProblem": mat_dict['const_eqn'] = "newtonian" mat_dict['type'] = "viscous" mat_dict['mu'] = 1.0 formulation_dict['domain'] = "eulerian" else: mat_dict['const_eqn'] = "lin_elastic" mat_dict['type'] = "elastic" mat_dict['la'] = 15.0 mat_dict['mu'] = 5.0 formulation_dict['domain'] = "lagrangian" if unsteady: formulation_dict['time'] = { 'unsteady': True, 'interval': [0., 1.], 'dt': 0.1 } else: formulation_dict['time'] = {'unsteady': False} config = { 'material': mat_dict, 'mesh': mesh_dict, 'formulation': formulation_dict } return config
from __future__ import print_function import numpy as np import dolfin as dlf import fenicsmechanics as fm import fenicsmechanics.mechanicsproblem as mprob mesh_file, boundaries = fm.get_mesh_file_names("unit_domain", ret_facets=True, refinements=(2, 2)) # Region IDs ALL_ELSE = 0 CLIP = 1 TRACTION = 2 # Reduce this to just 2 time-varying expressions trac_clip = dlf.Expression(['t', 'pow(t, 2)'], t=0.0, degree=2) press_trac = dlf.Expression('10.0*cos(t)', t=0.0, degree=2) body_force = dlf.Constant([0.0]*2) # Elasticity parameters la = 2.0 # 1st Lame parameter mu = 0.5 # 2nd Lame parameter # Problem configuration dictionary config = {'material' : { 'type' : 'elastic',
import fenicsmechanics as fm mesh_file, boundaries = fm.get_mesh_file_names("lshape", ret_facets=True, refinements="fine") config = { 'material': { 'type': 'elastic', 'const_eqn': 'neo_hookean', 'incompressible': True, 'kappa': 10e9, 'mu': 1.5e6 }, 'mesh': { 'mesh_file': mesh_file, 'boundaries': boundaries }, 'formulation': { 'element': 'p1-p1', 'domain': 'lagrangian', 'inverse': True, 'bcs': { 'dirichlet': { 'displacement': [[0., 0.]], 'regions': [1] }, 'neumann': { 'values': [[0., -1e5]], 'regions': [2], 'types': ['cauchy'] }
import fenicsmechanics as fm # Specify material model and parameters mesh_file = fm.get_mesh_file_names("ellipsoid", refinements="1000um", ext="h5") mat_dict = { 'const_eqn': 'guccione', 'type': 'elastic', 'incompressible': True, 'density': 0.0, 'bt': 1.0, 'bf': 1.0, 'bfs': 1.0, 'C': 10.0, 'fibers': { 'fiber_files': mesh_file, 'fiber_names': [['fib1', 'fib2', 'fib3'], ['she1', 'she2', 'she3']], 'elementwise': True } } # Provide mesh file names mesh_dict = {'mesh_file': mesh_file, 'boundaries': mesh_file} # Specify time integration parameters, BCs, and polynomial degree. formulation_dict = { 'time': { 'dt': 0.01, 'interval': [0., 1.] }, 'element': 'p2-p1', 'domain': 'lagrangian',
p_file = 'results/forward-pressure-%s-%s.pvd' % name_dims else: p_file = None else: disp_file = None vel_file = None hdf5_file = None xdmf_file = None p_file = None if args.hdf5: ext = "h5" else: ext = "xml.gz" mesh_file, boundaries = fm.get_mesh_file_names("unit_domain", ret_facets=True, refinements=mesh_dims, ext=ext) # Check if the mesh file exists if not os.path.isfile(mesh_file): raise Exception('The mesh file, \'%s\', does not exist. ' % mesh_file + 'Please run the script \'generate_mesh_files.py\'' + 'with the same arguments first.') # Check if the mesh function file exists if not os.path.isfile(boundaries): raise Exception('The mesh function file, \'%s\', does not exist. ' % boundaries + 'Please run the script \'generate_mesh_files.py\'' + 'with the same arguments first.')
import dolfin as dlf import fenicsmechanics as fm from fenicsmechanics.dolfincompat import MPI_COMM_WORLD # For use with emacs python shell. try: sys.argv.remove("--simple-prompt") except ValueError: pass parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--pressure", default=0.004, type=float, help="Pressure to be applied at z = 0.") mesh_file = fm.get_mesh_file_names("beam", refinements=["1000"], ext="h5") parser.add_argument("--mesh-file", type=str, default=mesh_file, help="Name of mesh file to use for mesh and facet function.") parser.add_argument("--generate-mesh", action="store_true", help="Generates mesh using mshr.") parser.add_argument("--resolution", default=70, type=int, help="Resolution used to generate mesh with mshr.") parser.add_argument("--incompressible", action="store_true", help="Model as incompressible material.") parser.add_argument("--bulk-modulus", type=float, default=1e3, dest="kappa", help="Bulk modulus of the material.") parser.add_argument("--loading-steps", "-ls", type=int, default=10,
parser.add_argument("--loading-steps", "-ls", type=int, default=100, help="Number of loading steps to use.") parser.add_argument("--polynomial-degree", "-pd", type=int, default=2, dest="pd", choices=[1, 2, 3], help="Polynomial degree to be used for displacement.") args = parser.parse_args() mesh_file = fm.get_mesh_file_names("ellipsoid", ext="h5", refinements=["%ium" % args.mesh_size]) fiber_files = mesh_file # Region IDs HNBC = 0 # homogeneous Neumann BC HDBC = 10 # homogeneous Dirichlet BC INBC = 20 # inhomogeneous Neumann BC # Time parameters t0, tf = interval = [0., 1.] dt = (tf - t0) / args.loading_steps KAPPA = 1e100 if args.incompressible else args.kappa # Material subdictionary