Skip to content

Commit 24435ed

Browse files
committed
Standardize naming patterns across the FEAScript codebase by:
Renaming files: FEAWorkerScript.js to workerScript.js FEAWrapperScript.js to wrapperScript.js Renaming classes: FEAWorkerScript to FEAScriptWorker FEAWorkerWrapper to workerWrapper Updating all references in HTML examples and index.js export
1 parent 3a26c1f commit 24435ed

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

examples/solidHeatTransferScript/HeatConduction2DFin/HeatConduction2DFinWorker.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h1>Heat Conduction in a Two-Dimensional Fin Example (Worker)</h1>
4747
<!-- Import FEAScript library -->
4848
<script type="module">
4949
import {
50-
FEAWorkerScript,
50+
FEAScriptWorker,
5151
plotSolution,
5252
printVersion,
5353
} from "https://core.feascript.com/src/index.js";
@@ -60,8 +60,8 @@ <h1>Heat Conduction in a Two-Dimensional Fin Example (Worker)</h1>
6060
document.getElementById("loading").style.display = "block";
6161

6262
try {
63-
// Create a new FEAWorkerScript instance
64-
const model = new FEAWorkerScript();
63+
// Create a new FEAScriptWorker instance
64+
const model = new FEAScriptWorker();
6565

6666
// Ensure the worker is ready
6767
await model.ping();

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
export { FEAScriptModel } from "./FEAScript.js";
1212
export { plotSolution } from "./visualization/plotSolutionScript.js";
1313
export { printVersion, logSystem } from "./utilities/loggingScript.js";
14-
export { FEAWorkerScript } from "./FEAWorkerScript.js";
14+
export { FEAScriptWorker } from "./workers/workerScript.js";

src/methods/jacobiMethodScript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function jacobiMethod(A, b, x0, maxIterations = 100, tolerance = 1e-7) {
4848
// Update x for next iteration
4949
x = [...xNew];
5050

51-
// If difference is small enough, we've converged
51+
// Successfully converged if maxDiff is less than tolerance
5252
if (maxDiff < tolerance) {
5353
return {
5454
solution: x,
@@ -58,7 +58,7 @@ export function jacobiMethod(A, b, x0, maxIterations = 100, tolerance = 1e-7) {
5858
}
5959
}
6060

61-
// If we reach here, we didn't converge within maxIterations
61+
// maxIterations were reached without convergence
6262
return {
6363
solution: x,
6464
iterations: maxIterations,

src/FEAWorkerScript.js renamed to src/workers/workerScript.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
// import * as Comlink from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
1212
// The Web Worker functionality now uses the local Comlink library to avoid CORS issues
13-
import * as Comlink from "./vendor/comlink.mjs";
14-
import { basicLog } from "./utilities/loggingScript.js";
13+
import * as Comlink from "../vendor/comlink.mjs";
14+
import { basicLog } from "../utilities/loggingScript.js";
1515

16-
export class FEAWorkerScript {
16+
export class FEAScriptWorker {
1717
/**
18-
* Constructor to initialize the FEAWorkerScript class
19-
* Sets up the worker and initializes the FEAWorkerWrapper.
18+
* Constructor to initialize the FEAScriptWorker class
19+
* Sets up the worker and initializes the workerWrapper.
2020
*/
2121
constructor() {
2222
this.worker = null;
@@ -34,18 +34,18 @@ export class FEAWorkerScript {
3434
async _initWorker() {
3535
try {
3636
this.worker = new Worker(
37-
new URL("./FEAWrapperScript.js", import.meta.url),
37+
new URL("./wrapperScript.js", import.meta.url),
3838
{
3939
type: "module",
4040
}
4141
);
4242

4343
this.worker.onerror = (event) => {
44-
console.error("FEAWorkerScript: Worker error:", event);
44+
console.error("FEAScriptWorker: Worker error:", event);
4545
};
46-
const FEAWorkerWrapper = Comlink.wrap(this.worker);
46+
const workerWrapper = Comlink.wrap(this.worker);
4747

48-
this.feaWorker = await new FEAWorkerWrapper();
48+
this.feaWorker = await new workerWrapper();
4949

5050
this.isReady = true;
5151
} catch (error) {
@@ -88,7 +88,7 @@ export class FEAWorkerScript {
8888
*/
8989
async setSolverConfig(solverConfig) {
9090
await this._ensureReady();
91-
basicLog(`FEAWorkerScript: Setting solver config to: ${solverConfig}`);
91+
basicLog(`FEAScriptWorker: Setting solver config to: ${solverConfig}`);
9292
return this.feaWorker.setSolverConfig(solverConfig);
9393
}
9494

@@ -99,7 +99,7 @@ export class FEAWorkerScript {
9999
*/
100100
async setMeshConfig(meshConfig) {
101101
await this._ensureReady();
102-
basicLog(`FEAWorkerScript: Setting mesh config`);
102+
basicLog(`FEAScriptWorker: Setting mesh config`);
103103
return this.feaWorker.setMeshConfig(meshConfig);
104104
}
105105

@@ -112,7 +112,7 @@ export class FEAWorkerScript {
112112
async addBoundaryCondition(boundaryKey, condition) {
113113
await this._ensureReady();
114114
basicLog(
115-
`FEAWorkerScript: Adding boundary condition for boundary: ${boundaryKey}`
115+
`FEAScriptWorker: Adding boundary condition for boundary: ${boundaryKey}`
116116
);
117117
return this.feaWorker.addBoundaryCondition(boundaryKey, condition);
118118
}
@@ -124,7 +124,7 @@ export class FEAWorkerScript {
124124
*/
125125
async setSolverMethod(solverMethod) {
126126
await this._ensureReady();
127-
basicLog(`FEAWorkerScript: Setting solver method to: ${solverMethod}`);
127+
basicLog(`FEAScriptWorker: Setting solver method to: ${solverMethod}`);
128128
return this.feaWorker.setSolverMethod(solverMethod);
129129
}
130130

@@ -134,14 +134,14 @@ export class FEAWorkerScript {
134134
*/
135135
async solve() {
136136
await this._ensureReady();
137-
basicLog("FEAWorkerScript: Requesting solution from worker...");
137+
basicLog("FEAScriptWorker: Requesting solution from worker...");
138138

139139
const startTime = performance.now();
140140
const result = await this.feaWorker.solve();
141141
const endTime = performance.now();
142142

143143
basicLog(
144-
`FEAWorkerScript: Solution completed in ${(
144+
`FEAScriptWorker: Solution completed in ${(
145145
(endTime - startTime) /
146146
1000
147147
).toFixed(2)}s`

src/FEAWrapperScript.js renamed to src/workers/wrapperScript.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
// import * as Comlink from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
1212
// The Web Worker functionality now uses the local Comlink library to avoid CORS issues
13-
import * as Comlink from "./vendor/comlink.mjs";
14-
import { FEAScriptModel } from "./FEAScript.js";
13+
import * as Comlink from "../vendor/comlink.mjs";
14+
import { FEAScriptModel } from "../FEAScript.js";
1515
import { create, all } from "https://cdn.jsdelivr.net/npm/mathjs@latest/+esm";
1616

1717
const math = create(all);
1818

1919
globalThis.math = math;
2020

21-
class FEAWorkerWrapper {
21+
class workerWrapper {
2222
/**
23-
* Constructor to initialize the FEAWorkerWrapper class.
23+
* Constructor to initialize the workerWrapper class.
2424
* Creates an instance of the FEAScriptModel.
2525
* @throws Will throw an error if the FEAScriptModel fails to initialize.
2626
*/
@@ -152,4 +152,4 @@ class FEAWorkerWrapper {
152152
}
153153
}
154154

155-
Comlink.expose(FEAWorkerWrapper);
155+
Comlink.expose(workerWrapper);

0 commit comments

Comments
 (0)