Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .github/workflows/scripts-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# ______ ______ _____ _ _
# | ____| ____| /\ / ____| (_) | |
# | |__ | |__ / \ | (___ ___ ____ _ ____ | |_
# | __| | __| / /\ \ \___ \ / __| __| | _ \| __|
# | | | |____ / ____ \ ____) | (__| | | | |_) | |
# |_| |______/_/ \_\_____/ \___|_| |_| __/| |
# | | | |
# |_| | |_
# Website: https://feascript.com/ \__|
#

name: Run FEAScript Examples

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
run-examples:
Expand Down Expand Up @@ -33,17 +44,17 @@ jobs:
echo "=========================================="
echo "Running FEAScript examples with Node.js ${{ matrix.node-version }}"
echo "=========================================="

# Counter for tracking test results
PASSED=0
FAILED=0
TOTAL=0

# Array to store failed examples
FAILED_EXAMPLES=()
# Find all .js files in examples directory, excluding generalFormPDEScript
for file in $(find examples -name "*.js" -type f | grep -v "generalFormPDEScript" | sort); do

# Find all .js files in examples directory
for file in $(find examples -name "*.js" -type f | sort); do
TOTAL=$((TOTAL + 1))
LOG_FILE="${file%.js}.log"
echo ""
Expand Down Expand Up @@ -71,7 +82,7 @@ jobs:
fi
echo "----------------------------------------"
done

# Print summary
echo ""
echo "=========================================="
Expand All @@ -81,7 +92,7 @@ jobs:
echo "Passed: $PASSED"
echo "Failed: $FAILED"
echo ""

