Ian
February 18, 2025, 2:14pm
1
Hi, I have a physical model in a 3D domain(cube for temporarily).
I am using fenicsx now, and in the model, there is a laser shining on the upper surface. So the weak form has a term like:
F=....*dx+lasersource*ds
Due to the physical model, I only want the integrate term lasersource*ds
established on the upper surface. What should I do?
Stein
February 18, 2025, 2:19pm
2
You’ll have to create a meshtags
object where you tag that surface. Then you create a surface measure with that meshtags object attached:
ds = ufl.Measure('ds', domain=mesh, subdomain_data=surface_meshtags)
In your weak form, you’d use:
lasersource*testfunction*ds(1)
Assuming you’ve tagged that surface with value 1
.
See this post from two hours ago
It should be like
marker_value = 33
inner_facets = mesh.locate_entities_boundary(msh, 1, boundary_marker)
facet_tags = mesh.meshtags(msh, 1, inner_facets, np.full(len(inner_facets), marker_value, dtype=np.int32))
ds = ufl.Measure("ds", domain=msh, subdomain_data=facet_tags, subdomain_id=marker_value)
2 Likes
Ian
February 19, 2025, 11:56am
3
Thanks for your advice!
Did you mean this?
def top_surface(x):
return np.isclose(x[2], 1, atol=1e-8)
top_facets = mesh.locate_entities_boundary(domain, domain.topology.dim - 1, top_surface)
facet_tags = mesh.meshtags(domain, 1, top_facets, np.full(len(top_facets), marker_value, dtype=np.int32))
ds = ufl.Measure("ds", domain=domain, subdomain_data=facet_tags)
And for the integrate term
F_heat=×××*dx-(nu * e ** 2*100 / (2 * m_e * omega_p ** 2)) * laser_source * v_T * ds(1))
However, there is a value called marker_value
, I don’t know the meaning of this . Besides, do you know how to tag the upper surface with value 1
?
Ian
February 19, 2025, 11:59am
4
oh,should I let marker_value=1?
dokken
February 19, 2025, 12:02pm
5
A mesh-tag can contain multiple entities, with different values.
In the integration, by choosing a specific value, say 1
, you integrate over all entities in the mesh-tag whose corresponding value is 1
.
Ian
February 19, 2025, 12:15pm
6
Thank you, I think I get it.
So I think maybe I can integrate in the upper surface by using this?
def top_surface(x):
return np.isclose(x[2], 1, atol=1e-8)
marker_value=1
top_facets = mesh.locate_entities_boundary(domain, domain.topology.dim - 1, top_surface)
facet_tags = mesh.meshtags(domain, 2, top_facets, np.full(len(top_facets), marker_value, dtype=np.int32))
ds = ufl.Measure("ds", domain=domain, subdomain_data=facet_tags)
F=lasersource*ds(1)
dokken
February 19, 2025, 12:30pm
7
Ian:
def top_surface(x):
return np.isclose(x[2], 1, atol=1e-8)
marker_value=1
top_facets = mesh.locate_entities_boundary(domain, domain.topology.dim - 1, top_surface)
facet_tags = mesh.meshtags(domain, 2, top_facets, np.full(len(top_facets), marker_value, dtype=np.int32))
ds = ufl.Measure("ds", domain=domain, subdomain_data=facet_tags)
F=lasersource*ds(1)
Yes. But i would be consistent, use marker_value throughout, i.e. including ds(marker_value)
, in case you change it to something else than 1 at a later instance.
1 Like
Ian
February 19, 2025, 12:34pm
8
I get it, thank you for your advice!