argiope/mesh.py
def structured_mesh(shape = (2,2,2), dim = (1.,1.,1.)):
    """
    Returns a structured mesh. 
    
    :arg shape: 2 or 3 integers (eg: shape = (10, 10, 10)).
    :type shape: tuple
    :arg dim: 2 or 3 floats (eg: dim = (4., 2., 1.))
    :type dim: tuple
    
    .. note::

       This function does not use GMSH for mesh generation.


    
    >>> import argiope as ag
    >>> mesh = ag.mesh.structured_mesh(shape =(10,10,10), dim=(1.,1.,1.)))
    """
    # PREPROCESSING
    shape = np.array(shape)
    dim   = np.array(dim) 
    Ne = shape.prod()
    Nn = (shape + 1).prod()
    # LABELS
    nindex = np.arange(Nn) + 1
    eindex = np.arange(Ne) + 1
    # COORDINATES
    coords = [ np.linspace(0., dim[i], shape[i] + 1) for i in range(len(shape))]
    coords = np.array(np.meshgrid(*coords))
    coords = np.array([c.swapaxes(0,1).flatten("F") for c in coords]).T
    if len(shape) == 2:
        c = coords
        coords = np.zeros((Nn, 3))
        coords[:, :2] = c  
    # CONNECTIVITY    
    conn = _make_conn(shape)
    # MESH INSTANCE
    mesh = Mesh(nlabels = nindex,
                coords  = coords,
                elabels = eindex,
                conn = conn,)
    if len(shape) == 2: mesh.elements[("type", "argiope")] = "quad4"
    if len(shape) == 3: mesh.elements[("type", "argiope")] = "hexa8"    
    return mesh
def structured_mesh(shape = (2,2,2), dim = (1.,1.,1.)):
    """
    Returns a structured mesh. 
    
    :arg shape: 2 or 3 integers (eg: shape = (10, 10, 10)).
    :type shape: tuple
    :arg dim: 2 or 3 floats (eg: dim = (4., 2., 1.))
    :type dim: tuple
    
    .. note::

       This function does not use GMSH for mesh generation.


    
    >>> import argiope as ag
    >>> mesh = ag.mesh.structured_mesh(shape =(10,10,10), dim=(1.,1.,1.)))
    """
    # PREPROCESSING
    shape = np.array(shape)
    dim   = np.array(dim) 
    Ne = shape.prod()
    Nn = (shape + 1).prod()
    # LABELS
    nindex = np.arange(Nn) + 1
    eindex = np.arange(Ne) + 1
    # COORDINATES
    coords = [ np.linspace(0., dim[i], shape[i] + 1) for i in range(len(shape))]
    coords = np.array(np.meshgrid(*coords))
    coords = np.array([c.swapaxes(0,1).flatten("F") for c in coords]).T
    if len(shape) == 2:
        c = coords
        coords = np.zeros((Nn, 3))
        coords[:, :2] = c  
    # CONNECTIVITY    
    conn = _make_conn(shape)
    # MESH INSTANCE
    mesh = Mesh(nlabels = nindex,
                coords  = coords,
                elabels = eindex,
                conn = conn,)
    if len(shape) == 2: mesh.elements[("type", "argiope")] = "quad4"
    if len(shape) == 3: mesh.elements[("type", "argiope")] = "hexa8"    
    return mesh
def structured_mesh ( shape = ( 2 , 2 , 2 ) , dim = ( 1. , 1. , 1. ) ) : # PREPROCESSING shape = np . array ( shape ) dim = np . array ( dim ) Ne = shape . prod ( ) Nn = ( shape + 1 ) . prod ( ) # LABELS nindex = np . arange ( Nn ) + 1 eindex = np . arange ( Ne ) + 1 # COORDINATES coords = [ np . linspace ( 0. , dim [ i ] , shape [ i ] + 1 ) for i in range ( len ( shape ) ) ] coords = np . array ( np . meshgrid ( * coords ) ) coords = np . array ( [ c . swapaxes ( 0 , 1 ) . flatten ( "F" ) for c in coords ] ) . T if len ( shape ) == 2 : c = coords coords = np . zeros ( ( Nn , 3 ) ) coords [ : , : 2 ] = c # CONNECTIVITY     conn = _make_conn ( shape ) # MESH INSTANCE mesh = Mesh ( nlabels = nindex , coords = coords , elabels = eindex , conn = conn , ) if len ( shape ) == 2 : mesh . elements [ ( "type" , "argiope" ) ] = "quad4" if len ( shape ) == 3 : mesh . elements [ ( "type" , "argiope" ) ] = "hexa8" return mesh
Returns a structured mesh. 
    
    :arg shape: 2 or 3 integers (eg: shape = (10, 10, 10)).
    :type shape: tuple
    :arg dim: 2 or 3 floats (eg: dim = (4., 2., 1.))
    :type dim: tuple
    
    .. note::

       This function does not use GMSH for mesh generation.


    
    >>> import argiope as ag
    >>> mesh = ag.mesh.structured_mesh(shape =(10,10,10), dim=(1.,1.,1.)))
Returns a structured mesh . : arg shape : 2 or 3 integers ( eg : shape = ( 10 10 10 )) . : type shape : tuple : arg dim : 2 or 3 floats ( eg : dim = ( 4 . 2 . 1 . )) : type dim : tuple .. note ::