Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a netgen flag to specify the index value associated with each label #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

UZerbinati
Copy link
Collaborator

Adding a netgen flag to specify the index value associated with each label.
Here is a minimal working code.

from firedrake import *
from firedrake.output import VTKFile
from netgen.occ import *

rect=WorkPlane().Rectangle(2,2).Face()
circ = WorkPlane().MoveTo(1,1).Rectangle(0.5,0.5).Face()
rect.edges.name = "outer"
circ.edges.name = "inner"
shape = rect-circ
geo = OCCGeometry(shape, dim=2)
ngmesh = geo.GenerateMesh(maxh=1.)
mesh = Mesh(ngmesh, netgen_flags={"labels": {"outer": 1, "inner": 2}})
V = FunctionSpace(mesh, "CG", 1)
f = Function(V)
DirichletBC(V, -1, [1]).apply(f)
DirichletBC(V, 1, [2]).apply(f)

vtk = VTKFile("output/test_labels.pvd").write(f)

image

Umberto Zerbinati added 4 commits April 24, 2024 13:01
@UZerbinati UZerbinati requested review from pefarrell and rckirby April 25, 2024 15:11
Copy link
Collaborator

@pefarrell pefarrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. This seems misguided. I would prefer the interface where the user code would look like

DirichletBC(V, 0, "outer")

and for the user to forget about the integer labels altogether. @rckirby , what do you think?

@rckirby
Copy link
Collaborator

rckirby commented Apr 26, 2024

This PR is motivated by a use case where I'm hooking up to an external operator that can only do its thing on a boundary if all the boundary segments of interest share the same integer label. So your cleaner interface is cleaner but...

Does anything stop us from using this PR to relabel all "inner" as "inner" rather than 1, that is, the first "inner" corresponds to sets of boundary segments in the netgen geometry and the second refers to labels that we attach to those edges in the mesh?

@UZerbinati
Copy link
Collaborator Author

This PR is motivated by a use case where I'm hooking up to an external operator that can only do its thing on a boundary if all the boundary segments of interest share the same integer label. So your cleaner interface is cleaner but...

Exactly the issue is that Netgen will number differently entities with the same labels, what we do here is to force all entities with the same label to have a given id in the DMPlex when conversion happens.

Does anything stop us from using this PR to relabel all "inner" as "inner" rather than 1, that is, the first "inner" corresponds to sets of boundary segments in the netgen geometry and the second refers to labels that we attach to those edges in the mesh?

Can we attach a label that is a string to the entities of a DMPlex, I only have seen Firedrake using integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants