FEM1D_BVP_LINEAR
Finite Element Method, 1D, Boundary Value Problem, Piecewise Linear Elements
FEM1D_BVP_LINEAR,
a Python program which
applies the finite element method, with piecewise linear elements,
to a two point boundary value problem in one spatial dimension,
and compares the computed and exact solutions
with the L2 and seminorm errors.
The boundary value problem (BVP) that is to be solved has the form:
- d/dx ( a(x) * du/dx ) + c(x) * u(x) = f(x)
in the interval 0 < x < 1. The functions a(x), c(x), and f(x) are
given.
Boundary conditions are applied at the endpoints, and in this case,
these are assumed to have the form:
u(0.0) = 0.0;
u(1.0) = 0.0.
To compute a finite element approximation, a set of n equally spaced
nodes is defined from 0.0 to 1.0, a set of piecewise linear basis functions
is set up, with one basis function associated with each node,
and then an integral form of the BVP is used, in which the differential
equation is multiplied by each basis function, and integration by parts is
used to simplify the integrand.
A simple two point Gauss quadrature formula is used to estimate the
resulting integrals over each interval.
Usage:
u = fem1d_bvp_linear ( n, a, c,
f, x )
where
-
n is the number of equally spaced nodes.
-
a is the function which evaluates a(x);
-
c is the function which evaluates c(x);
-
f is the function which evaluates f(x).
-
x is the input vector of n nodes.
-
u is the output vector of n values at the nodes,
which can also be regarded as the finite element coefficients.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
FEM1D_BVP_LINEAR is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
FEM1D,
a Python program which
applies the finite element method to a linear two point boundary value problem
in a 1D region.
FEM1D_BVP_QUADRATIC,
a Python program which
applies the finite element method (FEM), with piecewise quadratic
elements, to a two point boundary value problem (BVP) in one
spatial dimension, and compares the computed and exact solutions
with the L2 and seminorm errors.
FEM2D_BVP_LINEAR,
a Python program which
applies the finite element method (FEM), with piecewise linear elements,
to a 2D boundary value problem (BVP) in a rectangle,
and compares the computed and exact solutions
with the L2 and seminorm errors.
Reference:
-
Dianne O'Leary,
Finite Differences and Finite Elements: Getting to Know You,
Computing in Science and Engineering,
Volume 7, Number 3, May/June 2005.
-
Dianne O'Leary,
Scientific Computing with Case Studies,
SIAM, 2008,
ISBN13: 978-0-898716-66-5,
LC: QA401.O44.
-
Hans Rudolf Schwarz,
Finite Element Methods,
Academic Press, 1988,
ISBN: 0126330107,
LC: TA347.F5.S3313..
-
Gilbert Strang, George Fix,
An Analysis of the Finite Element Method,
Cambridge, 1973,
ISBN: 096140888X,
LC: TA335.S77.
-
Olgierd Zienkiewicz,
The Finite Element Method,
Sixth Edition,
Butterworth-Heinemann, 2005,
ISBN: 0750663200,
LC: TA640.2.Z54
Source Code:
-
barebones.py,
a version of fem1d_bvp_linear.py with the comments removed.
-
fem1d_bvp_linear.py,
sets up and solves the finite element problem.
-
fem1d_bvp_linear_test00.py
-
fem1d_bvp_linear_test01.py
-
fem1d_bvp_linear_test02.py
-
fem1d_bvp_linear_test03.py
-
fem1d_bvp_linear_test04.py
-
fem1d_bvp_linear_test05.py
-
fem1d_bvp_linear_test06.py
-
fem1d_bvp_linear_test07.py
-
fem1d_bvp_linear_test08.py
-
fem1d_bvp_linear_test09.py
-
fem1d_bvp_linear_test10.py
-
h1s_error_linear.py,
estimates the seminorm of the error, given the
piecewise linear solution of
the finite element problem, and a function that evaluates
the derivative of the exact solution.
-
l1_error.py,
estimates the little l1 norm of the error, given the solution of
the finite element problem, and a function that evaluates
the exact solution.
-
l2_error_linear.py,
estimates the L2 norm of the error, given the
piecewise linear solution of
the finite element problem, and a function that evaluates
the exact solution.
-
max_error_linear.py,
estimates the max norm of the error, given the
piecewise linear solution of
the finite element problem, and a function that evaluates
the exact solution.
-
timestamp.py,
prints the YMDHMS date as a timestamp.
Examples and Tests:
You can go up one level to
the Python source codes.
Last revised on 14 January 2015.