# If there are failures, list them
if [ $FAILED -gt 0 ]; then
echo "Failed examples:"
Expand All @@ -103,4 +114,4 @@ jobs:
examples/**/*.log
examples/**/*.out
retention-days: 7
if-no-files-found: ignore
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<!-- [![liberapay](https://img.shields.io/liberapay/receives/FEAScript.svg?logo=liberapay)](https://liberapay.com/FEAScript/) -->

[FEAScript](https://feascript.com/) is a lightweight finite element simulation library written in JavaScript. It empowers users to create and execute simulations for physics and engineering applications in both browser-based and server-side environments. This is the core library of the FEAScript project.
[FEAScript](https://feascript.com/) is a lightweight finite element simulation library written in JavaScript. It empowers users to perform simulations for physics and engineering applications in both browser-based and server-side environments. This is the core library of the FEAScript project.

> 🚧 **FEAScript is currently under heavy development.** Its functionality and interfaces may change rapidly as new features and enhancements are introduced.
Expand Down
4 changes: 2 additions & 2 deletions dist/feascript.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/feascript.cjs.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/feascript.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/feascript.esm.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/feascript.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/feascript.umd.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptFrontPropagation.png" width="80" alt="FEAScript Logo">
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptFrontPropagation.png" width="80" alt="FEAScript Front Propagation Logo">

## Solidification Front Propagation in a Two-Dimensional Domain
## Solidification Front Propagation in a 2D Domain

This example demonstrates solving an eikonal equation in a two-dimensional domain using the FEAScript library. The problem represents a typical solidification front propagation scenario, where the objective is to track the movement of an interface, such as in metal cooling or crystal growth processes.
This example demonstrates solving an eikonal equation in a 2D domain using the FEAScript library. The problem represents a typical solidification front propagation scenario, where the objective is to track the movement of an interface, such as in metal cooling or crystal growth processes.

### Instructions

Expand All @@ -26,4 +26,4 @@ This example requires the `feascript` npm package and its peer dependencies (`ma
node SolidificationFront2D.js
```

**Note:** For detailed information on the model setup, boundary conditions, and simulation results, refer to the comments in the JavaScript files and the corresponding standard [tutorial](https://feascript.com/tutorials/SolidificationFront2D.html).
**Note:** For detailed information on the model setup, boundary conditions, and simulation results, refer to the comments in the JavaScript files and the corresponding [tutorial](https://feascript.com/tutorials/SolidificationFront2D.html).
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ model.addBoundaryCondition("3", ["constantValue", 0]); // Right
// Set solver method (optional)
model.setSolverMethod("lusolve");

// Solve the problem and get the solution
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();

// Print results to console
// Print results
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);
39 changes: 39 additions & 0 deletions examples/generalFormPDEScript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- Image placeholder -->
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptGenPDE.png" width="80" alt="FEAScript General Form PDE Logo">

## General Form PDE Solver

This example demonstrates solving a general form partial differential equation using the FEAScript library. The problem models equations of the form:

$$
\frac{d}{dx}\left(A(x)\frac{du}{dx}\right) + B(x)\frac{du}{dx} + C(x)u = D(x)
$$

where $u$ is the unknown function, $x$ is the position, and $A$, $B$, $C$, $D$ are user-provided coefficient functions.

### Available Versions

This example is available in the following implementations:

1. **Advection-Diffusion with Gaussian Source** (`advectionDiffusion1D.js`) - Demonstrates an advection-diffusion problem with a Gaussian source term

### Instructions

This example requires the `feascript` npm package and its peer dependencies (`mathjs`). It imports FEAScript directly from the npm package and runs the simulation in a Node.js environment. To run the example, follow these instructions:

1. **Create package.json with ES module support:**

```bash
echo '{"type":"module"}' > package.json
```

2. **Install dependencies:**

```bash
npm install feascript mathjs
```

3. **Run the example:**
```bash
node advectionDiffusion1D.js
```
55 changes: 55 additions & 0 deletions examples/generalFormPDEScript/advectionDiffusion1D.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ______ ______ _____ _ _ //
// | ____| ____| /\ / ____| (_) | | //
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
// | | | | //
// |_| | |_ //
// Website: https://feascript.com/ \__| //

// Import Math.js
import * as math from "mathjs";
global.math = math;

// Import FEAScript library
import { FEAScriptModel, printVersion } from "feascript";

console.log("FEAScript Version:", printVersion);

// Create a new FEAScript model
const model = new FEAScriptModel();

// Set solver configuration with coefficient functions
model.setSolverConfig("generalFormPDEScript", {
coefficientFunctions: {
// Equation d²u/dx² + 10 du/dx = -10 * exp(-200 * (x - 0.5)²)
A: (x) => 1, // Diffusion coefficient
B: (x) => 10, // Advection coefficient
C: (x) => 0, // Reaction coefficient
D: (x) => -10 * Math.exp(-200 * Math.pow(x - 0.5, 2)), // Source term
},
});

// Define mesh configuration
model.setMeshConfig({
meshDimension: "1D",
elementOrder: "quadratic",
numElementsX: 20,
maxX: 1.0,
});

// Define boundary conditions
model.addBoundaryCondition("0", ["constantValue", 1]); // Left boundary, u(0) = 1
model.addBoundaryCondition("1", "zeroGradient"); // Right boundary, zero gradient (du/dx = 0)

// Set solver method
model.setSolverMethod("lusolve");

// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();

// Print results
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);
33 changes: 0 additions & 33 deletions examples/generalFormPDEScript/exampleGeneralFormPDE.js

This file was deleted.

58 changes: 0 additions & 58 deletions examples/generalFormPDEScript/readme.md

This file was deleted.

6 changes: 3 additions & 3 deletions examples/heatConductionScript/heatConduction1DWall/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptHeatTransfer.png" width="80" alt="FEAScript Logo">
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptHeatTransfer.png" width="80" alt="FEAScript Heat Conduction Logo">

## Heat Conduction Through a Wall

Expand All @@ -14,7 +14,7 @@ The example requires the `feascript` npm package and its peer dependencies (`mat
echo '{"type":"module"}' > package.json
```

2. **Install FEAScript and dependencies:**
2. **Install dependencies:**

```bash
npm install feascript mathjs
Expand All @@ -25,4 +25,4 @@ The example requires the `feascript` npm package and its peer dependencies (`mat
node HeatConduction1DWall.js
```

**Note:** For an HTML version of this example, and additional details, refer to the corresponding [tutorial](https://feascript.com/tutorials/HeatConduction1DWall.html).
**Note:** For detailed information on the model setup, boundary conditions, and simulation results, refer to the comments in the JavaScript files and the corresponding [tutorial](https://feascript.com/tutorials/HeatConduction1DWall.html).
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ model.addBoundaryCondition("1", ["constantTemp", 5]);
// Set solver method (optional)
model.setSolverMethod("lusolve");

// Solve the problem and get the solution
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();

// Print results to console
// Print results
console.log(`Number of nodes: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://feascript.github.io/FEAScript-website/assets/FEAScriptHeatTransfer.png" width="80" alt="FEAScript Logo">

## Heat Conduction in a Two-Dimensional Fin
## Heat Conduction in a 2D Fin

This example demonstrates solving a steady-state heat transfer problem in a 2D rectangular domain using the FEAScript library. The problem represents a typical cooling fin scenario, where the objective is to model heat conduction and understand temperature distribution under specific boundary conditions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ model.addBoundaryCondition("3", ["constantTemp", 200]);
// Set solver method (optional)
model.setSolverMethod("lusolve");

// Solve the problem and get the solution
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();

// Print results to console
// Print results
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ async function main() {
model.addBoundaryCondition("2", ["convection", 1, 20]); // top boundary
model.addBoundaryCondition("3", ["symmetry"]); // left boundary

// Solve the problem and get the solution
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();

// Print results to console
// Print results
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);
Expand Down
Loading