From 51e840008149e7a5752a4ef863946d02ad401fc6 Mon Sep 17 00:00:00 2001 From: sridhar-mani <2019309038@student.annauniv.edu> Date: Sun, 6 Apr 2025 14:13:27 +0530 Subject: [PATCH 1/4] Made materials seperation for the elements --- src/readers/gmshQuadReader.js | 56 ++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/src/readers/gmshQuadReader.js b/src/readers/gmshQuadReader.js index bca51b7..2925aa0 100644 --- a/src/readers/gmshQuadReader.js +++ b/src/readers/gmshQuadReader.js @@ -8,7 +8,8 @@ const importGmsh = async (file) => { ascii: false, fltBytes: 8, totalNodesX:0, - totalNodesY:0 + totalNodesY:0, + physicalPropMap:[] }; let textre = await file.text(); textre = textre @@ -18,10 +19,17 @@ const importGmsh = async (file) => { let inNodesSections = false; + const totalElements = newFin.nodalNumbering.length; + const numMaterials = newFin.physicalPropMap.length; + const baseChunkSize = Math.floor(totalElements / numMaterials); + const remainder = totalElements % numMaterials; + let inElementsSecitons = false; let inMeshSections = false; + let inPhysicalNames = false; + let lineNumber = 0; for (let line of textre) { @@ -34,6 +42,17 @@ const importGmsh = async (file) => { inMeshSections = false; continue; } + if (line == "$PhysicalNames") { + inPhysicalNames = true; + continue; + } + if (line == "$EndPhysicalNames") { + lineNumber = 0; + inPhysicalNames = false; + + continue; + } + if (line == "$Nodes") { inNodesSections = true; continue; @@ -41,6 +60,8 @@ const importGmsh = async (file) => { if (line == "$EndNodes") { lineNumber = 0; inNodesSections = false; + + continue; } if (line == "$Elements") { @@ -53,9 +74,10 @@ const importGmsh = async (file) => { inElementsSecitons = false; continue; } + let temp = line.split(" "); + lineNumber = lineNumber + 1; if (inMeshSections) { - let temp = line.split(" "); let gmshVersion = parseFloat(temp[0]); let asciiOr = temp[1] === "0" ? true : false; let fltBytesOr = temp[2]; @@ -64,7 +86,22 @@ const importGmsh = async (file) => { newFin.ascii = asciiOr; newFin.fltBytes = fltBytesOr; } - let temp = line.split(" "); + + if(inPhysicalNames){ + if(lineNumber>1){ + let dimension = parseInt(temp[0]); +let tag = parseInt(temp[1]); +let name = temp[2].replace(/^"|"$/g, ""); + + newFin.physicalPropMap=[...newFin.physicalPropMap, + { + tag:tag, + dimension:dimension, + name:name + } + ] + } + } if (inNodesSections) { if (temp.length === 3) { newFin.totalNodesX += 1; @@ -140,13 +177,24 @@ const importGmsh = async (file) => { } newFin.boundaryElements = newFin.boundaryElements.filter((each) => each); + +let tempElementArr = []; +let startIndex = 0; + +for (let i = 0; i < numMaterials; i++) { + // Distribute one extra element for the first 'remainder' chunks + const currentChunkSize = baseChunkSize + (i < remainder ? 1 : 0); + tempElementArr.push(newFin.nodalNumbering.slice(startIndex, startIndex + currentChunkSize)); + startIndex += currentChunkSize; +} + +newFin.nodalNumbering = tempElementArr; // }); // if (useKernel) { // await taichiRunner.runKernel(useKernel); // } - return newFin; }; From 5c38d0e3bfc976a60197f2e46ad713a65a207d28 Mon Sep 17 00:00:00 2001 From: "Sridhar.Mani" Date: Tue, 8 Apr 2025 16:22:39 +0530 Subject: [PATCH 2/4] Refactor HeatConduction2DFin.html layout and enhance gmshQuadReader.js for improved file handling; update plotSolutionScript.js for responsive plotting --- .../HeatConduction2DFin.html | 145 ++++-- src/readers/gmshQuadReader.js | 418 +++++++++++++++--- src/visualization/plotSolutionScript.js | 21 +- 3 files changed, 485 insertions(+), 99 deletions(-) diff --git a/examples/solidHeatTransferScript/HeatConduction2DFin/HeatConduction2DFin.html b/examples/solidHeatTransferScript/HeatConduction2DFin/HeatConduction2DFin.html index 8c98ab1..6fb6c45 100644 --- a/examples/solidHeatTransferScript/HeatConduction2DFin/HeatConduction2DFin.html +++ b/examples/solidHeatTransferScript/HeatConduction2DFin/HeatConduction2DFin.html @@ -21,29 +21,120 @@ - - + + + + + -

Heat Conduction in a Two-Dimensional Fin Example

-
- -

- The mesh configuration and boundary conditions are defined directly within the JavaScript code in this - example. Please refresh the page to update the results. Detailed instructions for this example can be - found in the corresponding - FEAScript tutorial. If you need further assistance, you can visit the - FEAScript website. -

- -

© 2023- FEAScript

- -