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

Interpolator with ElementVector #973

Open
HelgeGehring opened this issue Nov 14, 2022 · 3 comments
Open

Interpolator with ElementVector #973

HelgeGehring opened this issue Nov 14, 2022 · 3 comments

Comments

@HelgeGehring
Copy link
Contributor

HelgeGehring commented Nov 14, 2022

import numpy as np
from skfem import *

mesh = MeshTri()
basis = Basis(mesh, ElementTriP1())
basis.interpolator(basis.zeros())(np.array([[[0, 0]]]).swapaxes(0, -1))

works, but

import numpy as np
from skfem import *

mesh = MeshTri()
basis = Basis(mesh, ElementVector(ElementTriP1()))
basis.interpolator(basis.zeros())(np.array([[[0, 0]]]).swapaxes(0, -1))

doesn't.

ValueError: row, column, and data array must all be the same length
@kinnala
Copy link
Owner

kinnala commented Nov 15, 2022

This should be fixed first:

basis.probes(np.array([[0], [0]]))

which leads to the same error.

@kinnala
Copy link
Owner

kinnala commented Nov 15, 2022

Obviously fixing this requires detection of the tensorial order of the field. This is kind of already done in Basis.refinterp by passing test values to Element.gbasis and checking the shape of the output. This should be moved to Basis._detect_tensor_order and used both in Basis.refinterp and Basis.probes.

Nevertheless, fixing this requires some thorough thinking how Basis.probes should be generalized. Since Basis.probes returns a matrix and the different elements in the range of the linear operator described by the matrix are already describing the different points passed to Basis.probes, perhaps Basis.probes needs to return multiple matrices instead?

@kinnala
Copy link
Owner

kinnala commented Nov 15, 2022

Another option is to use Basis._detect_tensor_order already in Basis.interpolator and skip the reuse of Basis.probes if the output of Basis._detect_tensor_order is higher than scalar field, and rely on a different implementation.

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