underworld3 icon indicating copy to clipboard operation
underworld3 copied to clipboard

Error encountered when trying to interpolate mesh variable

Open gthyagi opened this issue 2 years ago • 10 comments

Hi,

In serial: I encountered this error for StructuredQuadBox mesh, however, it works fine for UnstructuredSimplexBox. In parallel: both meshes encounter error.

[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Point 24: -0.25 0. 0. not located in mesh
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.1, Oct 31, 2023 
[0]PETSC ERROR: Unknown Name on a  named MU00155712X by tgol0006 Sat Jan  6 20:15:35 2024
[0]PETSC ERROR: Configure options AR=arm64-apple-darwin20.0.0-ar CC=mpicc CXX=mpicxx FC=mpifort CFLAGS="-ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/tgol0006/micromamba/envs/underworld3/include  " CPPFLAGS="-D_FORTIFY_SOURCE=2 -isystem /Users/tgol0006/micromamba/envs/underworld3/include -mmacosx-version-min=11.0" CXXFLAGS="-ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /Users/tgol0006/micromamba/envs/underworld3/include  " FFLAGS="-march=armv8.3-a -ftree-vectorize -fPIC -fno-stack-protector -O2 -pipe -isystem /Users/tgol0006/micromamba/envs/underworld3/include  " LDFLAGS="-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/tgol0006/micromamba/envs/underworld3/lib -L/Users/tgol0006/micromamba/envs/underworld3/lib" LIBS="-lmpifort -lgfortran" --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --FOPTFLAGS=-O3 --with-clib-autodetect=0 --with-cxxlib-autodetect=0 --with-fortranlib-autodetect=0 --with-debugging=0 --with-blas-lib=libblas.dylib --with-lapack-lib=liblapack.dylib --with-yaml=1 --with-hdf5=1 --with-fftw=1 --with-hwloc=0 --with-hypre=1 --with-metis=1 --with-mpi=1 --with-mumps=1 --with-parmetis=1 --with-pthread=1 --with-ptscotch=1 --with-shared-libraries --with-ssl=0 --with-scalapack=1 --with-superlu=1 --with-superlu_dist=1 --with-suitesparse=1 --with-x=0 --with-scalar-type=real --with-batch --prefix=/Users/tgol0006/micromamba/envs/underworld3
[0]PETSC ERROR: #1 DMInterpolationSetUp_UW() at underworld3/function/petsc_tools.c:139
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[5], line 7
      4 v_soln = uw.discretisation.MeshVariable("U", mesh, mesh.dim, degree=1)
      6 with mesh.access():
----> 7     pressure_interp = uw.function.evaluate(p_soln.sym[0], p_soln.coords)
      9 # # set up interpolation coordinates
     10 # ycoords = np.linspace(minY + 0.01 * (maxY - minY), maxY - 0.01 * (maxY - minY), 10)
     11 # xcoords = np.full_like(ycoords, -1)
     12 # xy_coords = np.column_stack([xcoords, ycoords])
     13 # pressure_interp = uw.function.evaluate(p_soln.sym[0], xy_coords)

File ~/uw_folder/underworld3_dev/underworld3/underworld3/function/_function.pyx:412, in underworld3.function._function.evaluate()

File ~/uw_folder/underworld3_dev/underworld3/underworld3/function/_function.pyx:375, in underworld3.function._function.evaluate.interpolate_vars_on_mesh()

RuntimeError: Error encountered when trying to interpolate mesh variable.
Interpolation location is possibly outside the domain.

Code:

from mpi4py import MPI
from petsc4py import PETSc
import underworld3 as uw
import numpy as np

minX, maxX = -1.0, 0.0
minY, maxY = -1.0, 0.0
res = 2

mesh = uw.meshing.StructuredQuadBox(elementRes=(int(res), int(res)), 
                                    minCoords=(minX, minY), 
                                    maxCoords=(maxX, maxY)
                                   )

# mesh = uw.meshing.UnstructuredSimplexBox(minCoords=(minX, minY), 
#                                          maxCoords=(maxX, maxY),
#                                          cellSize=1/res, 
#                                          regular=False, 
#                                          qdegree=2, 
#                                          # refinement=1
#                                         )

p_soln = uw.discretisation.MeshVariable("P", mesh, 1, degree=2)
v_soln = uw.discretisation.MeshVariable("U", mesh, mesh.dim, degree=1)

with mesh.access():
    pressure_interp = uw.function.evaluate(p_soln.sym[0], p_soln.coords)

gthyagi avatar Jan 06 '24 09:01 gthyagi

There are/were some issues with the quadbox Interpolation. Think it may have been updated recently by PETSc. You can use uw.function.evalf to use the kdtree interpolation and get round the error for now

bknight1 avatar Jan 06 '24 22:01 bknight1

Does QuadBox mean a DMDA?

knepley avatar Jan 06 '24 22:01 knepley

No - quadrilateral with dmplex

L

Sent from my iPhone

On 7 Jan 2024, at 09:24, Matthew Knepley @.***> wrote:



Does QuadBox mean a DMDA?

— Reply to this email directly, view it on GitHubhttps://github.com/underworldcode/underworld3/issues/144#issuecomment-1879848195, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADABPI6TUAD43VH2MO6NVLLYNHFH7AVCNFSM6AAAAABBPNWXRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZZHA2DQMJZGU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

lmoresi avatar Jan 06 '24 22:01 lmoresi

Okay. I have many tests for DMProjectFunction and DMProjectField for these. Is one of these failing?

knepley avatar Jan 06 '24 22:01 knepley

Thanks @bknight1, uw.function.evalf works fine both in serial and parallel. However, the numerical solution it provides diverges significantly from the analytical solution. This cause issue in converting some of the examples to tests in parallel.

gthyagi avatar Jan 07 '24 23:01 gthyagi

@knepley could you please point me to the tests you are referring? Thanks

gthyagi avatar Jan 07 '24 23:01 gthyagi

@gthyagi I'd check if we implemented the PETSc projections or if we're still using our own. I vaguely remember we tried the PETSc way when we last met in Sydney

bknight1 avatar Jan 07 '24 23:01 bknight1

@gthyagi The place to start is Plex ex3, which test function projection into a lot of function spaces.

knepley avatar Feb 26 '24 03:02 knepley

@gthyagi - is this still a live issue ?

If it is still live, is it a UW problem or a PETSc problem ?

lmoresi avatar Aug 29 '24 12:08 lmoresi

@lmoresi Yes, the issue is still present. I'll investigate further and provide an update on where the problem originates.

gthyagi avatar Sep 16 '24 00:09 gthyagi