Skip to content

Commit 6fd11f8

Browse files
authored
Merge branch 'main' into feature/tests
2 parents ff2e152 + 5cec443 commit 6fd11f8

72 files changed

Lines changed: 18355 additions & 3122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: [FEAScript]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: FEAScript
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/scripts-test.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#
2+
# ════════════════════════════════════════════════════════════════
3+
# FEAScript Core Library
4+
# Lightweight Finite Element Simulation in JavaScript
5+
# Version: 0.2.0 | https://feascript.com
6+
# MIT License © 2023–2026 FEAScript
7+
# ════════════════════════════════════════════════════════════════
8+
#
9+
10+
name: Run FEAScript Examples
11+
12+
on:
13+
push:
14+
branches: [main]
15+
pull_request:
16+
branches: [main]
17+
18+
jobs:
19+
run-examples:
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
node-version: [18.x, 20.x]
25+
fail-fast: false # Continue testing other versions even if one fails
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Node.js ${{ matrix.node-version }}
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ matrix.node-version }}
35+
cache: npm
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Run FEAScript examples
41+
run: |
42+
echo "=========================================="
43+
echo "Running FEAScript examples with Node.js ${{ matrix.node-version }}"
44+
echo "=========================================="
45+
46+
# Counter for tracking test results
47+
PASSED=0
48+
FAILED=0
49+
TOTAL=0
50+
51+
# Array to store failed examples
52+
FAILED_EXAMPLES=()
53+
54+
# Find all .js files in examples directory
55+
for file in $(find examples -name "*.js" -type f | sort); do
56+
TOTAL=$((TOTAL + 1))
57+
LOG_FILE="${file%.js}.log"
58+
echo ""
59+
echo "▶ Running: $file"
60+
echo "----------------------------------------"
61+
62+
# Run the example and capture output to log file
63+
if timeout 300 node "$file" > "$LOG_FILE" 2>&1; then
64+
echo "✓ PASSED: $file"
65+
PASSED=$((PASSED + 1))
66+
# Show a preview of the output
67+
echo "Output preview:"
68+
head -n 5 "$LOG_FILE" | sed 's/^/ /'
69+
if [ $(wc -l < "$LOG_FILE") -gt 5 ]; then
70+
echo " ... (see $LOG_FILE for full output)"
71+
fi
72+
else
73+
EXIT_CODE=$?
74+
echo "✗ FAILED: $file (exit code: $EXIT_CODE)"
75+
FAILED=$((FAILED + 1))
76+
FAILED_EXAMPLES+=("$file")
77+
# Show error output for failed tests
78+
echo "Error output:"
79+
tail -n 20 "$LOG_FILE" | sed 's/^/ /'
80+
fi
81+
echo "----------------------------------------"
82+
done
83+
84+
# Print summary
85+
echo ""
86+
echo "=========================================="
87+
echo "Test Summary"
88+
echo "=========================================="
89+
echo "Total examples run: $TOTAL"
90+
echo "Passed: $PASSED"
91+
echo "Failed: $FAILED"
92+
echo ""
93+
94+
# If there are failures, list them
95+
if [ $FAILED -gt 0 ]; then
96+
echo "Failed examples:"
97+
for failed in "${FAILED_EXAMPLES[@]}"; do
98+
echo " - $failed"
99+
done
100+
echo ""
101+
exit 1
102+
else
103+
echo "All examples passed successfully! ✓"
104+
fi
105+
106+
- name: Upload test results on failure
107+
if: failure()
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: test-results-node-${{ matrix.node-version }}
111+
path: |
112+
examples/**/*.log
113+
examples/**/*.out
114+
retention-days: 7
115+
if-no-files-found: ignore

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Dependencies
12
/node_modules
23
node_modules
3-
node_modules/
4+
node_modules/
5+
6+
# Example dependencies
7+
examples/**/package.json
8+
examples/**/package-lock.json
9+
examples/**/node_modules/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
examples/
22
test/
33
.gitignore
4+
README.md
5+
LICENSE
6+
dist/
47
package-lock.json

