In [1]:
import numpy
from matplotlib import pyplot
from matplotlib import colors
% matplotlib inline
In [2]:
import os, sys
sys.path.append(os.path.split(os.getcwd())[0])
In [3]:
import utils.poly as poly
import utils.quadrature as quad
The coordinates of solution points using Gauss-Lobatto-Legendre quadrature points.
In [4]:
xi = quad.GaussLobattoJacobi(4).nodes
The Lagrange basis using the Gauss-Lobatto-Legendre quadrature points.
In [5]:
Lk = poly.LagrangeBasis(xi)
This is used to plotting the basis functions.
In [6]:
x = numpy.linspace(-1., 1., 100)
phi = Lk(x)
In [7]:
pyplot.figure(figsize=(6, 3))
pyplot.plot(x, phi[:, 0], 'r-', lw=3, label="1st basis")
pyplot.plot(x, phi[:, 1], 'm-', lw=3, label="2nd basis")
pyplot.plot(x, phi[:, 2], 'c-', lw=3, label="3rd basis")
pyplot.plot(x, phi[:, 3], 'g-', lw=3, label="4th basis")
pyplot.plot(xi, numpy.zeros(4), 'k.--', lw=2,
markersize=15, markerfacecolor='r', markeredgecolor='r')
pyplot.plot(xi, numpy.ones(4), 'k.--', lw=2,
markersize=15, markerfacecolor='r', markeredgecolor='r')
pyplot.ylim(-0.2, 1.05)
pyplot.title(r'$\eta(\xi)$', fontsize=25)
pyplot.xlabel(r'$\xi$', fontsize=15)
pyplot.grid()
pyplot.legend(loc=0, bbox_to_anchor=(1.02, 1.04));