I've realized for this troubleshooting a simplified example, where I generate a 1D mesh corresponding to the radius of a circular section.
Then I've added the mim and I've calculated the corresponding area both analytically and numerically with asm_generic considering the axisymmetric configuration.
I removed convexes and points from the mesh with the del_convex and del_point methods and then I generated other elements on the same mesh object.
The numerical area calculation turns out to be wrong.
import getfem as gf
import numpy as np
RoundRadius=0.01
NumberOfElements = 5
nodes = np.arange(0, RoundRadius+RoundRadius/NumberOfElements, RoundRadius/NumberOfElements)
mesh = gf.Mesh("cartesian", nodes)
im_degree = 3
mim = gf.MeshIm(mesh, im_degree)
RoundSection = np.pi*R**2
RoundSection_asm = gf.asm_generic(mim, 0, '2*pi*X' , -1)
print ("STARTING AREA CALCULATION")
print ("analitical section =", RoundSection, "VS numerical section = ", RoundSection_asm)
# Change completely the mesh
mesh.del_convex(mesh.cvid())
mesh.del_point(mesh.pid())
NumberOfElements = 10
nodes = np.arange(0, RoundRadius+RoundRadius/NumberOfElements, RoundRadius/NumberOfElements)
mesh.add_point([nodes])
for x in range(NumberOfElements):
mesh.add_convex(gf.GeoTrans('GT_QK(1,1)'), [[nodes[x], nodes[x+1]]])
RoundSection_asm = gf.asm_generic(mim, 0, '2*pi*X' , -1)
print ("AREA CALCULATION AFTER MESH CHANGE")
print ("analytical section =", RoundSection, "VS numerical section = ", RoundSection_asm)
# Let's try to apply another mesh method
mesh.set_pts([nodes])
RoundSection_asm = gf.asm_generic(mim, 0, '2*pi*X' , -1)
print ("AREA CALCULATION AFTER MESH.SET_PTS METHOD")
print ("analytical section =", RoundSection, "VS numerical section = ", RoundSection_asm)