Thank you.
I have two additional questions:
1) Regarding the application of Dirichlet BC in the same tutorial (mixed CG):
Dirichlet BC are applied (for example for the left dofs) with left_dofs = fem.locate_dofs_topological(V1, fdim, subdomain1_facet_tags.find(1))
, where the last argument refers to previously defined tags, also as in Multiphysics: Solving PDEs on subdomains — FEniCS Workshop.
My question: if I work with a mesh imported without identifiers (Physical groups, etc) and I rather want to locate the facets with a function, e.g.,
def bnd_encastre(x1):
return np.isclose(...)
How should I proceed?
- In the previous function, should
x1
be set as x1 = ufl.SpatialCoordinate(subdomain1)
, with subdomain1
the submesh?
- Should I locate the entities with
dolfinx.mesh.locate_entities
and then pass them to dolfinx.fem.locate_dofs_topological
?
- If yes, should it be done on the submesh (
subdomain1
) or on the parent mesh (mesh
)?
Just to illustrate what I mean:
bnd_encastre_facets0_sub1 = dolfinx.mesh.locate_entities(subdomain1, mesh.topology.dim - 1, bnd_encastre)
bnd_encastre_dofs0_sub1 = dolfinx.fem.locate_dofs_topological(V1, mesh.topology.dim - 1, bnd_encastre_facets0_sub1)
bc_boundar_sub1 = dolfinx.fem.dirichletbc(np.array((0,) * mesh.geometry.dim, dtype=default_scalar_type), bnd_encastre_dofs0_sub1, V1)
Note that V1
refers to a function space on the submesh, the same as it is done in the tutorial.
2) I want to define a Function and interpolate to it an expression that depends i) on: the displacement (on each of the subdomains, u1
, u2
) and spatial position (x1
, x2
).
- Should I define two functions (for each of the subdomains, e.g.,
v1
and v2
), respectively from the function spaces on the submerges V1
and V2
, and then do something similar to:
v1_expr = dolfinx.fem.Expression(function(x1,u1), V1.element.interpolation_points())
v1.interpolate(v1_expr)
v2_expr = dolfinx.fem.Expression(function(x2,u2), V2.element.interpolation_points())
v2.interpolate(v2_expr)
with function(x1, u1)
denotes any generic expression defined previously.
I am bumping into errors in an implementation and I want to double check and understand the concepts before.
Thank you in advance.