SNES VI and mixed systems #3403
Answered
by
wence-
colinjcotter
asked this question in
Firedrake support
-
I would like to set up a mixed system with VI constraints for one variable but not the other. |
Beta Was this translation helpful? Give feedback.
Answered by
wence-
Feb 12, 2024
Replies: 1 comment 3 replies
-
You always have to pass in functions that represent the bounds in the full space, but you can put "unobtainable" bounds in the slots you don't want to constrain. See https://petsc.org/main/manualpages/SNES/SNESVISetVariableBounds/ So something like: import numpy as np
from firedrake.datatypes import ScalarType # can't remember where this one lives
MAX_REAL = np.finfo(ScalarType).max
# recreating code in petscmath.h
BOUND_POS_INF = MAX_REAL / 4
BOUND_NEG_INF = -BOUND_POS_INF
lbound = Function(W)
lbound.sub(0).interpolate(some_known_bound)
lbound.sub(1).interpolate(BOUND_NEG_INF)
... # same for upper bound
solver = ...
solver.solve(bounds=(lbound, ubound)) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
colinjcotter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You always have to pass in functions that represent the bounds in the full space, but you can put "unobtainable" bounds in the slots you don't want to constrain. See https://petsc.org/main/manualpages/SNES/SNESVISetVariableBounds/
So something like: