Overview

Heat conduction in a 2D fin, with WebGPU.

This page demonstrates solving the 2D heat conduction fin problem using FEAScript with a WebGPU-accelerated Jacobi solver. For the mathematical formulation and theory, see the basic tutorial.

⚠️ Important: This feature is experimental and requires a browser that supports WebGPU.

WebGPU implementation

The code below shows how to use FEAScript with the WebGPU-accelerated Jacobi solver. The solution is plotted as a 2D contour.

<body>
  <!-- ...body region... -->
  <script type="module">
    import {
      FEAScriptModel,
      plotSolution,
      printVersion,
    } from "https://core.feascript.com/src/index.js";

    window.addEventListener("DOMContentLoaded", async () => {
      console.log("FEAScript version:", printVersion);

      // 1. Create the model and select the physics
      const model = new FEAScriptModel();
      model.setModelConfig("heatConductionScript");

      // 2. Define the mesh
      model.setMeshConfig({
        meshDimension: "2D",
        elementOrder: "quadratic",
        numElementsX: 8,
        numElementsY: 4,
        maxX: 4,
        maxY: 2,
      });

      // 3. Apply the boundary conditions
      model.addBoundaryCondition("0", ["constantTemperature", 200]); // Bottom
      model.addBoundaryCondition("1", ["symmetry"]);                 // Left
      model.addBoundaryCondition("2", ["convection", 1, 20]);        // Top
      model.addBoundaryCondition("3", ["constantTemperature", 200]); // Right

      // 4. Solve on the GPU with the WebGPU Jacobi solver
      model.setSolverMethod("jacobi-gpu");
      const result = await model.solveAsync();

      // 5. Plot the results
      plotSolution(model, result, "contour", "resultsCanvas");
    });
  </script>
  <!-- ...rest of body region... -->
</body>

Results

Below is the 2D contour plot of the computed temperature distribution. This plot is generated in real time using FEAScript.

Solving...

Stay in the loop

Join the mailing list.

Receive new tutorials, project updates and news.