### Solve dual nonlinear equation: ETSc error code is: 63

217

views

0

Greetings.

I am trying to solve a boundary value problem:

$-\Delta\theta+\left(\theta^4-\varphi\right)=0,$−Δ

$-\Delta\varphi+\left(\varphi-\theta^4\right)=0$−Δ

with conditions:

$\frac{\delta\theta}{\delta_n}|_{\Gamma}=f,\frac{\delta\varphi}{\delta n}|_{\Gamma}=g$

Code that I have:

I am trying to solve a boundary value problem:

$-\Delta\theta+\left(\theta^4-\varphi\right)=0,$−Δ

`θ`+(`θ`^{4}−`φ`)=0,$-\Delta\varphi+\left(\varphi-\theta^4\right)=0$−Δ

`φ`+(`φ`−`θ`^{4})=0,with conditions:

$\frac{\delta\theta}{\delta_n}|_{\Gamma}=f,\frac{\delta\varphi}{\delta n}|_{\Gamma}=g$

`δ``θ``δ`_{n}|_{Γ}=`ƒ`,`δ``φ``δ``n`|_{Γ}=`g`.Code that I have:

```
from dolfin import *
import dolfin.cpp.mesh
omega = dolfin.cpp.mesh.UnitSquareMesh(64, 64)
p1 = FiniteElement("CG", omega.ufl_cell(), 2)
W = FunctionSpace(omega, p1 * p1)
theta, phi = split(Function(W))
v, h = split(TestFunction(W))
f, g = Expression("sin(x[0])*x[1]", degree=2), Expression("0.7*x[0]", degree=2)
F = inner(grad(theta), grad(v)) * dx + inner(grad(phi), grad(h)) * dx \
+ inner((theta ** 4 - phi), v) * dx \
+ inner((phi - theta ** 4), h) * dx \
- f * v * ds - g * h * ds
w = Function(W)
solve(F == 0, w)
```

gives me after the first iteration:

```
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 1.073e-01 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
...
...traceback...
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /tmp/dolfin/dolfin/la/PETScMatrix.cpp.
*** Process: 0
***
*** DOLFIN version: 2017.2.0
*** Git changeset: 4c59bbdb45b95db2f07f4e3fd8985c098615527f
*** -------------------------------------------------------------------------
```

Similar issues: [1], [2], [3] did not help.

I would appreciate any help with it.

Community: FEniCS Project

### 1 Answer

4

You have to define

`w`

previous to the definition of your variational problem. Try this:```
from dolfin import *
omega = UnitSquareMesh(64, 64)
p1 = FiniteElement("CG", omega.ufl_cell(), 2)
W = FunctionSpace(omega, p1 * p1)
w = Function(W)
theta, phi = split(w)
v, h = split(TestFunction(W))
f, g = Expression("sin(x[0])*x[1]", degree=2), Expression("0.7*x[0]", degree=2)
F = inner(grad(theta), grad(v)) * dx + inner(grad(phi), grad(h)) * dx \
+ inner((theta ** 4 - phi), v) * dx \
+ inner((phi - theta ** 4), h) * dx \
- f * v * ds - g * h * ds
solve(F == 0, w)
```

Thanks. Now it works.

written
5 months ago by
Pavel Mesenev

Please login to add an answer/comment or follow this question.