Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2d7b6ba
Update README.md to include npm version badge
nikoscham Aug 10, 2025
1595447
Refactor solver imports
nikoscham Aug 21, 2025
ee2e429
chore: bump version to 0.1.3 and update description in package.json
nikoscham Aug 22, 2025
c75e162
Feature/frontal solver (#33)
nikoscham Aug 22, 2025
f352863
Merge branch 'main' into dev
nikoscham Aug 22, 2025
d0f56eb
Merge branch 'dev' into feature/frontalSolver
nikoscham Aug 22, 2025
dbf34ce
Enhance README and examples; add frontal solver implementation
nikoscham Aug 27, 2025
6fa7769
Reorganize README structure; move "Ways to Use FEAScript" section for…
nikoscham Aug 27, 2025
bcf2492
Refactor README and add support section; update usage instructions fo…
nikoscham Sep 5, 2025
4d46652
Refactor frontPropagationScript and solidHeatTransferScript to utiliz…
nikoscham Sep 6, 2025
ea40a2a
Add validation for geometry parameters in Mesh2D class; ensure requir…
nikoscham Sep 6, 2025
6cefdee
Update logging messages in mesh generation and utility scripts; chang…
nikoscham Sep 6, 2025
4986933
Rename meshUtils.js to meshUtilsScript.js and update imports in solve…
nikoscham Sep 8, 2025
0ea8cd2
Refactor FEAScript and solver scripts to utilize prepared mesh data; …
nikoscham Sep 8, 2025
8f59df9
Refactor frontPropagationScript and solidHeatTransferScript to improv…
nikoscham Sep 8, 2025
1db10e5
Refactor frontalSolverScript and update temporaryFrontalTest to use m…
nikoscham Sep 9, 2025
d24092b
Refactor frontalSolverScript to utilize external assembly for heat tr…
nikoscham Sep 9, 2025
d72b209
Update README.md to clarify JavaScript API section title and improve …
nikoscham Sep 9, 2025
6e33ac8
Update README.md to remove commented-out Liberapay badge for cleaner …
nikoscham Sep 11, 2025
0385e9d
Refactor FEAScript and related scripts to improve clarity and modular…
nikoscham Sep 11, 2025
ceb3eba
Update README.md to improve structure and consistency in the JavaScri…
nikoscham Sep 11, 2025
f060111
Update README.md for improved clarity and consistency in language and…
nikoscham Sep 11, 2025
3b7eded
Update README.md for formatting consistency; remove unused nodesCoord…
nikoscham Sep 11, 2025
1b65764
Add frontal solver integration and enhance solid heat transfer assembly
nikoscham Sep 12, 2025
f898d84
Refactor LU solver implementation to use sparse matrix for improved p…
nikoscham Sep 12, 2025
9c1ed7f
Build new npm package
nikoscham Sep 12, 2025
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
155 changes: 77 additions & 78 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,87 @@ Thank you for your interest in contributing! FEAScript is in early development,

## Contribution Guidelines

1. **Respect the existing coding style:** Observe the code near your intended changes and aim to preserve that style in your modifications.

2. **Recommended tools:**
1. **Development Tools:**
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.

3. **Naming conventions:**
2. **Coding Style:**
Observe the code near your intended changes and aim to preserve that style in your modifications.

3. **Variable Naming:**
Use [camelCase](https://en.wikipedia.org/wiki/Camel_case) formatting for variable names throughout the code.

4. **Testing changes locally:**
4. **File Naming:**
All JavaScript source files in FEAScript end with the suffix `Script` before the `.js` extension (e.g., `loggingScript.js`, `meshGenerationScript.js`, `newtonRaphsonScript.js`). This is an explicit, project‑level stylistic choice to:

- Visually distinguish internal FEAScript modules from third‑party or external library files.
- Keep historical and stylistic consistency across the codebase.

Exceptions:

- Public entry file: `index.js` (standard entry point convention).
- Core model file: `FEAScript.js` (matches the library name; appending "Script" would be redundant).

5. **File Structure:**
All files in the FEAScript-core codebase should follow this structure:

1. **Banner**: All files start with the FEAScript ASCII art banner.
2. **Imports**:
- External imports (from npm packages) first, alphabetically ordered.
- Internal imports next, grouped by module/folder.
3. **Classes/Functions**: Implementation with proper JSDoc comments.

Example:

```javascript
// ______ ______ _____ _ _ //
// | ____| ____| /\ / ____| (_) | | //
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
// | | | | //
// |_| | |_ //
// Website: https://feascript.com/ \__| //

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

// Internal imports
import { relatedFunction } from "../utilities/helperScript.js";

/**
* Class to handle specific functionality
*/
export class MyClass {
/**
* Constructor to initialize the class
* @param {object} options - Configuration options
*/
constructor(options) {
// Implementation
}

/**
* Function to perform a specific action
* @param {number} input - Input value
* @returns {number} Processed result
*/
doSomething(input) {
// Implementation
return input * DEFAULT_VALUE;
}
}
```

6. **Branching & Workflow:**
To contribute a new feature or fix:

- Do not commit directly to `main` or `dev`.
- Instead, start your work in a feature branch based on the `dev` branch.

**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.

7. **Local Testing:**
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:

```javascript
Expand All @@ -26,76 +98,3 @@ Thank you for your interest in contributing! FEAScript is in early development,
```

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.

## Branching & Workflow

To contribute a new feature or fix:

- Do not commit directly to `main` or `dev`.
- Instead, start your work in a feature branch based on the `dev` branch.

**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.

## File Structure Guidelines

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

1. **Banner**: All files start with the FEAScript ASCII art banner.
2. **Imports**:
- External imports (from npm packages) first, alphabetically ordered.
- Internal imports next, grouped by module/folder.
3. **Classes/Functions**: Implementation with proper JSDoc comments.

Example:

```javascript
// ______ ______ _____ _ _ //
// | ____| ____| /\ / ____| (_) | | //
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
// | | | | //
// |_| | |_ //
// Website: https://feascript.com/ \__| //

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

// Internal imports
import { relatedFunction } from "../utilities/helperScript.js";

/**
* Class to handle specific functionality
*/
export class MyClass {
/**
* Constructor to initialize the class
* @param {object} options - Configuration options
*/
constructor(options) {
// Implementation
}

/**
* Function to perform a specific action
* @param {number} input - Input value
* @returns {number} Processed result
*/
doSomething(input) {
// Implementation
return input * DEFAULT_VALUE;
}
}
```

## File Naming Convention

All JavaScript source files in FEAScript end with the suffix `Script` before the `.js` extension (e.g., `loggingScript.js`, `meshGenerationScript.js`, `newtonRaphsonScript.js`). This is an explicit, project‑level stylistic choice to:

- Visually distinguish internal FEAScript modules from third‑party or external library files.
- Keep historical and stylistic consistency across the codebase.

Exceptions:
- Public entry file: `index.js` (standard entry point convention).
- Core model file: `FEAScript.js` (matches the library name; appending "Script" would be redundant).
149 changes: 99 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,71 @@

# FEAScript-core

[![npm version](https://img.shields.io/npm/v/feascript)](https://www.npmjs.com/package/feascript) <img src="https://img.shields.io/liberapay/receives/FEAScript.svg?logo=liberapay">
[![npm version](https://img.shields.io/npm/v/feascript)](https://www.npmjs.com/package/feascript)

[FEAScript](https://feascript.com/) is a lightweight finite element simulation library built 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 FEAScript.
<!-- [![liberapay](https://img.shields.io/liberapay/receives/FEAScript.svg?logo=liberapay)](https://liberapay.com/FEAScript/) -->

> 🚧 **FEAScript is currently under heavy development.** Functionality and interfaces may change rapidly as new features and enhancements are introduced. 🚧
[FEAScript](https://feascript.com/) is a lightweight finite element simulation library built 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 is currently under heavy development.** Its functionality and interfaces may change rapidly as new features and enhancements are introduced.

## Contents

- [Installation](#installation)
- [Example Usage](#example-usage)
- [FEAScript Platform](#feascript-platform)
- [Contribute](#contribute)
- [Ways to Use FEAScript](#ways-to-use-feascript)
- [JavaScript API (FEAScript Core)](#javascript-api-feascript-core)
- [Use FEAScript in the Browser](#use-feascript-in-the-browser)
- [Use FEAScript with Node.js](#use-feascript-with-nodejs)
- [Use FEAScript with Scribbler](#use-feascript-with-scribbler)
- [Visual Editor (FEAScript Platform)](#visual-editor-feascript-platform)
- [Quick Example](#quick-example)
- [Support FEAScript](#support-feascript)
- [Contributing](#contributing)
- [License](#license)

## Installation
## Ways to Use FEAScript

FEAScript offers two main approaches to creating simulations:

1. **[JavaScript API (FEAScript Core)](#javascript-api-feascript-core)** – For developers comfortable with coding, providing full programmatic control in browsers, Node.js, or interactive notebooks.
2. **[Visual Editor (FEAScript Platform)](#visual-editor-feascript-platform)** – For users who prefer a no-code approach, offering a block-based visual interface built with [Blockly](https://developers.google.com/blockly).

Each approach is explained in detail below.

FEAScript is entirely implemented in pure JavaScript and can run in two environments:
### JavaScript API (FEAScript Core)

1. **In the browser** with a simple HTML page, where all simulations are executed locally without any installations or using any cloud services.
2. **Via Node.js** with plain JavaScript files, for server-side simulations.
The JavaScript API is the core programmatic interface for FEAScript. Written entirely in pure JavaScript, it runs in three environments:

### Option 1: In the Browser
1. **[In the browser](#use-feascript-in-the-browser)** – Use FEAScript in a simple HTML page, running simulations locally without additional installations or cloud services.
2. **[With Node.js](#use-feascript-with-nodejs)** – Use FEAScript in server-side JavaScript applications or CLI tools.
3. **[With Scribbler](#use-feascript-with-scribbler)** – Use FEAScript in the [Scribbler](https://scribbler.live/) interactive JavaScript notebook environment.

#### Use FEAScript in the Browser

You can use FEAScript in browser environments in two ways:

**Direct Import from the Web (ES Module):**
- **Import from Hosted ESM Build:**

```html
<script type="module">
import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";
</script>
```
```html
<script type="module">
import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";
</script>
```

**Download and Use Locally:**
- **Download and Use Locally:**

```html
<script type="module">
import { FEAScriptModel } from "./path/to/dist/feascript.esm.js";
</script>
```
You can download the latest stable release from [GitHub Releases](https://github.com/FEAScript/FEAScript-core/releases).

You can download the latest stable release from [GitHub Releases](https://github.com/FEAScript/FEAScript-core/releases). Explore various browser-based examples and use cases in our [website](https://feascript.com/#tutorials).
```html
<script type="module">
import { FEAScriptModel } from "./path/to/dist/feascript.esm.js";
</script>
```

### Option 2: Via Node.js
👉 Explore browser-based tutorials on our [website](https://feascript.com/#tutorials).

Install FEAScript and its peer dependencies from npm:
#### Use FEAScript with Node.js

Install FEAScript and its peer dependencies from npm as follows:

```bash
npm install feascript mathjs plotly.js
Expand All @@ -66,11 +85,31 @@ import { FEAScriptModel } from "feascript";
echo '{"type":"module"}' > package.json
```

When running examples from within this repository, this step is not needed as the root package.json already has the proper configuration. Explore various Node.js examples and use cases [here](https://github.com/FEAScript/FEAScript-core/tree/main/examples).
When running examples from within this repository, this step isn’t needed as the root package.json already has the proper configuration.

👉 Explore Node.js use cases on the [examples directory](https://github.com/FEAScript/FEAScript-core/tree/main/examples).

## Example Usage
#### Use FEAScript with Scribbler

This is an indicative example of FEAScript, shown for execution in the browser. Adapt paths, solver types, and boundary conditions as needed for your specific problem:
FEAScript also works well in interactive JavaScript notebook environments where you can write code, visualize results inline, and share your work with others. [Scribbler](https://scribbler.live/) is one such platform that comes with preloaded scientific libraries, making it an excellent choice for FEAScript simulations.

👉 Explore FEAScript notebook examples on the [Scribbler Hub](https://hub.scribbler.live/portfolio/#!nikoscham/FEAScript-Scribbler-examples).

### Visual Editor (FEAScript Platform)

For users who prefer a visual approach to creating simulations, we offer the [FEAScript Platform](https://platform.feascript.com/) - a browser-based visual editor built on the [Blockly](https://developers.google.com/blockly) library. This no-code interface allows you to:

- Build and run finite element simulations directly in your browser by connecting visual blocks together
- Create complex simulations without writing any JavaScript code
- Save and load projects in XML format for easy sharing and reuse

While FEAScript's JavaScript API offers full programmatic control for advanced customization, the FEAScript Platform provides an accessible entry point for users without coding experience.

👉 Explore FEAScript Platform examples on our [website](https://feascript.com/#tutorials).

## Quick Example

Here is a minimal browser-based example using the JavaScript API. Adapt paths, solver types, and boundary conditions as needed for your specific problem:

```html
<body>
Expand All @@ -79,41 +118,51 @@ This is an indicative example of FEAScript, shown for execution in the browser.
// Import FEAScript library
import { FEAScriptModel } from "https://core.feascript.com/dist/feascript.esm.js";

window.addEventListener("DOMContentLoaded", async () => {
// Create and configure model
window.addEventListener("DOMContentLoaded", () => {
// Create a new FEAScript model
const model = new FEAScriptModel();
model.setSolverConfig("solverType"); // e.g., "solidHeatTransfer" for a stationary solid heat transfer case

// Set the solver type for your problem
model.setSolverConfig("solverType"); // Example: "solidHeatTransferScript"

// Configure the mesh
model.setMeshConfig({
meshDimension: "1D" | "2D", // Mesh dimension
elementOrder: "linear" | "quadratic", // Element order
numElementsX: number, // Number of elements in x-direction
numElementsY: number, // Number of elements in y-direction (for 2D)
maxX: number, // Domain length in x-direction
maxY: number, // Domain length in y-direction (for 2D)
meshDimension: "1D", // Choose either "1D" or "2D"
elementOrder: "linear", // Choose either "linear" or "quadratic"
numElementsX: 10, // Number of elements in x-direction
numElementsY: 6, // Number of elements in y-direction (for 2D only)
maxX: 1.0, // Domain length in x-direction
maxY: 0.5, // Domain length in y-direction (for 2D only)
});

// Apply boundary conditions
model.addBoundaryCondition("boundaryIndex", ["conditionType" /* parameters */]);
// Add boundary conditions with appropriate parameters
model.addBoundaryCondition("boundaryIndex", ["conditionType" /* parameters */]); // Example boundary condition

// Solve
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();
});
</script>
<!-- ...continue of body region... -->
<!-- ...rest of body region... -->
</body>
```

## FEAScript Platform
**Note:** The code above uses placeholder values that you should replace with appropriate options, e.g.:

For users who prefer a visual approach to creating simulations, we offer the [FEAScript platform](https://platform.feascript.com/) - a browser-based visual editor built on the [Blockly](https://developers.google.com/blockly) library. This no-code interface allows you to:
- "solverType" should be replaced with an actual solver type such as "solidHeatTransferScript" for heat conduction problems
- "conditionType" should be replaced with an actual boundary condition type such as "constantTemp"
- "boundaryIndex" should be replaced with a string identifying the boundary

- Build and run finite element simulations directly in your browser by connecting visual blocks
- Create complex simulations without writing any JavaScript code
- Save and load projects in XML format for easy sharing and reuse
## Support FEAScript

> 💖 **If you find FEAScript useful, please consider supporting its development through a donation:**

<a href="https://liberapay.com/FEAScript/donate">
<img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg">
</a>

While FEAScript's JavaScript API offers full programmatic control for advanced customization, the FEAScript platform provides an accessible entry point for users without coding experience.
Your support helps ensure the continued development and maintenance of this project.

## Contribute
## Contributing

We warmly welcome contributors to help expand and refine FEAScript. Please see the [CONTRIBUTING.md](./CONTRIBUTING.md) file for detailed guidance on how to contribute.

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
Expand Up @@ -46,6 +46,6 @@ model.setSolverMethod("lusolve");
const { solutionVector, nodesCoordinates } = model.solve();

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