- Thank you received: 3
Removing spline control points from mesh or ngmesh
3 years 8 months ago #3598
by ddrake
Removing spline control points from mesh or ngmesh was created by ddrake
Hi, I noticed that when a spline geometry is used to generate a mesh, the spline control points from the geometry may end up as mesh vertices. These extra vertices are not associated with any elements in the NGSolve mesh, and may be outside the domain, as in the simple example below.
Most of the time these extra vertices don't cause any trouble, and when they do, it's not too hard to work around the issues, but I would like to know if there is some way to remove them.
# This outputs:
# Generate Mesh from spline geometry
# controlverts [V1, V3, V5, V7]
# pts [(1.0, -1.0), (1.0, 1.0), (-1.0, 1.0), (-1.0, -1.0)]
But if we then do this:
The output is:
value 0.0 # evaluating at vertex V0 works fine, but V1 is outside the domain.
WARNING: MeshPoint not in mesh, can't convert to BaseMappedIntegrationPoint!
Then a TypeError is raised when we try to evaluate gfu at mip...
Best,
Dow
Most of the time these extra vertices don't cause any trouble, and when they do, it's not too hard to work around the issues, but I would like to know if there is some way to remove them.
Code:
from netgen.geom2d import SplineGeometry
import netgen.meshing as nm
import ngsolve as ng
geo = SplineGeometry()
geo.AddCircle([0, 0], 1)
mesh = ng.Mesh(geo.GenerateMesh(maxh=.2))
controlverts = [v for v in mesh.vertices if len(v.elements) == 0]
pts = [v.point for v in controlverts]
print("controlverts", controlverts)
print("pts", pts)
# Generate Mesh from spline geometry
# controlverts [V1, V3, V5, V7]
# pts [(1.0, -1.0), (1.0, 1.0), (-1.0, 1.0), (-1.0, -1.0)]
But if we then do this:
Code:
fes = ng.H1(mesh, order=1)
gfu = ng.GridFunction(fes)
gfu.vec[:] = 0
for v in mesh.vertices:
pt = v.point
mip = mesh(*v.point)
value = gfu(mip)
print("value", value)
The output is:
value 0.0 # evaluating at vertex V0 works fine, but V1 is outside the domain.
WARNING: MeshPoint not in mesh, can't convert to BaseMappedIntegrationPoint!
Then a TypeError is raised when we try to evaluate gfu at mip...
Best,
Dow
Attachments:
3 years 7 months ago #3621
by matthiash
Replied by matthiash on topic Removing spline control points from mesh or ngmesh
Hi Dow,
Thanks for the report. The issue is fixed on master, see
github.com/NGSolve/netgen/commit/7b62f39...fa6008cd05ffb01821ea
Best,
Matthias
Thanks for the report. The issue is fixed on master, see
github.com/NGSolve/netgen/commit/7b62f39...fa6008cd05ffb01821ea
Best,
Matthias
The following user(s) said Thank You: ddrake
Time to create page: 0.092 seconds