I am trying to solve a following problem:
First integral is the standard integral over the domain. Second integral is over a surface within the domain \Omega, mesh elements are aligned with the surface and \nabla_t is a 2D gradient within the surface. Third integral is a boundary condition on the internal surface’s boundary and fourth is a standard Neumann BC on the domain’s boundary.
When I include the second term in my simulation, there is no effect on the results. What could be the possible problem?
As far as I know, currently there is no easy option to include 1D integral as ufl. Measure
only supports dim-1
integrals. Can it be done with the “custom” Measure
type?
Following is the code I am using:
from dolfinx import default_scalar_type
from dolfinx.fem import (Constant, dirichletbc, Function, functionspace,
locate_dofs_topological)
from dolfinx.fem.petsc import LinearProblem
from dolfinx.io import XDMFFile
from dolfinx.mesh import locate_entities, create_submesh
from ufl import (TestFunction, TrialFunction, FacetNormal,Measure, Dx,
dx, grad, inner)
from mpi4py import MPI
with XDMFFile(MPI.COMM_WORLD, "mesh/t10_tetra.xdmf", "r") as xdmf:
mesh = xdmf.read_mesh(name="Grid")
ct = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim - 1)
with XDMFFile(MPI.COMM_WORLD, "mesh/t10_surf.xdmf", "r") as xdmf:
ft = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim - 2)
with XDMFFile(MPI.COMM_WORLD, "mesh/t10_line.xdmf", "r") as xdmf:
lt = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
left_marker=20006
right_marker=20004
V = functionspace(mesh, ("Lagrange", 1))
right_facets = ft.find(right_marker)
right_dofs = locate_dofs_topological(V, mesh.topology.dim - 1, right_facets)
bcs = [dirichletbc(default_scalar_type(0), right_dofs, V)]
ds = Measure("ds", domain=mesh, subdomain_data=ft)
u, v = TrialFunction(V), TestFunction(V)
n = FacetNormal(mesh)
a = inner(grad(u), grad(v)) * dx + default_scalar_type(100)*(inner(Dx(u,0),Dx(v,0)))*ds(40001) ###second term has no effect
L = Constant(mesh, default_scalar_type(0)) * v * dx + inner(v,default_scalar_type(100))*ds(left_marker)#
ds1 = Measure("ds", domain=mesh, subdomain_data=lt)
L2 = 0.01*inner(v,default_scalar_type(100))*ds1(10001) ### ds only works for dim-1
problem = LinearProblem(a, L, bcs=bcs, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()
with XDMFFile(mesh.comm, "out.xdmf", "w") as file:
file.write_mesh(mesh)
file.write_function(uh)
and the mesh can be found here:
https://mega.nz/folder/vvxGXKQI#L8VEvztkVvdi1IF5UZrlMQ
Marker 40001 is the surface inside the boundary.