-
Notifications
You must be signed in to change notification settings - Fork 62
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
VectorPyCoefficent invalid size causing crash #186
Comments
This now seems to be a problem with my original I generate meshes on I have a python script that changes a few lines to change where the boundary is, which seems to work fine and renders in |
Hm, I am noticing I need to add a Error
But I also get intermittent errors such as,
Strain class StrainVectorCoefficient(mfem.VectorPyCoefficient):
def __init__(
self,
dim: int):
super(StrainVectorCoefficient, self).__init__(dim)
self.dim = dim
self.u = None # displacement GridFunction
self.grad = mfem.DenseMatrix()
def SetDisplacement(self, u: mfem.GridFunction):
self.u = u
def Eval(
self, v: mfem.Vector,
T: mfem.ElementTransformation,
ip: mfem.IntegrationPoint) -> None:
self.u.GetVectorGradient(T, self.grad)
self.grad.Symmetrize()
size = self.grad.Size()
# Set the principle strains xx, yy, zz, xy, xz, yz
if size == 2:
v[0] = self.grad[0, 0]
v[1] = self.grad[1, 1]
v[2] = self.grad[0, 1]
elif size == 3:
v[0] = self.grad[0, 0]
v[1] = self.grad[1, 1]
v[2] = self.grad[2, 2]
v[3] = self.grad[0, 1]
v[4] = self.grad[0, 2]
v[5] = self.grad[1, 2]
return v
def get_xyz(c, mesh, gf):
_, elem_ids, ips = mesh.FindPoints([c])
c = [gf.GetValue(elem_ids[0], ips[0], i) for i in range(4)]
return c
dim = 3
strain_coef = StrainVectorCoefficient(dim)
strain_coef.SetDisplacement(x)
vector_space = mfem.FiniteElementSpace(mesh, fec, dim)
strain = mfem.GridFunction(vector_space)
strain.ProjectCoefficient(strain_coef)
print("data")
# WARN: if sleep is lower than 3 it crashes prematurely
sleep(5)
print("Strain", get_xyz((10, 0, 5), mesh, strain))
# NOTE: Complains about destructors missing
del strain
del strain_coef The original issue is still present with |
Hi @ddkn,. |
Hi @sshiraiwa, sorry for getting back late, grad school has been a bit chaotic. Here is an example with a script, and GMSH geofile and msh, example.zip. The One issue I discovered, is if I try to measure a spot that does not exist, the system crashes. I would likely need to implement some interpolation. The strain vector should work now. I did notice that small changes in the mesh generation can wildly change the element number. As of now I would say being able to render via Thanks again for taking your time to help me out! |
Hello everyone,
I was too quick to praise success in Issue 184 with
I have now created a stress vector coefficient as such
The program only runs for a few iterations printing out
Meaning at some point it fails to get the
self.sigma.Size()
, the output from the console is thisIt can also read
realloc(): invalid next size
. Has anyone else dealt with this issue? For context in my other issue I calculate strain similarly but only do this and it works fine :/, the same model, everythingThe text was updated successfully, but these errors were encountered: