FEM1D_NONLINEAR is a C++ program which applies the finite element method to a simple nonlinear boundary value problem in one spatial dimension.
The nonlinear boundary problem involves an unknown function u on an interval [a,b]. Typically, a single boundary condition, either u(a) or u'(a), is given at the left endpoint, and u(b) or u'(b) at the right endpoint. The associated differential equation, which must hold in the interior of [a,b], happens to have the form:
-d/dx ( p(x) du/dx ) + q(x) * u + u * du/dx = f(x)where p(x), q(x) and f(x) are given functions.
The nonlinearity arises because of the term u*du/dx; if this term were not present, standard finite element techniques would allow the system to be set up and solved almost as easily as a linear system of algebraic equations is solved.
Newton's method, which works well for scalar nonlinear equations, can also be applied to this problem, as long as we are willing to extend our notions of a function and derivative. We need to imagine our differential equation as a function F(u):
F(u) = -d/dx ( p(x) du/dx ) + q(x) * u + u * du/dx - f(x)(with the boundary conditions wrapped in here somewhere as well!) If we differentiate this function, we get a Jacobian operator, which is evaluated at u, and applied to any small increment v. This equation implicitly describes the tangent plane of solutions near to a given solution u.
J(u,v) = -d/dx ( p(x) dv/dx ) + q(x) * v + u * dv/dx + v * du/dxNow if we apply the finite element formulation to represent u and v in terms of sums of basis functions, we can set up a linear system, to be evaluated at u and solved for the Newton increment delta_u:
J(u,delta_u) = - F(u)By using the Newton increment to update u and repeating the process as needed, we can expect to get a good finite element solution of our original nonlinear boundary value problem.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
FEM1D_NONLINEAR is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.
FEM1D, a data directory which contains examples of 1D FEM files, three text files that describe a 1D finite element model;
FEM1D, a C++ program which applies the finite element method to a linear two point boundary value problem in 1D.
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.
FEM1D_HEAT_STEADY, a C++ program which uses the finite element method to solve the steady (time independent) heat equation in 1D.
FEM1D_PACK, a C++ library which contains utilities for 1D finite element calculations.
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.
FEM1D_PROJECT, a C++ program which projects data into a finite element space, including the least squares approximation of data, or the projection of a finite element solution from one mesh to another.
FEM1D_SAMPLE, a C++ program which samples a scalar or vector finite element function of one variable, defined by FEM files, returning interpolated values at the sample points.
You can go up one level to the C++ source codes.