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
print 'N_im.shape', N_im.shape
print 'dN_ima', dN_imr
print 'dN_ima.shape', dN_imr.shape
print '*************************'


class FETS2D4u4x(FETSEval):
    dof_r = tr.Array(value=[[-1, -1], [1, -1], [1, 1], [-1, 1]])
    geo_r = tr.Array(value=[[-1, -1], [1, -1], [1, 1], [-1, 1]])
    vtk_r = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
    n_nodal_dofs = 2


# Discretization
L_x, L_y = 100, 100
mesh = FEGrid(coord_max=(L_x, L_y), shape=(100, 30), fets_eval=FETS2D4u4x())

x_Ia = mesh.X_Id
# print 'x_Ia', x_Ia

n_I, n_a = x_Ia.shape
dof_Ia = np.arange(n_I * n_a, dtype=np.int_).reshape(n_I, -1)
# print 'dof_Ia', dof_Ia

I_Ei = mesh.I_Ei
# print 'I_Ei', I_Ei

x_Eia = x_Ia[I_Ei, :]
# print 'x_Eia', x_Eia

dof_Eia = dof_Ia[I_Ei]
Esempio n. 3
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()
Esempio n. 4
0
 def _get_mesh(self):
     return FEGrid(coord_max=(self.L_x, self.L_y, self.L_z),
                   shape=(self.n_x, self.n_y, self.n_z),
                   fets_eval=self.fets)
