Hello everyone,
Recently I have encountered a problem when using the split function with MixedElements. When I use w0.split() the result is very similar to the initial condition but the solver gives an error “Unable to successfully call PETSc function ‘MatSetValuesLocal’.” and when I use split(w0) the solver works but there are perturbations with respect to the initial condition when I plot it.
Attached is a snippet of the code:
mesh = IntervalMesh(900, 0, 1.5e-4)
V1 = FiniteElement("CG", mesh.ufl_cell(), 2)
V2 = FiniteElement("CG", mesh.ufl_cell(), 2)
ME = FunctionSpace(mesh,MixedElement([V1, V2]))
dw = TrialFunction(ME)
q, p = TestFunctions(ME)
w = Function(ME)
w0 = Function(ME)
class InitialConditions(UserExpression):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def eval(self, values, x): #Returns values for a function of dimension two
if x[0]<xi=4*1.5e-6/6:
values[0]=1.0
values[1]=1.0
else:
values[0]=0.0
values[1]=0.0
def value_shape(self):
return (2,)
u_init = InitialConditions()
w0.interpolate(u_init)
c, eta = split(w)
c0, eta0 = split(w0)
fig, ax = pl.subplots()
figure()
plot(eta0)
ax.set_xlim(0.0000975, 0.0001025)
c0, eta0 = w0.split()
figure()
plot(eta0)
ax.set_xlim(0.0000975, 0.0001025)
I would be very grateful if anyone knows why this is happening.
Thanks,
Jesús