Skip to content

Commit 20df350

Browse files
committed
Refactor method documentation and improve logging messages in FEAScriptModel
1 parent cdcba47 commit 20df350

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/FEAScript.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class FEAScriptModel {
3939
}
4040

4141
/**
42-
* Sets the solver configuration
42+
* Method to set the solver configuration
4343
* @param {string} solverConfig - Parameter specifying the type of solver
4444
* @param {object} [options] - Optional additional configuration
4545
*/
@@ -48,54 +48,56 @@ export class FEAScriptModel {
4848
warnLog("setSolverConfig() is deprecated. Use setModelConfig() instead");
4949

5050
// Store coefficient functions if provided
51-
if (options?.coefficientFunctions) {
51+
if (options?.coefficientFunctions !== undefined) {
5252
this.coefficientFunctions = options.coefficientFunctions;
53-
debugLog("Coefficient functions set");
53+
debugLog("coefficientFunctions set");
5454
}
55-
// Only update if a value is provided, otherwise keep the default
55+
// Only update if a value is provided
5656
if (options?.maxIterations !== undefined) {
5757
this.maxIterations = options.maxIterations;
58+
debugLog(`maxIterations set to ${this.maxIterations}`);
5859
}
5960
if (options?.tolerance !== undefined) {
6061
this.tolerance = options.tolerance;
62+
debugLog(`tolerance set to ${this.tolerance}`);
6163
}
6264

63-
debugLog(`Solver config set to: ${solverConfig}`);
65+
debugLog(`solverConfig set to ${solverConfig}`);
6466
}
6567

66-
// Alias modelConfig to solverConfig (solverConfig is deprecated)
68+
// Alias modelConfig to solverConfig (solverConfig is deprecated, use setModelConfig instead)
6769
setModelConfig(modelConfig, options = {}) {
6870
this.setSolverConfig(modelConfig, options);
6971
}
7072

7173
setMeshConfig(meshConfig) {
7274
this.meshConfig = meshConfig;
73-
debugLog(`Mesh config set with dimensions: ${meshConfig.meshDimension}`);
75+
debugLog(`meshConfig set with dimensions: ${meshConfig.meshDimension}`);
7476
}
7577

7678
addBoundaryCondition(boundaryKey, condition) {
7779
this.boundaryConditions[boundaryKey] = condition;
78-
debugLog(`Boundary condition added for boundary: ${boundaryKey}, type: ${condition[0]}`);
80+
debugLog(`boundaryConditions added for boundary: ${boundaryKey}, type: ${condition[0]}`);
7981
}
8082

8183
setSolverMethod(solverMethod) {
8284
this.solverMethod = solverMethod;
83-
debugLog(`Solver method set to: ${solverMethod}`);
85+
debugLog(`solverMethod set to: ${solverMethod}`);
8486
}
8587

8688
/**
87-
* Function to solve the finite element problem synchronously
89+
* Method to solve the finite element problem synchronously
8890
* @param {object} [options] - Additional parameters for the solver, such as `maxIterations` and `tolerance`
8991
* @returns {object} An object containing the solution vector and mesh information
9092
*/
9193
solve(options = {}) {
9294
if (!this.solverConfig || !this.meshConfig || !this.boundaryConditions) {
93-
errorLog("Solver config, mesh config, and boundary conditions must be set before solving.");
95+
errorLog("solverConfig, meshConfig and boundaryConditions must be set before solving");
9496
}
9597
/**
9698
* For consistency across both linear and nonlinear formulations,
97-
* this project always refers to the assembled right-hand side vector
98-
* as `residualVector` and the assembled system matrix as `jacobianMatrix`.
99+
* we always refer to the assembled right-hand side vector as
100+
* `residualVector` and the assembled system matrix as `jacobianMatrix`.
99101
*
100102
* In linear problems `jacobianMatrix` is equivalent to the
101103
* classic stiffness/conductivity matrix and `residualVector`
@@ -121,7 +123,7 @@ export class FEAScriptModel {
121123
// Select and execute the appropriate solver based on solverConfig
122124
basicLog("Beginning solving process...");
123125
console.time("totalSolvingTime");
124-
basicLog(`Using solver: ${this.solverConfig}`);
126+
basicLog(`Using solver ${this.solverConfig}`);
125127
if (this.solverConfig === "heatConductionScript") {
126128
// Check if using frontal solver
127129
if (this.solverMethod === "frontal") {
@@ -174,7 +176,7 @@ export class FEAScriptModel {
174176
residualVector = newtonRaphsonResult.residualVector;
175177
solutionVector = newtonRaphsonResult.solutionVector;
176178

177-
// Increment for next iteration
179+
// Increment eikonalActivationFlag for next iteration
178180
eikonalActivationFlag += 1 / eikonalExteralIterations;
179181
}
180182
} else if (this.solverConfig === "generalFormPDEScript") {
@@ -205,7 +207,7 @@ export class FEAScriptModel {
205207
}
206208

207209
/**
208-
* Function to solve the finite element problem asynchronously
210+
* Method to solve the finite element problem asynchronously
209211
* @param {object} computeEngine - The compute engine to use for the asynchronous solver (e.g., a worker or a WebGPU context)
210212
* @param {object} [options] - Additional parameters for the solver, such as `maxIterations` and `tolerance`
211213
* @returns {Promise<object>} A promise that resolves to an object containing the solution vector and the coordinates of the mesh nodes

0 commit comments

Comments
 (0)