Esempio n. 5
0
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=[
    #                        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='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()
Esempio n. 6
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 import MATS2DPlastic
        from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q
        from ibvpy.fets.fets2D import FETS2D9Q
        from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U
        from ibvpy.fets.fets_ls.fets_crack import FETSCrack
        #fets_eval = FETS2D4Q( mats_eval = MATS2DPlastic( E = 1., nu = 0. ) )
        fets_eval = FETS2D4Q8U(mats_eval=MATS2DPlastic(E=1., nu=0.))
        xfets_eval = FETSCrack(parent_fets=fets_eval,
                               int_order=5,
                               tri_subdivision=1)

        # Discretization

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

        #ls_function = lambda X, Y: X - Y - 0.13
        ls_function = lambda X, Y: (X - 0.52)**2 + (Y - 0.72)**2 - 0.51**2
        bls_function = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.28**2)
        bls_function2 = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.38**2)

        # design deficits:
        # - How to define a level set spanned over several fe_grids
        #   (i.e. it is defined over the hierarchy of FESubDomains)
        # - Patching of subdomains within the FEPatchedGrid (FERefinementGrid)
        # - What are the compatibility conditions?
        # - What is the difference between FEGridLeveSetSlice
        #   and FELSDomain?
        #   FELSDomain is associated with a DOTS - Slice is not.

        # FEGrid has a multidimensional array - elem_grid
        # it can be accessed through this index.
        # it is masked by the activity map. The activity map can
        # be defined using slices and level sets.
        # the elems array enumerates the elements using the activity map.
        # in this way, the specialization of grids is available implicitly.
        #
        fe_xdomain = FELSDomain(
            domain=fe_domain,
            fets_eval=xfets_eval,
            fe_grid=fe_grid1,
            ls_function=ls_function,
            bls_function=bls_function,
        )

        fe_tip_xdomain = FELSDomain(
            domain=fe_domain,
            fets_eval=xfets_eval,
            fe_grid=fe_xdomain,
            ls_function=bls_function,
        )

        # deactivation must be done only after the dof enumeration has been completed
        fe_xdomain.deactivate_intg_elems_in_parent()
        fe_tip_xdomain.deactivate_intg_elems_in_parent()

        fe_xdomain.bls_function = bls_function2
        fe_tip_xdomain.ls_function = bls_function2

        # deactivation must be done only after the dof enumeration has been completed
        fe_xdomain.deactivate_intg_elems_in_parent()
        fe_tip_xdomain.deactivate_intg_elems_in_parent()

        #
        # General procedure:
        # 1) define the level sets with the boundaries
        # 2) use the bls to identify the tips of the level set
        # 3) use independent level sets to introduce indpendently junctions.
        #
        # get the extended dofs of the bls_elems and constrain it
        #
        cdofs = fe_tip_xdomain.elem_xdof_map.flatten()
        bc_list = [BCDof(var='u', dof=dof, value=0.0) for dof in cdofs]

        # construct the time stepper

        ts = TS(
            dof_resultants=True,
            sdomain=fe_domain,
            bcond_list=[
                BCSlice(
                    var='u', value=-0.1, dims=[1], slice=fe_grid1[:, 0, :, 0]),
                BCSlice(
                    var='u', value=0., dims=[0], slice=fe_grid1[:, 0, :, 0]),
                BCSlice(var='u',
                        value=0.,
                        dims=[0, 1],
                        slice=fe_grid1[:, -1, :, -1])
            ] + bc_list,
            rtrace_list=[
                #                                 RTDofGraph(name = 'Fi,right over u_right (iteration)' ,
                #                                       var_y = 'F_int', idx_y = 0,
                #                                       var_x = 'U_k', idx_x = 1),
                RTraceDomainListField(name='Stress',
                                      var='sig_app',
                                      idx=0,
                                      warp=True),
                RTraceDomainListField(name='Displacement',
                                      var='u',
                                      idx=0,
                                      warp=True),
                #                                     RTraceDomainField(name = 'N0' ,
                #                                                  var = 'N_mtx', idx = 0,
                #                                                  record_on = 'update')
            ])
        #

        do = 'print'

        if do == 'print':

            p = 'state'

            if p == 'grids':
                print('fe_xdomain.ls mask')
                print(fe_xdomain.ls_mask)
                print('fe_xdomain.idx mask')
                print(fe_xdomain.idx_mask)
                print('fe_xdomain.intg mask')
                print(fe_xdomain.intg_mask)
                print('fe_xdomain.xelems_mask')
                print(fe_xdomain.xelems_mask)
                print('fe_xdomain.xelems_grid_ix')
                print(fe_xdomain.xelems_grid_ix)
                print('fe_xdomain.ls_elem_grid')
                print(fe_xdomain.ls_elem_grid)
                print('fe_xdomain.ls_ielem_grid')
                print(fe_xdomain.ls_ielem_grid)
                print('fe_xdomain.intg_elem_grid')
                print(fe_xdomain.intg_elem_grid)

                print('fe_tip_xdomain.ls_mask`')
                print(fe_tip_xdomain.ls_mask)
                print('fe_tip_xdomain.intg_mask`')
                print(fe_tip_xdomain.intg_mask)
                print('fe_tip_xdomain.idx_mask`')
                print(fe_tip_xdomain.idx_mask)
                print('fe_tip_xdomain.xelems_mask')
                print(fe_tip_xdomain.xelems_mask)
                print('fe_tip_xdomain.xelems_grid_ix')
                print(fe_tip_xdomain.xelems_grid_ix)
                print('fe_tip_xdomain.ls_elem_grid')
                print(fe_tip_xdomain.ls_elem_grid)
                print('fe_tip_xdomain.ls_ielems_grid')
                print(fe_tip_xdomain.ls_ielem_grid)
                print('fe_tip_xdomain.intg_elem_grid')
                print(fe_tip_xdomain.intg_elem_grid)

            if p == 'maps':

                print('fe_xdomain.elem_dof_map')
                print(fe_xdomain.elem_dof_map)
                print('fe_tip_xdomain.elem_dof_map')
                print(fe_tip_xdomain.elem_dof_map)

                print('fe_xdomain.elems')
                print(fe_xdomain.elems)
                print('fe_tip_xdomain.elems')
                print(fe_tip_xdomain.elems)

                print('fe_xdomain.elem_X_map')
                print(fe_xdomain.elem_X_map)
                print('fe_tip_xdomain.elem_X_map')
                print(fe_tip_xdomain.elem_X_map)

            if p == 'fields':

                print("ls_values ", fe_xdomain.dots.dof_node_ls_values)
                print("tip ls_values ", fe_tip_xdomain.dots.dof_node_ls_values)

                print('intersection points ', fe_xdomain.ls_intersection_r)
                print('tip intersection points ',
                      fe_tip_xdomain.ls_intersection_r)

                print("triangles ", fe_xdomain.dots.rt_triangles)
                print("vtk points ", fe_xdomain.dots.vtk_X)
                print("vtk data ",
                      fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0))

                print('ip_triangles', fe_xdomain.dots.int_division)
                print('ip_coords', fe_xdomain.dots.ip_coords)
                print('ip_weigths', fe_xdomain.dots.ip_weights)
                print('ip_offset', fe_xdomain.dots.ip_offset)
                print('ip_X_coords', fe_xdomain.dots.ip_X)
                print('ip_ls', fe_xdomain.dots.ip_ls_values)
                print('vtk_ls', fe_xdomain.dots.vtk_ls_values)
                print('J_det ', fe_xdomain.dots.J_det_grid)

            if p == 'state':

                # Add the time-loop control
                print('STATE: initial')

                print('fe_xdomain.dots.state_elem grid')
                print(fe_xdomain.dots.state_start_elem_grid)
                print('fe_tip_xdomain.dots.state_elem grid')
                print(fe_tip_xdomain.dots.state_start_elem_grid)
                print('fe_xdomain.dots.state_end_elem grid')
                print(fe_xdomain.dots.state_end_elem_grid)
                print('fe_tip_xdomain.dots.state_end_elem grid')
                print(fe_tip_xdomain.dots.state_end_elem_grid)

                fe_xdomain.dots.state_array[:] = 25.5
                print('state_array 25', fe_xdomain.dots.state_array)
                fe_tip_xdomain.dots.state_array[:] = 58

                bls_function3 = lambda X, Y: -((X - 0.5)**2 +
                                               (Y - 0.21)**2 - 0.58**2)

                fe_xdomain.bls_function = bls_function3
                fe_tip_xdomain.ls_function = bls_function3

                print('STATE: changed')

                print('fe_xdomain.dots.state_elem grid')
                print(fe_xdomain.dots.state_start_elem_grid)
                print('fe_tip_xdomain.dots.state_elem grid')
                print(fe_tip_xdomain.dots.state_start_elem_grid)
                print('fe_xdomain.dots.state_end_elem grid')
                print(fe_xdomain.dots.state_end_elem_grid)
                print('fe_tip_xdomain.dots.state_end_elem grid')
                print(fe_tip_xdomain.dots.state_end_elem_grid)

                print('state_array 25', fe_xdomain.dots.state_array.shape)
                print('state_array 25', fe_xdomain.dots.state_array[570:])
                print('state_array 58', fe_tip_xdomain.dots.state_array.shape)

        elif do == 'ui':

            tloop = TLoop(tstepper=ts,
                          debug=False,
                          tolerance=1e-4,
                          KMAX=3,
                          RESETMAX=0,
                          tline=TLine(min=0.0, step=1, max=1.0))

            tloop.eval()
            from ibvpy.plugins.ibvpy_app import IBVPyApp
            ibvpy_app = IBVPyApp(ibv_resource=ts)
            ibvpy_app.main()
