11
11
// Internal imports
12
12
import { jacobiMethod } from "./methods/jacobiMethodScript.js" ;
13
13
import { newtonRaphson } from "./methods/newtonRaphsonScript.js" ;
14
+ import { solveLinearSystem } from "./methods/linearSystemScript.js" ;
14
15
import { assembleFrontPropagationMat } from "./solvers/frontPropagationScript.js" ;
15
16
import { assembleSolidHeatTransferMat } from "./solvers/solidHeatTransferScript.js" ;
16
17
import { basicLog , debugLog , errorLog } from "./utilities/loggingScript.js" ;
@@ -63,15 +64,19 @@ export class FEAScriptModel {
63
64
let solutionVector = [ ] ;
64
65
let nodesCoordinates = { } ;
65
66
66
- // Assembly matrices
67
- basicLog ( "Beginning matrix assembly ..." ) ;
68
- console . time ( "assemblyMatrices " ) ;
67
+ // Select and execute the appropriate solver based on solverConfig
68
+ basicLog ( "Beginning solving process ..." ) ;
69
+ console . time ( "totalSolvingTime " ) ;
69
70
if ( this . solverConfig === "solidHeatTransferScript" ) {
70
71
basicLog ( `Using solver: ${ this . solverConfig } ` ) ;
71
72
( { jacobianMatrix, residualVector, nodesCoordinates } = assembleSolidHeatTransferMat (
72
73
this . meshConfig ,
73
74
this . boundaryConditions
74
75
) ) ;
76
+
77
+ // Solve the assembled linear system
78
+ const linearSystemResult = solveLinearSystem ( this . solverMethod , jacobianMatrix , residualVector ) ;
79
+ solutionVector = linearSystemResult . solutionVector ;
75
80
} else if ( this . solverConfig === "frontPropagationScript" ) {
76
81
basicLog ( `Using solver: ${ this . solverConfig } ` ) ;
77
82
let eikonalActivationFlag = 0 ; // Parameterization flag (from 0 to 1)
@@ -84,7 +89,7 @@ export class FEAScriptModel {
84
89
boundaryConditions : this . boundaryConditions ,
85
90
eikonalActivationFlag,
86
91
eikonalViscousTerm,
87
- solverMethod : this . solverMethod
92
+ solverMethod : this . solverMethod ,
88
93
} ;
89
94
90
95
while ( eikonalActivationFlag <= 1 ) {
@@ -102,35 +107,12 @@ export class FEAScriptModel {
102
107
nodesCoordinates = newtonRaphsonResult . nodesCoordinates ;
103
108
solutionVector = newtonRaphsonResult . solution ;
104
109
105
- // Increment eikonalActivationFlag for next step if needed
110
+ // Increment eikonalActivationFlag for next step
106
111
eikonalActivationFlag += 0.1 ;
107
112
}
108
113
}
109
- console . timeEnd ( "assemblyMatrices" ) ;
110
- basicLog ( "Matrix assembly completed" ) ;
111
-
112
- // Solve the linear system based on the specified solver method
113
- basicLog ( `Solving system using ${ this . solverMethod } ...` ) ;
114
- console . time ( "systemSolving" ) ;
115
- if ( this . solverMethod === "lusolve" ) {
116
- // Use LU decomposition method
117
- solutionVector = math . lusolve ( jacobianMatrix , residualVector ) ;
118
- } else if ( this . solverMethod === "jacobi" ) {
119
- // Use Jacobi method
120
- const initialGuess = new Array ( residualVector . length ) . fill ( 0 ) ;
121
- const jacobiResult = jacobiMethod ( jacobianMatrix , residualVector , initialGuess , 1000 , 1e-6 ) ;
122
-
123
- // Log convergence information
124
- if ( jacobiResult . converged ) {
125
- debugLog ( `Jacobi method converged in ${ jacobiResult . iterations } iterations` ) ;
126
- } else {
127
- debugLog ( `Jacobi method did not converge after ${ jacobiResult . iterations } iterations` ) ;
128
- }
129
-
130
- solutionVector = jacobiResult . solution ;
131
- }
132
- console . timeEnd ( "systemSolving" ) ;
133
- basicLog ( "System solved successfully" ) ;
114
+ console . timeEnd ( "totalSolvingTime" ) ;
115
+ basicLog ( "Solving process completed" ) ;
134
116
135
117
return { solutionVector, nodesCoordinates } ;
136
118
}
0 commit comments