The lower is a constant obstacle psi =-0.03I have the plot using freefem++
On Thu, Jul 17, 2025 at 4:02 PM Matthew Knepley <knepley@gmail.com> wrote:On Thu, Jul 17, 2025 at 10:49 AM Smail Merabet <merabetsmail@gmail.com> wrote:Dear Matthew,thanks for reply, I tried this:psi = Constant(-0.03)
# Create the full function in mixed space
obs = Function(Vh, name="Obstacle")
upp = Function(Vh, name="Upper")
obs_sub1 = obs.sub(1)
upp_sub1 = upp.sub(1)
# Interpolate into the subfunctions
obs_sub1.interpolate(conditional(lt(psi, 0), 0, psi))
I do not understand the Firedrake side, but did you plot your lower bound? I have no idea what conditional gives back.Thanks,Mattupp_sub1.interpolate(Constant(1e10))
But the result doesn't satisfy the constraint $w \geq \psi$Many ThanksOn Thu, Jul 17, 2025 at 1:22 PM Matthew Knepley <knepley@gmail.com> wrote: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])whereTh = 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,Mattsolver.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 = 302Hope 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 advanceSmail 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--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