if example == '1D': fets_sample = FETSEval( dof_r = [[-1], [0], [1]], geo_r = [[-1], [1]], n_nodal_dofs = 1 ) fe_domain = FEGrid( coord_max = ( 2., ), shape = ( 2, ), # inactive_elems = [3], fets_eval = fets_sample ) print("n_e ", fe_domain.shape) #second element,right node fe_slice = fe_domain[1, -1] #second element #fe_slice = fe_domain[1] elif example == '2D': fets_sample = FETS2D4Q() fe_domain = FEGrid( coord_max = ( 3., 2. ), shape = ( 3, 2 ), # inactive_elems = [3], fets_eval = fets_sample ) #first element right top node fe_slice = fe_domain[2, 1, -1, -1] elif example == '3D': fets_sample = FETS3D8H20U() fe_domain = FEGrid( coord_max = ( 3., 2., 4 ), shape = ( 3, 2, 4 ), # inactive_elems = [3], fets_eval = fets_sample )
def combined_fe2D4q_with_fe2D4q8u(): fets_eval_4u_conc = FETS2D4Q(mats_eval=MATS2DElastic(E=28500, nu=0.2)) fets_eval_4u_steel = FETS2D4Q(mats_eval=MATS2DElastic(E=210000, nu=0.25)) fets_eval_8u = FETS2D4Q8U(mats_eval=MATS2DElastic()) # Discretization fe_domain = FEDomain() fe_grid_level1 = FERefinementGrid(name='master grid', fets_eval=fets_eval_4u_conc, domain=fe_domain) fe_grid = FEGrid(level=fe_grid_level1, coord_max=(2., 6., 0.), shape=(11, 30), fets_eval=fets_eval_4u_conc) fe_grid_level2 = FERefinementGrid(name='refinement grid', parent=fe_grid_level1, fets_eval=fets_eval_4u_steel, fine_cell_shape=(1, 1)) # fe_grid_level1[ 5, :5 ].refine_using( fe_grid_level2 ) # 1. first get the slice for the level - distinguish it from the slice at the subgrid # this includes slicing in the subgrids. what if the subgrid does not exist? # # Each subgrid must hold its own slice within the level. The index operator fills # the grid [...] instanciates the whole grid and returns the instance of # FEGridLevelSlice. The expanded subgrid contains its constructor slice. # # 2. If the slice is within an existing slice no change in the FESubgrid is required # only the instance of the slice is returned. The FEGridLevelSlice goes always into # an expanded part of FEGrid. # # 3. If the slice does not fit into any existing slice - all domain with an intersection # of the existing slice must be constructed as well. # # 2. deactivate elements # 3. # BUT how to impose the boundary conditions on the particular refinement? The # slice has an attribute fe_grid_level2.refine_elem((5, 0)) fe_grid_level2.refine_elem((5, 1)) fe_grid_level2.refine_elem((5, 2)) fe_grid_level2.refine_elem((5, 3)) fe_grid_level2.refine_elem((5, 4)) fe_grid_level2.refine_elem((5, 5)) # apply the boundary condition on a subgrid # print(fe_grid_level2.fe_subgrids) fe_first_grid = fe_grid_level2.fe_subgrids[0] ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice(var='f', value=1., dims=[0], slice=fe_grid[:, -1, :, -1]), BCSlice(var='u', value=0., dims=[0, 1], slice=fe_first_grid[:, 0, :, 0]) ], 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), # RTraceDomainField(name = 'Displacement' , # var = 'u', idx = 0), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) print(tloop.eval()) from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=tloop) ibvpy_app.main()
def app(): avg_radius = 0.03 md = MATS2DScalarDamage(E=20.0e3, nu=0.2, epsilon_0=1.0e-4, epsilon_f=8.0e-4, #epsilon_f = 12.0e-4, #test doubling the e_f stress_state="plane_strain", stiffness="secant", #stiffness = "algorithmic", strain_norm=Rankine()) # me = MATS2DElastic( E = 20.0e3, # nu = 0.2, # stress_state = "plane_strain" ) fets_eval = FETS2D4Q(mats_eval=md)#, ngp_r = 3, ngp_s = 3) n_el_x = 60 # Discretization fe_grid = FEGrid(coord_max=(.6, .15, 0.), shape=(n_el_x, 15), fets_eval=fets_eval) mf = MFnLineArray(xdata=array([0, 1, 2, 7, 8 , 28]), ydata=array([0, 3., 3.2, 3.3, 3.32, 3.72 ])) #averaging function avg_processor = RTNonlocalAvg(avg_fn=QuarticAF(radius=avg_radius, correction=True)) ts = TS(sdomain=fe_grid, u_processor=avg_processor, bcond_list=[ # constraint for all left dofs in y-direction: BCSlice(var='u', slice=fe_grid[0, 0, 0, 0], dims=[0, 1], value=0.), BCSlice(var='u', slice=fe_grid[-1, 0, -1, 0], dims=[1], value=0.), BCSlice(var='u', slice=fe_grid[n_el_x / 2, -1, 0, -1], dims=[1], time_function=mf.get_value, value= -2.0e-5), ], rtrace_list=[ # RTraceGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = right_dof, # var_x = 'U_k', idx_x = right_dof, # record_on = 'update'), RTraceDomainListField(name='Deformation' , var='eps_app', idx=0, record_on='update'), RTraceDomainListField(name='Displacement' , var='u', idx=1, record_on='update', warp=True), RTraceDomainListField(name='Damage' , var='omega', idx=0, record_on='update', warp=True), # RTraceDomainField(name = 'Stress' , # var = 'sig', idx = 0, # record_on = 'update'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # Add the time-loop control # tl = TLoop(tstepper=ts, tolerance=5.0e-4, KMAX=100, tline=TLine(min=0.0, step=.25, max=10.0)) tl.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
sig_mtx, D_mtx = self.mats_eval_neg.get_corr_pred( sctx, eps_mtx, d_eps, tn, tn1, ) else: sig_mtx, D_mtx = self.mats_eval.get_corr_pred( sctx, eps_mtx, d_eps, tn, tn1, ) return sig_mtx, D_mtx if __name__ == '__main__': from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.core.scontext import SContext fets_ls_eval = FETSLSEval(parent_fets=FETS2D4Q()) point_set = [ array([[0, 0], [10, 0], [0, 10]]), array([[10, 0], [10, 10], [0, 10]]) ] print 'triangulation' points, triangs = fets_ls_eval.get_triangulation(point_set) print 'points ', points print 'triangles ', triangs
# # Thanks for using Simvisage open source! # # Created on Jan 21, 2011 by: rch from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.api import FEDomain, FEGrid, FERefinementGrid, TStepper as TS, TLoop, \ BCSlice, RTraceDomainListField from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets1D.fets1D2l import FETS1D2L if __name__ == '__main__': if True: fets_eval_4u = FETS2D4Q(mats_eval=MATS2DElastic()) fe_grid = FEGrid(name='fe_grid1', coord_max=(4., 4.), shape=(4, 4), fets_eval=fets_eval_4u) interior_elems = fe_grid[1:3, 1:3, :, :].elems interior_bc = fe_grid[1, 1, 1:, 1:] bcond_list = [ BCSlice(var='u', dims=[0, 1], slice=fe_grid[:, 0, :, 0], value=0.0), BCSlice(var='u', dims=[0, 1], slice=interior_bc, link_slice=fe_grid[1, 0, 0, 0],
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTraceDomainListField, TLoop, TLine from ibvpy.mats.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.api import BCDofGroup from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q fets_eval = FETS2DTF(parent_fets=FETS2D4Q(), mats_eval=MATS2D5Bond(E_m=30, nu_m=0.2, E_f=10, nu_f=0.1, G=10.)) from ibvpy.mesh.fe_grid import FEGrid from mathkit.mfn import MFnLineArray # Discretization fe_grid = FEGrid(coord_max=(10., 4., 0.), n_elems=(10, 3), fets_eval=fets_eval) mf = MFnLineArray( # xdata = arange(10), ydata=array([0, 1, 2, 3])) tstepper = TS( sdomain=fe_grid, bcond_list=[ BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_grid.get_left_dofs), # BCDofGroup( var='u', value = 0., dims = [1], # get_dof_method = fe_grid.get_bottom_dofs ), BCDofGroup(var='u', value=.005, dims=[0], time_function=mf.get_value, get_dof_method=fe_grid.get_right_dofs) ], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = right_dof, # var_x = 'U_k', idx_x = right_dof, # record_on = 'update'), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, # #position = 'int_pnts', # record_on = 'update'), # RTraceDomainListField(name = 'Damage' , # var = 'omega', idx = 0, # record_on = 'update', # warp = True), RTraceDomainListField(name='Displ matrix', var='u_m', idx=0, record_on='update', warp=True), RTraceDomainListField(name='Displ reinf', var='u_f', idx=0, record_on='update', warp=True), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control #global tloop tloop = TLoop(tstepper=tstepper, KMAX=300, tolerance=1e-4, tline=TLine(min=0.0, step=1.0, max=1.0)) #import cProfile #cProfile.run('tloop.eval()', 'tloop_prof' ) print(tloop.eval()) #import pstats #p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) # Put the whole thing into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
B_mtx = self.get_B_mtx(sctx.loc, sctx.X, sctx.dots.dof_node_ls_values[e_id], sctx.dots.vtk_ls_values[e_id][p_id]) return dot(B_mtx, u) if __name__ == '__main__': from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, BCDof, 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.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D9q import FETS2D9Q fets_eval = FETS2D4Q(mats_eval=MATS2DElastic(E=1., nu=0.)) xfets_eval = FETSCrack(parent_fets=fets_eval, int_order=5) # 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), rt_tol=0.1, fets_eval=fets_eval, level=fe_level1) # fe_grid1.deactivate( (1,0) ) # fe_grid1.deactivate( (1,1) ) fe_xdomain = XFESubDomain(
def app(): avg_radius = 0.03 md = MATS2DScalarDamage( E=20.0e3, nu=0.2, epsilon_0=1.0e-4, epsilon_f=8.0e-4, #epsilon_f = 12.0e-4, #test doubling the e_f stress_state="plane_strain", stiffness="secant", #stiffness = "algorithmic", strain_norm=Rankine()) mdm = MATS2DMicroplaneDamage( E=20.0e3, nu=0.2, #epsilon_f = 12.0e-4, #test doubling the e_f stress_state="plane_strain", model_version='compliance', phi_fn=PhiFnStrainSoftening(G_f=0.0014, f_t=2.0, md=0.0, h=2. * avg_radius)) # mp = MATSProxy( mats_eval = mdm ) # mp.varpars['epsilon_0'].switch = 'varied' # mp.varpars['epsilon_0'].spatial_fn = MFnNDGrid( shape = ( 8, 5, 1 ), # active_dims = ['x', 'y'], # x_mins = GridPoint( x = 0., y = 0. ), # x_maxs = GridPoint( x = length, y = heigth ) ) # mp.varpars['epsilon_0'].spatial_fn.set_values_in_box( 500., [0, 0, 0], [0.2, 0.2, 0.] ) # mp.varpars['epsilon_0'].spatial_fn.set_values_in_box( 500., [0.8, 0, 0], [1., 0.2, 0.] ) # mp.varpars['epsilon_0'].spatial_fn.set_values_in_box( 50., [0., 0.46, 0], [1., 0.5, 0.] ) # me = MATS2DElastic( E = 20.0e3, # nu = 0.2, # stress_state = "plane_strain" ) fets_eval = FETS2D4Q(mats_eval=mdm) #, ngp_r = 3, ngp_s = 3) n_el_x = 20 # 60 # Discretization fe_grid = FEGrid(coord_max=(.6, .15, 0.), shape=(n_el_x, n_el_x / 4), fets_eval=fets_eval) mf = MFnLineArray(xdata=array([0, 1, 2]), ydata=array([0, 3., 3.2])) #averaging function avg_processor = RTNonlocalAvg( avg_fn=QuarticAF(radius=avg_radius, correction=True)) loading_dof = fe_grid[n_el_x / 2, -1, 0, -1].dofs.flatten()[1] print('loading_dof', loading_dof) ts = TS( sdomain=fe_grid, u_processor=avg_processor, bcond_list=[ # constraint for all left dofs in y-direction: BCSlice(var='u', slice=fe_grid[0, 0, 0, 0], dims=[0, 1], value=0.), BCSlice(var='u', slice=fe_grid[-1, 0, -1, 0], dims=[1], value=0.), BCSlice(var='u', slice=fe_grid[n_el_x / 2, -1, 0, -1], dims=[1], time_function=mf.get_value, value=-2.0e-4), ], rtrace_list=[ RTDofGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=loading_dof, var_x='U_k', idx_x=loading_dof, record_on='update'), RTraceDomainListField(name='Deformation', var='eps_app', idx=0, record_on='update'), RTraceDomainListField(name='Deformation', var='sig_app', idx=0, record_on='update'), RTraceDomainListField(name='Displacement', var='u', idx=1, record_on='update', warp=True), RTraceDomainListField(name='fracture_energy', var='fracture_energy', idx=0, record_on='update', warp=True), RTraceDomainListField(name='Damage', var='omega_mtx', idx=0, warp=True, record_on='update'), # RTraceDomainField(name = 'Stress' , # var = 'sig', idx = 0, # record_on = 'update'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control # tl = TLoop(tstepper=ts, tolerance=5.0e-5, KMAX=200, tline=TLine(min=0.0, step=.1, max=1.0)) tl.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # 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=[ # 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), 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()