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

InteriorBasis raises IndexError on MeshLine loaded from MSH #178

Closed
gdmcbain opened this issue May 8, 2019 · 8 comments
Closed

InteriorBasis raises IndexError on MeshLine loaded from MSH #178

gdmcbain opened this issue May 8, 2019 · 8 comments

Comments

@gdmcbain
Copy link
Contributor

gdmcbain commented May 8, 2019

Following #175, another problem is that InteriorBasis(mesh, ElementLineP1()) raises

IndexError: index 2 is out of bounds for axis 0 with size 2

if mesh is loaded from a Gmsh file:

mesh = MeshLine.load(argv[1])

Example: example.tar.gz, where:

  • line.geo:
Point(1) = {0, 0, 0};
Point(2) = {1, 0, 0};
Line(1) = {1, 2};
Physical Point("left") = {1};
Physical Point("right") = {2};
Physical Curve("domain") = {1};

(The same error is raised without the Physical entities too.)

  • line.py
mesh = MeshLine.load(argv[1])
element = ElementLineP1()
basis = InteriorBasis(mesh, element)
@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 8, 2019

The same error is raised with just

mesh.mapping()

@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 8, 2019

Or MappingAffine(mesh).

@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 8, 2019

It looks like the problem is that mesh.p.shape[0] == 3 so that we've gotten redundant zeros for mesh.p[1:].

Is the error upstream in meshio or here in skfem.Mesh in load or from_meshio?

Does the same problem affect two-dimensional meshes? Gmsh always uses three-dimensional coordinates for nodes and I think these are passed on by meshio.read.

@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 9, 2019

I had thought to use Mesh.dim to strip the trailing coordinates but I see that it's defined a posteriori in terms of Mesh.p.shape.

def dim(self):
"""Return the spatial dimension of the mesh."""
return int(self.p.shape[0])

Would it be reasonable to define it as an a priori class variable, dim = 1 for MeshLine, 2 for Mesh2D and 3 for Mesh3D?

@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 9, 2019

Neither can something like

isinstance(cls, MeshLine)

be used in Mesh.from_meshio since MeshLine isn't defined at that point (similarly for Mesh2D).

@gdmcbain
Copy link
Contributor Author

gdmcbain commented May 9, 2019

Ah: it was just that MeshLine doesn't override Mesh.strip_extra_coordinates as Mesh2D does.

@kinnala
Copy link
Owner

kinnala commented May 19, 2019

I suppose this can be closed now?

@kinnala kinnala closed this as completed May 19, 2019
@gdmcbain
Copy link
Contributor Author

Yes, thanks; this was fixed by 9036ffd which was included in #176.

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

2 participants