How to create a ds only on the upper surface in fenicsx

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?:slight_smile:

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 :wink:

2 Likes

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? :confounded:

oh,should I let marker_value=1?

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.

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)

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

I get it, thank you for your advice! :smiley: