Skip to content

Commit 24247a1

Browse files
committed
Update solution plotting in tutorials
1 parent 7440bf3 commit 24247a1

14 files changed

Lines changed: 43 additions & 161 deletions
-5.94 KB
Loading
-6.42 KB
Loading
18.8 KB
Loading
30.4 KB
Loading

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ <h2 id="howtousefeascript"><a name="Getting Started"></a>How to Use FEAScript</h
323323
model.addBoundaryCondition("boundaryIndex", ["conditionType", /* parameters */]);
324324

325325
// Solve
326-
const { solutionVector, nodesCoordinates } = model.solve();
326+
const result = model.solve();
327327

328328
// Plot results
329-
plotSolution(solutionVector, nodesCoordinates, model.solverConfig, model.meshConfig.meshDimension, "contour", "resultsCanvas");
329+
plotSolution(model, result, "contour", "resultsCanvas");
330330
});
331331
&lt;/script&gt;
332332
&lt;!-- ...rest of body region... --&gt;

tutorials/advection-diffusion-1d.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,10 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
223223

224224
// Solve
225225
model.setSolverMethod("lusolve");
226-
const { solutionVector, nodesCoordinates } = model.solve();
226+
const result = model.solve();
227227

228228
// Plot results
229-
plotSolution(
230-
solutionVector,
231-
nodesCoordinates,
232-
model.solverConfig,
233-
model.meshConfig.meshDimension,
234-
"line",
235-
"resultsCanvas"
236-
);
229+
plotSolution(model, result, "line", "resultsCanvas");
237230
});
238231
&lt;/script&gt;
239232
&lt;!-- ...rest of body region... --&gt;
@@ -324,17 +317,10 @@ <h2 id="results"><a name="Results"></a>Results</h2>
324317
model.setSolverMethod("lusolve");
325318

326319
// Solve the problem and get the solution
327-
const { solutionVector, nodesCoordinates } = model.solve();
320+
const result = model.solve();
328321

329322
// Plot the solution as a 1D line plot
330-
plotSolution(
331-
solutionVector,
332-
nodesCoordinates,
333-
model.solverConfig,
334-
model.meshConfig.meshDimension,
335-
"line",
336-
"resultsCanvas"
337-
);
323+
plotSolution(model, result, "line", "resultsCanvas");
338324
});
339325
</script>
340326

tutorials/heat-conduction-1d-wall.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,10 @@ <h2 id="solvingwithfeascript"><a name="Solving with FEAScript"></a>Solving with
211211

212212
// Solve
213213
model.setSolverMethod("lusolve");
214-
const { solutionVector, nodesCoordinates } = model.solve();
214+
const result = model.solve();
215215

216216
// Plot results
217-
plotSolution(
218-
solutionVector,
219-
nodesCoordinates,
220-
model.solverConfig,
221-
model.meshConfig.meshDimension,
222-
"line",
223-
"resultsCanvas"
224-
);
217+
plotSolution(model, result, "line", "resultsCanvas");
225218

226219
});
227220
&lt;/script&gt;
@@ -303,17 +296,10 @@ <h2 id="results"><a name="Results"></a>Results</h2>
303296
model.setSolverMethod("lusolve");
304297

305298
// Solve the problem and get the solution
306-
const { solutionVector, nodesCoordinates } = model.solve();
299+
const result = model.solve();
307300

308301
// Plot the solution as a 1D line plot
309-
plotSolution(
310-
solutionVector,
311-
nodesCoordinates,
312-
model.solverConfig,
313-
model.meshConfig.meshDimension,
314-
"line",
315-
"resultsCanvas"
316-
);
302+
plotSolution(model, result, "line", "resultsCanvas");
317303
});
318304
</script>
319305
<footer>

tutorials/heat-conduction-2d-fin-gmsh.html

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ <h2 id="gmshfileimport"><a name="gmshfileimport"></a>Gmsh File Import</h2>
162162
&lt;!-- ...body region... --&gt;
163163
&lt;script type="module"&gt;
164164
// Import FEAScript library
165-
import { FEAScriptModel, importGmshQuadTri, plotSolution, printVersion } from "https://core.feascript.com/dist/feascript.esm.js";
165+
import { FEAScriptModel, importGmshQuadTri, plotInterpolatedSolution, printVersion } from "https://core.feascript.com/dist/feascript.esm.js";
166166