CONTRIBUTING.md

Lines changed: 120 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,58 @@
22

33
Thank you for your interest in contributing! FEAScript is in early development, with continuous additions of new features and improvements. To ensure a smooth and collaborative development process, please review and follow the guidelines below.
44

5-
## Contribution Guidelines
5+
## Contents
66

7-
1. **Respect the existing coding style:** Observe the code near your intended changes and aim to preserve that style in your modifications.
7+
- [Development Environment & Coding Style](#development-environment--coding-style)
8+
- [Variable & File Naming](#variable--file-naming)
9+
- [File Structure](#file-structure)
10+
- [Branching & Workflow](#branching--workflow)
11+
- [Local Testing](#local-testing)
12+
- [Running the Node.js Examples](#running-the-nodejs-examples)
813

9-
2. **Recommended tools:**
10-
We recommend using [Visual Studio Code](https://code.visualstudio.com/) with the [Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for automatic code formatting. Additionally, use a **110-character line width** to maintain consistent formatting.
14+
## Development Environment & Coding Style
1115

12-
3. **Naming conventions:**
13-
Use [camelCase](https://en.wikipedia.org/wiki/Camel_case) formatting for variable names throughout the code.
16+
- Use [Visual Studio Code](https://code.visualstudio.com/) with the [Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) for automatic code formatting
17+
- Use a **110-character line width** to maintain consistent formatting
18+
- Observe the code near your intended changes and aim to preserve that style in your modifications
1419

15-
4. **Testing changes locally:**
16-
Before submitting a pull request, test your modifications by running the FEAScript library from a local directory. For example, you can load the library in your HTML file as follows:
20+
## Variable & File Naming
1721

18-
```javascript
19-
import { FEAScriptModel, plotSolution, printVersion } from "[USER_DIRECTORY]/FEAScript-core/src/index.js";
20-
```
22+
- Use [camelCase](https://en.wikipedia.org/wiki/Camel_case) formatting for variable names throughout the code
23+
- JavaScript source file names use camelCase (e.g., `logging.js`, `meshGeneration.js`, `newtonRaphson.js`)
2124

22-
FEAScript can be run on a local server. To start a local server, you can use [Python HTTP Server](https://docs.python.org/3/library/http.server.html):
25+
### Exceptions
2326

24-
```bash
25-
python -m http.server
26-
```
27+
- Public entry file: `index.js` (standard entry point convention)
28+
- Core model file: `FEAScript.js` (matches the library name)
2729

28-
where the server will be available at `http://127.0.0.1:8000/`. Static file server npm packages like [serve](https://github.com/vercel/serve#readme) and [Vite](https://vite.dev/) can also be used.
29-
30-
## Branching & Workflow
31-
32-
To contribute a new feature or fix:
33-
34-
- Do not commit directly to `main` or `dev`.
35-
- Instead, start your work in a feature branch based on the `dev` branch.
36-
37-
**If you are not a member of the repository (e.g., an external contributor), you must first [fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo).** Make your changes in your fork, then submit a Pull Request from your fork's feature branch into the`dev` branch.
38-
39-
## File Structure Guidelines
30+
## File Structure
4031

4132
All files in the FEAScript-core codebase should follow this structure:
4233

43-
1. **Banner**: All files start with the FEAScript ASCII art banner
44-
2. **Imports**:
45-
- External imports (from npm packages) first, alphabetically ordered
46-
- Internal imports next, grouped by module/folder
47-
3. **Classes/Functions**: Implementation with proper JSDoc comments
34+
1. Banner: All files start with the FEAScript banner
35+
2. Imports:
36+
- External imports first, alphabetically ordered
37+
- Internal imports next, grouped by module/folder
38+
3. Classes/Functions: Implementation with proper JSDoc comments
4839

4940
Example:
5041

5142
```javascript
52-
// ______ ______ _____ _ _ //
53-
// | ____| ____| /\ / ____| (_) | | //
54-
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
55-
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
56-
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
57-
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
58-
// | | | | //
59-
// |_| | |_ //
60-
// Website: https://feascript.com/ \__| //
43+
/**
44+
* ════════════════════════════════════════════════════════════
45+
* FEAScript Library
46+
* Lightweight Finite Element Simulation in JavaScript
47+
* Version: {VERSION} | https://feascript.com
48+
* MIT License © 2023–20xx FEAScript
49+
* ════════════════════════════════════════════════════════════
50+
*/
6151

6252
// External imports
6353
import { mathLibrary } from "math-package";
6454

6555
// Internal imports
66-
import { relatedFunction } from "../utilities/helperScript.js";
56+
import { relatedFunction } from "../utilities/helper.js";
6757

6858
/**
6959
* Class to handle specific functionality
@@ -88,3 +78,91 @@ export class MyClass {
8878
}
8979
}
9080
```
81+
82+
## Branching & Workflow
83+
84+
To contribute a new feature or fix:
85+
86+
- Do not commit directly to `main`
87+
- Instead, create a short‑lived branch:
88+
- `feature/<topic>` for new functionality
89+
- `fix/<issue>` for bug fixes
90+
91+
External contributors:
92+
93+
1. Fork the repo
94+
2. Branch from `main` in your fork
95+
3. Push and open a PR from your fork’s branch into `main`
96+
97+
## Local Testing
98+
99+
Before submitting a pull request, test your modifications by running the FEAScript library from a local directory. For example, you can load the library in your HTML file as follows:
100+
101+
```javascript
102+
import { FEAScriptModel, plotSolution, printVersion } from "[USER_DIRECTORY]/FEAScript-core/src/index.js";
103+
```
104+
105+
FEAScript can be run on a local server. You **must** start the server from the workspace root directory (the folder that contains both `FEAScript-core/` and `FEAScript-website/`), not from inside either subfolder. The HTML files use relative paths such as `../feascript-website.css` and `../../FEAScript-core/src/index.js` that only resolve correctly from that root.
106+
107+
```bash
108+
# Navigate to the workspace root first
109+
cd /path/to/FEAScript-workspace
110+
111+
# Then start the server
112+
python3 -m http.server
113+
```
114+
115+
The server will be available at `http://127.0.0.1:8000/`. Open a tutorial at its full path, e.g.:
116+
117+
```
118+
http://127.0.0.1:8000/FEAScript-website/tutorials/solidification-front-2d-worker.html
119+
```
120+
121+
Static file server npm packages like [serve](https://github.com/vercel/serve#readme) and [Vite](https://vite.dev/) can also be used.
122+
123+
## Running the Node.js Examples
124+
125+
All examples under `examples/` can be run directly with Node.js to verify the library works in a non-browser environment. Run them from the `FEAScript-core/` directory (so that the `feascript` package resolves via `node_modules`):
126+
127+
```bash
128+
cd /path/to/FEAScript-workspace/FEAScript-core
129+
130+
# Heat conduction — 1D wall
131+
node examples/heatConductionScript/heatConduction1DWall/heatConduction1DWall.js
132+
133+
# Heat conduction — 2D fin (structured mesh)
134+
node examples/heatConductionScript/heatConduction2DFin/heatConduction2DFin.js
135+
136+
# Heat conduction — 2D fin (rectangular Gmsh mesh)
137+
node examples/heatConductionScript/heatConduction2DFin/heatConduction2DFinGmsh.js
138+
139+
# Heat conduction — 2D rhomboid fin (Gmsh mesh)
140+
node examples/heatConductionScript/heatConduction2DFin/heatConduction2DRhomFinGmsh.js
141+
142+
# Advection-diffusion — 1D with Gaussian source
143+
node examples/generalFormPDEScript/advectionDiffusion1D/advectionDiffusion1D.js
144+
145+
# Solidification front propagation — 2D
146+
node examples/frontPropagationScript/solidificationFront2D/solidificationFront2D.js
147+
148+
# Lid-driven cavity — 2D creeping flow
149+
node examples/creepingFlowScript/lidDrivenCavity2DCreepingFlow/lidDrivenCavity2DCreepingFlow.js
150+
```
151+
152+
Each script prints its computed solution array to the console. A successful run exits with code 0 and produces numerical output; any import or runtime error indicates a problem.
153+
154+
To run all examples in one go and check for failures:
155+
156+
```bash
157+
for f in \
158+
examples/heatConductionScript/heatConduction1DWall/heatConduction1DWall.js \
159+
examples/heatConductionScript/heatConduction2DFin/heatConduction2DFin.js \
160+
examples/heatConductionScript/heatConduction2DFin/heatConduction2DFinGmsh.js \
161+
examples/heatConductionScript/heatConduction2DFin/heatConduction2DRhomFinGmsh.js \
162+
examples/generalFormPDEScript/advectionDiffusion1D/advectionDiffusion1D.js \
163+
examples/frontPropagationScript/solidificationFront2D/solidificationFront2D.js \
164+
examples/creepingFlowScript/lidDrivenCavity2DCreepingFlow/lidDrivenCavity2DCreepingFlow.js; do
165+
echo -n " $f ... "
166+
node "$f" > /dev/null 2>&1 && echo "OK" || echo "FAILED"
167+
done
168+
```

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023-2025 FEAScript
3+
Copyright (c) 2023-2026 FEAScript
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

NOTICE.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
FEAScript makes use of the following third-party software:
22

3-
1. **math.js**
4-
- License: Apache 2.0 License
3+
1. **Comlink**
4+
- License: Apache 2.0 (https://github.com/GoogleChromeLabs/comlink/blob/main/LICENSE)
5+
- Source: https://github.com/GoogleChromeLabs/comlink
6+
7+
2. **d3-scale**
8+
- License: ISC (https://github.com/d3/d3-scale/blob/main/LICENSE)
9+
- Source: https://github.com/d3/d3-scale
10+
11+
3. **gl-matrix**
12+
- License: MIT (https://github.com/toji/gl-matrix/blob/master/LICENSE.md)
13+
- Source: https://github.com/toji/gl-matrix
14+
15+
4. **math.js**
16+
- License: Apache 2.0 (https://github.com/josdejong/mathjs/blob/develop/LICENSE)
517
- Source: https://github.com/josdejong/mathjs
6-
- License: https://github.com/josdejong/mathjs/blob/develop/LICENSE
718

8-
2. **plotly.js**
9-
- License: MIT License
19+
5. **plotly.js**
20+
- License: MIT (https://github.com/plotly/plotly.js/blob/master/LICENSE)
1021
- Source: https://github.com/plotly/plotly.js/tree/master
11-
- License: https://github.com/plotly/plotly.js/blob/master/LICENSE
1222

13-
3. **Comlink**
14-
- License: Apache 2.0 License
15-
- Source: https://github.com/GoogleChromeLabs/comlink
16-
- License: https://github.com/GoogleChromeLabs/comlink/blob/main/LICENSE
23+
6. **stdlib-js**
24+
- License: Apache-2.0 (https://github.com/stdlib-js/blas/blob/main/LICENSE)
25+
- Source: https://github.com/stdlib-js/stdlib
26+
27+
7. **taichi.js**
28+
- License: MIT (https://github.com/AmesingFlank/taichi.js/blob/main/LICENSE)
29+
- Source: https://github.com/AmesingFlank/taichi.js
30+
31+
8. **vtk.js**
32+
- License: BSD 3-Clause (https://github.com/Kitware/vtk-js/blob/master/LICENSE)
33+
- Source: https://github.com/Kitware/vtk-js

0 commit comments

Comments
 (0)