|
| 1 | +// ______ ______ _____ _ _ // |
| 2 | +// | ____| ____| /\ / ____| (_) | | // |
| 3 | +// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ // |
| 4 | +// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| // |
| 5 | +// | | | |____ / ____ \ ____) | (__| | | | |_) | | // |
| 6 | +// |_| |______/_/ \_\_____/ \___|_| |_| __/| | // |
| 7 | +// | | | | // |
| 8 | +// |_| | |_ // |
| 9 | +// Website: https://feascript.com/ \__| // |
| 10 | + |
| 11 | +// Import Math.js |
| 12 | +import * as math from "mathjs"; |
| 13 | +global.math = math; |
| 14 | + |
| 15 | +// Import FEAScript library |
| 16 | +import { FEAScriptModel, logSystem, VERSION } from "feascript"; |
| 17 | + |
| 18 | +console.log("FEAScript Version:", VERSION); |
| 19 | + |
| 20 | +// Create a new FEAScript model |
| 21 | +const model = new FEAScriptModel(); |
| 22 | + |
| 23 | +// Set solver configuration for front propagation |
| 24 | +model.setSolverConfig("frontPropagationScript"); |
| 25 | + |
| 26 | +// Define mesh configuration |
| 27 | +model.setMeshConfig({ |
| 28 | + meshDimension: "2D", |
| 29 | + elementOrder: "quadratic", |
| 30 | + numElementsX: 12, |
| 31 | + numElementsY: 8, |
| 32 | + maxX: 4, |
| 33 | + maxY: 2, |
| 34 | +}); |
| 35 | + |
| 36 | +// Define boundary conditions |
| 37 | +model.addBoundaryCondition("0", ["constantValue", 0]); // Bottom |
| 38 | +model.addBoundaryCondition("1", ["constantValue", 0]); // Left |
| 39 | +model.addBoundaryCondition("2", ["zeroGradient"]); // Top |
| 40 | +model.addBoundaryCondition("3", ["constantValue", 0]); // Right |
| 41 | + |
| 42 | +// Set solver method (optional) |
| 43 | +model.setSolverMethod("lusolve"); |
| 44 | + |
| 45 | +// Solve the problem and get the solution |
| 46 | +const { solutionVector, nodesCoordinates } = model.solve(); |
| 47 | + |
| 48 | +// Print results to console |
| 49 | +console.log("Solution vector:", solutionVector); |
| 50 | +console.log("Node coordinates:", nodesCoordinates); |
| 51 | +console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`); |
0 commit comments