You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expand geometry handling in generateMeshFromGeometry() function #20
This issue has been added to the FEAScript roadmap for the upcoming 0.2.0 release (https://github.com/orgs/FEAScript/discussions/17). Currently, the generateMeshFromGeometry() function supports only rectangular domains. We aim to extend this functionality to support additional 2D geometries (trapezoid-shaped & ring (annulus)-shaped), enabling users to more easily create meshes for diverse simulation domains. The relevant function is located in meshGenerationScript.js (https://github.com/FEAScript/FEAScript-core/blob/main/src/mesh/meshGenerationScript.js).
Tasks
Implement support for trapezoid-shaped 2D domains
Implement support for 2D ring (annulus)-shaped domains
Add support for expansion ratio in mesh generation (e.g., graded mesh density along one direction)
changed the title [-]Expand geometry handling in `generateMeshFromGeometry()` function (from `meshGenerationScript.js`)[/-][+]Expand geometry handling in `generateMeshFromGeometry()` function[/+]on May 19, 2025
Hi, I am interested in working on this issue and will start working on it between 30 Sep to 2nd October.
Welcome to the FEAScript community Harshal (@Harshalyadav)! Thank you for your interest in contributing to the project.
Adding support for additional 2D geometries will be a very valuable feature for the library.
I’ll get back to you soon with some extra instructions regarding the task!
Best regards and please also consider ⭐️ the library!
Nikos
// Trapezoid (new)
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsX: 8,
numElementsY: 4,
geometryShape: "trapezoid",
shortBaseX: 1, // length of the shorter parallel side
longBaseX: 3, // length of the longer parallel side
maxY: 2, // height
});
// Annulus (new)
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsR: 8, // radial elements
numElementsTheta: 16, // angular elements
geometryShape: "annulus",
minR: 1, // radius of the inner boundary
maxR: 2, // radius of the outer boundary
});
2. Implement Trapezoid Mesh Generation
For each row of nodes (y-coordinate), calculate the corresponding width
Use linear interpolation between shortBaseX and longBaseX based on y position
Position nodes at equidistant points along each row
3. Implement Annulus (Ring) Mesh Generation
Use polar coordinates (r, θ) for node positioning
Convert to Cartesian coordinates (x, y) for storage
4. Add Support for Expansion Ratio
Implement a graded mesh density by adding an expansion ratio option:
// For rectangle or trapezoid
model.setMeshConfig({
// Other parameters...
expansionRatioX: 1.2, // values > 1 make elements larger in positive X direction
expansionRatioY: 0.8, // values < 1 make elements smaller in positive Y direction
});
// For annulus (expansion is radial)
model.setMeshConfig({
// Other parameters...
expansionRatioR: 1.2 // For annulus, this controls radial expansion
});
Please do what you can—if you cannot complete everything 100%, that’s totally fine! Just push as far as you can, and we can continue or review together.
Hi @agrim317! Thanks for your interest in contributing to the project! @Harshalyadav, just checking — are you still working on this issue? If not, we can reassign it to @agrim317 to keep progress moving.
@nikoscham I’ve made the necessary code changes, but I’m not sure how to properly test them. I tried following the testing steps mentioned in the contribution guide, but they didn’t seem to work for me. Could you please guide me on how to run or validate the mesh generation code locally to verify my changes?
Well, I suppose you have prepared an HTML file with a test case (e.g. something like a variant of heat-conduction-2d-fin.html, but with a different geometry).
In order to run it locally you should:
1. Import the updated FEAScript library to the HTML from your local folder
(This means the FEAScript-core folder is two directories above where your HTML file is located)
2. Serve files through a local web server (this is to avoid CORS + local file restriction)
Using Python 3, navigate to the folder where you have saved the HTML file you want to test (suppose your example is the mod-heat-conduction-2d-fin.html), then run:
Hey @Harshalyadav. Just a reminder that Hacktoberfest is wrapping up soon (October 31st). You can always contribute after Hacktoberfest, but you might miss out on their rewards. All the best
I have implemented trapezoid-shaped 2D domains by extending the existing rectangle geometry-based mesh generation with two optional parameters:
angleLeft (default 90)
angleRight (default 90)
When both angles are 90° the mesh is a rectangle (default case).
Example (heat conduction 2D fin) using trapezoid mesh
// Set solver configuration
model.setModelConfig("heatConductionScript");
// Define mesh configuration
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsX: 8,
numElementsY: 4,
maxX: 4,
maxY: 2,
angleLeft: 130,
angleRight: 130,
});
// Define boundary conditions
model.addBoundaryCondition("0", ["constantTemp", 200]);
model.addBoundaryCondition("1", ["symmetry"]);
model.addBoundaryCondition("2", ["convection", 1, 20]);
model.addBoundaryCondition("3", ["constantTemp", 200]);
// Set solver method
model.setSolverMethod("lusolve");
// Solve the problem and get the solution
const result = model.solve();
// Plot the solution as a 2D contour plot
plotInterpolatedSolution(model, result, "contour", "resultsCanvas"); // This would not work with the simple plotSolution function
This implementation addresses the trapezoidal geometry use case, which I believe covers the most common non-rectangular shape, while keeping the configuration consistent with the existing workflow. I will close this issue for now. We will revisit it if users require support for more complex geometries generated by the internal mesher or for graded mesh density.
Activity
[-]Expand geometry handling in `generateMeshFromGeometry()` function (from `meshGenerationScript.js`)[/-][+]Expand geometry handling in `generateMeshFromGeometry()` function[/+]Harshalyadav commentedon Sep 16, 2025
Hi,
I am interested in working on this issue and will start working on it between 30 Sep to 2nd October.
nikoscham commentedon Sep 16, 2025
Welcome to the FEAScript community Harshal (@Harshalyadav)! Thank you for your interest in contributing to the project.
Adding support for additional 2D geometries will be a very valuable feature for the library.
I’ll get back to you soon with some extra instructions regarding the task!
Best regards and please also consider ⭐️ the library!
Nikos
nikoscham commentedon Sep 22, 2025
Hi @Harshalyadav! Here are some guidelines to help you tackle this task.
First, examine the existing code in
src/mesh/meshGenerationScript.jsto understand how rectangular domains are handled. The current implementation:Implementation Plan
1. Modify the Configuration Structure
Extend
setMeshConfig()to accept the new geometries as shown in the provided examples:2. Implement Trapezoid Mesh Generation
3. Implement Annulus (Ring) Mesh Generation
4. Add Support for Expansion Ratio
Implement a graded mesh density by adding an expansion ratio option:
Please do what you can—if you cannot complete everything 100%, that’s totally fine! Just push as far as you can, and we can continue or review together.
Thanks a lot for your work on this!
agrim317 commentedon Oct 19, 2025
Hi @nikoscham ,
I’m interested in working on this issue. If it’s still open and not currently being worked on, could you please assign it to me?
nikoscham commentedon Oct 19, 2025
Hi @agrim317! Thanks for your interest in contributing to the project!
@Harshalyadav, just checking — are you still working on this issue? If not, we can reassign it to @agrim317 to keep progress moving.
Harshalyadav commentedon Oct 19, 2025
@nikoscham Thanks for checking! Yes, I’m still working on this issue. I’ll share an update soon.
Harshalyadav commentedon Oct 22, 2025
@nikoscham I’ve made the necessary code changes, but I’m not sure how to properly test them. I tried following the testing steps mentioned in the contribution guide, but they didn’t seem to work for me. Could you please guide me on how to run or validate the mesh generation code locally to verify my changes?
nikoscham commentedon Oct 23, 2025
Hey @Harshalyadav! Thanks for the update.
Well, I suppose you have prepared an HTML file with a test case (e.g. something like a variant of heat-conduction-2d-fin.html, but with a different geometry).
In order to run it locally you should:
1. Import the updated FEAScript library to the HTML from your local folder
Instead of:
Use:
Where
[USER_DIRECTORY]is the location where you have saved theFEAScript-corefolder.For example, in my case I use:
(This means the
FEAScript-corefolder is two directories above where your HTML file is located)2. Serve files through a local web server (this is to avoid CORS + local file restriction)
Using Python 3, navigate to the folder where you have saved the HTML file you want to test (suppose your example is the
mod-heat-conduction-2d-fin.html), then run:Then open your browser and visit:
Let me know if that works for you!
Harshalyadav commentedon Oct 23, 2025
@nikoscham Thanks for the detailed explanation!
nikoscham commentedon Oct 30, 2025
Hey @Harshalyadav. Just a reminder that Hacktoberfest is wrapping up soon (October 31st). You can always contribute after Hacktoberfest, but you might miss out on their rewards. All the best
Harshalyadav commentedon Oct 30, 2025
Hey! Thanks for the reminder
nikoscham commentedon Jan 16, 2026
I have implemented trapezoid-shaped 2D domains by extending the existing rectangle geometry-based mesh generation with two optional parameters:
When both angles are 90° the mesh is a rectangle (default case).
Example (heat conduction 2D fin) using trapezoid mesh
This implementation addresses the trapezoidal geometry use case, which I believe covers the most common non-rectangular shape, while keeping the configuration consistent with the existing workflow. I will close this issue for now. We will revisit it if users require support for more complex geometries generated by the internal mesher or for graded mesh density.
Add skew angle parameters (angleLeft` and `angleRight`) for 2D mesh g…