Skip to content

Commit 0f41a07

Browse files
committed
Add triangular element support across models, solvers and plotting
- Gmsh reader: accept 6-node triangles; map Gmsh triangles to FEAScript numbering (bottom to top, then left to right, as for quads) - Triangle support (linear and quadratic) in heat conduction, front propagation and creeping flow (P2-P1 Taylor-Hood), all boundary conditions, the frontal solver, and Plotly/VTK plotting - Frontal solver: keep assembling until a node is fully summed (unstructured meshes) - Front propagation: count continuation steps with an integer, scale the minimum viscous term with element size, stop and report on non-convergence - Fix 1D quadratic frontal Dirichlet side map, exact (ksi, eta) for distorted quads in plotting, 1D front propagation missing errorLog import - Remove dead code (unused imports/variables, 8-node VTK cell branch, printVersionInformation, unused heatTransferCoefficient option) - Tests: shared Gmsh meshes (rect.geo, linear/quadratic quads and triangles), regression tests for all models, element types, orders and solver methods, analytical Couette and planar front tests, 2D element and plot interpolation unit tests; logo in every test README
1 parent a3ea7e3 commit 0f41a07

60 files changed

Lines changed: 4137 additions & 844 deletions

Some content is hidden

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

‎dist/feascript-worker.esm.js‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript-worker.esm.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.cjs.js‎

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.cjs.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.esm.js‎

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.esm.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.umd.js‎

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.umd.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/FEAScript.js‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import { solveLinearSystem } from "./methods/linearSystemSolver.js";
1313
import { solveLinearSystemAsync } from "./methods/linearSystemSolver.js";
1414
import { prepareMesh } from "./mesh/meshUtils.js";
1515
import { assembleFrontPropagationMat } from "./models/frontPropagation.js";
16-
import {
17-
assembleGeneralFormPDEMat,
18-
assembleGeneralFormPDEFront,
19-
assembleGeneralFormPDENonlinearMat,
20-
} from "./models/generalFormPDE.js";
16+
import { assembleGeneralFormPDEMat, assembleGeneralFormPDENonlinearMat } from "./models/generalFormPDE.js";
2117
import { assembleHeatConductionMat, assembleHeatConductionFront } from "./models/heatConduction.js";
2218
import { assembleCreepingFlowMatrix } from "./models/creepingFlow.js";
2319
import { assembleEulerBernoulliBeamMat } from "./models/eulerBernoulliBeam.js";
@@ -182,7 +178,11 @@ export class FEAScriptModel {
182178
tolerance: options.tolerance ?? this.tolerance,
183179
};
184180