Esempio n. 7
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()
Esempio n. 8
0
#
# 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],
                    link_coeffs=[0],
                    value=0.0),
            BCSlice(var='f', dims=[1], slice=fe_grid[0, -1, :, -1], value=1.0)
Esempio n. 9
0
    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(
        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=[
Esempio n. 10
0
def __demo__():
    from ibvpy.api import \
        TStepper as TS, RTraceDomainListField, TLoop, \
        TLine, BCSlice, FEDomain, FERefinementGrid, FEGrid
    from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic

    fets_eval = FETS2D4Q8U(mats_eval=MATS2DElastic())

    fe_domain = FEDomain()

    r1 = FERefinementGrid(fets_eval=fets_eval, domain=fe_domain)
    r2 = FERefinementGrid(fets_eval=fets_eval, domain=fe_domain)
    # Discretization
    domain1 = FEGrid(coord_max=(3., 3.),
                     shape=(10, 4),
                     fets_eval=fets_eval,
                     level=r1)

    domain2 = FEGrid(coord_min=(3., 0.),
                     coord_max=(6., 3),
                     shape=(10, 4),
                     fets_eval=fets_eval,
                     level=r2)

    ts = TS(
        dof_resultants=True,
        sdomain=[domain1, domain2],  # fe_domain,
        bcond_list=[
            # Fix the left edge of domain1
            BCSlice(var='u', dims=[0, 1], value=0, slice=domain1[0, :, 0, :]),
            # Link the right edge of domain1 with the left edge of domain2
            #
            # note that following arrays must have the same lengths:
            # slice and link_slice
            # dims, link_dims and link_coeffs must have the same lengths

            # VAR-1:
            # linking along the complete line between 'domain1' and 'domain2'
            # all nodes along the y-axis
            # (used linking of more nodes at once in 'BCSlice')
            #
            BCSlice(var='u',
                    dims=[0, 1],
                    value=0.0,
                    slice=domain1[-1, :, -1, :],
                    link_slice=domain2[0, :, 0, :],
                    link_dims=[0, 1],
                    link_coeffs=[1., 1.]),

            # VAR-2:
            # linking along individual points between 'domain1' and 'domain2'
            # (used linking of single nodes in 'BCSlice')
            #
            #                          BCSlice(var='u', dims=[0, 1], value=0.0,
            #                                  slice=domain1[-1, -1, -1, -1],
            #                                  link_slice=domain2[0, -1, 0, -1],
            #                                  link_dims=[0, 1],
            #                                  link_coeffs=[1., 1.]),
            #                          BCSlice(var='u', dims=[0, 1], value=0.0,
            #                                  slice=domain1[-1, 0, -1, 0],
            #                                  link_slice=domain2[0, 0, 0, 0],
            #                                  link_dims=[0, 1],
            #                                  link_coeffs=[1., 1.]),

            # Load the right edge of domain2
            BCSlice(var='f', dims=[0], value=1, slice=domain2[-1, :, -1, :])
        ],
        rtrace_list=[
            RTraceDomainListField(name='Stress', var='sig_app', idx=0),
            RTraceDomainListField(name='Displacement',
                                  var='u',
                                  idx=0,
                                  warp=True),
        ])

    # Add the time-loop control
    tloop = TLoop(tstepper=ts,
                  debug=False,
                  tline=TLine(min=0.0, step=1.0, max=1.0))

    print '---- result ----'
    print tloop.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
    app = IBVPyApp(ibv_resource=tloop)
    app.main()
Esempio n. 11
0
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()
Esempio n. 12
0
from ibvpy.api import FEDomain, FEGrid, FERefinementGrid, TStepper as TS
from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q

if __name__ == '__main__':

    fets_eval_4u = FETS2D4Q(mats_eval=MATS2DElastic())

    fe_domain = FEDomain()

    fe_rgrid1 = FERefinementGrid(name='fe_rgrid1',
                                 fets_eval=fets_eval_4u,
                                 domain=fe_domain)

    fe_grid1 = FEGrid(name='fe_grid1',
                      coord_max=(2., 6., 0.),
                      shape=(1, 3),
                      fets_eval=fets_eval_4u,
                      level=fe_rgrid1)

    fe_grid2 = FEGrid(name='fe_grid2',
                      coord_min=(2., 6, 0.),
                      coord_max=(10, 15, 0.),
                      shape=(3, 2),
                      fets_eval=fets_eval_4u,
                      level=fe_rgrid1)

    print(fe_grid2[1, 0].elems)

    fe_grid2.deactivate((1, 0))
    print('activation map')
    print(fe_grid2.activation_map)
Esempio n. 13
0
 def _get_sdomain(self):
     return FEGrid(coord_min=(0., ),
                   coord_max=(self.L_x, ),
                   shape=(self.n_E, ),
                   fets_eval=self.fets_eval)
Esempio n. 14
0
        return rte_dict


#----------------------- example --------------------

if __name__ == '__main__':
    from ibvpy.api import \
        TStepper as TS, FEGrid, RTraceGraph, RTraceDomainField, TLoop, \
        TLine, BCDof, DOTSEval, RTraceDomainListField

    fets_eval = FEQ4T()

    single_elem = True
    if single_elem:
        quad_elem = FEGrid(coord_min=(-5, -5),
                           coord_max=(10, 10),
                           fets_eval=fets_eval,
                           shape=(1, 1))
        print quad_elem.dof_grid_spec.node_coords
        print 'xxxx'
        ts = TS(
            sdomain=quad_elem,
            bcond_list=[BCDof(var='u', dof=i, value=0.) for i in [0, 3]] +
            [BCDof(var='f', dof=i, value=10) for i in [1, 2]],
            rtrace_list=[
                RTraceDomainListField(name='Temperature',
                                      var='u',
                                      warp=False,
                                      idx=0,
                                      record_on='update'),
                RTraceDomainListField(name='Flux',
                                      var='eps',