|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 6 | + <title>FEAScript: Heat Conduction in a Two-Dimensional Fin</title> |
| 7 | + |
| 8 | + <!-- Math.js and Plotly.js libraries --> |
| 9 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.0.0/math.min.js"></script> |
| 10 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.27.0/plotly.min.js"></script> |
| 11 | + |
| 12 | + <!-- Style --> |
| 13 | + <style> |
| 14 | + html { |
| 15 | + max-width: 1500px; |
| 16 | + margin: auto; |
| 17 | + font-family: "Roboto", sans-serif; |
| 18 | + font-size: 90%; |
| 19 | + } |
| 20 | + |
| 21 | + body { |
| 22 | + padding: 20px; |
| 23 | + line-height: 1.6; |
| 24 | + } |
| 25 | + |
| 26 | + h1, |
| 27 | + h2, |
| 28 | + h3 { |
| 29 | + background: none; |
| 30 | + font-weight: normal; |
| 31 | + margin: 0; |
| 32 | + padding-top: 0.4em; |
| 33 | + padding-bottom: 0.2em; |
| 34 | + width: auto; |
| 35 | + margin-bottom: 0.5em; |
| 36 | + } |
| 37 | + |
| 38 | + h1 { |
| 39 | + color: #555; |
| 40 | + font-size: 150%; |
| 41 | + margin-bottom: 0.4em; |
| 42 | + line-height: 1.2em; |
| 43 | + } |
| 44 | + |
| 45 | + p { |
| 46 | + margin: 1em 0; |
| 47 | + max-width: 1000px; |
| 48 | + margin-bottom: 1em; |
| 49 | + } |
| 50 | + |
| 51 | + a { |
| 52 | + text-decoration: none; |
| 53 | + } |
| 54 | + </style> |
| 55 | + </head> |
| 56 | + |
| 57 | + <!-- Webpage text --> |
| 58 | + <body> |
| 59 | + <h1>Heat Conduction in a Two-Dimensional Fin</h1> |
| 60 | + <div id="solutionPlot"></div> |
| 61 | + |
| 62 | + <p> |
| 63 | + The mesh configuration and boundary conditions can be adjusted by editing the respective JSON files |
| 64 | + (meshConfig.json and boundaryConditionsConfig.json). The solver configuration is set explicitly to |
| 65 | + solidHeatTransferScript in this example. Please refresh the page to update the results. Detailed |
| 66 | + instructions for this example can be found in the corresponding |
| 67 | + <a |
| 68 | + href="https://github.com/FEAScript/FEAScript-website/blob/main/tutorialSolidHeatTransfer01/tutorialSolidHeatTransfer01.html" |
| 69 | + target="_blank" |
| 70 | + >FEAScript tutorial</a |
| 71 | + >. If you need further assistance, you can visit the |
| 72 | + <a href="https://feascript.com/" target="_blank">FEAScript website</a>. |
| 73 | + </p> |
| 74 | + |
| 75 | + <p> |
| 76 | + This example requires Cross-Origin Resource Sharing (CORS) to run if the JSON files are stored locally. |
| 77 | + To enable CORS on Firefox, you can follow these steps: |
| 78 | + </p> |
| 79 | + <ol> |
| 80 | + <li>Open Firefox and type <code>about:config</code> in the address bar, then press Enter.</li> |
| 81 | + <li>Accept the risk and continue to the advanced settings.</li> |
| 82 | + <li> |
| 83 | + In the search bar, type |
| 84 | + <code>security.fileuri.strict_origin_policy</code>. |
| 85 | + </li> |
| 86 | + <li> |
| 87 | + Double-click on the |
| 88 | + <code>security.fileuri.strict_origin_policy</code> preference to set it to <code>false</code>. |
| 89 | + </li> |
| 90 | + </ol> |
| 91 | + |
| 92 | + <p> |
| 93 | + FEAScript is distributed under the terms of the |
| 94 | + <a href="https://opensource.org/license/mit" target="_blank">MIT license</a>. © 2024 FEAScript. |
| 95 | + </p> |
| 96 | + |
| 97 | + <!-- JSON fetching --> |
| 98 | + <script> |
| 99 | + let meshConfig, boundaryConditionsConfig; |
| 100 | + const solverConfig = "solidHeatTransferScript"; // Set solverConfig explicitly |
| 101 | + |
| 102 | + // Function to fetch and parse JSON files |
| 103 | + function fetchJSON(url) { |
| 104 | + return fetch(url).then((response) => response.json()); |
| 105 | + } |
| 106 | + |
| 107 | + // Fetch JSON files asynchronously from the provided URLs |
| 108 | + Promise.all([fetchJSON("meshConfig.json"), fetchJSON("boundaryConditionsConfig.json")]).then( |
| 109 | + ([meshConfigData, boundaryConditionsConfigData]) => { |
| 110 | + meshConfig = meshConfigData; |
| 111 | + boundaryConditionsConfig = boundaryConditionsConfigData; |
| 112 | + } |
| 113 | + ); |
| 114 | + </script> |
| 115 | + |
| 116 | + <!-- FEAScript module and visualization --> |
| 117 | + <script type="module"> |
| 118 | + import { |
| 119 | + FEAScript, |
| 120 | + plotSolution, |
| 121 | + printVersion, |
| 122 | + } from "https://feascript.github.io/FEAScript/src/index.js"; |
| 123 | + |
| 124 | + window.addEventListener("DOMContentLoaded", () => { |
| 125 | + // Print FEAScript version in the console |
| 126 | + printVersion(); |
| 127 | + // Calculate solution and render plot once JSON data is loaded |
| 128 | + let { solutionVector, nodesCoordinates } = FEAScript( |
| 129 | + solverConfig, |
| 130 | + meshConfig, |
| 131 | + boundaryConditionsConfig |
| 132 | + ); |
| 133 | + // Plot the solution as a 2D contour plot |
| 134 | + plotSolution( |
| 135 | + solutionVector, |
| 136 | + nodesCoordinates, |
| 137 | + solverConfig, |
| 138 | + meshConfig.meshDimension, |
| 139 | + "contour", |
| 140 | + "solutionPlot" |
| 141 | + ); |
| 142 | + }); |
| 143 | + </script> |
| 144 | + </body> |
| 145 | +</html> |
0 commit comments