Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error encountered when trying to interpolate mesh variable #144

Open
gthyagi opened this issue Jan 6, 2024 · 10 comments
Open

Error encountered when trying to interpolate mesh variable #144

gthyagi opened this issue Jan 6, 2024 · 10 comments

Comments

@gthyagi
Copy link
Contributor

gthyagi commented Jan 6, 2024

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 gthyagi changed the title Error encountered when trying to interpolate mesh variable in StructuredQuadBox Error encountered when trying to interpolate mesh variable Jan 6, 2024
@bknight1
Copy link
Member

bknight1 commented Jan 6, 2024

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

@knepley
Copy link
Collaborator

knepley commented Jan 6, 2024

Does QuadBox mean a DMDA?

@lmoresi
Copy link
Member

lmoresi commented Jan 6, 2024 via email

@knepley
Copy link
Collaborator

knepley commented Jan 6, 2024

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

@gthyagi
Copy link
Contributor Author

gthyagi commented Jan 7, 2024

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
Copy link
Contributor Author

gthyagi commented Jan 7, 2024

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

@bknight1
Copy link
Member

bknight1 commented Jan 7, 2024

@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

@knepley
Copy link
Collaborator

knepley commented Feb 26, 2024

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

@lmoresi
Copy link
Member

lmoresi commented Aug 29, 2024

@gthyagi - is this still a live issue ?

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

@gthyagi
Copy link
Contributor Author

gthyagi commented Sep 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants