-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsolidificationFront2D.html
More file actions
76 lines (62 loc) · 3 KB
/
solidificationFront2D.html
File metadata and controls
76 lines (62 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<!--
════════════════════════════════════════════════════════════════
FEAScript Core Library
Lightweight Finite Element Simulation in JavaScript
Version: 0.2.0 | https://feascript.com
MIT License © 2023–2026 FEAScript
════════════════════════════════════════════════════════════════
-->
<html>
<head>
<title>FEAScript Example: Solidification Front 2D</title>
<meta charset="UTF-8" />
<!-- Link to the CSS files -->
<link href="https://feascript.com/feascript-website.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet" />
<!-- Import the Math.js library for mathematical operations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.12.0/math.min.js"></script>
<!-- Import the Plotly.js library for plotting -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.35.3/plotly.min.js"></script>
</head>
<body>
<h2>Solidification Front 2D</h2>
<!-- Container element where the solution plot will be rendered -->
<div id="resultsCanvas"></div>
<script type="module">
// Import FEAScript library
import { FEAScriptModel, plotSolution, printVersion } from "https://core.feascript.com/dist/feascript.esm.js";
// import { FEAScriptModel, plotSolution, printVersion } from "../../../src/index.js";
window.addEventListener("DOMContentLoaded", () => {
console.log("FEAScript Version:", printVersion);
// Create a new FEAScript model
const model = new FEAScriptModel();
// Select physics/PDE
model.setModelConfig("frontPropagationScript");
// Define mesh configuration
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsX: 12,
numElementsY: 8,
maxX: 4,
maxY: 2,
});
// Define boundary conditions
model.addBoundaryCondition("0", ["constantValue", 0]); // Bottom boundary
model.addBoundaryCondition("1", ["constantValue", 0]); // Left boundary
model.addBoundaryCondition("2", ["zeroGradient"]); // Top boundary
model.addBoundaryCondition("3", ["constantValue", 0]); // Right boundary
// Set solver method
model.setSolverMethod("lusolve");
// Solve the problem
const result = model.solve();
// Print results to console
console.log(`Number of nodes in mesh: ${result.nodesCoordinates.nodesXCoordinates.length}`);
console.log("Solution vector:", result.solutionVector);
// Plot the solution as a 2D contour plot
plotSolution(model, result, "contour", "resultsCanvas");
});
</script>
</body>
</html>