# FEM1D_BVP_QUADRATIC Finite Element Method, 1D, Boundary Value Problem, Piecewise Quadratic Elements

FEM1D_BVP_QUADRATIC is a C program which applies the finite element method, with piecewise quadratic 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 quadratoc 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 three point Gauss quadrature formula is used to estimate the resulting integrals over each interval.

### Languages:

FEM1D_BVP_QUADRATIC is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version and a Python version..

### Related Data and Programs:

FD1D_BVP, a C program which applies the finite difference method to a two point boundary value problem in one spatial dimension.

FEM1D, a C program which applies the finite element method to a linear two point boundary value problem in a 1D region.

FEM1D_ADAPTIVE, a C program which applies the finite element method to a linear two point boundary value problem in a 1D region, using adaptive refinement to improve the solution.

FEM1D_BVP_LINEAR, a C 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.

FEM1D_HEAT_STEADY, a C program which uses the finite element method to solve the steady (time independent) heat equation in 1D.

FEM1D_NONLINEAR, a C program which applies the finite element method to a nonlinear two point boundary value problem in a 1D region.

FEM1D_PMETHOD, a C program which applies the p-method version of the finite element method to a linear two point boundary value problem in a 1D region.

FEM2D_BVP_QUADRATIC, a C program which applies the finite element method (FEM), with piecewise quadratic 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:

1. Dianne O'Leary,
Finite Differences and Finite Elements: Getting to Know You,
Computing in Science and Engineering,
Volume 7, Number 3, May/June 2005.
2. Dianne O'Leary,
Scientific Computing with Case Studies,
SIAM, 2008,
ISBN13: 978-0-898716-66-5,
LC: QA401.O44.
3. Hans Rudolf Schwarz,
Finite Element Methods,
ISBN: 0126330107,
LC: TA347.F5.S3313..
4. Gilbert Strang, George Fix,
An Analysis of the Finite Element Method,
Cambridge, 1973,
ISBN: 096140888X,
LC: TA335.S77.
5. Olgierd Zienkiewicz,
The Finite Element Method,
Sixth Edition,
Butterworth-Heinemann, 2005,
ISBN: 0750663200,
LC: TA640.2.Z54

### Examples and Tests:

One of the tests makes convergence plots in the H1, L2 and Max norms.

### List of Routines:

• FEM1D_BVP_QUADRATIC solves a two point boundary value problem.
• H1S_ERROR_QUADRATIC estimates the seminorm error of a finite element solution.
• I4VEC_ZERO_NEW creates and zeroes an I4VEC.
• L1_ERROR estimates the l1 error norm of a finite element solution.
• L2_ERROR_QUADRATIC estimates the L2 error norm of a finite element solution.
• MAX_ERROR_QUADRATIC estimates the max error norm of a finite element solution.
• R8_MAX returns the maximum of two R8's.
• R8MAT_SOLVE2 computes the solution of an N by N linear system.
• R8MAT_ZERO_NEW returns a new zeroed R8MAT.
• R8VEC_EVEN_NEW returns N real values, evenly spaced between ALO and AHI.
• R8VEC_ZERO_NEW creates and zeroes an R8VEC.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the C source codes.

Last revised on 12 July 2015.