|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Frontal Solver Test Using FEAScriptModel</title> |
| 6 | + <!-- Plotly & Math.js needed by plotSolution --> |
| 7 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.0.0/math.min.js"></script> |
| 8 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.27.0/plotly.min.js"></script> |
| 9 | + <style> |
| 10 | + #solutionPlot { |
| 11 | + width: 640px; |
| 12 | + height: 480px; |
| 13 | + } |
| 14 | + </style> |
| 15 | + </head> |
| 16 | + <body> |
| 17 | + <p>Running frontal solver with FEAScriptModel...</p> |
| 18 | + <div id="solutionPlot"></div> |
| 19 | + <script type="module"> |
| 20 | + // Import FEAScript library |
| 21 | + import { FEAScriptModel, plotSolution } from "../../FEAScript-core/src/index.js"; |
| 22 | + |
| 23 | + // Create a new FEAScript model |
| 24 | + const model = new FEAScriptModel(); |
| 25 | + |
| 26 | + // Set solver configuration |
| 27 | + model.setSolverConfig("solidHeatTransferScript"); |
| 28 | + |
| 29 | + // Define mesh configuration |
| 30 | + model.setMeshConfig({ |
| 31 | + meshDimension: "2D", |
| 32 | + elementOrder: "quadratic", |
| 33 | + numElementsX: 12, |
| 34 | + numElementsY: 8, |
| 35 | + maxX: 4, |
| 36 | + maxY: 2, |
| 37 | + }); |
| 38 | + |
| 39 | + // Set boundary conditions (matching what's in the frontal solver) |
| 40 | + model.addBoundaryCondition("0", ["constantTemp", 200]); // Bottom edge |
| 41 | + model.addBoundaryCondition("1", ["constantTemp", 0]); // Left edge |
| 42 | + model.addBoundaryCondition("2", ["constantTemp", 0]); // Top edge |
| 43 | + model.addBoundaryCondition("3", ["constantTemp", 200]); // Right edge |
| 44 | + |
| 45 | + // Set solver method to frontal |
| 46 | + model.setSolverMethod("frontal"); |
| 47 | + |
| 48 | + // Solve the problem and get the solution |
| 49 | + const { solutionVector, nodesCoordinates } = model.solve(); |
| 50 | + |
| 51 | + // Plot the solution |
| 52 | + plotSolution( |
| 53 | + solutionVector, |
| 54 | + nodesCoordinates, |
| 55 | + "solidHeatTransferScript", |
| 56 | + "2D", |
| 57 | + "contour", |
| 58 | + "solutionPlot", |
| 59 | + "structured" |
| 60 | + ); |
| 61 | + </script> |
| 62 | + </body> |
| 63 | +</html> |
0 commit comments