You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] -AttributeError: 'NaturalBC' object has no attribute 'fn_F' when using add_natural_bc #25
Hi uw3 support team,
I encountered an error when applying a natural boundary condition to the Poisson solver in Underworld3, which prevents the solve from running successfully.
Please attach the example script you are running so we can debug. It also looks like you’re using an older version of Underworld, please update to the latest release, as some of these issues are already fixed.
Hi Thyagi,
Thank you for your response. Could you please confirm the current version of Underworld? I checked on GitHub and found the version listed as:
__version__ = "0.99.0b"
This matches the version I already have installed.
Cheers,
Belay
Hi Thyagi,
Thank you for your response. Could you please confirm the current version of Underworld? I checked on GitHub and found the version listed as: version = "0.99.0b"
This matches the version I already have installed.
Cheers,
Belay …
The version number may look the same, but we’ve recently pushed many important changes.
We've confirmed the root cause: the NaturalBC namedtuple defines fn_f (lowercase) but solver code references fn_F (uppercase). Additionally, the Poisson natural BC setup has a deeper issue causing PETSc error 73 ("Object in wrong state") — the test (test_1000_poissonNaturalBC.py) is currently skipped pending a fix.
Note that the Stokes solver's natural BCs (traction conditions) work correctly — the issue is specific to the scalar Poisson solver path.
This is tracked in our internal planning and will be addressed as part of the solver cleanup work. We'll update this issue when we have a fix.
@Belay-129 — in the meantime, Dirichlet BCs work correctly for the Poisson solver. If your problem allows it, you may be able to reformulate using a Dirichlet condition on the dependent variable rather than a Neumann flux condition.
The root cause was two bugs in the scalar Poisson solver (SNES_Scalar):
Natural BCs were registered with per-boundary labels ("Bottom") instead of the consolidated "UW_Boundaries" label
The compiled boundary residual/jacobian functions were never passed to PETSc's DS system — the code was completely missing from _setup_solver
Both issues were present in the Scalar solver but not the Vector (Stokes) solver, which is why Stokes natural BCs (traction conditions) worked correctly.
The fix mirrors the working Stokes pattern. Verified with an analytical solution (T = x²y with mixed Dirichlet/Neumann BCs) on simplex and quad meshes.
@Belay-129 — this fix is now on the development branch. Your original code pattern should work:
Activity
gthyagi commentedon Sep 23, 2025
Hi @Belay-129,
Please attach the example script you are running so we can debug. It also looks like you’re using an older version of Underworld, please update to the latest release, as some of these issues are already fixed.
Cheers,
Thyagi
Belay-129 commentedon Sep 23, 2025
Belay-129 commentedon Sep 23, 2025
'''
mesh = uw.meshing.UnstructuredSimplexBox(
minCoords=(423755, -10000),
maxCoords=(496255, 0),
cellSize=1000,
regular=False,
)
'''
'''
k_scalar = uw.discretisation.MeshVariable("k", mesh, 1)
'''
'''
T_soln = uw.discretisation.MeshVariable("T", mesh, 1)
'''
'''
Set up the Poisson system
poisson = uw.systems.Poisson(mesh, u_Field=T_soln)
poisson.constitutive_model = uw.constitutive_models.DiffusionModel
poisson.constitutive_model.Parameters.diffusivity = k_scalar.sym[0]
poisson.f = 0
'''
BCs
'''
poisson.add_dirichlet_bc([17.0], "Top")
q_bottom = 0.065 #W/m2
poisson.add_natural_bc([q_bottom], "Bottom")
'''
solve
poisson.solve()
gthyagi commentedon Sep 23, 2025
The version number may look the same, but we’ve recently pushed many important changes.
jcgraciosa commentedon Sep 23, 2025
Hello @gthyagi and @Belay-129, I found the cause of the issue and I'm investigating a fix.
I'll give you some updates soon.
Cheers,
JC
Belay-129 commentedon Sep 23, 2025
Fix for bug underworldcode#25 along with changes for natural BC in Sc…
Fix for bug #25 along with changes for natural BC in Scalar solver to…
lmoresi commentedon Feb 26, 2026
Status update — bug confirmed, tracked internally
We've confirmed the root cause: the
NaturalBCnamedtuple definesfn_f(lowercase) but solver code referencesfn_F(uppercase). Additionally, the Poisson natural BC setup has a deeper issue causing PETSc error 73 ("Object in wrong state") — the test (test_1000_poissonNaturalBC.py) is currently skipped pending a fix.Note that the Stokes solver's natural BCs (traction conditions) work correctly — the issue is specific to the scalar Poisson solver path.
This is tracked in our internal planning and will be addressed as part of the solver cleanup work. We'll update this issue when we have a fix.
@Belay-129 — in the meantime, Dirichlet BCs work correctly for the Poisson solver. If your problem allows it, you may be able to reformulate using a Dirichlet condition on the dependent variable rather than a Neumann flux condition.
Fix Poisson solver natural (Neumann) boundary conditions
lmoresi commentedon Feb 28, 2026
Fixed in PR #60 (merged to
development)The root cause was two bugs in the scalar Poisson solver (SNES_Scalar):
_setup_solverBoth issues were present in the Scalar solver but not the Vector (Stokes) solver, which is why Stokes natural BCs (traction conditions) worked correctly.
The fix mirrors the working Stokes pattern. Verified with an analytical solution (T = x²y with mixed Dirichlet/Neumann BCs) on simplex and quad meshes.
@Belay-129 — this fix is now on the
developmentbranch. Your original code pattern should work: