예제 #1
0
    def example_2d():
        from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic
        from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q

        fets_eval = FETS2D4Q(mats_eval=MATS2DElastic(E=2.1e5))

        # Discretization
        fe_domain1 = FEGrid(coord_max=(2., 5., 0.),
                            shape=(10, 10),
                            fets_eval=fets_eval)

        fe_subgrid1 = FERefinementLevel(parent=fe_domain1,
                                        fine_cell_shape=(1, 1))

        print 'children'
        print fe_domain1.children

        fe_subgrid1.refine_elem((5, 5))
        fe_subgrid1.refine_elem((6, 5))
        fe_subgrid1.refine_elem((7, 5))
        fe_subgrid1.refine_elem((8, 5))
        fe_subgrid1.refine_elem((9, 5))

        fe_domain = FEDomain(subdomains=[fe_domain1])

        ts = TS(dof_resultants=True,
                sdomain=fe_domain,
                bcond_list=[BCDofGroup(var='f', value=0.1, dims=[0],
                                       get_dof_method=fe_domain1.get_top_dofs),
                            BCDofGroup(var='u', value=0., dims=[0, 1],
                                       get_dof_method=fe_domain1.get_bottom_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),
                             #                           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 _rtrace_list_default(self):
     return [
         #                                 RTraceDomainListField( name = 'Displacement' ,
         #                                                var = 'u', idx = 0, warp = True ),
         #                                 RTraceDomainListField( name = 'Stress' ,
         #                                                var = 'sig_app', idx = 0, warp = True,
         #                                                record_on = 'update', ),
         #                    self.max_princ_stress,
         RTraceDomainListField(name='Damage',
                               var='omega_mtx',
                               idx=0,
                               warp=True,
                               record_on='update'),
     ]
예제 #3
0
def test_bar4():
    '''Clamped bar 3 domains, each with 2 elems (displ at right end)
    [0]-[1]-[2] [3]-[4]-[5] [6]-[7]-[8]
    u[0] = 0, u[2] = u[3], u[5] = u[6], u[8] = 1'''

    fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10., A=1.))

    # Discretization
    fe_domain1 = FEGrid(coord_max=(2., 0., 0.),
                        shape=(2, ),
                        n_nodal_dofs=1,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    fe_domain2 = FEGrid(coord_min=(2., 0., 0.),
                        coord_max=(4., 0., 0.),
                        shape=(2, ),
                        n_nodal_dofs=1,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    fe_domain3 = FEGrid(coord_min=(4., 0., 0.),
                        coord_max=(6., 0., 0.),
                        shape=(2, ),
                        n_nodal_dofs=1,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    ts = TS(iterms=[(fets_eval, fe_domain1), (fets_eval, fe_domain2),
                    (fets_eval, fe_domain3)],
            dof_resultants=True,
            bcond_list=[
                BCDof(var='u', dof=0, value=0.),
                BCDof(var='u',
                      dof=2,
                      link_dofs=[3],
                      link_coeffs=[1.],
                      value=0.),
                BCDof(var='u',
                      dof=5,
                      link_dofs=[6],
                      link_coeffs=[1.],
                      value=0.),
                BCDof(var='u', dof=8, value=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='Displacement', var='u', idx=0)
            ])

    # 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
    app = IBVPyApp(ibv_resource=tloop)
    app.main()
예제 #4
0
def xtest_L_shaped():
    '''Clamped bar 3 domains, each with 2 elems (displ at right end)
    [0]-[1]-[2] [3]-[4]-[5] [6]-[7]-[8]
    u[0] = 0, u[2] = u[3], u[5] = u[6], u[8] = 1'''

    mp = MATS2DScalarDamage(
        E=34.e3,
        nu=0.2,
        epsilon_0=59.e-6,
        epsilon_f=3.2e-3,
        #epsilon_f = 3.2e-1,
        #stiffness  = "algorithmic",
        strain_norm_type='Mises')

    #    mp = MATS2DElastic( E = 34.e3,
    #                        nu = 0.2 )
    fets_eval = FETS2D4Q(mats_eval=mp)

    discr = (10, 10)
    # Discretization
    fe_domain1 = FEGrid(coord_min=(0, 0, 0),
                        coord_max=(1., 1., 0.),
                        shape=discr,
                        n_nodal_dofs=fets_eval.n_nodal_dofs,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    fe_domain2 = FEGrid(coord_min=(0., 1., 0),
                        coord_max=(1., 2., 0.),
                        shape=discr,
                        n_nodal_dofs=fets_eval.n_nodal_dofs,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    fe_domain3 = FEGrid(coord_min=(1., 1., 0),
                        coord_max=(2., 2., 0.),
                        shape=discr,
                        n_nodal_dofs=fets_eval.n_nodal_dofs,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    ts = TS(
        iterms=[(fets_eval, fe_domain1), (fets_eval, fe_domain2),
                (fets_eval, fe_domain3)],
        dof_resultants=True,
        bcond_list=[
            BCDofGroup(var='u',
                       value=0.,
                       dims=[0, 1],
                       get_dof_method=fe_domain1.get_bottom_dofs),
            BCDofGroup(var='u',
                       value=0.,
                       dims=[0, 1],
                       get_dof_method=fe_domain3.get_left_dofs,
                       get_link_dof_method=fe_domain2.get_right_dofs,
                       link_coeffs=[1.]),
            BCDofGroup(var='u',
                       value=0.,
                       dims=[0, 1],
                       get_dof_method=fe_domain2.get_bottom_dofs,
                       get_link_dof_method=fe_domain1.get_top_dofs,
                       link_coeffs=[1.]),
            BCDofGroup(var='u',
                       value=0.0004,
                       dims=[1],
                       get_dof_method=fe_domain3.get_right_dofs)
        ],
        rtrace_list=[
            RTraceDomainListField(name='Displacement', var='u', idx=1),
            RTraceDomainListField(name='Damage',
                                  var='omega',
                                  idx=0,
                                  record_on='update',
                                  warp=True),
            #                              RTraceDomainListField(name = 'Stress' ,
            #                              var = 'sig_app', idx = 0,
            #                              record_on = 'update',
            #                              warp = False),
            #                              RTraceDomainListField(name = 'Strain' ,
            #                              var = 'eps_app', idx = 0,
            #                              record_on = 'update',
            #                              warp = False),
        ])

    # Add the time-loop control
    global tloop
    tloop = TLoop(tstepper=ts,
                  tolerance=1e-4,
                  KMAX=50,
                  tline=TLine(min=0.0, step=0.2, max=1.0))

    tloop.eval()
    #    import cProfile
    #    cProfile.run('tloop.eval()', 'tloop_prof' )
    #
    #    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)

    from ibvpy.plugins.ibvpy_app import IBVPyApp
    app = IBVPyApp(ibv_resource=tloop)
    app.main()
예제 #5
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()
예제 #6
0
                      coord_max = (10, 15, 2.), 
                               shape   = (1,3),
                               fets_eval = fets_eval_4u,
                               level = fe_rgrid3 )                                   

    ts = TS( dof_resultants = True,
             sdomain = fe_domain,
             bcond_list =  [BCDofGroup(var='f', value = 1., dims = [0],
                                       get_dof_method = fe_grid1.get_top_dofs ),
                            BCDofGroup(var='u', value = 0., dims = [0,1],
                                       get_dof_method = fe_grid1.get_bottom_dofs ),
                                       ],
             rtrace_list =  [ RTDofGraph(name = 'Fi,right over u_right (iteration)' ,
                                   var_y = 'F_int', idx_y = 0,
                                   var_x = 'U_k', idx_x = 1),
                        RTraceDomainListField(name = 'Stress',
                             var = 'sig_app', idx = 0, warp = False ),
#                             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.setup())