Hi @knepley,
I've observed that when running in parallel, PETSc produces surface normals with flipped signs compared to serial execution, where all normals are consistently oriented. This inconsistency seems to be causing anomalous pressure and velocity fields. Could you please take a look?
Setup: This is a basic Stokes problem where a natural BC is applied on an internal boundary. Natural BC aligns in the surface normal orientation.
Thanks!
Serial output:
All normals (N) orient in same direction. Arrow represent velocity field and background color represent pressure field.
bdres - equation 18 X / N (2.96e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (1.67e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (3.76e-02, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (6.29e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (5.00e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (3.71e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (9.62e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (8.33e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (7.04e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,


Parallel (2 cpus) output:
bdres - equation 18 X / N (6.29e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (2.96e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (5.00e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (1.67e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (3.71e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
bdres - equation 18 X / N (3.76e-02, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
_bdres - equation 18 X / N (9.62e-01, 6.70e-01, 0.00e+00 / -0e+00, -1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,_
bdres - equation 18 X / N (9.62e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
_bdres - equation 18 X / N (8.33e-01, 6.70e-01, 0.00e+00 / -0e+00, -1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,_
bdres - equation 18 X / N (8.33e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,
_bdres - equation 18 X / N (7.04e-01, 6.70e-01, 0.00e+00 / -0e+00, -1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,_
bdres - equation 18 X / N (7.04e-01, 6.70e-01, 0.00e+00 / 0e+00, 1e+00, 0.00e+00 ) -> 0.000000e+00, -1.000000e+00,


UW script:
import underworld3 as uw
from underworld3.systems import Stokes
import sympy
mesh = uw.discretisation.Mesh(mesh_fname, boundaries=boundaries,
boundary_normals=boundary_normals_2D,
markVertices=True, useMultipleTags=True, useRegions=True,
coordinate_system_type=uw.coordinates.CoordinateSystemType.CARTESIAN, )
v_soln = uw.discretisation.MeshVariable(r"u", mesh, 2, degree=2)
p_soln = uw.discretisation.MeshVariable(r"p", mesh, 1, degree=1, continuous=True)
# Create Stokes object
stokes = Stokes(mesh, velocityField=v_soln, pressureField=p_soln,)
stokes.constitutive_model = uw.constitutive_models.ViscousFlowModel
stokes.constitutive_model.Parameters.viscosity = 1.0
stokes.saddle_preconditioner = 1.0
# bc's
stokes.add_natural_bc(sympy.Matrix([0.0, -1.0]), "Internal")
stokes.add_essential_bc(sympy.Matrix([sympy.oo, 0.0]), "Top")
stokes.add_essential_bc(sympy.Matrix([sympy.oo, 0.0]), "Bottom")
stokes.add_essential_bc(sympy.Matrix([0.0,sympy.oo]), "Left")
stokes.add_essential_bc(sympy.Matrix([0.0,sympy.oo]), "Right")
stokes.bodyforce = sympy.Matrix([0, 0])
stokes.tolerance = 1e-6
stokes.solve(verbose=False, debug=True, debug_name=f'Natural_BC_Bug_{uw.mpi.size}')
Hi @knepley,
I've observed that when running in parallel, PETSc produces surface normals with flipped signs compared to serial execution, where all normals are consistently oriented. This inconsistency seems to be causing anomalous pressure and velocity fields. Could you please take a look?
Setup: This is a basic Stokes problem where a natural BC is applied on an internal boundary. Natural BC aligns in the surface normal orientation.
Thanks!
Serial output:
All normals (N) orient in same direction. Arrow represent velocity field and background color represent pressure field.
Parallel (2 cpus) output:
UW script: