Add Element2d.SetGeomInfo() Python API for external mesh curving#232
Open
ksugahar wants to merge 1 commit intoNGSolve:masterfrom
Open
Add Element2d.SetGeomInfo() Python API for external mesh curving#232ksugahar wants to merge 1 commit intoNGSolve:masterfrom
ksugahar wants to merge 1 commit intoNGSolve:masterfrom
Conversation
This adds a SetGeomInfo method to Element2d that allows setting the UV
parametric coordinates (geominfo) for surface element vertices.
This is essential for high-order curving of externally imported meshes
(e.g., from Gmsh, Cubit, or other mesh generators). When meshes are
imported without geometry, the geominfo is not set automatically, which
prevents mesh.Curve(order) from working correctly.
Usage:
```python
for el in mesh.Elements2D():
for i in range(len(el.vertices)):
# Get UV coordinates from geometry
u, v = compute_uv_for_vertex(el.vertices[i])
el.SetGeomInfo(i, u, v)
mesh.Curve(order)
```
Parameters:
- vertex_index: 0-based index of the vertex within the element
- u, v: Surface parametric coordinates
- trignum: Triangle number for STL meshing (default: 0)
Feature request: https://forum.ngsolve.org/t/feature-request-python-api-for-high-order-curving-of-externally-imported-meshes/3810
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
Successful Workflow Report: 3D High-Order Elements with SetGeomInfo APII've been using this PR to enable high-order curving for externally imported meshes from Coreform Cubit. The results are excellent! Workflow
Accuracy Results
This achieves Netgen-native accuracy for externally imported meshes! Published LibraryThe workflow is implemented in my Python library: Key Functions# Set UV for analytic surfaces
set_cylinder_geominfo(ngmesh, radius, height, center, axis)
set_sphere_geominfo(ngmesh, radius, center)
set_torus_geominfo(ngmesh, major_radius, minor_radius, center, axis)
set_cone_geominfo(ngmesh, base_radius, height, center, axis)Why This Matters
Thank you for implementing this API! It's exactly what was needed for external mesh curving. |
Author
Binary Release AvailableI've published a pre-built Windows binary with this PR applied: Download: NGSolve 6.2.2601 + SetGeomInfo API This allows users to test the SetGeomInfo API without building from source. Installation
import sys
sys.path.insert(0, "path/to/extracted/Lib/site-packages")
import ngsolveThe binary includes the Periodic BC fix (upstream commit 2581a74) and PR #232. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
SetGeomInfomethod toElement2dthat allows setting the UV parametric coordinates (geominfo) for surface element vertices.Motivation
This is essential for high-order curving of externally imported meshes (e.g., from Gmsh, Cubit, or other mesh generators). When meshes are imported without geometry, the geominfo is not set automatically, which prevents
mesh.Curve(order)from working correctly.Usage
API
Parameters:
vertex_index: 0-based index of the vertex within the elementu,v: Surface parametric coordinatestrignum: Triangle number for STL meshing (default: 0)Related
Element2d.IsValid(),Element2d.IsDeleted(), andElement2d.geominfo(read-only) methods🤖 Generated with Claude Code