Thursday, May 14, 2026

Try to Understand Boundary Conditions in FEM Using a Simple 1D Bar


In Finite Element Method (FEM), boundary conditions define how a structure interacts with its surroundings. They are essential because, without them, the FEM system cannot produce a unique physical solution.

Consider a simple 1D bar with 3 nodes and 2 elements:

Node 1        Node 2        Node 3
|-------------|-------------|

In this example:

  • the left end is fixed,
  • and a force is applied at the right end.

Dirichlet Boundary Condition

At Node 1:

u1=0u_1 = 0

This means the displacement is fixed to zero. This is called a Dirichlet boundary condition because the displacement value is prescribed directly.

In the Python code:

fixed_dofs = [0]

This prevents the bar from moving freely.


Neumann Boundary Condition

At Node 3:

F3=1000 NF_3 = 1000\text{ N}

This specifies an external force acting on the bar. This is called a Neumann boundary condition.

In the code:

F = np.array([0, 0, 1000.0])

FEM Equation

The FEM system is written as:

[K]{u}={F}[K]\{u\} = \{F\}

where:

  • [K] is the stiffness matrix,
  • {u} is the displacement vector,
  • {F} is the load vector.

The local stiffness matrix for each element is:



The Python code assembles these into the global matrix and solves for the unknown displacements.


Why Boundary Conditions Matter

Without the fixed support, the entire bar could move freely, making the stiffness matrix singular and the FEM problem unsolvable.

Boundary conditions:

  • define supports and loads,
  • remove rigid body motion,
  • and ensure a meaningful solution.

In this simple example:

  • the fixed support is a Dirichlet condition,
  • the applied force is a Neumann condition.

Understanding these concepts is fundamental to learning FEM.

Friday, May 8, 2026

Understanding Nodal Interpolation vs L² Projection in Finite Element Method (FEM)




                                                        Figure 1: 2D Comparison



Figure 2: 1D Comparison


When solving engineering problems using the Finite Element Method (FEM), we often need to represent a continuous physical field (temperature, stress, velocity, etc.) on a discrete mesh. Two common ways to do this are nodal interpolation and L² projection.

The Exact FunctionFor demonstration, we used the following 2D oscillatory function as our "true" or exact solution:
f(x,y)=sin(2πx)cos(2πy)+0.8sin(4πx)sin(4πy)

This function contains multiple waves, making it a good test case to see how well different approximation techniques perform.1. Nodal InterpolationNodal interpolation is the simplest approach. We evaluate the exact function only at the mesh nodes and then use linear shape functions to create a piecewise linear surface across each triangle.
Characteristics:
  • The approximated surface passes exactly through the nodal values.
  • Easy to implement.
  • Can be "peaky" or overshoot/undershoot between nodes, especially on coarse meshes.
2. L² ProjectionL² projection finds the best possible piecewise linear function (in the finite element space) that approximates the exact function in the least squares sense.Mathematically, it minimizes the L² norm of the error:


This is achieved by solving a linear system involving the mass matrix M and the load vector b.Characteristics:
  • Does not necessarily pass exactly through the nodal values of the exact function.
  • Usually provides a smoother and more accurate overall approximation.
  • Better at capturing average behavior across each element.
Visual ComparisonI generated three 3D plots for the same coarse triangular mesh:
  • Left: Exact function — smooth and wavy.
  • Middle: Nodal Interpolation — follows the nodes but shows visible faceting and local inaccuracies.
  • Right: L² Projection — visibly smoother and closer to the true surface in the least-squares sense.
Even with a relatively coarse mesh, the difference between simple interpolation and L² projection is noticeable. L² projection generally reduces the overall error when representing continuous fields in FEM.Why Does This Matter?In real FEM simulations, we rarely have the "exact" solution. However, understanding these concepts helps engineers:
  • Choose proper post-processing techniques
  • Reduce approximation errors
  • Better interpret results from simulation software
Takeaway:
While nodal interpolation is fast and intuitive, L² projection often gives a superior representation of the solution — especially when accuracy across the entire domain is important.


References:
1. Larson, M. G., & Bengzon, F. (2013). The Finite Element Method: Theory, implementation, and applications. In Texts in computational science and engineering. https://doi.org/10.1007/978-3-642-33287-6
2. Grok