示例#1
0
    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.mats2D_sdamage.mats2D_sdamage import MATS2DScalarDamage
        from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q
        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

        fets_eval = FETS2D4Q( mats_eval = MATS2DScalarDamage( E = 1., nu = 0. ) )

        xfets_eval = FETSCrack( parent_fets = fets_eval, int_order = 1 )

        # Discretization

        fe_domain = FEDomain()
        fe_level1 = FERefinementGrid( domain = fe_domain,
                                      fets_eval = fets_eval )
        fe_grid1 = FEGrid( coord_max = ( 2., 1., 0. ),
                           shape = ( 2, 1 ),
                           fets_eval = fets_eval,
                           level = fe_level1 )


        fe_xdomain = XFESubDomain( domain = fe_domain,
                                    rt_quad = False,
                                    fets_eval = xfets_eval,
                                    #fe_grid_slice = fe_grid1['Y - 0.5@ X < .5'] 
                                    fe_grid_slice = fe_grid1['X - 0.5']
                                    )

        fe_xdomain.deactivate_sliced_elems()

        ts = TS( dof_resultants = True,
                 sdomain = fe_domain
                    )



        ts.setup()
#        print 'parent elems ', fe_xdomain.fe_grid_slice.elems
#        print 'intersection points ', fe_xdomain.fe_grid_slice.r_i
#        print 'ip_coords ', fe_xdomain.dots.ip_coords
        print 'state array step 1 ', fe_xdomain.dots.state_array
        fe_xdomain.dots.state_array[:3] = [1, 2, 3]
        print 'state array write ', fe_xdomain.dots.state_array
        fe_xdomain.fe_grid_slice = fe_grid1['Y-0.5']
#        print 'parent elems ', fe_xdomain.fe_grid_slice.elems
#        print 'intersection points ', fe_xdomain.fe_grid_slice.r_i
#        print 'ip_coords ', fe_xdomain.dots.ip_coords
        print 'state array step 2 ', fe_xdomain.dots.state_array
    def example_1d():
        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.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic
        from ibvpy.fets.fets1D.fets1D2l import FETS1D2L
        from ibvpy.fets.fets1D.fets1D2l3u import FETS1D2L3U
        from ibvpy.fets.fets_ls.fets_crack import FETSCrack
        fets_eval = FETS1D2L( mats_eval = MATS1DElastic( E = 1. ) ) #, A=1.))
        #xfets_eval = fets_eval # use the same element for the enrichment
        xfets_eval = FETSCrack( parent_fets = fets_eval )
        # Discretization

        fe_domain = FEDomain()
        fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval )
        fe_grid1 = FEGrid( coord_max = ( 4., 0., 0. ),
                           shape = ( 4, ),
                           fets_eval = fets_eval,
                           level = fe_level1 )


        enr = True
        if enr:
            fe_xdomain = XFESubDomain( domain = fe_domain,
                                       fets_eval = xfets_eval,
                                       fe_grid_slice = fe_grid1[  '(X - 2) **2 - 0.5 ' ] )
            fe_xdomain.deactivate_sliced_elems()

        print 'elem_dof_map', fe_xdomain.elem_dof_map

        fe_domain = FEDomain()
        fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval )
        fe_grid1 = FEGrid( coord_max = ( 4 * 3.14, 0., 0. ),
                           shape = ( 8, ),
                           fets_eval = fets_eval,
                           level = fe_level1 )


        enr = True
        if enr:
            fe_xdomain = XFESubDomain( domain = fe_domain,
                                       fets_eval = xfets_eval,
                                       fe_grid_slice = fe_grid1[  'cos(X) - 0.5' ] )
            fe_xdomain.deactivate_sliced_elems()

        print 'elem_dof_map2', fe_xdomain.elem_dof_map
示例#3
0
    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()
示例#4
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( domain = fe_domain,
                                   fets_eval = xfets_eval,
                                   #fe_grid_idx_slice = fe_grid1[1,0],
                                   fe_grid_slice = fe_grid1['X  -  0.5  -0.1*Y'] )

        ts = TS( dof_resultants = True,
                 sdomain = fe_domain,
                 bcond_list = [BCDofGroup( var = 'u', value = 0., dims = [0, 1],
                                          get_dof_method = fe_grid1.get_right_dofs ),
                                BCDofGroup( var = 'u', value = 0., dims = [1],
                                          get_dof_method = fe_grid1.get_left_dofs ),
                                BCDofGroup( var = 'u', value = -1., dims = [0],
                                           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),
示例#5
0
    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_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.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()
示例#8
0
    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()
示例#9
0
    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, 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()
示例#11
0
    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()
示例#12
0
    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()
示例#13
0
    # 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(
        domain=fe_domain,
        fets_eval=xfets_eval,
        # fe_grid_idx_slice = fe_grid1[1,0],
        fe_grid_slice=fe_grid1['X  -  0.5  -0.1*Y'])

    ts = TS(
        dof_resultants=True,
        sdomain=fe_domain,
        bcond_list=[
            BCDofGroup(var='u',
                       value=0.,
                       dims=[0, 1],
                       get_dof_method=fe_grid1.get_right_dofs),
            BCDofGroup(var='u',
                       value=0.,
                       dims=[1],
                       get_dof_method=fe_grid1.get_left_dofs),
示例#14
0
    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()
示例#15
0
    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()
def example_with_new_domain():
    from ibvpy.api import \
        TStepper as TS, RTraceGraph, RTraceDomainListField, \
        RTraceDomainListInteg, TLoop,FEDomain, FERefinementGrid,\
        TLine, BCDof, IBVPSolve as IS, DOTSEval
    from ibvpy.mats.mats2D.mats2D_conduction.mats2D_conduction import MATS2DConduction
    from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic
    from ibvpy.fets.fets2D.fets2D4q4t import FETS2D4Q4T
    from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q
    from ibvpy.api import BCDofGroup
    from ibvpy.fets.fets_ls.fets_ls_eval import FETSLSEval
    from ibvpy.fets.fets_ls.fets_crack import FETSCrack
    from ibvpy.mesh.xfe_subdomain import XFESubDomain
    
    #fets_eval = FETS2D4Q(mats_eval = MATS2DElastic(E= 1.,nu=0.))
    fets_eval = FETS2D4Q4T(mats_eval = MATS2DConduction(k = 1.)) 
    xfets_eval = FETSLSEval( parent_fets = fets_eval, int_order = 3 )

    
    from ibvpy.mesh.fe_grid import FEGrid
    from ibvpy.mesh.fe_refinement_grid import FERefinementGrid
    from ibvpy.mesh.fe_domain import FEDomain
    from mathkit.mfn.mfn_line.mfn_line import MFnLineArray

    # Discretization
    fe_domain = FEDomain()
    fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval )
    fe_grid = 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_grid['X  -  0.5 '] )

    fe_xdomain.deactivate_sliced_elems()

    tstepper = TS( sdomain = fe_domain,
                   bcond_list =  [ BCDofGroup( var='u', value = 0., dims = [0],
                                               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],
                                  get_dof_method = fe_grid.get_top_right_dofs ) ],

         rtrace_list =  [ 
#                     RTraceDomainListField(name = 'Damage' ,
#                                    var = 'omega', idx = 0,
#                                    record_on = 'update',
#                                    warp = True),
#                     RTraceDomainListField(name = 'Displacement' ,
#                                    var = 'u', 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, debug = True,
                   tline = TLine( min = 0.0,  step = 1.0, max = 1.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


    #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()