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
2 changes: 1 addition & 1 deletion .github/workflows/scripts-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# ════════════════════════════════════════════════════════════════
# FEAScript Core Library
# Lightweight Finite Element Simulation in JavaScript
# Finite Element Simulation in JavaScript
# Version: 0.2.0 | https://feascript.com
# MIT License © 2023–2026 FEAScript
# ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Example:
/**
* ════════════════════════════════════════════════════════════
* FEAScript Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: {VERSION} | https://feascript.com
* MIT License © 2023–20xx FEAScript
* ════════════════════════════════════════════════════════════
Expand Down
26 changes: 13 additions & 13 deletions dist/feascript-worker.esm.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

30 changes: 15 additions & 15 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.

24 changes: 12 additions & 12 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.

22 changes: 11 additions & 11 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,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "feascript",
"version": "0.3.0-RC",
"description": "Lightweight finite element simulation library built in JavaScript",
"description": "Finite element simulation library built in JavaScript",
"main": "dist/feascript.cjs.js",
"module": "dist/feascript.esm.js",
"browser": "dist/feascript.umd.js",
Expand Down
23 changes: 14 additions & 9 deletions src/FEAScript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand All @@ -13,11 +13,7 @@ import { solveLinearSystem } from "./methods/linearSystemSolver.js";
import { solveLinearSystemAsync } from "./methods/linearSystemSolver.js";
import { prepareMesh } from "./mesh/meshUtils.js";
import { assembleFrontPropagationMat } from "./models/frontPropagation.js";
import {
assembleGeneralFormPDEMat,
assembleGeneralFormPDEFront,
assembleGeneralFormPDENonlinearMat,
} from "./models/generalFormPDE.js";
import { assembleGeneralFormPDEMat, assembleGeneralFormPDENonlinearMat } from "./models/generalFormPDE.js";
import { assembleHeatConductionMat, assembleHeatConductionFront } from "./models/heatConduction.js";
import { assembleCreepingFlowMatrix } from "./models/creepingFlow.js";
import { assembleEulerBernoulliBeamMat } from "./models/eulerBernoulliBeam.js";
Expand Down Expand Up @@ -182,7 +178,11 @@ export class FEAScriptModel {
tolerance: options.tolerance ?? this.tolerance,
};

while (eikonalActivationFlag <= 1) {
// Count the incremental steps with an integer, so that the last step activates the eikonal equation
// exactly (accumulating 1 / eikonalExteralIterations can overshoot 1 and skip it)
for (let stepIndex = 0; stepIndex <= eikonalExteralIterations; stepIndex++) {
eikonalActivationFlag = stepIndex / eikonalExteralIterations;

// Update the context object with current eikonalActivationFlag
context.eikonalActivationFlag = eikonalActivationFlag;

Expand All @@ -199,8 +199,13 @@ export class FEAScriptModel {
residualVector = newtonRaphsonResult.residualVector;
solutionVector = newtonRaphsonResult.solutionVector;

// Increment eikonalActivationFlag for next iteration
eikonalActivationFlag += 1 / eikonalExteralIterations;
// Stop at the first step that does not converge, instead of continuing from a wrong solution
if (!newtonRaphsonResult.converged) {
errorLog(
`Front propagation did not converge at eikonal activation ${eikonalActivationFlag} (step ${stepIndex} of ${eikonalExteralIterations}). The solution is not valid; a finer mesh may be required.`,
);
break;
}
}
} else if (this.solverConfig === "generalFormPDEScript") {
// Check if using frontal solver
Expand Down
2 changes: 1 addition & 1 deletion src/base/linalg/blasUtilities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion src/base/linalg/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion src/base/solvers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion src/base/solvers/jacobiSolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion src/base/solvers/mathjsLUSolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
Expand Down
79 changes: 74 additions & 5 deletions src/mesh/basisFunctions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
/**
* ════════════════════════════════════════════════════════════════
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License © 2023–2026 FEAScript
* ════════════════════════════════════════════════════════════════
*/