185-
while (eikonalActivationFlag <= 1) {
181+
// Count the incremental steps with an integer, so that the last step activates the eikonal equation
182+
// exactly (accumulating 1 / eikonalExteralIterations can overshoot 1 and skip it)
183+
for (let stepIndex = 0; stepIndex <= eikonalExteralIterations; stepIndex++) {
184+
eikonalActivationFlag = stepIndex / eikonalExteralIterations;
185+
186186
// Update the context object with current eikonalActivationFlag
187187
context.eikonalActivationFlag = eikonalActivationFlag;
188188

@@ -199,8 +199,13 @@ export class FEAScriptModel {
199199
residualVector = newtonRaphsonResult.residualVector;
200200
solutionVector = newtonRaphsonResult.solutionVector;
201201

202-
// Increment eikonalActivationFlag for next iteration
203-
eikonalActivationFlag += 1 / eikonalExteralIterations;
202+
// Stop at the first step that does not converge, instead of continuing from a wrong solution
203+
if (!newtonRaphsonResult.converged) {
204+
errorLog(
205+
`Front propagation did not converge at eikonal activation ${eikonalActivationFlag} (step ${stepIndex} of ${eikonalExteralIterations}). The solution is not valid; a finer mesh may be required.`,
206+
);
207+
break;
208+
}
204209
}
205210
} else if (this.solverConfig === "generalFormPDEScript") {
206211
// Check if using frontal solver

‎src/mesh/basisFunctions.js‎

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,25 @@
88
*/
99

1010
// Internal imports
11-
import { basicLog, debugLog, errorLog } from "../utilities/logging.js";
11+
import { errorLog } from "../utilities/logging.js";
12+
13+
/**
14+
* Local node indices on each side of the reference triangle, following the quad side numbering
15+
* (side 0: bottom, eta = 0; side 1: left, ksi = 0; side 2: hypotenuse, ksi + eta = 1)
16+
* Nodes are listed in order along each side
17+
*/
18+
export const triangleBoundarySides = {
19+
linear: {
20+
0: [0, 2], // Nodes at the bottom side of the reference triangle
21+
1: [0, 1], // Nodes at the left side of the reference triangle
22+
2: [1, 2], // Nodes at the hypotenuse of the reference triangle
23+
},
24+
quadratic: {
25+
0: [0, 3, 5], // Nodes at the bottom side of the reference triangle
26+
1: [0, 1, 2], // Nodes at the left side of the reference triangle
27+
2: [2, 4, 5], // Nodes at the hypotenuse of the reference triangle
28+
},
29+
};
1230

1331
/**
1432
* Class to handle basis functions and their derivatives based on element configuration
@@ -104,44 +122,53 @@ export class BasisFunctions {
104122
}
105123

106124
if (this.elementShape === "triangle") {
107-
// Reference triangle with vertices (0,0), (1,0), (0,1); L1 = 1 - ksi - eta, L2 = ksi, L3 = eta
125+
// Reference triangle with vertices (0,0), (0,1), (1,0); area coordinate l1 = 1 - ksi - eta
108126
const l1 = 1 - ksi - eta;
109127

110128
if (this.elementOrder === "linear") {
111-
// Node order: vertices 0, 1, 2 (counterclockwise)
129+
// Nodes numbered from bottom to top, then left to right (same rule as the quads):
130+
// 1
131+
// | \
132+
// | \
133+
// 0 --- 2
112134
basisFunction[0] = l1;
113-
basisFunction[1] = ksi;
114-
basisFunction[2] = eta;
135+
basisFunction[1] = eta;
136+
basisFunction[2] = ksi;
115137

116138
basisFunctionDerivKsi[0] = -1;
117-
basisFunctionDerivKsi[1] = 1;
118-
basisFunctionDerivKsi[2] = 0;
139+
basisFunctionDerivKsi[1] = 0;
140+
basisFunctionDerivKsi[2] = 1;
119141

120142
basisFunctionDerivEta[0] = -1;
121-
basisFunctionDerivEta[1] = 0;
122-
basisFunctionDerivEta[2] = 1;
143+
basisFunctionDerivEta[1] = 1;
144+
basisFunctionDerivEta[2] = 0;
123145
} else if (this.elementOrder === "quadratic") {
124-
// Node order (same as Gmsh): vertices 0, 1, 2, then midside nodes 3 (0-1), 4 (1-2), 5 (2-0)
146+
// Nodes numbered from bottom to top, then left to right (same rule as the quads):
147+
// 2
148+
// | \
149+
// 1 4
150+
// | \
151+
// 0--3--5
125152
basisFunction[0] = l1 * (2 * l1 - 1);
126-
basisFunction[1] = ksi * (2 * ksi - 1);
153+
basisFunction[1] = 4 * l1 * eta;
127154
basisFunction[2] = eta * (2 * eta - 1);
128155
basisFunction[3] = 4 * l1 * ksi;
129156
basisFunction[4] = 4 * ksi * eta;
130-
basisFunction[5] = 4 * eta * l1;
157+
basisFunction[5] = ksi * (2 * ksi - 1);
131158

132159
basisFunctionDerivKsi[0] = 1 - 4 * l1;
133-
basisFunctionDerivKsi[1] = 4 * ksi - 1;
160+
basisFunctionDerivKsi[1] = -4 * eta;
134161
basisFunctionDerivKsi[2] = 0;
135162
basisFunctionDerivKsi[3] = 4 * (l1 - ksi);
136163
basisFunctionDerivKsi[4] = 4 * eta;
137-
basisFunctionDerivKsi[5] = -4 * eta;
164+
basisFunctionDerivKsi[5] = 4 * ksi - 1;
138165

139166
basisFunctionDerivEta[0] = 1 - 4 * l1;
140-
basisFunctionDerivEta[1] = 0;
167+
basisFunctionDerivEta[1] = 4 * (l1 - eta);
141168
basisFunctionDerivEta[2] = 4 * eta - 1;
142169
basisFunctionDerivEta[3] = -4 * ksi;
143170
basisFunctionDerivEta[4] = 4 * ksi;
144-
basisFunctionDerivEta[5] = 4 * (l1 - eta);
171+
basisFunctionDerivEta[5] = 0;
145172
}
146173
} else if (this.elementOrder === "linear") {
147174
// Linear basis functions for 2D elements

0 commit comments

Comments
 (0)