Examples overview
FEAScript-core ships with Node.js examples for every model, in the
examples folder. Each example is a single
script that sets up a model in the five steps of your first simulation,
solves it and prints the results.
These pages show, for each example, the geometry and boundary conditions, the mesh, and the results. The results were computed with FEAScript-core 0.4.0, by running the examples unchanged.
Examples
| Model | Example | Mesh |
|---|---|---|
| Heat conduction | Wall in 1D | 10 linear elements |
| Heat conduction | Bi-material wall in 1D | 20 linear elements |
| Heat conduction | Fin in 2D | 8 × 4 quadratic quadrilaterals |
| Heat conduction | Fin in 2D, Gmsh mesh | 30 quadratic quadrilaterals (Gmsh) |
| Heat conduction | Rhomboid fin in 2D, Gmsh mesh | 24 quadratic quadrilaterals (Gmsh) |
| Heat conduction | Fin in 2D with spatially varying k and Q | 8 × 4 quadratic quadrilaterals |
| General-form PDE | Advection-diffusion in 1D | 20 quadratic elements |
| General-form PDE | Nonlinear reaction-diffusion in 1D | 20 linear elements |
| Front propagation | Solidification front in 2D | 12 × 8 quadratic quadrilaterals |
| Creeping flow | Lid-driven cavity in 2D | 12 × 6 Q2-Q1 quadrilaterals |
| Creeping flow | Couette flow in 2D | 4 × 2 Q2-Q1 quadrilaterals |
| Euler–Bernoulli beam | Clamped and spring-supported beam | 2 cubic Hermite elements |
| Euler–Bernoulli beam | Cantilever beam | 4 cubic Hermite elements |
Running an example
The examples import FEAScript from npm. In the folder of a model (for example
examples/heatConduction), or in an empty folder with a copy of the example:
-
Create a
package.jsonwith ES module support:echo '{"type":"module"}' > package.json -
Install FEAScript:
npm install feascript -
Run the example, for example:
node heatConduction2DFin/heatConduction2DFin.js
The Gmsh examples read their .msh file from the folder of the script, so they can be run from any folder.
Every example prints the FEAScript version first, then its results: some print the node coordinates and the
solution vector, others a short summary next to the exact or published values. The command to run each example
is given in its section.
How the figures were made
Geometries and meshes are drawn from the same values as the examples: the structured meshes from the mesh
generator of FEAScript, the Gmsh meshes from the .msh files of the examples. The result figures show the
solution that each example computes. Contour lines follow the finite element solution inside each element: the
field is evaluated with the shape functions of the element on a fine grid of points, not interpolated linearly
between the nodes. The highest and lowest values quoted on these pages are found the same way, so they can lie
between the nodes.