# sfepy.discrete.dg.poly_spaces module

class sfepy.discrete.dg.poly_spaces.LegendrePolySpace(name, geometry, order, extended)

  Legendre hierarchical polynomials basis, over [0, 1] domain.

  get_interpol_scheme()

    For dim > 1 returns F and P matrices according to gmsh basis specification [1]: Let us assume that the approximation of the view’s value over an element is written as a linear combination of d basis functions f_i, i=0, ..., n-1 (the coefficients being stored in list-of-values).

    Defining

    f_i = \sum\limits_{j=0}^{d-1} F_{ij}\cdot p_j,

    with

    p_j(u, v, w) = u^{P_j^{(0)}}\cdot v^{P_j^{(1)}}\cdot w^{P_j^{(2)}} (u, v and w being the coordinates in the element’s parameter space), then val-coef-matrix denotes the n x n matrix F and val-exp-matrix denotes the n x 3 matrix P where n is number of basis functions as calculated by `get_n_el_nod`.

    Expects matrices to be saved in atributes coefM and expoM!

    [1]

    Remacle, J.-F., Chevaugeon, N., Marchandise, E., & Geuzaine, C. (2007). Efficient visualization of high-order finite elements. International Journal for Numerical Methods in Engineering, 69(4), 750-771. https://doi.org/10.1002/nme.1787

    Returns:
      interp_scheme_struct Struct

        Struct with name of the scheme, geometry desc and P and F

  get_nth_fun(n)

    Uses shifted Legendre polynomials formula on interval [0, 1].

    Convenience function for testing

    Parameters:
      n int
    Returns:
      fun callable

        n-th function of the legendre basis

  get_nth_fun_der(n, diff=1)

    Returns diff derivative of nth function. Uses shifted legendre polynomials formula on interval [0, 1].

    Useful for testing.

    Parameters:
      n int
      diff int

        (Default value = 1)

    Returns:
      fun callable

        derivative of n-th function of the 1D legendre basis

  gradjacobiP(coors, alpha, beta, diff=1)

    diff derivative of the jacobi polynomials on interval [-1, 1] up to self.order + 1 at coors

    Parameters:
      coors
      alpha float
      beta float
      diff int

        (Default value = 1)

    Returns:
      values ndarray

        output shape is shape(coor) + (self.order + 1,)

  gradlegendreP(coors, diff=1)
    Parameters:
      diff int

        default 1

      coors array_like

        coordinates, preferably in interval [-1, 1] for which this basis is intented

    Returns:
      values ndarray

        values at coors of all the legendre polynomials up to self.order

  jacobiP(coors, alpha, beta)

    Values of the jacobi polynomials on interval [-1, 1] up to self.order + 1 at coors

    Parameters:
      coors array_like
      beta float
      alpha float
    Returns:
      values ndarray

        output shape is shape(coor) + (self.order + 1,)

  legendreP(coors)
    Parameters:
      coors array_like

        coordinates, preferably in interval [-1, 1] for which this basis is intented

    Returns:
      values ndarray

        values at coors of all the legendre polynomials up to self.order

  legendre_funs = [<function LegendrePolySpace.<lambda>>, <function LegendrePolySpace.<lambda>>, <function LegendrePolySpace.<lambda>>, <function LegendrePolySpace.<lambda>>, <function LegendrePolySpace.<lambda>>, <function LegendrePolySpace.<lambda>>]

class sfepy.discrete.dg.poly_spaces.LegendreSimplexPolySpace(name, geometry, order, extended=False)
  name = 'legendre_simplex'

class sfepy.discrete.dg.poly_spaces.LegendreTensorProductPolySpace(name, geometry, order)
  build_interpol_scheme()

    Builds F and P matrices returned by self.get_interpol_scheme.

    Note that this function returns coeficients according to gmsh parametrization of Quadrangle i.e. [-1, 1] x [-1, 1] and hence the form of basis function is not the same as exhibited by the LegendreTensorProductPolySpace object which acts on parametrization [0, 1] x [0, 1].

    Returns:
      F ndarray

        coefficient matrix

      P ndarray

        exponent matrix

  name = 'legendre_tensor_product'

sfepy.discrete.dg.poly_spaces.get_n_el_nod(order, dim, extended=False)

  Number of nodes per element for discontinuous legendre basis, i.e. number of iterations yielded by iter_by_order

  When extended is False

  N_p = \frac{(n + 1) \cdot (n + 2) \cdot ... \cdot (n + d)}{d!}

  where n is the order and d the dimension. When extended is True

  N_p = (n + 1) ^ d

  where n is the order and d the dimension.

  Parameters:
    order int

      desired order of multidimensional basis

    dim int

      dimension of the basis

    extended bool

      iterate over extended tensor product basis (Default value = False)

  Returns:
    n_el_nod int

      number of basis functions in basis

sfepy.discrete.dg.poly_spaces.iter_by_order(order, dim, extended=False)

  Iterates over all combinations of basis functions indexes needed to create multidimensional basis in a way that creates hierarchical basis

  Parameters:
    order int

      desired order of multidimensional basis

    dim int

      dimension of the basis

    extended bool

      iterate over extended tensor product basis (Default value = False)

  Yields:
    idx tuple

      containing basis function indexes, used in `_combine_polyvals` and `_combine_polyvals_der`