Hello,
My goal is to solve this problem:
\begin{align*} 0 &= dif1 * \nabla u1 + mixed1 * u1 - theta1 * u2 \\ 0 &= dif2 * \nabla u2 + mixed1 * u2 + theta2 * u1 \end{align*}
where
\begin{align*} dif1,\ dif2 &= 0.1 \\ mixed1,\ mixed2 &= 0.1 \\ theta1, theta2 &= 0.1 \end{align*}
and the boundary conditions are
\begin{align*} u1 &= 2.0 \quad {\rm on} \ \Gamma_{D} \\ u2 &= 0.0 \quad {\rm on} \ \Gamma_{D} \\ \end{align*}
I wrote the following code
from dolfin import *
import matplotlib.pyplot as plt
# Mesh
mesh = UnitSquareMesh(32, 32)
# Finite Element
P1 = FiniteElement('Lagrange', mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, 'Lagrange', 1)
W = FunctionSpace(mesh, P1*P1)
# Boundary
def boundary(x):
return x[0] < DOLFIN_EPS or x[1] < DOLFIN_EPS \
or x[0] > 1.0 - DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS
# Condition
u10 = Constant(2.0)
u20 = Constant(0.0)
bc1 = DirichletBC(W.sub(0), u10, boundary)
bc2 = DirichletBC(W.sub(1), u20, boundary)
bcs = [bc1, bc2]
# Problem
#
# Coefficients
mixed1 = Constant(0.1)
mixed2 = Constant(0.1)
dif1 = Constant(0.1)
dif2 = Constant(0.1)
theta1 = Constant(0.1)
theta2 = Constant(0.1)
#
# Test - trial functions
(u1, u2) = TrialFunctions(W)
(v1, v2) = TestFunctions(W)
w = Function(W)
u1 = w.sub(0)
u2 = w.sub(1)
#
# Variational formulation
a1 = dif1*dot(grad(u1), grad(v1))*dx
f1 = mixed1*u1 - theta1*u2
L1 = f1*v1*dx
F1 = a1 - L1
a2 = dif2*dot(grad(u2), grad(v2))*dx
f2 = mixed2*u2 + theta2*u1
L2 = f2*v2*dx
F2 = a2 - L2
F = F1 + F2
# Solution
solve(F == 0, w, bcs)
It gives the following error:
*** Error: Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /build/dolfin-LDAJTl/dolfin-2019.1.0/dolfin/la/PETScMatrix.cpp.
*** Process: 0
I read the former posts, but couldn’t solve the issue. Any help would be appreciated.
- Which argument is out of range?
- How the code can be fixed?
Thanks!