def _tloop_default(self): self.ts = TStepper(tse=self.dim.mats_eval, sdomain=FEUnitElem(mats_eval=self.dim.mats_eval)) # Put the time-stepper into the time-loop # n_steps = self.n_steps tloop = TLoop(tstepper=self.ts, KMAX=100, RESETMAX=self.n_restarts, tolerance=1e-8, tline=TLine(min=0.0, step=1.0 / n_steps, max=1.0)) return tloop
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.mats.mats2D import MATS2DPlastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D import FETS2D9Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets_ls.fets_crack import FETSCrack #fets_eval = FETS2D4Q( mats_eval = MATS2DPlastic( E = 1., nu = 0. ) ) fets_eval = FETS2D4Q8U(mats_eval=MATS2DPlastic(E=1., nu=0.)) xfets_eval = FETSCrack(parent_fets=fets_eval, int_order=5, tri_subdivision=1) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(1., 1.), shape=(8, 8), fets_eval=fets_eval, level=fe_level1) #ls_function = lambda X, Y: X - Y - 0.13 ls_function = lambda X, Y: (X - 0.52)**2 + (Y - 0.72)**2 - 0.51**2 bls_function = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.28**2) bls_function2 = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.38**2) # design deficits: # - How to define a level set spanned over several fe_grids # (i.e. it is defined over the hierarchy of FESubDomains) # - Patching of subdomains within the FEPatchedGrid (FERefinementGrid) # - What are the compatibility conditions? # - What is the difference between FEGridLeveSetSlice # and FELSDomain? # FELSDomain is associated with a DOTS - Slice is not. # FEGrid has a multidimensional array - elem_grid # it can be accessed through this index. # it is masked by the activity map. The activity map can # be defined using slices and level sets. # the elems array enumerates the elements using the activity map. # in this way, the specialization of grids is available implicitly. # fe_xdomain = FELSDomain( domain=fe_domain, fets_eval=xfets_eval, fe_grid=fe_grid1, ls_function=ls_function, bls_function=bls_function, ) fe_tip_xdomain = FELSDomain( domain=fe_domain, fets_eval=xfets_eval, fe_grid=fe_xdomain, ls_function=bls_function, ) # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() fe_xdomain.bls_function = bls_function2 fe_tip_xdomain.ls_function = bls_function2 # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() # # General procedure: # 1) define the level sets with the boundaries # 2) use the bls to identify the tips of the level set # 3) use independent level sets to introduce indpendently junctions. # # get the extended dofs of the bls_elems and constrain it # cdofs = fe_tip_xdomain.elem_xdof_map.flatten() bc_list = [BCDof(var='u', dof=dof, value=0.0) for dof in cdofs] # construct the time stepper ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice( var='u', value=-0.1, dims=[1], slice=fe_grid1[:, 0, :, 0]), BCSlice( var='u', value=0., dims=[0], slice=fe_grid1[:, 0, :, 0]), BCSlice(var='u', value=0., dims=[0, 1], slice=fe_grid1[:, -1, :, -1]) ] + bc_list, rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField(name='Stress', var='sig_app', idx=0, warp=True), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # do = 'print' if do == 'print': p = 'state' if p == 'grids': print('fe_xdomain.ls mask') print(fe_xdomain.ls_mask) print('fe_xdomain.idx mask') print(fe_xdomain.idx_mask) print('fe_xdomain.intg mask') print(fe_xdomain.intg_mask) print('fe_xdomain.xelems_mask') print(fe_xdomain.xelems_mask) print('fe_xdomain.xelems_grid_ix') print(fe_xdomain.xelems_grid_ix) print('fe_xdomain.ls_elem_grid') print(fe_xdomain.ls_elem_grid) print('fe_xdomain.ls_ielem_grid') print(fe_xdomain.ls_ielem_grid) print('fe_xdomain.intg_elem_grid') print(fe_xdomain.intg_elem_grid) print('fe_tip_xdomain.ls_mask`') print(fe_tip_xdomain.ls_mask) print('fe_tip_xdomain.intg_mask`') print(fe_tip_xdomain.intg_mask) print('fe_tip_xdomain.idx_mask`') print(fe_tip_xdomain.idx_mask) print('fe_tip_xdomain.xelems_mask') print(fe_tip_xdomain.xelems_mask) print('fe_tip_xdomain.xelems_grid_ix') print(fe_tip_xdomain.xelems_grid_ix) print('fe_tip_xdomain.ls_elem_grid') print(fe_tip_xdomain.ls_elem_grid) print('fe_tip_xdomain.ls_ielems_grid') print(fe_tip_xdomain.ls_ielem_grid) print('fe_tip_xdomain.intg_elem_grid') print(fe_tip_xdomain.intg_elem_grid) if p == 'maps': print('fe_xdomain.elem_dof_map') print(fe_xdomain.elem_dof_map) print('fe_tip_xdomain.elem_dof_map') print(fe_tip_xdomain.elem_dof_map) print('fe_xdomain.elems') print(fe_xdomain.elems) print('fe_tip_xdomain.elems') print(fe_tip_xdomain.elems) print('fe_xdomain.elem_X_map') print(fe_xdomain.elem_X_map) print('fe_tip_xdomain.elem_X_map') print(fe_tip_xdomain.elem_X_map) if p == 'fields': print("ls_values ", fe_xdomain.dots.dof_node_ls_values) print("tip ls_values ", fe_tip_xdomain.dots.dof_node_ls_values) print('intersection points ', fe_xdomain.ls_intersection_r) print('tip intersection points ', fe_tip_xdomain.ls_intersection_r) print("triangles ", fe_xdomain.dots.rt_triangles) print("vtk points ", fe_xdomain.dots.vtk_X) print("vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0)) print('ip_triangles', fe_xdomain.dots.int_division) print('ip_coords', fe_xdomain.dots.ip_coords) print('ip_weigths', fe_xdomain.dots.ip_weights) print('ip_offset', fe_xdomain.dots.ip_offset) print('ip_X_coords', fe_xdomain.dots.ip_X) print('ip_ls', fe_xdomain.dots.ip_ls_values) print('vtk_ls', fe_xdomain.dots.vtk_ls_values) print('J_det ', fe_xdomain.dots.J_det_grid) if p == 'state': # Add the time-loop control print('STATE: initial') print('fe_xdomain.dots.state_elem grid') print(fe_xdomain.dots.state_start_elem_grid) print('fe_tip_xdomain.dots.state_elem grid') print(fe_tip_xdomain.dots.state_start_elem_grid) print('fe_xdomain.dots.state_end_elem grid') print(fe_xdomain.dots.state_end_elem_grid) print('fe_tip_xdomain.dots.state_end_elem grid') print(fe_tip_xdomain.dots.state_end_elem_grid) fe_xdomain.dots.state_array[:] = 25.5 print('state_array 25', fe_xdomain.dots.state_array) fe_tip_xdomain.dots.state_array[:] = 58 bls_function3 = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.58**2) fe_xdomain.bls_function = bls_function3 fe_tip_xdomain.ls_function = bls_function3 print('STATE: changed') print('fe_xdomain.dots.state_elem grid') print(fe_xdomain.dots.state_start_elem_grid) print('fe_tip_xdomain.dots.state_elem grid') print(fe_tip_xdomain.dots.state_start_elem_grid) print('fe_xdomain.dots.state_end_elem grid') print(fe_xdomain.dots.state_end_elem_grid) print('fe_tip_xdomain.dots.state_end_elem grid') print(fe_tip_xdomain.dots.state_end_elem_grid) print('state_array 25', fe_xdomain.dots.state_array.shape) print('state_array 25', fe_xdomain.dots.state_array[570:]) print('state_array 58', fe_tip_xdomain.dots.state_array.shape) elif do == 'ui': tloop = TLoop(tstepper=ts, debug=False, tolerance=1e-4, KMAX=3, RESETMAX=0, tline=TLine(min=0.0, step=1, max=1.0)) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def example_1d(): fets_eval = FETS1D2L3U(mats_eval=MATS1DElastic(E=20.)) xfets_eval = FETSCrack(parent_fets=fets_eval, int_order=2) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(2., 0., 0.), shape=(2, ), fets_eval=fets_eval, level=fe_level1) enr = True if enr: fe_xdomain = XFESubDomain( domain=fe_domain, fets_eval=xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice=fe_grid1['X - .75']) fe_xdomain.deactivate_sliced_elems() ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice(var='u', value=-1. / 2., dims=[0], slice=fe_grid1[0, 0]), BCSlice(var='u', value=0., dims=[0], slice=fe_grid1[-1, -1]), ], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField(name='Stress', var='eps', idx=0, warp=True), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # # # Add the time-loop control tloop = TLoop(tstepper=ts, debug=True, tolerance=1e-4, RESETMAX=0, tline=TLine(min=0.0, step=1, max=1.0)) #print "elements ",fe_xdomain.elements[0] if enr: print('parent elems ', fe_xdomain.fe_grid_slice.elems) print('parent dofs ', fe_xdomain.fe_grid_slice.dofs) print("dofmap ", fe_xdomain.elem_dof_map) print("ls_values ", fe_xdomain.dots.dof_node_ls_values) print('intersection points ', fe_xdomain.fe_grid_slice.r_i) # print("triangles ", fe_xdomain.dots.int_division) print('ip_coords', fe_xdomain.dots.ip_coords) print('ip_weigths', fe_xdomain.dots.ip_weights) print('ip_offset ', fe_xdomain.dots.ip_offset) print('ip_X_coords', fe_xdomain.dots.ip_X) print('ip_ls', fe_xdomain.dots.ip_ls_values) print('vtk_X ', fe_xdomain.dots.vtk_X) print('vtk triangles ', fe_xdomain.dots.rt_triangles) print("vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0)) print('vtk_ls', fe_xdomain.dots.vtk_ls_values) print('J_det ', fe_xdomain.dots.J_det_grid) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def example_1d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, BCDof, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from mats1D_elastic_tf import MATS1DElasticTF from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.fets.fets1D.fets1D2l import FETS1D2L from ibvpy.fets.fets1D.fets1D2l3u import FETS1D2L3U from fets_crack_rough import FETSCrackRough fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=2.0)) xfets_eval = FETSCrackRough(parent_fets=fets_eval, mats_eval=MATS1DElasticTF(E_m=1.0, E_f=1.0, G=1.0)) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(3.0, 0.0, 0.0), shape=(3,), fets_eval=fets_eval, level=fe_level1) enr = True if enr: fe_xdomain = XFESubDomain( domain=fe_domain, fets_eval=xfets_eval, # fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice=fe_grid1["X - 1.5"], ) ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCDof(var="u", value=1.0, dims=[0], dof=3), BCDof(var="u", value=0.0, dims=[0], dof=0), BCDof(var="u", value=0.0, dims=[0], dof=4), BCDof(var="u", value=0.0, dims=[0], dof=5), BCDof(var="u", value=0.0, dims=[0], dof=6), BCDof(var="u", value=0.0, dims=[0], dof=7), # BCDof(var='u', value = 0., dims = [0], # link_dofs = [8,9,13], # link_coeffs = [-1,-1,-1], # dof = 12), ], rtrace_list=[ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField(name="Displ m", var="u_rm", idx=0, warp=True, warp_var="u_rm"), RTraceDomainListField(name="Displ f", var="u_rf", idx=0, warp=True, warp_var="u_rf"), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ], ) # # # Add the time-loop control tloop = TLoop( tstepper=ts, tolerance=1e-4, # KMAX = 2, # debug = True, RESETMAX = 2, tline=TLine(min=0.0, step=1, max=1.0), ) # print "elements ",fe_xdomain.elements[0] if enr: fe_xdomain.deactivate_sliced_elems() print "parent elems ", fe_xdomain.fe_grid_slice.elems print "parent dofs ", fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print "intersection points ", fe_xdomain.fe_grid_slice.r_i # print "triangles ", fe_xdomain.dots.int_division print "ip_coords", fe_xdomain.dots.ip_coords print "ip_weigths", fe_xdomain.dots.ip_weights print "ip_offset ", fe_xdomain.dots.ip_offset print "ip_X_coords", fe_xdomain.dots.ip_X print "ip_ls", fe_xdomain.dots.ip_ls_values print "vtk_X ", fe_xdomain.dots.vtk_X print "vtk triangles ", fe_xdomain.dots.rt_triangles print "vtk data ", fe_xdomain.dots.get_vtk_cell_data("blabla", 0, 0) print "vtk_ls", fe_xdomain.dots.vtk_ls_values print "J_det ", fe_xdomain.dots.J_det_grid print tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
# var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displacement' , var = 'u', idx = 0, warp = True ), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1., max = 1.0 ) ) #print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() print 'parent elems ', fe_xdomain.fe_grid_slice.elems print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.fe_grid_slice.r_i print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'blabla', 0, 0 ) print 'ip_triangles', fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.mats.mats2D import MATS2DPlastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D import FETS2D9Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets_ls.fets_crack import FETSCrack #fets_eval = FETS2D4Q( mats_eval = MATS2DPlastic( E = 1., nu = 0. ) ) fets_eval = FETS2D4Q8U( mats_eval = MATS2DPlastic( E = 1., nu = 0. ) ) xfets_eval = FETSCrack( parent_fets = fets_eval, int_order = 5, tri_subdivision = 1 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 1., 1. ), shape = ( 8, 8 ), fets_eval = fets_eval, level = fe_level1 ) #ls_function = lambda X, Y: X - Y - 0.13 ls_function = lambda X, Y: ( X - 0.52 ) ** 2 + ( Y - 0.72 ) ** 2 - 0.51 ** 2 bls_function = lambda X, Y:-( ( X - 0.5 ) ** 2 + ( Y - 0.21 ) ** 2 - 0.28 ** 2 ) bls_function2 = lambda X, Y:-( ( X - 0.5 ) ** 2 + ( Y - 0.21 ) ** 2 - 0.38 ** 2 ) # design deficits: # - How to define a level set spanned over several fe_grids # (i.e. it is defined over the hierarchy of FESubDomains) # - Patching of subdomains within the FEPatchedGrid (FERefinementGrid) # - What are the compatibility conditions? # - What is the difference between FEGridLeveSetSlice # and FELSDomain? # FELSDomain is associated with a DOTS - Slice is not. # FEGrid has a multidimensional array - elem_grid # it can be accessed through this index. # it is masked by the activity map. The activity map can # be defined using slices and level sets. # the elems array enumerates the elements using the activity map. # in this way, the specialization of grids is available implicitly. # fe_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_grid1, ls_function = ls_function, bls_function = bls_function, ) fe_tip_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_xdomain, ls_function = bls_function, ) # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() fe_xdomain.bls_function = bls_function2 fe_tip_xdomain.ls_function = bls_function2 # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() # # General procedure: # 1) define the level sets with the boundaries # 2) use the bls to identify the tips of the level set # 3) use independent level sets to introduce indpendently junctions. # # get the extended dofs of the bls_elems and constrain it # cdofs = fe_tip_xdomain.elem_xdof_map.flatten() bc_list = [ BCDof( var = 'u', dof = dof, value = 0.0 ) for dof in cdofs ] # construct the time stepper ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [BCSlice( var = 'u', value = -0.1, dims = [1], slice = fe_grid1[:, 0, :, 0] ), BCSlice( var = 'u', value = 0., dims = [0], slice = fe_grid1[:, 0, :, 0] ), BCSlice( var = 'u', value = 0., dims = [0, 1], slice = fe_grid1[:, -1, :, -1] ) ] + bc_list, rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField( name = 'Stress' , var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displacement' , var = 'u', idx = 0, warp = True ), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # do = 'print' if do == 'print': p = 'state' if p == 'grids': print 'fe_xdomain.ls mask' print fe_xdomain.ls_mask print 'fe_xdomain.idx mask' print fe_xdomain.idx_mask print 'fe_xdomain.intg mask' print fe_xdomain.intg_mask print 'fe_xdomain.xelems_mask' print fe_xdomain.xelems_mask print 'fe_xdomain.xelems_grid_ix' print fe_xdomain.xelems_grid_ix print 'fe_xdomain.ls_elem_grid' print fe_xdomain.ls_elem_grid print 'fe_xdomain.ls_ielem_grid' print fe_xdomain.ls_ielem_grid print 'fe_xdomain.intg_elem_grid' print fe_xdomain.intg_elem_grid print 'fe_tip_xdomain.ls_mask`' print fe_tip_xdomain.ls_mask print 'fe_tip_xdomain.intg_mask`' print fe_tip_xdomain.intg_mask print 'fe_tip_xdomain.idx_mask`' print fe_tip_xdomain.idx_mask print 'fe_tip_xdomain.xelems_mask' print fe_tip_xdomain.xelems_mask print 'fe_tip_xdomain.xelems_grid_ix' print fe_tip_xdomain.xelems_grid_ix print 'fe_tip_xdomain.ls_elem_grid' print fe_tip_xdomain.ls_elem_grid print 'fe_tip_xdomain.ls_ielems_grid' print fe_tip_xdomain.ls_ielem_grid print 'fe_tip_xdomain.intg_elem_grid' print fe_tip_xdomain.intg_elem_grid if p == 'maps': print 'fe_xdomain.elem_dof_map' print fe_xdomain.elem_dof_map print 'fe_tip_xdomain.elem_dof_map' print fe_tip_xdomain.elem_dof_map print 'fe_xdomain.elems' print fe_xdomain.elems print 'fe_tip_xdomain.elems' print fe_tip_xdomain.elems print 'fe_xdomain.elem_X_map' print fe_xdomain.elem_X_map print 'fe_tip_xdomain.elem_X_map' print fe_tip_xdomain.elem_X_map if p == 'fields': print "ls_values ", fe_xdomain.dots.dof_node_ls_values print "tip ls_values ", fe_tip_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.ls_intersection_r print 'tip intersection points ', fe_tip_xdomain.ls_intersection_r print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'blabla', 0, 0 ) print 'ip_triangles', fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights print 'ip_offset', fe_xdomain.dots.ip_offset print 'ip_X_coords', fe_xdomain.dots.ip_X print 'ip_ls', fe_xdomain.dots.ip_ls_values print 'vtk_ls', fe_xdomain.dots.vtk_ls_values print 'J_det ', fe_xdomain.dots.J_det_grid if p == 'state': # Add the time-loop control print 'STATE: initial' print 'fe_xdomain.dots.state_elem grid' print fe_xdomain.dots.state_start_elem_grid print 'fe_tip_xdomain.dots.state_elem grid' print fe_tip_xdomain.dots.state_start_elem_grid print 'fe_xdomain.dots.state_end_elem grid' print fe_xdomain.dots.state_end_elem_grid print 'fe_tip_xdomain.dots.state_end_elem grid' print fe_tip_xdomain.dots.state_end_elem_grid fe_xdomain.dots.state_array[:] = 25.5 print 'state_array 25', fe_xdomain.dots.state_array fe_tip_xdomain.dots.state_array[:] = 58 bls_function3 = lambda X, Y:-( ( X - 0.5 ) ** 2 + ( Y - 0.21 ) ** 2 - 0.58 ** 2 ) fe_xdomain.bls_function = bls_function3 fe_tip_xdomain.ls_function = bls_function3 print 'STATE: changed' print 'fe_xdomain.dots.state_elem grid' print fe_xdomain.dots.state_start_elem_grid print 'fe_tip_xdomain.dots.state_elem grid' print fe_tip_xdomain.dots.state_start_elem_grid print 'fe_xdomain.dots.state_end_elem grid' print fe_xdomain.dots.state_end_elem_grid print 'fe_tip_xdomain.dots.state_end_elem grid' print fe_tip_xdomain.dots.state_end_elem_grid print 'state_array 25', fe_xdomain.dots.state_array.shape print 'state_array 25', fe_xdomain.dots.state_array[570:] print 'state_array 58', fe_tip_xdomain.dots.state_array.shape elif do == 'ui': tloop = TLoop( tstepper = ts, debug = False, tolerance = 1e-4, KMAX = 3, RESETMAX = 0, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.core.astrategy import AStrategyBase from ibvpy.api import BCDof, BCDofGroup, FEGrid, BCSlice, FEDomain, FERefinementGrid, \ TStepper as TS, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from ibvpy.rtrace.rt_dof import RTraceGraph from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.mats.mats2D5.mats2D5_bond.mats2D5_plastic_bond import MATS2D5PlasticBond from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic import numpy as np ######################################### #Material Parameters ######################################### #E_m = 34 000 MPa #nu_m = 0.2 #E_f = 54 000 MPa #Tau_fr = 1.25 MPA #G = 12 500 MPa # s_crit assumed 1.e-4 yielding ######################################### #Geometry ######################################### #WEB #### #b = 18 mm #h = 84 mm # ######## #FLANGES ######## #b = 110 mm #h = 18 mm (including the height of the transfer zone 6 mm) # # m_eval_tf = MATS2D5PlasticBond( E_m = 612. , #MPa including thickness 0.01M # nu_m = 0.2, # # E_f = 6., #MPa EA # nu_f = 0., # G = 1.25e4 , #MPa # #sigma_y = 1.25 , #MPa \tau_fr # sigma_y = 1.25 , # stress_state = 'plane_stress' ) m_eval_tf = MATS2D5Bond( E_m = 34000 * 0.018 , #MPa including thickness 0.01M nu_m = 0.2, # E_f = 54000. * 2.22e-4, #MPa EA nu_f = 0., G = 1.25e4 , #MPa stress_state = 'plane_stress' ) m_eval_web = MATS2DElastic( E = 34000 * 0.018 + 54000. * 2.22e-4, #MPa including thickness 0.01M nu = 0.2, # stress_state = 'plane_stress' ) m_eval_flange = MATS2DElastic( E = 34000 * 0.11 + 54000. * 1.854e-3, #MPa including thickness 0.01M nu = 0.2, # stress_state = 'plane_stress' ) fets_eval_tf = FETS2DTF( parent_fets = FETS2D4Q8U(), mats_eval = m_eval_tf ) fets_eval_web = FETS2D4Q8U( mats_eval = m_eval_web ) fets_eval_flange = FETS2D4Q8U( mats_eval = m_eval_flange ) # Discretization fineness_x_left = 4 fineness_x_right = 2 fineness_y_web = 1 fineness_y_flange = 1 fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_tf ) ## #web ## fe_grid1 = FEGrid( coord_max = ( 0.285, .084 ), shape = ( fineness_x_left, fineness_y_web ), fets_eval = fets_eval_tf, level = fe_level1 ) fe_level2 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_web ) fe_grid2 = FEGrid( coord_min = ( 0.285, 0. ), coord_max = ( 0.450, .084 ), shape = ( fineness_x_right, fineness_y_web ), fets_eval = fets_eval_web, level = fe_level2 ) ## #flanges ## ##lower fe_level3 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_flange ) fe_grid3 = FEGrid( coord_min = ( 0., -0.018 ), coord_max = ( 0.285, 0. ), shape = ( fineness_x_left, fineness_y_flange ), fets_eval = fets_eval_flange, level = fe_level3 ) fe_level4 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_flange ) fe_grid4 = FEGrid( coord_min = ( 0.285, -0.018 ), coord_max = ( 0.450, 0., ), shape = ( fineness_x_right, fineness_y_flange ), fets_eval = fets_eval_flange, level = fe_level4 ) ##upper fe_level5 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_flange ) fe_grid5 = FEGrid( coord_min = ( 0., 0.084 ), coord_max = ( 0.285, 0.102 ), shape = ( fineness_x_left, fineness_y_flange ), fets_eval = fets_eval_flange, level = fe_level5 ) fe_level6 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval_flange ) fe_grid6 = FEGrid( coord_min = ( 0.285, 0.084, ), coord_max = ( 0.450, 0.102, ), shape = ( fineness_x_right, fineness_y_flange ), fets_eval = fets_eval_flange, level = fe_level6 ) def get_g2_bottom_dofs(): a = np.sort( np.unique( np.hstack( ( fe_grid2[1:-1, 0, :, 0].dofs.flatten(), fe_grid2[0, 0, 1:-1, 0].dofs.flatten(), fe_grid2[-1, 0, :-1, 0].dofs.flatten() ) ) ) ).reshape( -1, 2 ) return a, [] def get_g2_top_dofs(): a = np.sort( np.unique( np.hstack( ( fe_grid2[1:-1, -1, :, -1].dofs.flatten(), fe_grid2[0, -1, 1:, -1].dofs.flatten(), fe_grid2[-1, -1, :-1, -1].dofs.flatten() ) ) ) ).reshape( -1, 2 ) return a, [] def get_g4_top_dofs(): a = np.sort( np.unique( np.hstack( ( fe_grid4[1:-1, -1, :, -1].dofs.flatten(), fe_grid4[0, -1, 1:, -1].dofs.flatten(), fe_grid4[-1, -1, :-1, -1].dofs.flatten() ) ) ) ).reshape( -1, 2 ) return a, [] def get_g6_bottom_dofs(): a = np.sort( np.unique( np.hstack( ( fe_grid6[1:-1, 0, :, 0].dofs.flatten(), fe_grid6[0, 0, 1:-1, 0].dofs.flatten(), fe_grid6[-1, 0, :-1, 0].dofs.flatten() ) ) ) ).reshape( -1, 2 ) return a, [] bottom_right_dof = fe_grid4[-1, 0, -1, 0].dofs[0, 0, 1] ts = TS( #dof_resultants = True, #sdomain = fe_domain, sdomain = [fe_grid1, fe_grid2, fe_grid3, fe_grid4, fe_grid5, fe_grid6], bcond_list = [ #RHS symmetry constraints BCDofGroup( var = 'u', value = 0.0 , dims = [0], get_dof_method = fe_grid2.get_right_dofs ), BCDofGroup( var = 'u', value = 0.0 , dims = [0], get_dof_method = fe_grid4.get_right_dofs ), BCDofGroup( var = 'u', value = 0.0 , dims = [0], get_dof_method = fe_grid6.get_right_dofs ), # support BCDofGroup( var = 'u', value = 0., dims = [0, 1], get_dof_method = fe_grid3.get_bottom_left_dofs ), #stitch together the layers of two field zone BCDofGroup( var = 'u', value = 0., dims = [2, 3], link_dims = [0, 1], link_coeffs = [1.], get_link_dof_method = fe_grid1.get_right_dofs, get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [2, 3], link_dims = [0, 1], link_coeffs = [1.], get_link_dof_method = fe_grid1.get_top_dofs, get_dof_method = fe_grid1.get_top_dofs ), BCDofGroup( var = 'u', value = 0., dims = [2, 3], link_dims = [0, 1], link_coeffs = [1.], get_link_dof_method = fe_grid1.get_bottom_dofs, get_dof_method = fe_grid1.get_bottom_dofs ), # bottom flange -> web left BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_link_dof_method = fe_grid3.get_top_dofs, get_dof_method = fe_grid1.get_bottom_dofs ), # web -> top flange left BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_dof_method = fe_grid1.get_top_dofs, get_link_dof_method = fe_grid5.get_bottom_dofs ), #web cracked area-elastic area BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [2, 3], link_coeffs = [1.], get_link_dof_method = fe_grid1.get_right_dofs, get_dof_method = fe_grid2.get_left_dofs ), #flange connection BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_dof_method = fe_grid3.get_right_dofs, get_link_dof_method = fe_grid4.get_left_dofs ), BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_dof_method = fe_grid5.get_right_dofs, get_link_dof_method = fe_grid6.get_left_dofs ), #web -> bottom flange right BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_dof_method = get_g2_bottom_dofs, get_link_dof_method = get_g4_top_dofs ), #web -> top flange right BCDofGroup( var = 'u', value = 0., dims = [0, 1], link_dims = [0, 1], link_coeffs = [1.], get_dof_method = get_g2_top_dofs, get_link_dof_method = get_g6_bottom_dofs ), #load BCSlice( var = 'u', value = -.001 , dims = [1], slice = fe_grid6[-1, :, -1, :] ), BCSlice( var = 'u', value = -.001 , dims = [1], slice = fe_grid2[-1, :, -1, :] ), BCSlice( var = 'u', value = -.001 , dims = [1], slice = fe_grid4[-1, :, -1, :] ), ], rtrace_list = [#todo: create tracer integrating the forces along the right line RTraceGraph( name = 'Fi,right over u_right' , var_y = 'F_int', idx_y = bottom_right_dof, var_x = 'U_k', idx_x = bottom_right_dof ), RTraceDomainListField( name = 'Stress' , var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displ matrix' , var = 'u_m' , warp = True, warp_var = 'u_m' ), RTraceDomainListField( name = 'Stress' , var = 'sig_app' ), ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, tline = TLine( min = 0.0, step = .25, max = .25 ) ) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.core.astrategy import AStrategyBase from ibvpy.api import BCDof, BCDofGroup, FEGrid, BCSlice, FEDomain, \ FERefinementGrid, TStepper as TS, RTraceDomainListField from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from apps.scratch.jakub.global_enrichement.fets_crack_tf import FETSCrackTF from ibvpy.mesh.xfe_subdomain import XFESubDomain from enthought.traits.api import HasTraits, Array from ibvpy.mesh.fe_ls_domain import FELSDomain from ibvpy.mats.mats2D5.mats2D5_bond.mats2D5_plastic_bond import MATS2D5PlasticBond from ibvpy.core.tloop import TLoop, TLine import numpy as np ######################################### #Material Parameters ######################################### #E_m = 34 000 MPa #nu_m = 0.2 #E_f = 54 000 MPa #Tau_fr = 3 MPA #G = 30 000 MPa #s_crit assumed 1.e-5 yielding m_eval = MATS2D5PlasticBond( E_m = 340. , #MPa including thickness 0.01M nu_m = 0.2, # E_f = 6., #MPa EA nu_f = 0., G = 1.25e5 , #MPa #sigma_y = 1.25 , #MPa \tau_fr sigma_y = 1.25 * 1000000. , #temporary set higher to avoid nonlinear comp. stress_state = 'plane_stress' ) fets_eval = FETS2DTF( parent_fets = FETS2D4Q16U(), mats_eval = m_eval ) xfets_eval = FETSCrackTF( parent_fets = fets_eval, int_order = 5 , tri_subdivision = 1 ) H = lambda x: np.array( 0.5 * np.sign( x ) + 1, dtype = int ) # Discretization fineness_x = 19 fineness_y = 5 fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 0.285, .076, 0. ), shape = ( fineness_x, fineness_y ), fets_eval = fets_eval, level = fe_level1 ) # # # #first crack from right: Y < 0.051 in 1.LS; 1 in 2. LS # fe_xdomain = XFESubDomain( domain = fe_domain, # fets_eval = xfets_eval, # boundary = lambda X, Y: H( -Y + 0.051 ) * H( X - 0.225 ), # # slice = fe_grid1['19047.61905005*X**4 -20215.92603891*X**3 +\ # 8022.94611889*X**2 -1409.39497482*X+\ # 92.40622701-Y'] )#polyfit p=4 # fe_xdomain.deactivate_sliced_elems() # fe_xdomain = XFESubDomain( domain = fe_domain, # fets_eval = xfets_eval, # boundary = lambda X, Y: H( -Y + 0.051 ) * H( X - 0.225 ), # # slice = fe_grid1['19047.61905005*X**4 -20215.92603891*X**3 +\ # 8022.94611889*X**2 -1409.39497482*X+\ # 92.40622701-Y'] )#polyfit p=4 bls_function = lambda X, Y: ( np.sign( X - 0.22 ) + np.sign( -Y + 0.051 ) ) - 1 ls_function = lambda X, Y:19047.61905005 * X ** 4 - 20215.92603891 * X ** 3 + \ 8022.94611889 * X ** 2 - 1409.39497482 * X + \ 92.40622701 - Y # ls_function = lambda X, Y: X - 0.151 - Y # bls_function = lambda X, Y:-( ( X - 0.151 ) ** 2 + ( Y - 0.0 ) ** 2 - 0.05 ** 2 ) fe_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_grid1, ls_function = ls_function, bls_function = bls_function, # ) fe_tip_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_xdomain, ls_function = bls_function, ) # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() print 'dof offset arr ', fe_domain.dof_offset_arr #third crack from right: Y < 0.046 in 2.LS; 1 in 3.LS; X > 0.15 # fe_xdomain2 = XFESubDomain( domain = fe_domain, #third crack # fets_eval = xfets_eval, # fe_grid_slice = fe_grid1['-88.81571047 *X**3+ 56.5274648 *X**2 -\ # 10.97186991*X +0.66858495-Y'] )#p=3 # fe_xdomain2.deactivate_sliced_elems() # #fifth crack: 1 in 3. LS; X > 0.0875 #fe_xdomain3 = XFESubDomain( domain = fe_domain, #fifth crack # fets_eval = xfets_eval, # fe_grid_slice = fe_grid1['9.50347099e+02*X**4 -5.47856002e+02*X**3+\ # 1.13942734e+02*X**2 -9.37037987*X+\ # 2.56078567e-01-Y'] )#p=4 #fe_xdomain3.deactivate_sliced_elems() ## ##second crack: 0.035 in 2. and further LS #fe_xdomain4 = XFESubDomain( domain = fe_domain, #second crack # fets_eval = xfets_eval, # fe_grid_slice = fe_grid1['2.30769231*X**2+ 0.09807692*X -\ # 0.12504808 - Y '] ) #p=2 #fe_xdomain4.deactivate_sliced_elems() ## ##fourth crack: 0.02 in 3. and further LS #fe_xdomain5 = XFESubDomain( domain = fe_domain, #fourth crack # fe_grid_slice = fe_grid1['X - 0.615*0.25 - Y '] ) #p=1 #fe_xdomain5.deactivate_sliced_elems() # ## ##sixth crack: 0.051 in 3.LS; 0.066 in 4.LS; X > 0.0425 #fe_xdomain6 = XFESubDomain( domain = fe_domain, #sixth crack # fets_eval = xfets_eval, # fe_grid_slice = fe_grid1['7.36512162e+02*X**4 -3.12383247e+02*X**3 +\ # 4.72881197e+01*X**2 -2.41064925*X+\ # 3.73082528e-02 - Y'] ) #p=4 #fe_xdomain6.deactivate_sliced_elems() # ## ##seventh crack: 0.025 in 4.LS; X > 0.0125 #fe_xdomain7 = XFESubDomain( domain = fe_domain, #seventh crack # fets_eval = xfets_eval, # fe_grid_slice = fe_grid1[' 1.89166054e+02*X**3 + 6.13523745*X**2+\ # 0.107873027*X -7.68782666e-03 -Y'] ) #p=3 # class FakeSlice( HasTraits ): # dofs = Array( int ) # elems = Array( int ) # dof_X = Array( float ) # # fs1 = FakeSlice() # c1 = fe_xdomain.elem_dof_map[-7:, -32:].reshape( -1, 16, 2 ) # #c1 = fe_xdomain.elem_dof_map[:, -32:].reshape( -1, 16, 2 ) # #c2a = fe_xdomain2.elem_dof_map[:-11, -32:].reshape( -1, 16, 2 ) # # #fs1.dofs = np.vstack( ( c1, c2a ) ) # fs1.dofs = c1 # fs1.elems = np.zeros( fs1.dofs.shape[0] ) # fs1.dof_X = np.zeros( ( fs1.dofs.shape[0], 3 ) ) ## # ## # ## fs2 = FakeSlice() ## c2b = fe_xdomain2.elem_dof_map[-11:, -32:].reshape( -1, 16, 2 ) ## fs2.dofs = c2b ## fs2.elems = np.zeros( fs2.dofs.shape[0] ) ## fs2.dof_X = np.zeros( ( fs2.dofs.shape[0], 3 ) ) bc_list = [ BCSlice( var = 'u', value = 0.0004 , dims = [0, 2], #value = 0.002 slice = fe_grid1[ -1, :-1, : ] ), BCSlice( var = 'u', value = 0., dims = [0, 1], slice = fe_grid1[ 0, 0, 0, 0 ] ), BCSlice( var = 'u', value = -.001 , dims = [1], slice = fe_grid1[-1, :, -1, :] ), #redundant bc removed automatically during initiation #BCDof( var = 'u', value = 0., dof = 1 ) ] boundary_list = [bls_function, bls_function, #redundant bc removed automatically during initiation bls_function ] class ChangeBC( AStrategyBase ): def begin_time_step( self, t ): '''Prepare a new load step ''' print 'begin_time_step' ls = boundary_list.pop() fe_xdomain.bls_function = ls fe_tip_xdomain.ls_function = ls fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() cdofs = fe_tip_xdomain.elem_xdof_map.flatten() const_list = [ BCDof( var = 'u', dof = dof, value = 0.0 ) for dof in cdofs ] print 'dof offset arr ', fe_domain.dof_offset_arr self.tloop.bcond_list = bc_list + const_list K = self.tstepper.K K.reset() for bc in self.tloop.bcond_list: bc.setup( 'sctx' ) #BCDofGroup and BCSlice are realized during their setup #hack: sctx not used, therefore dummy string parsed for bc in self.tloop.bcond_list: bc.apply_essential( K ) ##treatment of ls #fe_xdomain.boundary = boundary_list[0] def end_time_step( self, t ): '''Prepare a new load step ''' print 'end_time_step' self.tloop.bcond_list = [] #bc_list.pop() cdofs = fe_tip_xdomain.elem_xdof_map.flatten() bc_tip_list = [ BCDof( var = 'u', dof = dof, value = 0.0 ) for dof in cdofs ] ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = bc_list + bc_tip_list, rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), ############################################ RTraceDomainListField( name = 'Displ matrix' , var = 'u_m' , warp = True, warp_var = 'u_m' ), # RTraceDomainListField( name = 'Displ reinf' , # warp = True, # warp_var = 'u_f', # var = 'u_f' ), # RTraceDomainListField( name = 'Strain matrix' , # var = 'eps_m', warp_var = 'u_m' ), # RTraceDomainListField( name = 'Strain reinf' , # var = 'eps_f', warp_var = 'u_f' ), #, ## RTraceDomainListField( name = 'Stress matrix' , ## var = 'sig_app_m' ), ## RTraceDomainListField( name = 'Stress reinf' , ## var = 'sig_app_f' ), # RTraceDomainListField( name = 'slip' , # var = 'eps_b', warp_var = 'u_f' ), # RTraceDomainListField( name = 'bond stress' , # var = 'sig_b', warp_var = 'u_f' ), ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, #adap = ChangeBC(), tline = TLine( min = 0.0, step = .25, max = .5 ) ) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField, BCDof from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.mats.mats2D5.mats2D5_bond.mats2D5_plastic_bond import MATS2D5PlasticBond from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from ibvpy.fets.fets_ls.fets_crack import FETSCrack import numpy as np # from fets2D4qtf import FETS2D4QTF # from fets2D4q8utf import FETS2D4Q8UTF # from fets2D4q9utf import FETS2D4Q9UTF fets_eval = FETS2D4Q( mats_eval = MATS2DElastic( E = 1., nu = 0. ) ) # fets_eval = FETS2DTF( parent_fets = FETS2D4Q(), # mats_eval = MATS2D5PlasticBond( # E_m = 340., nu_m = 0.2, # E_f = 6., nu_f = 0., # G = 1.25e5, sigma_y = 100000., # stress_state = 'plane_strain' ) ) # xfets_eval = FETSCrackTF( parent_fets = fets_eval, # debug_on = True, # int_order = 5 ) xfets_eval = FETSCrack( parent_fets = fets_eval, int_order = 3 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( #coord_min = ( 1.5, -1.5, 0. ), coord_max = ( 3., 3., 0. ), shape = ( 3, 3 ), fets_eval = fets_eval, level = fe_level1 ) enr = True if enr: H = lambda x: np.array( 0.5 * np.sign( x ) + 1, dtype = int ) fe_xdomain = XFESubDomain( domain = fe_domain, rt_quad = False, fets_eval = xfets_eval, boundary = lambda X, Y: H( -Y + 1.5 ), # fe_grid_slice = fe_grid1['(X+1.)**2 + (Y-1.5)**2 - 5.1 '] #fe_grid_slice = fe_grid1['X - 0.5*Y - 1.51 '] ) print 'elems', fe_xdomain.dof_node_ls_values ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [ BCDofGroup( var = 'u', value = .2, dims = [0 ], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [0, 1], get_dof_method = fe_grid1.get_left_dofs ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displ' , var = 'u' ), # RTraceDomainListField(name = 'Strain reinf mtrl' , # var = 'eps_app_f', # warp = True, # warp_var = 'u_f'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) if enr: #print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() #fe_xdomain2.deactivate_sliced_elems() # print 'parent elems ', fe_xdomain.fe_grid_slice.elems # print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs # print "dofmap ", fe_xdomain.elem_dof_map # print "ls_values ", fe_xdomain.dots.dof_node_ls_values # print 'intersection points ', fe_xdomain.fe_grid_slice.r_i # print "triangles ", fe_xdomain.dots.rt_triangles # print "vtk points ", fe_xdomain.dots.vtk_X # print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'nodes', 0, 0 ) # print 'ip_triangles', fe_xdomain.dots.int_division # print 'ip_coords', fe_xdomain.dots.ip_coords # print 'ip_weigths', fe_xdomain.dots.ip_weights # print 'ip_offset', fe_xdomain.dots.ip_offset # print 'ip_X_coords', fe_xdomain.dots.ip_X # print 'ip_ls', fe_xdomain.dots.ip_ls_values # print 'vtk_ls', fe_xdomain.dots.vtk_ls_values # print 'J_det ', fe_xdomain.dots.J_det_grid tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
# var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # # # Add the time-loop control tloop = TLoop( tstepper=ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline=TLine(min=0.0, step=1., max=1.0)) # print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() print('parent elems ', fe_xdomain.fe_grid_slice.elems) print('parent dofs ', fe_xdomain.fe_grid_slice.dofs) print("dofmap ", fe_xdomain.elem_dof_map) print("ls_values ", fe_xdomain.dots.dof_node_ls_values) print('intersection points ', fe_xdomain.fe_grid_slice.r_i) print("triangles ", fe_xdomain.dots.rt_triangles) print("vtk points ", fe_xdomain.dots.vtk_X) print("vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0)) print('ip_triangles', fe_xdomain.dots.int_division) print('ip_coords', fe_xdomain.dots.ip_coords)
def _tloop_default(self): return TLoop()
record_on='update'), ]) # Put the time-stepper into the time-loop # if elastic_debug: tmax = 1. n_steps = 1 else: tmax = 0.001 # tmax = 0.0006 n_steps = 100 tl = TLoop(tstepper=ts, DT=tmax / n_steps, KMAX=100, RESETMAX=0, min=0.0, max=tmax) # T=TRange(min=0.0, max=tmax)) from numpy import argmax alpha_arr = np.linspace(-pi / 2 * 1.05, 2 * (pi / 2.) + pi / 2. * 0.05, 20) sig0_m_list = [] sig1_m_list = [] eps0_m_list = [] eps1_m_list = [] for alpha in alpha_arr:
def example_2d(): from ibvpy.core.astrategy import AStrategyBase from ibvpy.api import BCDof, BCDofGroup, FEGrid, BCSlice, FEDomain, \ FERefinementGrid, TStepper as TS, RTraceDomainListField from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from apps.scratch.jakub.global_enrichement.fets_crack_tf import FETSCrackTF from ibvpy.mesh.xfe_subdomain import XFESubDomain from enthought.traits.api import HasTraits, Array from ibvpy.mesh.fe_ls_domain import FELSDomain from mathkit.matrix_la.sys_mtx_assembly import SysMtxAssembly from ibvpy.mats.mats2D5.mats2D5_bond.mats2D5_plastic_bond import MATS2D5PlasticBond from ibvpy.core.tloop import TLoop, TLine import numpy as np ######################################### #Material Parameters ######################################### #E_m = 34 000 MPa #nu_m = 0.2 #E_f = 54 000 MPa #Tau_fr = 3 MPA #G = 30 000 MPa #s_crit assumed 1.e-5 yielding m_eval = MATS2D5PlasticBond( E_m = 340. , #MPa including thickness 0.01M nu_m = 0.2, # E_f = 6., #MPa EA nu_f = 0., G = 1.25e5 , #MPa #sigma_y = 1.25 , #MPa \tau_fr sigma_y = 1.0 * 50. , #temporary set higher to avoid nonlinear comp. stress_state = 'plane_stress' ) fets_eval = FETS2DTF( parent_fets = FETS2D4Q(), mats_eval = m_eval ) xfets_eval = FETSCrackTF( parent_fets = fets_eval, int_order = 5 , tri_subdivision = 0 ) # Discretization fineness_x = 3 fineness_y = 3 fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 0.2, 0.2, 0. ), shape = ( fineness_x, fineness_y ), fets_eval = fets_eval, level = fe_level1 ) # inclined crack with moving circles as domain ls_function = lambda X, Y: X - 0.07 - Y bls_function1 = lambda X, Y:-( ( X - 0.07 ) ** 2 + ( Y - 0.0 ) ** 2 - 0.08 ** 2 ) bls_function2 = lambda X, Y:-( ( X - 0.07 ) ** 2 + ( Y - 0.0 ) ** 2 - 0.14 ** 2 ) # vertical crack with lower halfspace as a domain ls_function = lambda X, Y: X - 0.0343 - Y ls_function2 = ls_function # lambda X, Y: X - 0.03 - Y bls_function1 = lambda X, Y:-( Y - 0.1734 ) bls_function2 = lambda X, Y:-( Y - 0.09596 ) bls_function3 = lambda X, Y:-( Y - 0.19 ) fe_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_grid1, ls_function = ls_function, bls_function = bls_function1, # ) fe_tip_xdomain = FELSDomain( domain = fe_domain, fets_eval = xfets_eval, fe_grid = fe_xdomain, ls_function = bls_function1, ) # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() bc_list = [ # BCSlice( var = 'u', value = 0.0004 , dims = [0, 2], #value = 0.002 # slice = fe_grid1[ -1, :-1, : ] ), BCSlice( var = 'u', value = 0., dims = [0, 1], slice = fe_grid1[ 0, :, 0, : ] ), BCSlice( var = 'u', value = .01 , dims = [0], slice = fe_grid1[-1, :, -1, :] ), #redundant bc removed automatically during initiation #BCDof( var = 'u', value = 0., dof = 1 ) ] ls_list = [ls_function2, ls_function, #redundant bc removed automatically during initiation ls_function ] boundary_list = [bls_function2, bls_function1, #redundant bc removed automatically during initiation bls_function1 ] class ChangeBC( AStrategyBase ): def begin_time_step( self, t ): '''Prepare a new load step ''' # before changing anything - remember the old dof_offsets of the domains old_dof_offset_arr = fe_domain.dof_offset_arr.copy() print 'begin_time_step' bls = boundary_list.pop() ls = ls_list.pop() # reactivate everything fe_grid1.inactive_elems = [] fe_xdomain.idx_mask[...] = False fe_tip_xdomain.idx_mask[...] = False fe_xdomain.ls_function = ls fe_xdomain.bls_function = bls fe_tip_xdomain.ls_function = bls fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() old_U_k = self.tloop.U_k.copy() self.tstepper.sdomain.changed_structure = True # Initialize the variables # self.tloop.R_k = self.tstepper.new_resp_var() self.tloop.U_k = self.tstepper.U_k self.tloop.d_U = self.tstepper.d_U self.tloop.U_n = self.tstepper.new_cntl_var() self.tstepper.K = SysMtxAssembly() new_U_k = self.tloop.U_k new_dof_offset_arr = fe_domain.dof_offset_arr #copy the segments of the old displacements into the new vector for os, oe, ns, ne in zip( old_dof_offset_arr[:-1], old_dof_offset_arr[1:], new_dof_offset_arr[:-1], new_dof_offset_arr[1:] ): min_length = min( oe - os, ne - ns ) new_U_k[ ns: ns + min_length ] = old_U_k[ os: os + min_length ] self.cdofs = fe_tip_xdomain.elem_xdof_map.flatten() # set the crack tip (jump that was there so far to zero) # new_U_k[ self.cdofs ] = 0.0 const_list = [ BCDof( var = 'u', dof = dof, value = 0.0 ) for dof in self.cdofs ] self.tloop.bcond_list = bc_list + const_list K = self.tstepper.K K.reset() for bc in self.tloop.bcond_list: bc.setup( 'sctx' ) #BCDofGroup and BCSlice are realized during their setup #hack: sctx not used, therefore dummy string parsed for bc in self.tloop.bcond_list: bc.apply_essential( K ) ##treatment of ls #fe_xdomain.boundary = boundary_list[0] def end_time_step( self, t ): '''Prepare a new load step ''' print 'end_time_step' self.tloop.bcond_list = [] #bc_list.pop() #cdofs = fe_tip_xdomain.elem_xdof_map.flatten() #bc_tip_list = [ BCDof( var = 'u', dof = dof, value = 0.0 ) # for dof in cdofs ] ts = TS( dof_resultants = True, sdomain = fe_domain, #bcond_list = bc_list + bc_tip_list, rtrace_list = [ RTraceDomainListField( name = 'Displ matrix' , var = 'u_m' , warp = True, warp_var = 'u_m' ), # RTraceDomainListField( name = 'Displ reinf' , # warp = True, # warp_var = 'u_f', # var = 'u_f' ), # RTraceDomainListField( name = 'Strain matrix' , # var = 'eps_m', warp_var = 'u_m' ), # RTraceDomainListField( name = 'Strain reinf' , # var = 'eps_f', warp_var = 'u_f' ), #, ## RTraceDomainListField( name = 'Stress matrix' , ## var = 'sig_app_m' ), ## RTraceDomainListField( name = 'Stress reinf' , ## var = 'sig_app_f' ), # RTraceDomainListField( name = 'slip' , # var = 'eps_b', warp_var = 'u_f' ), RTraceDomainListField( name = 'bond stress' , var = 'sig_b', warp_var = 'u_f' ), ] ) # # # Add the time-loop control adap = ChangeBC() tloop = TLoop( tstepper = ts, adap = adap, debug = False, tline = TLine( min = 0.0, step = .25, max = .25 ) ) u = tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField, BCSlice from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from fets_crack_tf_sopu import FETSCrackTFSOPU from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U #from ibvpy.fets.fets2D.fets2D4q25u import FETS2D4Q25U from ibvpy.fets.fets_eval import RTraceEvalElemFieldVar from numpy import dot, array, linalg, sum, deg2rad, argsort, arange, \ ones_like, vstack, ones, hstack, linspace, cosh from math import pi, sin, cos, sqrt import matplotlib.pyplot as plt # from fets2D4qtf import FETS2D4QTF # from fets2D4q8utf import FETS2D4Q8UTF # from fets2D4q9utf import FETS2D4Q9UTF #fets_eval = FETS2D4Q(mats_eval = MATS2DElastic(E= 1.,nu=0.)) fets_eval = FETS2DTF( parent_fets = FETS2D4Q(), mats_eval = MATS2D5Bond( E_m = 1., nu_m = 0., E_f = 1., nu_f = 0., G = 5., stress_state = 'plane_stress' ) ) fets_eval_sopu = FETS2DTF( parent_fets = FETS2D4Q(), mats_eval = MATS2D5Bond( E_m = 1., nu_m = 0., E_f = 1., nu_f = 0., G = 5., stress_state = 'plane_stress' ) ) xfets_eval = FETSCrackTFSOPU( parent_fets = fets_eval, sopu_fets = fets_eval_sopu, int_order = 5 ) alpha = 90.# angle of the crack measured anticlockwise from x axis alpha_r = deg2rad( alpha ) crack_normal = array( [sin( alpha_r ), -cos( alpha_r )] ) print 'crack_normal ', crack_normal def xget_eps_mn( sctx, u ): e_id = sctx.e_id p_id = sctx.p_id X_mtx = sctx.X r_pnt = sctx.loc B_mtx = xfets_eval.get_B_mtx( r_pnt, X_mtx, sctx.dots.dof_node_ls_values[e_id], sctx.dots.vtk_ls_values[e_id][p_id] ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[0], eps[2]], [eps[2], eps[1]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) def xget_eps_fn( sctx, u ): e_id = sctx.e_id p_id = sctx.p_id X_mtx = sctx.X r_pnt = sctx.loc B_mtx = xfets_eval.get_B_mtx( r_pnt, X_mtx, sctx.dots.dof_node_ls_values[e_id], sctx.dots.vtk_ls_values[e_id][p_id] ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[3], eps[5]], [eps[5], eps[4]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) xfets_eval.rte_dict.update( {'eps_mn' : RTraceEvalElemFieldVar( eval = xget_eps_mn ), 'eps_fn' : RTraceEvalElemFieldVar( eval = xget_eps_fn )} ) def get_eps_mn( sctx, u ): X_mtx = sctx.X r_pnt = sctx.loc B_mtx = fets_eval.get_B_mtx( r_pnt, X_mtx ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[0], eps[2]], [eps[2], eps[1]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) def get_eps_fn( sctx, u ): X_mtx = sctx.X r_pnt = sctx.loc B_mtx = fets_eval.get_B_mtx( r_pnt, X_mtx ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[3], eps[5]], [eps[5], eps[4]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) fets_eval.rte_dict.update( {'eps_mn' : RTraceEvalElemFieldVar( eval = get_eps_mn ), 'eps_fn' : RTraceEvalElemFieldVar( eval = get_eps_fn )} ) # Discretization #lin(3,2),(7,4),(15,10),(21,14),(31,21),(43,28),(63,42) #quad (3,2),(5,3),(7,4),(11,7),(17,11),(21,14),(31,21) #cub(1,1),(3,2),(5,3),(7,4),(11,7),(15,10),(21,14) fineness_x = 9 fineness_y = 1 fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 3.1, .15, 0. ), shape = ( fineness_x, fineness_y ), fets_eval = fets_eval, level = fe_level1 ) tracer_em = RTraceDomainListField( name = 'Strain matrix' , var = 'eps_m' ) tracer_ef = RTraceDomainListField( name = 'Strain reinf' , var = 'eps_f' ) enr = True if enr: fe_xdomain = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, rt_tol = 0., fe_grid_slice = fe_grid1['X - 1.55'] )#90.deg #fe_grid_slice = fe_grid1['X - 1.7320508075688767 *Y +0.26865334794732054'] )#30.deg #fe_grid_slice = fe_grid1['Y - 1.05'] )#0.deg #fe_grid_slice = fe_grid1['X-Y - .55'] )#45.deg #fe_grid_slice = fe_grid1['X-0.57735026918962573*Y - 0.94378221735089296'] )#60.deg ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [ # BCDofGroup(var='u', value = .2, dims = [0], # get_dof_method = fe_grid1.get_right_dofs ), #force bc valid for bilinear elems #TODO:make it work again # BCSlice(var='u', value = 0., dims = [0], # link_slice = fe_grid1[-1,:,-1,:], # link_coeffs = [1.], # link_dims = [2], # slice = fe_grid1[-1,:,-1,:]), BCDofGroup( var = 'u', value = 0., dims = [0], get_dof_method = fe_grid1.get_right_dofs, link_coeffs = [1.], link_dims = [2], get_link_dof_method = fe_grid1.get_right_dofs ), BCSlice( var = 'f', value = 1., dims = [0], slice = fe_grid1[-1, :, -1, :] ), ################################################### # #force bc valid for biquadratic elems # BCSlice(var='f', value = 1./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,0]), # BCSlice(var='f', value = 1./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,-1]), # BCSlice(var='f', value = 4./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,1]), ################################################### # #force bc valid for bicubic elems # BCSlice(var='f', value = .25/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,0]), # BCSlice(var='f', value = .25/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,-1]), # BCSlice(var='f', value = .75/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,1:-1]), ##################################################### # BCSlice(var='u', value = 1., dims = [0,2], # slice = fe_grid1[-1,:,-1,:]), BCDofGroup( var = 'u', value = 0., dims = [0, 2], get_dof_method = fe_grid1.get_left_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1, 3], get_dof_method = fe_grid1.get_bottom_left_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1, 3], get_dof_method = fe_grid1.get_bottom_right_dofs ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), # RTraceDomainListField(name = 'Displ matrix' , # var = 'u_m'), # RTraceDomainListField(name = 'Displ reinf' , # var = 'u_f'), tracer_em, tracer_ef, # RTraceDomainListField(name = 'Stress matrix' , # var = 'sig_app_m'), # RTraceDomainListField(name = 'Stress reinf' , # var = 'sig_app_f')#, # warp = True, # warp_var = 'u_f'), # RTraceDomainListField(name = 'Strain reinf mtrl' , # var = 'eps_app_f', # warp = True, # warp_var = 'u_f'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) fe_xdomain.deactivate_sliced_elems() tloop.eval() em = tracer_em.subfields[0] xem = tracer_em.subfields[1] xdata = em.vtk_X[:, 0].reshape( 2, -1 ) ydata = em.field_arr[:, 0, 0].reshape( 2, -1 ) idata = argsort( xdata , axis = 1 ) exdata = xem.vtk_X[:, 0] eydata = xem.field_arr[:, 0, 0] eidata = argsort( exdata ) #connect x_ax = hstack( ( hstack( ( xdata[0, idata[0]], exdata[eidata] ) ), xdata[1, idata[1]] ) ) / 3.1 y_ax = hstack( ( hstack( ( ydata[0, idata[0]], eydata[eidata] ) ), ydata[1, idata[1]] ) ) plt.plot( x_ax, y_ax, linewidth = 2, color = 'black' ) ef = tracer_ef.subfields[0] xef = tracer_ef.subfields[1] xdata = ef.vtk_X[:, 0].reshape( 2, -1 ) ydata = ef.field_arr[:, 0, 0].reshape( 2, -1 ) idata = argsort( xdata , axis = 1 ) exdata = xef.vtk_X[:, 0] eydata = xef.field_arr[:, 0, 0] eidata = argsort( exdata ) #connect x_ax = hstack( ( hstack( ( xdata[0, idata[0]], exdata[eidata] ) ), xdata[1, idata[1]] ) ) / 3.1 y_ax = hstack( ( hstack( ( ydata[0, idata[0]], eydata[eidata] ) ), ydata[1, idata[1]] ) ) plt.plot( x_ax, y_ax, linewidth = 2, color = 'silver' ) # #analytical lines # xa = linspace(0.,0.5,10) # omega = sqrt(5.) # ya = xa *cosh(omega*xa)/cosh(omega*0.5) # # print 'analyt. ',xa,ya # plt.plot( xa, ya, linewidth = 1, color = 'silver') plt.xlim( 0., 1. ) plt.ylim( 0., 1. ) plt.xlabel( r'$x$', fontsize = 20, family = 'serif' ) plt.ylabel( r'$\varepsilon_x$', fontsize = 20, family = 'serif', rotation = 'horizontal', verticalalignment = 'top' ) #plt.grid(linestyle='-', linewidth=1, color = 'grey') plt.axhline( y = 0.5, linewidth = 1, color = 'black' ) plt.axhline( y = 0.75, linewidth = 1, linestyle = '--', color = 'lightsteelblue' ) plt.axhline( y = 0.25, linewidth = 1, linestyle = '--', color = 'lightsteelblue' ) plt.axvline( x = 0.5 , linewidth = 1, color = 'lightsteelblue' ) plt.xticks( [0.5] , ( '' ) ) plt.yticks( linspace( 0., 1., 5 ) , ( '0.0', '0.25', '0.5', '0.75', '1.0' ) ) plt.annotate( r'$\varepsilon_\mathrm{f}$', xy = ( 0.5, 0.5 ), xytext = ( 0.35, 0.75 ), fontsize = 18, family = 'serif' ) plt.annotate( r'$\varepsilon_\mathrm{m}$', xy = ( 0.5, 0.5 ), xytext = ( 0.3, 0.25 ), fontsize = 18, family = 'serif' ) plt.show()
def example_2d(): disc_integ = 0 from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets_ls.fets_crack import FETSCrack fets_eval = FETS2D4Q( mats_eval = MATS2DElastic( E = 10., nu = 0, stress_state = "plane_strain" ) ) xfets_eval = FETSCrack( parent_fets = fets_eval, mats_eval_pos = MATS2DElastic( E = 10., nu = 0., stress_state = "plane_strain" ), mats_eval_neg = MATS2DElastic( E = 10., nu = 0., stress_state = "plane_strain" ), mats_eval_disc = MATS2DElastic( E = 10., nu = 0., stress_state = "plane_strain" ), int_order = 3 )#, nip_disc = disc_integ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 1., 1., 0. ), shape = ( 1, 1 ), fets_eval = fets_eval, level = fe_level1 ) # fe_grid1.deactivate( (1,0) ) # fe_grid1.deactivate( (1,1) ) fe_xdomain = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice = fe_grid1['X - .5 '] ) fe_xdomain.deactivate_sliced_elems() ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [BCDofGroup( var = 'u', value = 1., dims = [0], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [0, 1], get_dof_method = fe_grid1.get_left_dofs ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displacement' , var = 'u', idx = 0, warp = True ), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, #debug = True, #tolerance = 1e-4, KMAX = 3, #RESETMAX = 0, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) print 'parent elems ', fe_xdomain.fe_grid_slice.elems print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.fe_grid_slice.r_i print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'blabla', 0, 0 ) print 'ip_triangles', fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights print 'ip_offset', fe_xdomain.dots.ip_offset print 'ip_X_coords', fe_xdomain.dots.ip_X print 'ip_ls', fe_xdomain.dots.ip_ls_values print 'vtk_ls', fe_xdomain.dots.vtk_ls_values print 'J_det ', fe_xdomain.dots.J_det_grid print 'X_i ', fe_xdomain.dots.X_i if disc_integ: print 'ip_disc_coords', fe_xdomain.dots.ip_disc_coords print 'ip_disc_weigths', fe_xdomain.dots.ip_disc_weights print 'ip_disc_offset', fe_xdomain.dots.ip_disc_offset print 'J_disc_det ', fe_xdomain.dots.J_disc_grid print tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
tseval = MATS1DElastic() ts = TS(tse = tseval, bcond_list = [ BCDof(var = 'u', dof = 0, value = 1.) ], rtrace_list = [ RTraceGraph(name = 'strain 0 - stress 0', var_x = 'eps_app', idx_x = 0, var_y = 'sig_app', idx_y = 0, update_on = 'update') ] ) # Put the time-stepper into the time-loop # tmax = 4.0 # tmax = 0.0006 n_steps = 100 tl = TLoop(tstepper = ts, DT = tmax / n_steps, KMAX = 100, RESETMAX = 0, tline = TLine(min = 0.0, max = tmax)) # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # tl.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(tloop = tl) app.main()
tseval = MATSProxy() E_mod_varpar = tseval.varpars['E'] E_mod_varpar.spatial_fn = MFnNDGrid(shape=(10, 10, 1), x_maxs=GridPoint(x=10, y=10)) ts = TS(tse=tseval, bcond_list=[BCDof(var='u', dof=0, value=1.)], rtrace_list=[ RTDofGraph(name='strain 0 - stress 0', var_x='eps_app', idx_x=0, var_y='sig_app', idx_y=0, record_on='update') ]) # Put the time-stepper into the time-loop # tmax = 4.0 # tmax = 0.0006 n_steps = 100 tl = TLoop(tstepper=ts, DT=tmax / n_steps, KMAX=100, RESETMAX=0, tline=TLine(min=0.0, max=tmax)) isim = IS(tloop=tl) isim.configure_traits()
def example_1d(): fets_eval = FETS1D2L3U( mats_eval = MATS1DElastic( E = 20. ) ) xfets_eval = FETSCrack( parent_fets = fets_eval, int_order = 2 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 2., 0., 0. ), shape = ( 2, ), fets_eval = fets_eval, level = fe_level1 ) enr = True if enr: fe_xdomain = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice = fe_grid1['X - .75'] ) fe_xdomain.deactivate_sliced_elems() ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [BCSlice( var = 'u', value = -1. / 2., dims = [0], slice = fe_grid1[ 0, 0 ] ), BCSlice( var = 'u', value = 0., dims = [0], slice = fe_grid1[ -1, -1 ] ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField( name = 'Stress' , var = 'eps', idx = 0, warp = True ), RTraceDomainListField( name = 'Displacement' , var = 'u', idx = 0, warp = True ), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, debug = True, tolerance = 1e-4, RESETMAX = 0, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) #print "elements ",fe_xdomain.elements[0] if enr: print 'parent elems ', fe_xdomain.fe_grid_slice.elems print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.fe_grid_slice.r_i# print "triangles ", fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights print 'ip_offset ', fe_xdomain.dots.ip_offset print 'ip_X_coords', fe_xdomain.dots.ip_X print 'ip_ls', fe_xdomain.dots.ip_ls_values print 'vtk_X ', fe_xdomain.dots.vtk_X print 'vtk triangles ', fe_xdomain.dots.rt_triangles print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'blabla', 0, 0 ) print 'vtk_ls', fe_xdomain.dots.vtk_ls_values print 'J_det ', fe_xdomain.dots.J_det_grid tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField, BCSlice from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from fets_crack_tf_sopu import FETSCrackTFSOPU from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond #from fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from fets_crack_tf_sopu import FETSCrackTFSOPU from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from ibvpy.fets.fets_eval import RTraceEvalElemFieldVar from numpy import dot, array, linalg, sum, deg2rad from math import pi, sin, cos # from fets2D4qtf import FETS2D4QTF # from fets2D4q8utf import FETS2D4Q8UTF # from fets2D4q9utf import FETS2D4Q9UTF #fets_eval = FETS2D4Q(mats_eval = MATS2DElastic(E= 1.,nu=0.)) fets_eval = FETS2DTF( parent_fets = FETS2D4Q9U(), mats_eval = MATS2D5Bond( E_m = 1., nu_m = 0., E_f = 1., nu_f = 0., G = 10., stress_state = 'plane_stress' ) ) fets_eval_sopu = FETS2DTF( parent_fets = FETS2D4Q(), mats_eval = MATS2D5Bond( E_m = 1., nu_m = 0., E_f = 1., nu_f = 0., G = 10., stress_state = 'plane_stress' ) ) xfets_eval = FETSCrackTFSOPU( parent_fets = fets_eval, sopu_fets = fets_eval_sopu, int_order = 5 ) alpha = 90.# angle of the crack measured anticlockwise from x axis alpha_r = deg2rad( alpha ) crack_normal = array( [sin( alpha_r ), -cos( alpha_r )] ) print 'crack_normal ', crack_normal def xget_eps_mn( sctx, u ): e_id = sctx.e_id p_id = sctx.p_id X_mtx = sctx.X r_pnt = sctx.loc B_mtx = xfets_eval.get_B_mtx( r_pnt, X_mtx, sctx.dots.dof_node_ls_values[e_id], sctx.dots.vtk_ls_values[e_id][p_id] ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[0], eps[2]], [eps[2], eps[1]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) def xget_eps_fn( sctx, u ): e_id = sctx.e_id p_id = sctx.p_id X_mtx = sctx.X r_pnt = sctx.loc B_mtx = xfets_eval.get_B_mtx( r_pnt, X_mtx, sctx.dots.dof_node_ls_values[e_id], sctx.dots.vtk_ls_values[e_id][p_id] ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[3], eps[5]], [eps[5], eps[4]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) xfets_eval.rte_dict.update( {'eps_mn' : RTraceEvalElemFieldVar( eval = xget_eps_mn ), 'eps_fn' : RTraceEvalElemFieldVar( eval = xget_eps_fn )} ) def get_eps_mn( sctx, u ): X_mtx = sctx.X r_pnt = sctx.loc B_mtx = fets_eval.get_B_mtx( r_pnt, X_mtx ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[0], eps[2]], [eps[2], eps[1]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) def get_eps_fn( sctx, u ): X_mtx = sctx.X r_pnt = sctx.loc B_mtx = fets_eval.get_B_mtx( r_pnt, X_mtx ) eps = dot( B_mtx, u ) p_eps, p_vct = linalg.eigh( array( [[eps[3], eps[5]], [eps[5], eps[4]]] ) ) return array( [-sum( dot( ( p_eps[:, None] * p_vct ), crack_normal ) )] ) fets_eval.rte_dict.update( {'eps_mn' : RTraceEvalElemFieldVar( eval = get_eps_mn ), 'eps_fn' : RTraceEvalElemFieldVar( eval = get_eps_fn )} ) # Discretization #lin(3,2),(7,4),(15,10),(21,14),(31,21),(43,28),(63,42) #quad (3,2),(5,3),(7,4),(11,7),(17,11),(22,14),(31,21) #cub(1,1),(3,2),(5,3),(7,4),(11,7),(15,10),(21,14) fineness_x = 17 fineness_y = 11 fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 3.1, 2.1, 0. ), shape = ( fineness_x, fineness_y ), fets_eval = fets_eval, level = fe_level1 ) enr = True if enr: fe_xdomain = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, rt_tol = 0., fe_grid_slice = fe_grid1['X - 1.55'] )#90.deg #fe_grid_slice = fe_grid1['X - 1.7320508075688767 *Y +0.26865334794732054'] )#30.deg #fe_grid_slice = fe_grid1['Y - 1.05'] )#0.deg #fe_grid_slice = fe_grid1['X-Y - .55'] )#45.deg #fe_grid_slice = fe_grid1['X-0.57735026918962573*Y - 0.94378221735089296'] )#60.deg ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [ # BCDofGroup(var='u', value = .2, dims = [0], # get_dof_method = fe_grid1.get_right_dofs ), #force bc valid for bilinear elems #TODO:make it work again # BCSlice(var='u', value = 0., dims = [0], # link_slice = fe_grid1[-1,:,-1,:], # link_coeffs = [1.], # link_dims = [2], # slice = fe_grid1[-1,:,-1,:]), BCDofGroup( var = 'u', value = 0., dims = [0], get_dof_method = fe_grid1.get_right_dofs, link_coeffs = [1.], link_dims = [2], get_link_dof_method = fe_grid1.get_right_dofs ), BCSlice( var = 'f', value = 1., dims = [0], slice = fe_grid1[-1, :, -1, :] ), ################################################### # #force bc valid for biquadratic elems # BCSlice(var='f', value = 1./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,0]), # BCSlice(var='f', value = 1./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,-1]), # BCSlice(var='f', value = 4./3./2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,1]), ################################################### # #force bc valid for bicubic elems # BCSlice(var='f', value = .25/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,0]), # BCSlice(var='f', value = .25/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,-1]), # BCSlice(var='f', value = .75/2./fineness_y, dims = [0,2], # slice = fe_grid1[-1,:,-1,1:-1]), ##################################################### # BCSlice(var='u', value = 1., dims = [0,2], # slice = fe_grid1[-1,:,-1,:]), BCDofGroup( var = 'u', value = 0., dims = [0, 2], get_dof_method = fe_grid1.get_left_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1, 3], get_dof_method = fe_grid1.get_bottom_left_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1, 3], get_dof_method = fe_grid1.get_bottom_right_dofs ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), # RTraceDomainListField( name = 'Displ matrix' , # var = 'u_m' ), RTraceDomainListField( name = 'Displ reinf' , var = 'u_f', warp_var = 'u_f' ), # RTraceDomainListField( name = 'Strain matrix' , # var = 'eps_m' ), # RTraceDomainListField( name = 'Strain reinf' , # var = 'eps_f' ), #, # RTraceDomainListField( name = 'Stress matrix' , # var = 'sig_app_m' ), # RTraceDomainListField( name = 'Stress reinf' , # var = 'sig_app_f' )#, # warp = True, # warp_var = 'u_f'), # RTraceDomainListField(name = 'Strain reinf mtrl' , # var = 'eps_app_f', # warp = True, # warp_var = 'u_f'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) fe_xdomain.deactivate_sliced_elems() tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def construct_fail_envelope(): elastic_debug = False # Tseval for a material model # tseval = MACMDM( elastic_debug = elastic_debug ) value, coeff = get_value_and_coeff( 1., 0.0 ) bcond_alpha = BCDof(var='u', dof = 0, value = value, link_dofs = [1], link_coeffs = [coeff], time_function = lambda t: t ) ts = TS( tse = tseval, bcond_list = [ bcond_alpha ], rtrace_list = [ RTraceGraph(name = 'strain 0 - stress 0', var_x = 'eps_app', idx_x = 0, var_y = 'sig_app', idx_y = 0, record_on = 'update' ), RTraceGraph(name = 'strain 1 - stress 1', var_x = 'eps_app', idx_x = 1, var_y = 'sig_app', idx_y = 1, record_on = 'update' ), RTraceGraph(name = 'strain 0 - stress 1', var_x = 'eps_app', idx_x = 0, var_y = 'sig_app', idx_y = 1, record_on = 'update' ), RTraceGraph(name = 'strain 1 - stress 0', var_x = 'eps_app', idx_x = 1, var_y = 'sig_app', idx_y = 0, record_on = 'update' ), RTraceGraph(name = 'strain 0 - strain 1', var_x = 'eps_app', idx_x = 0, var_y = 'eps_app', idx_y = 1, record_on = 'update' ), ] ) # Put the time-stepper into the time-loop # if elastic_debug: tmax = 1. n_steps = 1 else: tmax = 0.001 # tmax = 0.0006 n_steps = 60 tl = TLoop( tstepper = ts, DT=tmax/n_steps, KMAX = 100, RESETMAX = 0, tline = TLine( min = 0.0, max = tmax ) ) from numpy import argmax alpha_arr = linspace( - Pi/2 * 1.05, 2*(Pi/2.) + Pi/2.*0.05, 20 ) sig0_m_list = [] sig1_m_list = [] eps0_m_list = [] eps1_m_list = [] for alpha in alpha_arr: value, coeff = get_value_and_coeff( 1., alpha ) bcond_alpha.value = value bcond_alpha.link_coeffs[0] = coeff tl.eval() eps0_sig0 = tl.rtrace_mngr.rtrace_list[0] eps1_sig1 = tl.rtrace_mngr.rtrace_list[1] sig0_midx = argmax( fabs( eps0_sig0.trace.ydata ) ) sig1_midx = argmax( fabs( eps1_sig1.trace.ydata ) ) sig0_m = eps0_sig0.trace.ydata[ sig0_midx ] sig1_m = eps1_sig1.trace.ydata[ sig1_midx ] eps0_m = eps0_sig0.trace.xdata[ sig0_midx ] eps1_m = eps1_sig1.trace.xdata[ sig1_midx ] sig0_m_list.append( sig0_m ) sig1_m_list.append( sig1_m ) eps0_m_list.append( eps0_m ) eps1_m_list.append( eps1_m ) from mfn_line import MFnLineArray sig_plot = MFnLineArray( xdata = sig0_m_list, ydata = sig1_m_list ) eps_plot = MFnLineArray( xdata = eps0_m_list, ydata = eps1_m_list ) sig_plot.configure_traits()
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField, BCDof from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from fets_crack_tf import FETSCrackTF from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.mats.mats2D5.mats2D5_bond.mats2D5_plastic_bond import MATS2D5PlasticBond from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U # from fets2D4qtf import FETS2D4QTF # from fets2D4q8utf import FETS2D4Q8UTF # from fets2D4q9utf import FETS2D4Q9UTF #fets_eval = FETS2D4Q(mats_eval = MATS2DElastic(E= 1.,nu=0.)) fets_eval = FETS2DTF( parent_fets = FETS2D4Q16U(), mats_eval = MATS2D5PlasticBond( E_m = 30, nu_m = 0., E_f = 3, nu_f = 0., G = 30., sigma_y = 100000., stress_state = 'plane_strain' ) ) xfets_eval = FETSCrackTF( parent_fets = fets_eval, debug_on = True, int_order = 5 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 3., 1., 0. ), shape = ( 3, 1 ), fets_eval = fets_eval, level = fe_level1 ) enr = True if enr: fe_xdomain = XFESubDomain( domain = fe_domain, rt_quad = False, fets_eval = xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice = fe_grid1['X - 1.5 - 0.2 *Y '] ) bcond_lock = [] for i in range( 160, 192 ): bcond_lock.append( BCDof( var = 'u', dof = i, value = 0. ) ) ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [ BCDofGroup( var = 'u', value = .2, dims = [0, ], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [1, 3], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup( var = 'u', value = 0., dims = [0, 1, 2, 3], get_dof_method = fe_grid1.get_left_dofs ), ] + bcond_lock, rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField( name = 'Displ matrix' , var = 'u_m', warp = True, warp_var = 'u_m' ), RTraceDomainListField( name = 'Displ reinf' , var = 'u_f', warp = True, warp_var = 'u_f' ), RTraceDomainListField( name = 'Strain matrix' , var = 'eps_m', warp = True, warp_var = 'u_m' ), RTraceDomainListField( name = 'Strain reinf' , var = 'eps_f', warp = True, warp_var = 'u_f' ), RTraceDomainListField( name = 'slip' , var = 'eps_b', #warp = True, warp_var = 'u_f' ), # RTraceDomainListField(name = 'Strain reinf mtrl' , # var = 'eps_app_f', # warp = True, # warp_var = 'u_f'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1, max = 1.0 ) ) fe_xdomain.deactivate_sliced_elems() if enr: #print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() #fe_xdomain2.deactivate_sliced_elems() print 'parent elems ', fe_xdomain.fe_grid_slice.elems print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.fe_grid_slice.r_i print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data( 'nodes', 0, 0 ) print 'ip_triangles', fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights print 'ip_offset', fe_xdomain.dots.ip_offset print 'ip_X_coords', fe_xdomain.dots.ip_X print 'ip_ls', fe_xdomain.dots.ip_ls_values print 'vtk_ls', fe_xdomain.dots.vtk_ls_values print 'J_det ', fe_xdomain.dots.J_det_grid tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
def example_2d(): from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D9q import FETS2D9Q fets_eval = FETS2D4Q(mats_eval=MATS2DElastic(E=1., nu=0.)) xfets_eval = FETSBimaterial(parent_fets=fets_eval, int_order=3, mats_eval=MATS2DElastic(E=1., nu=0.), mats_eval2=MATS2DElastic(E=5., nu=0.)) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(3., 1., 0.), shape=(3, 1), fets_eval=fets_eval, level=fe_level1) fe_xdomain = XFESubDomain( domain=fe_domain, fets_eval=xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice=fe_grid1['X - 1.5']) ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCDofGroup(var='u', value=1., dims=[0], get_dof_method=fe_grid1.get_right_dofs), BCDofGroup(var='u', value=0., dims=[1], get_dof_method=fe_grid1.get_right_dofs), BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_grid1.get_left_dofs), ], rtrace_list=[ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), RTraceDomainListField(name='Strain', var='eps', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # # # Add the time-loop control tloop = TLoop( tstepper=ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline=TLine(min=0.0, step=1., max=1.0)) #print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() print 'parent elems ', fe_xdomain.fe_grid_slice.elems print 'parent dofs ', fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print 'intersection points ', fe_xdomain.fe_grid_slice.r_i print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0) print 'ip_triangles', fe_xdomain.dots.int_division print 'ip_coords', fe_xdomain.dots.ip_coords print 'ip_weigths', fe_xdomain.dots.ip_weights print 'ip_offset', fe_xdomain.dots.ip_offset print 'ip_X_coords', fe_xdomain.dots.ip_X print 'ip_ls', fe_xdomain.dots.ip_ls_values print 'vtk_ls', fe_xdomain.dots.vtk_ls_values print 'J_det ', fe_xdomain.dots.J_det_grid print tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def example_2d(): from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D9q import FETS2D9Q fets_eval = FETS2D4Q(mats_eval=MATS2DElastic(E=1.0, nu=0.0)) xfets_eval = FETSBimaterial( parent_fets=fets_eval, int_order=3, mats_eval=MATS2DElastic(E=1.0, nu=0.0), mats_eval2=MATS2DElastic(E=5.0, nu=0.0), ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(3.0, 1.0, 0.0), shape=(3, 1), fets_eval=fets_eval, level=fe_level1) fe_xdomain = XFESubDomain( domain=fe_domain, fets_eval=xfets_eval, # fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice=fe_grid1["X - 1.5"], ) ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCDofGroup(var="u", value=1.0, dims=[0], get_dof_method=fe_grid1.get_right_dofs), BCDofGroup(var="u", value=0.0, dims=[1], get_dof_method=fe_grid1.get_right_dofs), BCDofGroup(var="u", value=0.0, dims=[0, 1], get_dof_method=fe_grid1.get_left_dofs), ], rtrace_list=[ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField(name="Displacement", var="u", idx=0, warp=True), RTraceDomainListField(name="Strain", var="eps", idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ], ) # # # Add the time-loop control tloop = TLoop( tstepper=ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline=TLine(min=0.0, step=1.0, max=1.0), ) # print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() print "parent elems ", fe_xdomain.fe_grid_slice.elems print "parent dofs ", fe_xdomain.fe_grid_slice.dofs print "dofmap ", fe_xdomain.elem_dof_map print "ls_values ", fe_xdomain.dots.dof_node_ls_values print "intersection points ", fe_xdomain.fe_grid_slice.r_i print "triangles ", fe_xdomain.dots.rt_triangles print "vtk points ", fe_xdomain.dots.vtk_X print "vtk data ", fe_xdomain.dots.get_vtk_cell_data("blabla", 0, 0) print "ip_triangles", fe_xdomain.dots.int_division print "ip_coords", fe_xdomain.dots.ip_coords print "ip_weigths", fe_xdomain.dots.ip_weights print "ip_offset", fe_xdomain.dots.ip_offset print "ip_X_coords", fe_xdomain.dots.ip_X print "ip_ls", fe_xdomain.dots.ip_ls_values print "vtk_ls", fe_xdomain.dots.vtk_ls_values print "J_det ", fe_xdomain.dots.J_det_grid print tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS,\ BCDofGroup, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q #from fets_strong_weak_tf import FETSStrongWeakTF from fets_sw_sopu import FETSStrongWeakTFSOPU from ibvpy.fets.fets2D.fets2Dtf import FETS2DTF from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U # from fets2D4qtf import FETS2D4QTF # from fets2D4q8utf import FETS2D4Q8UTF # from fets2D4q9utf import FETS2D4Q9UTF #fets_eval = FETS2D4Q(mats_eval = MATS2DElastic(E= 1.,nu=0.)) fets_eval = FETS2DTF(parent_fets = FETS2D4Q9U(), mats_eval = MATS2D5Bond(E_m = 30, nu_m = 0.3, E_f = 3, nu_f = 0.3, G = 8.)) fets_eval_sopu = FETS2DTF(parent_fets = FETS2D4Q(), mats_eval = MATS2D5Bond(E_m = 30, nu_m = 0.3, E_f = 3, nu_f = 0.3, G = 8.)) xfets_eval = FETSStrongWeakTFSOPU( parent_fets = fets_eval, sopu_fets = fets_eval_sopu, int_order = 5 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = (3.,2.,0.), shape = (15,10), fets_eval = fets_eval, level = fe_level1 ) enr = True if enr: fe_xdomain = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice = fe_grid1['X + 0.1 *Y - 1.501'] ) fe_xdomain2 = XFESubDomain( domain = fe_domain, fets_eval = xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice = fe_grid1['X - 0.1* Y - 2.201'] ) ts = TS( dof_resultants = True, sdomain = fe_domain, bcond_list = [BCDofGroup(var='u', value = .2, dims = [0], get_dof_method = fe_grid1.get_right_dofs ), BCDofGroup(var='u', value = 0., dims = [1], get_dof_method = fe_grid1.get_bottom_right_dofs ), BCDofGroup(var='u', value = 0., dims = [0], get_dof_method = fe_grid1.get_left_dofs ), BCDofGroup(var='u', value = 0., dims = [1], get_dof_method = fe_grid1.get_bottom_left_dofs ), ], rtrace_list = [ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True ), RTraceDomainListField(name = 'Displ matrix' , var = 'u_m', warp = True, warp_var = 'u_m'), RTraceDomainListField(name = 'Displ reinf' , var = 'u_f', warp = True, warp_var = 'u_f'), RTraceDomainListField(name = 'Strain matrix' , var = 'eps_m', warp = True, warp_var = 'u_m'), RTraceDomainListField(name = 'Strain reinf' , var = 'eps_f', warp = True, warp_var = 'u_f'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1, max = 1.0 )) fe_xdomain.deactivate_sliced_elems() fe_xdomain2.deactivate_sliced_elems() # if enr: # #print "elements ",fe_xdomain.elements[0] # fe_xdomain.deactivate_sliced_elems() # #fe_xdomain2.deactivate_sliced_elems() # print 'parent elems ',fe_xdomain.fe_grid_slice.elems # print 'parent dofs ',fe_xdomain.fe_grid_slice.dofs # print "dofmap ",fe_xdomain.elem_dof_map # print "ls_values ", fe_xdomain.dots.dof_node_ls_values # print 'intersection points ',fe_xdomain.fe_grid_slice.r_i # print "triangles ", fe_xdomain.dots.rt_triangles # print "vtk points ", fe_xdomain.dots.vtk_X # print "vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla',0,0) # print 'ip_triangles', fe_xdomain.dots.int_division # print 'ip_coords', fe_xdomain.dots.ip_coords # print 'ip_weigths', fe_xdomain.dots.ip_weights # print 'ip_offset', fe_xdomain.dots.ip_offset # print 'ip_X_coords', fe_xdomain.dots.ip_X # print 'ip_ls', fe_xdomain.dots.ip_ls_values # print 'vtk_ls', fe_xdomain.dots.vtk_ls_values # print 'J_det ',fe_xdomain.dots.J_det_grid tloop.eval() # #ts.setup() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp( ibv_resource = ts ) ibvpy_app.main()
# var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField( name = 'Stress' , #name = arbitrary string var = 'sig_app', warp = True ), #var = sig_app, eps, u RTraceDomainListField( name = 'Displacement' , var = 'u', warp = True ), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # # # Add the time-loop control tloop = TLoop( tstepper = ts, # tolerance = 1e-4, KMAX = 4, # debug = True, RESETMAX = 2, tline = TLine( min = 0.0, step = 1., max = 1.0 ) ) #print "elements ",fe_xdomain.elements[0] fe_xdomain.deactivate_sliced_elems() # print 'ls string ',fe_xdomain.fe_grid_slice.ls_function_eval # print 'parent elems ',fe_xdomain.fe_grid_slice.elems # print 'parent dofs ',fe_xdomain.fe_grid_slice.dofs # print "dofmap ",fe_xdomain.elem_dof_map # print "ls_values ", fe_xdomain.dots.dof_node_ls_values # print 'intersection points ',fe_xdomain.fe_grid_slice.r_i # print "triangles ", fe_xdomain.dots.rt_triangles # print "vtk points ", fe_xdomain.dots.vtk_X # print "vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla',0,0) # print 'ip_triangles', fe_xdomain.dots.int_division # print 'ip_coords', fe_xdomain.dots.ip_coords