167167
window.addEventListener("DOMContentLoaded", async () => {
168168
// Print FEAScript version in the console
@@ -200,17 +200,10 @@ <h2 id="gmshfileimport"><a name="gmshfileimport"></a>Gmsh File Import</h2>
200200

201201
// Solve
202202
model.setSolverMethod("lusolve");
203-
const { solutionVector, nodesCoordinates } = model.solve();
203+
const result = model.solve();
204204

205205
// Plot results
206-
plotSolution(
207-
solutionVector,
208-
nodesCoordinates,
209-
model.solverConfig,
210-
model.meshConfig.meshDimension,
211-
"contour",
212-
"resultsCanvas"
213-
);
206+
plotInterpolatedSolution(model, result, "contour", "resultsCanvas");
214207
});
215208
&lt;/script&gt;
216209
&lt;!-- ... rest of body region... --&gt;
@@ -358,14 +351,14 @@ <h2 id="results"><a name="results"></a>Results</h2>
358351
import {
359352
FEAScriptModel,
360353
importGmshQuadTri,
361-
plotSolution,
354+
plotInterpolatedSolution,
362355
printVersion,
363356
} from "https://core.feascript.com/dist/feascript.esm.js";
364357
// Import FEAScript library from a local directory
365358
// import {
366359
// FEAScriptModel,
367360
// importGmshQuadTri,
368-
// plotSolution,
361+
// plotInterpolatedSolution,
369362
// printVersion,
370363
// logSystem,
371364
// } from "../../FEAScript-core/src/index.js";
@@ -414,18 +407,10 @@ <h2 id="results"><a name="results"></a>Results</h2>
414407
gmshModel.setSolverMethod("lusolve");
415408

416409
// Solve the problem and get the solution
417-
const { solutionVector: gmshSolutionVector, nodesCoordinates: gmshNodesCoordinates } =
418-
gmshModel.solve();
419-
420-
// Plot the GMSH solution
421-
plotSolution(
422-
gmshSolutionVector,
423-
gmshNodesCoordinates,
424-
gmshModel.solverConfig,
425-
gmshModel.meshConfig.meshDimension,
426-
"contour",
427-
"resultsCanvas"
428-
);
410+
const result = gmshModel.solve();
411+
412+
// Plot the Gmsh solution
413+
plotInterpolatedSolution(gmshModel, result, "contour", "resultsCanvas");
429414
});
430415
</script>
431416

tutorials/heat-conduction-2d-fin-performance-test.html

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,14 @@ <h2>Run Performance Test</h2>
176176

177177
// Measure the solving time
178178
const startTime = performance.now();
179-
const { solutionVector, nodesCoordinates } = model.solve();
179+
const result = model.solve();
180180
const endTime = performance.now();
181181
const solvingTime = ((endTime - startTime) / 1000).toFixed(3); // Convert to seconds and round to 3 decimal places
182182

183183
// Display the time in the HTML
184184
document.getElementById("timeDisplay").innerHTML = `Solving time: ${solvingTime} seconds`;
185185

186-
plotSolution(
187-
solutionVector,
188-
nodesCoordinates,
189-
"heatConductionScript",
190-
"2D",
191-
"contour",
192-
"resultsCanvas"
193-
);
186+
plotSolution(model, result, "contour", "resultsCanvas");
194187
}
195188

196189
runSpeedTest(document.getElementById("solverSelect").value);

tutorials/heat-conduction-2d-fin-webgpu.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,10 @@ <h2 id="webgpuimplementation">WebGPU Implementation</h2>
183183
model.setSolverMethod("jacobi-gpu");
184184

185185
// Solve
186-
const { solutionVector, nodesCoordinates } = await model.solveAsync();
186+
const result = await model.solveAsync();
187187

188188
// Plot results
189-
plotSolution(
190-
solutionVector,
191-
nodesCoordinates,
192-
"heatConductionScript",
193-
"2D",
194-
"contour",
195-
"resultsCanvas"
196-
);
189+
plotSolution(model, result, "contour", "resultsCanvas");
197190
});
198191
&lt;/script&gt;
199192
&lt;!-- ...rest of body region... --&gt;
@@ -249,18 +242,11 @@ <h2 id="results">Results</h2>
249242

250243
model.setSolverMethod("jacobi-gpu");
251244

252-
const { solutionVector, nodesCoordinates } = await model.solveAsync();
245+
const result = await model.solveAsync();
253246

254247
resultDiv.style.display = "none";
255248

256-
plotSolution(
257-
solutionVector,
258-
nodesCoordinates,
259-
model.solverConfig,
260-
model.meshConfig.meshDimension,
261-
"contour",
262-
"resultsCanvas"
263-
);
249+
plotSolution(model, result, "contour", "resultsCanvas");
264250
});
265251
</script>
266252

0 commit comments

Comments
 (0)