### limiting solution to a given range

Hi,

I am new to FEniCS, and I try to solve a strange problem.

I have a PDE (actually, quite a few). I have Dirichlet condition at the edges, and I am looking for the solution $u$`u` .

However, there is an extra condition, the solution must be in the following form:

$u=c+f$`u`=`c`+`ƒ`

where $c$`c` is a known, well defined function over the whole domain, and $\left|f\right|\le1.0$|`ƒ` |≤1.0.

This is just a soft-condition, there is no guarantee that the function will ever reach 1.0, but it might.

(Physical example: there is a rubber-like plate, and there are two non-flat surfaces with the same shape below and above it.

As I push the surfaces towards each other, they might touch the rubber plate at certain points, and deform it.

I continue this process as long as the distance between the surfaces reach 1.0.

Also it is guaranteed that the soft condition is compatible with the boundary conditions, because

on the boundaries u = c (Dirichlet condition).)

There might be several ways to handle this situation, and maybe there is a documented way, just I did not find it, so

I would appreciate any pointers.

I the following ways to handle it but these might not be the correct way. (I am largely biased by finite differences approaches, and i am new to finite elements.)

- Set a huge cost on the solution, e.g. $\text{cost = |f| * 1000}$cost = |f| * 1000 if f>1.0, 0 otherwise. (This might not strictly enforce the condition, but if the deviation is small, I can live with this one.)
- Clip/limit the solution function somehow, e.g. constraint( -1.0 < f < 1.0).
- introduce some kind of internal borders

However, I did not find any straightforward way to implement any of these approaches. So could anyone suggest a pointer?

Is it solvable with FEniCS? Is there a documented way? Is there a recommended way?

(Remark: the actual problem is 2D, so the above physical example is more or less correct.)

### 1 Answer

If you think clipping the function will work for you, just grab the underlying numpy array

f_a = f.vector().array(),

clip, then assign back

f.vector().set_local(f_a).

Not sure what you mean by internal borders....