Example #1
0
    def example_1d():
        from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic
        from ibvpy.fets.fets1D.fets1D2l import FETS1D2L
        fets_eval = FETS1D2L(mats_eval=MATS1DElastic())
        # Discretization

        fe_domain = FEDomain()
        fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval)

        fe_domain1 = FEGrid(coord_max=(3., 0., 0.),
                            shape=(3, ),
                            level=fe_level1,
                            fets_eval=fets_eval)

        fe_child_domain = FERefinementGrid(parent_domain=fe_level1,
                                           fine_cell_shape=(2, ))
        fe_child_domain.refine_elem((1, ))

        ts = TS(domain=fe_domain,
                dof_resultants=True,
                sdomain=fe_domain,
                bcond_list=[
                    BCDof(var='u', dof=0, value=0.),
                    BCDof(var='f', dof=3, value=1.)
                ])

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

        print tloop.eval()
Example #2
0
def test_bar2():
    '''Clamped bar composed of two linked bars loaded at the right end
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    [11]-[12]-[13]-[14]-[15]-[16]-[17]-[18]-[19]-[20]-[21]
    u[0] = 0, u[5] = u[16], R[-1] = R[21] = 10
    '''
    fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10., A=1.))

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

    fe_domain2 = FEGrid(coord_min=(10., 0., 0.),
                        coord_max=(20., 0., 0.),
                        shape=(10, ),
                        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)],
            dof_resultants=True,
            bcond_list=[
                BCDof(var='u', dof=0, value=0.),
                BCDof(var='u',
                      dof=5,
                      link_dofs=[16],
                      link_coeffs=[1.],
                      value=0.),
                BCDof(var='f', dof=21, value=10)
            ],
            rtrace_list=[
                RTraceGraph(name='Fi,right over u_right (iteration)',
                            var_y='F_int',
                            idx_y=0,
                            var_x='U_k',
                            idx_x=1),
            ])

    # Add the time-loop control
    tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0))
    u = tloop.eval()
    print 'u', u
    #
    # '---------------------------------------------------------------'
    # 'Clamped bar composed of two linked bars control displ at right'
    # 'u[0] = 0, u[5] = u[16], u[21] = 1'
    # Remove the load and put a unit displacement at the right end
    # Note, the load is irrelevant in this case and will be rewritten
    #
    ts.bcond_list = [
        BCDof(var='u', dof=0, value=0.),
        BCDof(var='u', dof=5, link_dofs=[16], link_coeffs=[1.], value=0.),
        BCDof(var='u', dof=21, value=1.)
    ]
    # system solver
    u = tloop.eval()
    print 'u', u
Example #3
0
    def setUp(self):
        self.fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.))

        # Discretization
        self.domain = FEGrid(coord_max=(10., 0., 0.),
                             shape=(1, ),
                             fets_eval=self.fets_eval)

        self.ts = TS(sdomain=self.domain, dof_resultants=True)
        self.tloop = TLoop(tstepper=self.ts,
                           tline=TLine(min=0.0, step=1, max=1.0))
    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
Example #5
0
    def setUp(self):

        self.fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.))

        # Discretization
        self.fe_domain1 = FEGrid(coord_max=(3., 0., 0.),
                                 shape=(3, ),
                                 fets_eval=self.fets_eval)

        self.fe_domain2 = FEGrid(coord_min=(3., 0., 0.),
                                 coord_max=(6., 0., 0.),
                                 shape=(3, ),
                                 fets_eval=self.fets_eval)

        self.fe_domain3 = FEGrid(coord_min=(3., 0., 0.),
                                 coord_max=(6., 0., 0.),
                                 shape=(3, ),
                                 fets_eval=self.fets_eval)

        self.ts = TS(
            dof_resultants=True,
            sdomain=[self.fe_domain1, self.fe_domain2, self.fe_domain3],
            bcond_list=[
                BCDof(var='u', dof=0, value=0.),
                BCDof(var='u',
                      dof=4,
                      link_dofs=[3],
                      link_coeffs=[1.],
                      value=0.),
                BCDof(var='f', dof=7, value=1, link_dofs=[2], link_coeffs=[2])
            ],
            rtrace_list=[
                RTraceGraph(name='Fi,right over u_right (iteration)',
                            var_y='F_int',
                            idx_y=0,
                            var_x='U_k',
                            idx_x=1),
            ])

        # Add the time-loop control
        self.tloop = TLoop(tstepper=self.ts,
                           tline=TLine(min=0.0, step=1, max=1.0))
Example #6
0
    def example_1d():
        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.))
        xfets_eval = FETSBimaterial(mats_eval=MATS1DElastic(E=1.),
                                    mats_eval2=MATS1DElastic(E=2.),
                                    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., 0., 0.),
                          shape=(1, ),
                          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.'])

        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=[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),
                #                            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 = 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()
Example #7
0

#from sys_matrix import SysSparseMtx, SysDenseMtx
import unittest

from ibvpy.api import \
    TStepper as TS, RTDofGraph, RTraceDomainField, TLoop, \
    TLine, BCDof
from ibvpy.fets.fets1D.fets1D2l import FETS1D2L
from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic
from ibvpy.mesh.fe_grid import FEGrid
from numpy import array, sqrt
from scipy.linalg import norm

if __name__ == '__main__':
    fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.))

    # Discretization
    domain = FEGrid(coord_max=(10., 0., 0.),
                    shape=(1,),
                    fets_eval=fets_eval
                    )

    ts = TS(sdomain=domain,
            dof_resultants=True
            )
    tloop = TLoop(tstepper=ts,
                  tline=TLine(min=0.0,  step=1, max=1.0))

    '''Clamped bar loaded at the right end with unit displacement
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
Example #8
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()
Example #9
0
 def _get_fets(self):
     fets_eval = FETS1D2L(mats_eval=self.mats)
     # fets_eval = FETS1D2L3U( mats_eval = self.mats )
     return fets_eval
Example #10
0
        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)
        ]

    else:
        fets_eval_1d = FETS1D2L(mats_eval=MATS1DElastic())
        fe_grid = FEGrid(name='fe_grid1',
                         coord_max=(4., ),
                         shape=(4, ),
                         fets_eval=fets_eval_1d)

        interior_elems = fe_grid[1:3, :].elems
        interior_bc = fe_grid[1:2, 1:]

        bcond_list = [
            BCSlice(var='u', dims=[0], slice=fe_grid[0, 0], value=0.0),
            BCSlice(var='u',
                    dims=[0],
                    slice=interior_bc,
                    link_slice=fe_grid[0, 0],
                    link_coeffs=[0],