Hello,
I am trying to use SubDomain in dolfin-x. Below, a simple code is presented in dolfin which I can not represent it in dolfin-x.
The proposed simple code in dolfin is:
from dolfin import *
import matplotlib.pyplot as pltmesh = RectangleMesh(Point(0, 0), Point(1, 1), 10, 10)
V = FunctionSpace(mesh, “Lagrange”, 1)
v = TestFunction(V)
u = TrialFunction(V)s=dot(grad(u),grad(v))*dx
S = PETScMatrix()
assemble(s, tensor=S)class MW(SubDomain):
def inside(self, x, on_boundary):
return on_boundaryew=DirichletBC(V,(“0”),MW())
ew.apply(S)esolver = SLEPcEigenSolver(S)
esolver.solve()
and I have a problem how to define this part in dolfin-x:
class MW(SubDomain):
def inside(self, x, on_boundary):
return on_boundaryew=DirichletBC(V,(“0”),MW())
ew.apply(S)
and this is the proposed dolfin-x code:
import numpy as np
import matplotlib.pyplot as plt
from dolfinx.plotting import plot
from mpi4py import MPI
from dolfinx import Function, FunctionSpace, UnitSquareMesh, RectangleMesh
from dolfinx.fem import assemble_matrix, Form
from ufl import TrialFunction, TestFunction, grad, dx, dot
from slepc4py import SLEPc
from dolfinx.cpp.mesh import CellType
import dolfinxmesh = RectangleMesh(
MPI.COMM_WORLD,
[np.array([0, 0, 0]), np.array([1, 1, 0])], [10, 10],
cell_type=CellType.triangle)V = FunctionSpace(mesh, (“CG”, 1))
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dxA = assemble_matrix(a, )
A.assemble()eigensolver = SLEPc.EPS().create(MPI.COMM_WORLD)
eigensolver.setDimensions(6)
eigensolver.setWhichEigenpairs(2)
eigensolver.setOperators(A)eigensolver.solve()
vr, vi = A.createVecs()
Thanks in advance for your help.