Hi, I am a novice, please point out any mistakes if there are any. I am attempting to calculate the potential field distribution within a galaxy by solving the 3D Poisson equation. I have stored discrete mass density data in ‘grid_density’ of size (10, 10, 10), and I wish to interpolate or project this data into the defined function space to compute the Poisson equation. However, I encountered an error, and the following is the code and the error message. I would greatly appreciate it if you could provide some helpful advice to help me.
from fenics import *
mesh = BoxMesh(Point(-1,-1,-1),Point(1,1,1),10, 10, 10)
V = FunctionSpace(mesh, 'P', 1)
density = Function(V)
density = project(grid_density, V) # grid_density.shape = (10,10,10), storing mass density data
*** Error: Unable to set local values of PETSc vector.
*** Reason: Size of values array is not equal to local vector size.
*** Where: This error was encountered inside PETScVector.cpp.
*** Process: 0
*** DOLFIN version: 2019.1.0
*** Git changeset: 12ef077802cc9fad34cf984ec7af80585b44301b