Does SubDomain exist in fFEnicSx

What are the ways to define subdomains with fenicsx. For example, a circle centered at (x0,y0) with radius r. I tried to use the class SubDomain but it couldn’t be found. I’m using FEnicSx not fenics.

Thanks

See for instance Defining subdomains for different materials — FEniCSx tutorial

If you search the forum with the keyword meshtags you’ll find many other resources on this topic.

Thanks, I have already looked at that tutorial but does this SubDomain class still exist in FEnicSx? Because I tried to create a subdomain by creating a class inherited from SubDomain as in other tutorials but I couldn’t find how to import SubDomain. Maybe, creating subdomains by inheriting from SubDomain class is outdated in FEnicSx!? (I’m doing it in Python)

It does not exist anymore.

Allright. Thanks again.

For sub-domains in DOLFINx, we usually use functions based on numpy input-output and the function
dolfinx.mesh.locate_entities or dolfinx.mesh.locate_entities_boundary to determine what entities are in a subdomain, and in turn send the to a meshtag object to restrict integration.

Please provide a minimal reproducible example for more explicit feedback.

Thanks @dokken . I managed to create the subdomains using locate_entities. I wonder if using a subclassing strategy as in previous FEnics (class MySubdomain(SubDomain)) wouldn’t allow for a cleaner and more flexible way to define the subdomains because the encapsulation of other information necessary to create the subdomain in addition to the coordinates of points in the mesh. I watched a video on youtube (https://www.youtube.com/watch?v=D-YcVd4-_2E) where Garth Wells mention some design decisions related to using OOP. Looks like the decision was against using OOP for some things.

The interface of a “subdomain” class might look cleaner, but it results in less flexible code and less efficient code when used in python. The old sudomain class does nothing different than the locate_entities code, it just encapsulates multiple functions locate_entities and locate_entities_boundary for any dimension on an entity within a single function call.

1 Like