On Thu, Jul 17, 2025 at 7:52 AM Smail Merabet <merabetsmail@gmail.com> wrote:
Dear firedrake users, I try to solve a variational inequality using snes-firedrake.
I have two unknown functions say (theta,w)
so the functionspace is Vh = MixedFunctionSpace([Th,Wh]) 
 where
Th = FunctionSpace(mesh, "Lagrange", 1)
Wh = FunctionSpace(mesh, "Lagrange", 2)


the inequality constraint concerns only $w$

I set : 
obstacle = Function(Vh.sub(1)).interpolate((Constant(-0.03)))
upper = Function(Vh.sub(1)).interpolate(Constant(1e10))

The SNES is operating on the full space, but you have interpolated constraints on the subspace. You have to inject those to full space vectors before setting the bounds.

 Thanks,

    Matt
 
solver.solve(bounds=(obstacle, upper)) 

but this line causes the following error:

File "/Users/maths/Desktop/Firedrake/VI/Timoshenko-obs.py", line 64, in <module>
    solver.solve(bounds=(obstacle, upper))
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/Users/maths/firedrake/src/firedrake/firedrake/adjoint_utils/variational_solver.py", line 89, in wrapper
    out = solve(self, **kwargs)
  File "/Users/maths/firedrake/src/firedrake/firedrake/variational_solver.py", line 312, in solve
    self.snes.setVariableBounds(lb, ub)
  File "petsc4py/PETSc/SNES.pyx", line 1978, in petsc4py.PETSc.SNES.setVariableBounds
petsc4py.PETSc.Error: error code 75
[0] SNESVISetVariableBounds() at /Users/maths/firedrake/src/petsc/src/snes/impls/vi/vi.c:424
[0] SNESVISetVariableBounds_VI() at /Users/maths/firedrake/src/petsc/src/snes/impls/vi/vi.c:443
[0] Arguments are incompatible
[0] Incompatible vector lengths lower bound = 201 solution vector = 302 


Hope that one can help me ...

Best regards.
Smail. 

On Fri, Apr 11, 2025 at 9:11 AM Smail Merabet <merabetsmail@gmail.com> wrote:
Dear firedrake users, 

I try to solve a fourth-order 1d nonlinear problem using the Hermite element in firedrake.
The functional space for the weak solution is:
$$\mathcal{H}\times \mathcal{H}/times H^{2}_{0} $$ 
where,
$$
\mathcal{H} = \left\lbrace f\in H^2([0,\ell]), \; f(0)=0, \; f'(0)=0 \right\rbrace.
$$ 
I can't impose the boundary conditions correctly. When I compile the code, I get the following error: 
 FiniteElement('Hermite', interval, 3), name=None, index=1, component=None), IndexedProxyFunctionSpace(<firedrake.mesh.MeshTopology object at 0x125a2ce80>, FiniteElement('Hermite', interval, 3), name=None, index=2, component=None), name='None_None_None'), Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 0)), 9) defined on incompatible FunctionSpace!

Note the same problem was implemented using FEniCS with C0-interior penalty method, in the reference (sec. 3 eq 3.12-3.13): 

Enhanced models for the nonlinear bending of planar rods: localization phenomena and multistability
by:
Matteo Brunetti , Antonino Favata  and Stefano Vidoli.

I attached the codes to this email.

Thanks in advance
Smail MERABET

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener