I have a problem of shapes with array on NGSolve / Numpy.
The problem is the following, I have a “pwc” Compressed on a certain specific region (reducing the size of all element linked to pwc). Then I calculate an Integral element_wise, but the dimensions of this integral is on all the mesh and not only where I defined it…
pwc = Compress(L2(mesh,order=0,definedon=mesh.Materials(VARIABLE))) gfRho = GridFunction(pwc) Ates = Integrate(gfRho,mesh, element_wise=True,definedon=mesh.Materials(VARIABLE)) Ates = np.array(Ates) dJdrho = LinearForm(pwc) dJdrho.vec.FV().NumPy()[:] = Ates # ERROR, dimensions don't match Ates >> dJdrho
The previous code is a simplified one, I really need to convert the Integrate to a numpy array, I also really need to compress over the definition domain pwc. Also gfRho has a certain value I don’t show in the previous simplified code, but is also defined on pwc…
The question is : How can I “compress” the integrale on a specific domain, so that Ates and dJdrho can have the same size.
Thank you a lot !