question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indexing error in find_dofs

See original GitHub issue

Hi,

first off, great library: Indeed fills an important niche, thanks for creating!

While using it, being new to finite element methods, I have encountered an error that I am not sure how to fix (whether it’s a wrong use on my end or a problem with the code). When trying to implement Dirichlet boundary conditions (following example 14) in a MeshTet, I am encountering a numpy indexing error.

My script condenses to the following:

m = MeshTet3D(p=some_nodes, t=some_elements, boundaries=some_boundaries)
e = ElementTetP1()
basis = InteriorBasis(m, e)
surface_basis = FacetBasis(m, e, facets=m.boundaries["top"])
surface_dofs = surface_basis.find_dofs()['all'].all()

The boundaries dict contains, among others, an array of faces belonging to the top side. Things run smoothly up to the surface_basis.find_dofs() call, where the following error is raised:

~/.local/lib/python3.8/site-packages/skfem/mesh/mesh3d/mesh3d.py in boundary_edges(self)
     39                               facets]))
     40                    for itr in range(self.facets.shape[0])])).T, axis=1)
---> 41         return np.nonzero((self.edges.T[:, None] == boundary_edges)
     42                           .all(-1).any(-1))[0]
     43 
AttributeError: 'bool' object has no attribute 'all'

The error occurs because the shapes of self.edges.T[:,None], (180751, 1, 2), and boundary_edges, (107076, 2), do not match for an elementwise comparison. From a quick skim of the code, I assume that some sort of element comparison is taking place in that function, but I am not sure about that (without some in depth study of the source). I thought to open this issue because maybe there is something fundamentally wrong in my code snipped above and I hope it’s not too stupid, or otherwise it might be a bug.

Thanks in advance, Malte

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
kinnalacommented, Sep 30, 2020
1reaction
kinnalacommented, Sep 30, 2020

Since you are using linear elements, as a workaround you should be able to dig those DOF-numbers directly from the mesh structure. E.g., if you are assembling only scalar problems, just use the indices boundary_dofs = m.boundary_nodes().

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing Index Error: "Can not search: Exception occurred while ...
First Solution: · Open "Settings" top menu near the Asset Navigator · Click "Indexing" from left menu · Click "Delete all indexes and...
Read more >
Indexing Error on comparing two Dataframes - Stack Overflow
I am comparing column of 1 data frame with another and getting an Indexing Error. My Code: ##For reading and re-setting index df1 ......
Read more >
What Causes Indexing Errors? - SearchStax Docs
Indexing errors are caused by a mismatch between schema and data.
Read more >
Indexing error when run migration again · Issue #6873 - GitHub
Bug description When I create a new migration I get this Error message Error: Database error Error querying the database: Server error: ...
Read more >
How to identify the root cause of indexing errors 1422, 17630 ...
Releases prior to OpenEdge 11.4 report error 1422, starting with OpenEdge 11.4, 17630 is reported instead. These errors are equivalent: SYSTEM ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found