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

Interpolating Basis with ElementComposite fails #870

Closed
kinnala opened this issue Jan 28, 2022 · 1 comment · Fixed by #865
Closed

Interpolating Basis with ElementComposite fails #870

kinnala opened this issue Jan 28, 2022 · 1 comment · Fixed by #865
Labels

Comments

@kinnala
Copy link
Owner

kinnala commented Jan 28, 2022

Only the first component is interpolated; remaining components seem to be ignored.

MWE:

In [1]: from skfem import *                                                                      

In [2]: m = MeshTri()                                                                            

In [3]: basis = Basis(m, ElementTriP1() * ElementTriP1())                                        

In [4]: y = basis.zeros()                                                                        

In [5]: basis.interpolate(y)                                                                     
Out[5]: 
(<skfem DiscreteField object>
   Quadrature points per element: 6
   Number of elements: 2
   Order: 0
   Attributes: grad,
 <skfem DiscreteField object>)

Observe how the second component is empty DiscreteField.

@kinnala kinnala added the bug label Jan 28, 2022
@kinnala kinnala changed the title Interpolating Basis based on ElementComposite fails Interpolating Basis with ElementComposite fails Jan 28, 2022
@kinnala
Copy link
Owner Author

kinnala commented Jan 28, 2022

Due to my laziness, this is also being addressed in #865. This seems to be the fix:

@@ -283,12 +283,12 @@ class AbstractBasis:
         if w.shape[0] != self.N:
             raise ValueError("Input array has wrong size.")
 
-        refs = self.basis[0]
+        refs = self.split(w)
         dfs: List[DiscreteField] = []
 
         # loop over solution components
         for c in range(len(refs)):
-            ref = refs[c]
+            ref = refs[c][1].basis[0][0]
             if ref.is_zero():
                 dfs.append(ref)
                 continue
                 ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant