I am trying to solve a NonLinear mixed problem using PETSc SNES solver. The mixed space is made up of 3 elements (
P2-P1-P1) to solve for three unknowns say (
u, p, s). I need upper and lower bounds only on the last solution (
0<= s <=1). Extending from the snes demo, I need to create two functions carrying the upper and lower bounds for the solution of
s. As a naive attempt I did the following.
#Creating function spaces V_ele = VectorElement('P',mesh.ufl_cell(), 2) Q_ele = FiniteElement('P',mesh.ufl_cell(), 1) W = FunctionSpace(mesh,MixedElement(V_ele,Q_ele,Q_ele)) #Creating the box constraints to pass to the SNES solver smin, smax = Function(W), Function(W) smin_nodal_values = smin.sub(2).vector() smin_array = smin_nodal_values.get_local() smin_array.fill(Constant(0.0)) smin.sub(2).vector()[:] = smin_array smax_nodal_values = smax.sub(2).vector() smax_array = smax_nodal_values.get_local() smax_array.fill(Constant(1.0)) smax.sub(2).vector()[:] = smax_array
And then I go ahead and pass these to the solver by
Is there any better way to do this? At the moment I cannot verify with the solution of the problem, because there is a divergence maybe because of some other reason or because of this method. At least want to make sure I am doing this right. One thing I am not sure about is if I am passing any unintended bounds to the
p spaces also by this method. Since they are not assigned any bounds they must be 0 ? Ideally they should not have any.