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
error in meshvariable to meshvariable projection #3
When I change the origin from (0, 0, 0) to (10, 10, 10), the issue with anomalous values at the cell containing (0, 0, 0) disappears. This suggests it’s related to floating point precision.
Note: I haven’t checked yet whether this issue originates from the Gmsh level or the DMPlex level.
@gthyagi, I had a look at the attached code. The main cause of the issue is the behaviour of swarm.dm.addNPoints() inside mesh2mesh_swarm:
If the swarm is still empty, to add N points, you need to to do swarm.dm.addNPoints(N + 1) and this is what you see in lines 105 - 108.
If the swarm already has particles inside, then to add M points, you need to do swarm.dm.addNPoints(M)
With this, even if n_found1 is equal to zero, adds will be equal to 1. Consequently, addNPoints in line 161 adds a particle, but is not assigned a proper coordinate so it retains its default coordinate of (0., 0., 0.). This results to the issue you see.
One way to fix this is Putting lines 158 to 166 and 171 to 172 in mesh2mesh_swarm inside the if n_found1 > 0: clause.
@jcgraciosa, if this is a PETSc issue rather than Underworld, could you please provide a brief explanation along with a reproducible script to @knepley? Thanks for investigating the issue and implementing a temporary fix. Cheers!
________________________________
From: jcgraciosa ***@***.***>
Sent: Wednesday, July 9, 2025 6:56:17 PM
To: underworldcode/underworld3 ***@***.***>
Cc: Julian Giordani ***@***.***>; Mention ***@***.***>
Subject: Re: [underworldcode/underworld3] error in meshvariable to meshvariable projection (Issue #3)
[https://avatars.githubusercontent.com/u/12045001?s=20&v=4]jcgraciosa left a comment (underworldcode/underworld3#3)<#3 (comment)>
Sure! Here's a simple example @gthyagi<https://github.com/gthyagi>, @knepley<https://github.com/knepley>:
import underworld3 as uw
mesh = uw.meshing.UnstructuredSimplexBox(minCoords = (0., 0.),
maxCoords = (1, 1.),
cellSize = 1/2,
regular = False)
swarm = uw.swarm.Swarm(mesh)
swarm_var = uw.swarm.SwarmVariable(name = "test", swarm = swarm, size = 1)
swarm.dm.finalizeFieldRegister()
# add 10 particles to a blank swarm
swarm.dm.addNPoints(10)
with swarm.access():
print(swarm.data.shape) # WRONGLY adds only 9 instead of 10 particles
# add 2 more particles
swarm.dm.addNPoints(2)
with swarm.access():
print(swarm.data.shape) # this time, CORRECTLY added 2 particles
—
Reply to this email directly, view it on GitHub<#3 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADJPNKCI5D3SFM3NEGAKR233HTKLDAVCNFSM6AAAAACARC3YVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANJRG43DKMZYG4>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
@julesghub For the example, doing swarm.dm.getSize() after swarm.dm.addNPoints(10) returns 9. Calling it again after swarm.dm.addNPoints(2) returns 11.
Activity
gthyagi commentedon Jul 2, 2025
When I change the origin from (0, 0, 0) to (10, 10, 10), the issue with anomalous values at the cell containing (0, 0, 0) disappears. This suggests it’s related to floating point precision.
Note: I haven’t checked yet whether this issue originates from the Gmsh level or the DMPlex level.
gthyagi commentedon Jul 4, 2025
@knepley I believe this issue is occurring at the DMPlex and DMSwarm level. Do you have any comments on this?
It seems that if the model’s bounding box coordinates include zero, there’s a floating point precision error involving the zero value.
Note: Mesh1 and Mesh2 have the same bounding box coordinates but different cell sizes.
knepley commentedon Jul 5, 2025
@gthyagi What routine has the problem?
jcgraciosa commentedon Jul 8, 2025
@gthyagi, I had a look at the attached code. The main cause of the issue is the behaviour of
swarm.dm.addNPoints()insidemesh2mesh_swarm:swarm.dm.addNPoints(N + 1)and this is what you see in lines 105 - 108.swarm.dm.addNPoints(M)With this, even if
n_found1is equal to zero,addswill be equal to 1. Consequently,addNPointsin line 161 adds a particle, but is not assigned a proper coordinate so it retains its default coordinate of (0., 0., 0.). This results to the issue you see.One way to fix this is Putting lines 158 to 166 and 171 to 172 in
mesh2mesh_swarminside theif n_found1 > 0:clause.gthyagi commentedon Jul 9, 2025
@jcgraciosa, if this is a PETSc issue rather than Underworld, could you please provide a brief explanation along with a reproducible script to @knepley? Thanks for investigating the issue and implementing a temporary fix. Cheers!
jcgraciosa commentedon Jul 9, 2025
Sure! Here's a simple example @gthyagi, @knepley:
julesghub commentedon Jul 9, 2025
jcgraciosa commentedon Jul 9, 2025
@julesghub For the example, doing
swarm.dm.getSize()afterswarm.dm.addNPoints(10)returns 9. Calling it again afterswarm.dm.addNPoints(2)returns 11.knepley commentedon Jul 10, 2025
Embarassing. The initial size was -1, so addition functions did not work. I was using all direct sets. Here is the fix: https://gitlab.com/petsc/petsc/-/merge_requests/8541
jcgraciosa commentedon Jul 10, 2025
All good! Thank you so much for providing the fix @knepley!
Phase D: τ_∥ soft-cap (recommendation #4) — partial trade
EXPONENTIAL_VE_INTEGRATOR.md: investigation closed
Phase D: τ_∥ soft-cap (recommendation #4) — partial trade
EXPONENTIAL_VE_INTEGRATOR.md: investigation closed
Address Copilot review on PR #179 + fix flaky KDTree count test
Address Copilot review on PR #179 + fix flaky KDTree count test
test: bit-identical continuation — the core stash-for-steps guarantee