예제 #1
0
def combined_fe2D4q_with_fe2D4q8u():

    fets_eval_4u_conc = FETS2D4Q(mats_eval=MATS2DElastic(E=28500, nu=0.2))
    fets_eval_4u_steel = FETS2D4Q(mats_eval=MATS2DElastic(E=210000, nu=0.25))
    fets_eval_8u = FETS2D4Q8U(mats_eval=MATS2DElastic())

    # Discretization
    fe_domain = FEDomain()

    fe_grid_level1 = FERefinementGrid(name='master grid',
                                      fets_eval=fets_eval_4u_conc,
                                      domain=fe_domain)

    fe_grid = FEGrid(level=fe_grid_level1,
                     coord_max=(2., 6., 0.),
                     shape=(11, 30),
                     fets_eval=fets_eval_4u_conc)

    fe_grid_level2 = FERefinementGrid(name='refinement grid',
                                      parent=fe_grid_level1,
                                      fets_eval=fets_eval_4u_steel,
                                      fine_cell_shape=(1, 1))

    # fe_grid_level1[ 5, :5 ].refine_using( fe_grid_level2 )
    # 1. first get the slice for the level - distinguish it from the slice at the subgrid
    #    this includes slicing in the subgrids. what if the subgrid does not exist?
    #
    #    Each subgrid must hold its own slice within the level. The index operator fills
    #    the grid [...] instanciates the whole grid and returns the instance of
    #    FEGridLevelSlice. The expanded subgrid contains its constructor slice.
    #
    # 2. If the slice is within an existing slice no change in the FESubgrid is required
    #    only the instance of the slice is returned. The FEGridLevelSlice goes always into
    #    an expanded part of FEGrid.
    #
    # 3. If the slice does not fit into any existing slice - all domain with an intersection
    #    of the existing slice must be constructed as well.
    #
    # 2. deactivate elements
    # 3.
    # BUT how to impose the boundary conditions on the particular refinement? The
    # slice has an attribute

    fe_grid_level2.refine_elem((5, 0))
    fe_grid_level2.refine_elem((5, 1))
    fe_grid_level2.refine_elem((5, 2))
    fe_grid_level2.refine_elem((5, 3))
    fe_grid_level2.refine_elem((5, 4))
    fe_grid_level2.refine_elem((5, 5))

    # apply the boundary condition on a subgrid
    #
    print fe_grid_level2.fe_subgrids
    fe_first_grid = fe_grid_level2.fe_subgrids[0]

    ts = TS(
        dof_resultants=True,
        sdomain=fe_domain,
        bcond_list=[
            BCSlice(var='f', value=1., dims=[0], slice=fe_grid[:, -1, :, -1]),
            BCSlice(var='u',
                    value=0.,
                    dims=[0, 1],
                    slice=fe_first_grid[:, 0, :, 0])
        ],
        rtrace_list=[
            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),
            #                             RTraceDomainField(name = 'Displacement' ,
            #                                        var = 'u', idx = 0),
            #                                 RTraceDomainField(name = 'N0' ,
            #                                              var = 'N_mtx', idx = 0,
            #                                              record_on = 'update')
        ])

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

    print tloop.eval()
    from ibvpy.plugins.ibvpy_app import IBVPyApp
    ibvpy_app = IBVPyApp(ibv_resource=tloop)
    ibvpy_app.main()
예제 #2
0
def example_with_new_domain():
    from ibvpy.api import \
        TStepper as TS, RTraceDomainListField, TLoop, \
        TLine, BCSlice
    from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U
    from ibvpy.tmodel.mats3D.mats3D_cmdm import \
        MATS3DMicroplaneDamage
    from ibvpy.tmodel.matsXD.matsXD_cmdm import PhiFnStrainSoftening

#    tmodel =  MATS2DElastic(E=2,nu= .2,
#                          stress_state= 'rotational_symetry')
    mats = MATS3DMicroplaneDamage(model_version='stiffness',
                                  E=34e3,
                                  nu=0.2,
                                  phi_fn=PhiFnStrainSoftening(G_f=0.001117,
                                                              f_t=2.8968))

    fets_eval = FETS2Drotsym(prototype_fets=FETS2D4Q8U(),
                             mats_eval=mats)

    fets_eval.vtk_r *= 0.9
    from ibvpy.mesh.fe_grid import FEGrid

    radius = sqrt(1. / pi)
#    f_i = (radius/2.)*2*pi
#    f_o = (radius)*2*pi
#    print 'f ',f_i,' ', f_o
    # Discretization
    fe_grid = FEGrid(  # coord_min = (0.,radius/2.,0.),
        coord_max=(1., radius, 0.),
        shape=(20, 20),
        fets_eval=fets_eval)

    tstepper = TS(sdomain=fe_grid,
                  bcond_list=[
                      BCSlice(var='u', value=0., dims=[0],
                              slice=fe_grid[0, :, 0, :]),
                      BCSlice(var='u', value=0., dims=[1],
                              slice=fe_grid[0, 0, 0, 0]),
                      BCSlice(var='u', value=1.e-3, dims=[0],
                              slice=fe_grid[-1, :, -1, :]),
                  ],

                  rtrace_list=[
                      RTraceDomainListField(name='Stress',
                                            var='sig_app', idx=0, warp=True,
                                            record_on='update'),
                      RTraceDomainListField(name='fracture_energy',
                                            var='fracture_energy', idx=0, warp=True,
                                            record_on='update'),
                      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, KMAX=300, tolerance=1e-4,
                  tline=TLine(min=0.0,  step=1.0, max=1.0))

    #import cProfile
    #cProfile.run('tloop.eval()', 'tloop_prof' )
    print(tloop.eval())
    #import pstats
    #p = pstats.Stats('tloop_prof')
    # p.strip_dirs()
    # print 'cumulative'
    # p.sort_stats('cumulative').print_stats(20)
    # print 'time'
    # p.sort_stats('time').print_stats(20)

    # Put the whole thing into the simulation-framework to map the
    # individual pieces of definition into the user interface.
    #
    from ibvpy.plugins.ibvpy_app import IBVPyApp
    app = IBVPyApp(ibv_resource=tloop)
    app.main()
예제 #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.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()
예제 #4
0

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.api import\
     BCDofGroup, TStepper as TS, TLoop, TLine, RTDofGraph
from ibvpy.rtrace.rt_domain_list_field import RTraceDomainListField
from ibvpy.mesh.fe_grid import FEGrid
from ibvpy.mesh.fe_refinement_grid import FERefinementGrid
from ibvpy.mesh.fe_domain import FEDomain

if __name__ == '__main__':

    fets_eval_4u = FETS2D4Q(mats_eval = MATS2DElastic())
    fets_eval_8u = FETS2D4Q8U(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   = (1,3),
                               fets_eval = fets_eval_4u,
                               level = fe_rgrid1 )