// Internal imports
import { basicLog, debugLog, errorLog } from "../utilities/logging.js";
import { errorLog } from "../utilities/logging.js";

/**
* Local node indices on each side of the reference triangle, following the quad side numbering
* (side 0: bottom, eta = 0; side 1: left, ksi = 0; side 2: hypotenuse, ksi + eta = 1)
* Nodes are listed in order along each side
*/
export const triangleBoundarySides = {
linear: {
0: [0, 2], // Nodes at the bottom side of the reference triangle
1: [0, 1], // Nodes at the left side of the reference triangle
2: [1, 2], // Nodes at the hypotenuse of the reference triangle
},
quadratic: {
0: [0, 3, 5], // Nodes at the bottom side of the reference triangle
1: [0, 1, 2], // Nodes at the left side of the reference triangle
2: [2, 4, 5], // Nodes at the hypotenuse of the reference triangle
},
};

/**
* Class to handle basis functions and their derivatives based on element configuration
Expand All @@ -17,11 +35,13 @@ export class BasisFunctions {
/**
* Constructor to initialize the BasisFunctions class
* @param {string} meshDimension - The dimension of the mesh
* @param {string} elementOrder - The order of elements
* @param {string} [elementOrder='linear'] - The order of elements
* @param {string} [elementShape='quad'] - The 2D element shape, either 'quad' or 'triangle'
*/
constructor({ meshDimension, elementOrder }) {
constructor({ meshDimension, elementOrder = "linear", elementShape = "quad" }) {
this.meshDimension = meshDimension;
this.elementOrder = elementOrder;
this.elementShape = elementShape;
}

/**
Expand Down Expand Up @@ -101,7 +121,56 @@ export class BasisFunctions {
return;
}

if (this.elementOrder === "linear") {
if (this.elementShape === "triangle") {
// Reference triangle with vertices (0,0), (0,1), (1,0); area coordinate l1 = 1 - ksi - eta
const l1 = 1 - ksi - eta;

if (this.elementOrder === "linear") {
// Nodes numbered from bottom to top, then left to right (same rule as the quads):
// 1
// | \
// | \
// 0 --- 2
basisFunction[0] = l1;
basisFunction[1] = eta;
basisFunction[2] = ksi;

basisFunctionDerivKsi[0] = -1;
basisFunctionDerivKsi[1] = 0;
basisFunctionDerivKsi[2] = 1;

basisFunctionDerivEta[0] = -1;
basisFunctionDerivEta[1] = 1;
basisFunctionDerivEta[2] = 0;
} else if (this.elementOrder === "quadratic") {
// Nodes numbered from bottom to top, then left to right (same rule as the quads):
// 2
// | \
// 1 4
// | \
// 0--3--5
basisFunction[0] = l1 * (2 * l1 - 1);
basisFunction[1] = 4 * l1 * eta;
basisFunction[2] = eta * (2 * eta - 1);
basisFunction[3] = 4 * l1 * ksi;
basisFunction[4] = 4 * ksi * eta;
basisFunction[5] = ksi * (2 * ksi - 1);

basisFunctionDerivKsi[0] = 1 - 4 * l1;
basisFunctionDerivKsi[1] = -4 * eta;
basisFunctionDerivKsi[2] = 0;
basisFunctionDerivKsi[3] = 4 * (l1 - ksi);
basisFunctionDerivKsi[4] = 4 * eta;
basisFunctionDerivKsi[5] = 4 * ksi - 1;

basisFunctionDerivEta[0] = 1 - 4 * l1;
basisFunctionDerivEta[1] = 4 * (l1 - eta);
basisFunctionDerivEta[2] = 4 * eta - 1;
basisFunctionDerivEta[3] = -4 * ksi;
basisFunctionDerivEta[4] = 4 * ksi;
basisFunctionDerivEta[5] = 0;
}
} else if (this.elementOrder === "linear") {
// Linear basis functions for 2D elements
function l1(c) {
return 1 - c;
Expand Down
Loading
Loading