### How to compute $f<g$ amost everywhere for trialfunctions?

320

views

0

I am working with finite elements for Maxwell's Equations (i.e. with Nedelec's edge elements) and for computation I'm using the <a href="https://fenicsproject.org/">FEniCS-project</a>. While implementing the Augmented Lagragian Method, I need to solve a PDE with a non-linearity of the form:

\begin{align*}

f(v) := \begin{cases}

v, \quad &\text{ on } A=\lbrace x : |v(x)| \leq g(x)\rbrace\\

\frac{v}{|v|}g, &\text{ on } \Omega \backslash A

\end{cases}

\end{align*}

I wanted to implement this by defining a function:

Thanks for your answer. Actually, this was a typo. The function $f$ in my question was somehow not correct, as well. I edited it.

\begin{align*}

f(v) := \begin{cases}

v, \quad &\text{ on } A=\lbrace x : |v(x)| \leq g(x)\rbrace\\

\frac{v}{|v|}g, &\text{ on } \Omega \backslash A

\end{cases}

\end{align*}

I wanted to implement this by defining a function:

```
import dolfin
#Define initial values and data
f = dolfin.Constant((1.0,1.0,1.0))
bound = dolfin.Constant(1.0)
#Create mesh and define function spaces
nx = ny = nz = 10
mesh = dolfin.UnitCubeMesh(nx, ny, nz)
V = dolfin.FunctionSpace(mesh, 'N1curl', 1)
E = dolfin.TrialFunction(V)
v = dolfin.TestFunction(V)
#Define linear and bilinear forms
a = dolfin.dot(E, v)*dolfin.dx + dolfin.dot(dolfin.curl(E), dolfin.curl(v))*dolfin.dx
F = dolfin.dot(f, v)*dolfin.dx
#Define non-linearity
def non_lin(func, bound):
if func < bound:#somehow almost everywhere
return func
else:
return func / abs(func) * bound
a_new = a + non_lin(E, bound)
u = dolfin.Function(V)
dolfin.solve(a_new == F,u)
```

Thats an example which is not working yet... The problem lies in the function non_lin. Can someone help me?

Community: FEniCS Project

written
7 months ago by
FFoDWindow

### 1 Answer

0

Restate your problem to solve with NewtonSolver --- see the FEniCS tutorial for more info --- then use "conditional"

http://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#conditional-operators

to form the non-linearity.

http://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#conditional-operators

to form the non-linearity.

I've updated my function $f$ in the question. I guess with this it's not possible to use "conditional", is it? Is there any other possibility? Thanks.

written
7 months ago by
FFoDWindow

Like I said, you have to restate your problem as a nonlinear problem; in this case the trial function is the direction of decent of the residual. Refer to the FEniCS tutorial regarding nonlinear problems.

written
7 months ago by
pf4d

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

I don't even understand the first lines..

what is f now?

Are you sure you want to put "E" into your non_lin function?