-
Notifications
You must be signed in to change notification settings - Fork 82
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 slow for Hex1 #282
Comments
try reducing integration order. default might be too high for most use
cases.
|
Good idea. I'll start with that on Monday. |
That helps a bit, but even in reducing to |
The issue isn't strictly just
|
Is this line the culprit?
https://github.com/kinnala/scikit-fem/blob/48c836cd1dafcba54086428fad214f5f65083076/skfem/assembly/global_basis/interior_basis.py#L95
Could look into the possibility of parallelizing it. Not sure yet how that
would happen.
|
Yes. cProfile reveals that the issue is Of the 95.0 s to build the hexahedral |
This Jacobian:
https://github.com/kinnala/scikit-fem/blob/48c836cd1dafcba54086428fad214f5f65083076/skfem/mapping/mapping_isoparametric.py#L65
is necessarily more complicated than in affine case because it depends on
the quadrature point location on the reference element. Maybe there is room
for optimization though.
|
Yes. This is 431 calls to I wonder whether the values returned by J can be cached? That is, the values of the Jacobian on the quadrature points. |
Good idea.
I was just looking at this:
https://github.com/kinnala/scikit-fem/blob/48c836cd1dafcba54086428fad214f5f65083076/skfem/mapping/mapping_isoparametric.py#L181
Same parameters get called over and over again.
|
I'm looking into whether it would be possible to use |
Or since with
something like np.linalg.inv(jac.transpose(2, 3, 0, 1)).transpose(2, 3, 0, 1) |
That's (a7a129f) much more concise for It also fails six tests! |
Another permutation of the retranposition (be1e652) worked better. (Passing the tests, not speeding anything). |
The vectorized version also has the advantage of being independent of |
Great. Let's dig further into it. It seems to me also that both of these |
Unfortunately the vectorized reimplementation be1e652 of
This is despite the time spent in |
It seems that for most of the common cases, all the rows of |
…in the scalar case, by which I mean, e.g. all(np.allclose(ex01.basis.basis[i][0], ex01.e.lbasis(ex01.basis.X, i)[0]) for i in range(ex01.basis.Nbfun)) |
…even when the mapping is isoparametric and the elements aren't congruent, e.g. an irregular all(np.allclose(ex17.basis.basis[i][0],
ex17.element.lbasis(ex17.basis.X, i)[0])
for i in range(ex17.basis.Nbfun)) |
Ah, I see, this is expected and elegantly handled by the use of scikit-fem/skfem/element/element_h1.py Lines 11 to 16 in 48c836c
|
Ha, yes, it's much better. My ‘optimization’ though not ugly made the code slower. This looks like roughly a factor of ten faster than master. I had been hoping to exploit the redundancy of |
While working with
MeshHex
on #279 and #281, I noticed thatInteriorBasis
seemed slow forMeshHex
andElementHex1
.I solved a Laplace equation (like ex13) and this was the bottleneck; e.g. for
mesh.p.shape[1] == basis.N == 34001
:load
: 0.6 sInteriorBasis
: 82.5 sasm
: 8.2spyamgcl.amgcl
)solver_iter_pcg
)So the algebraic multigrid #264 is great and assembly is O. K. but building the basis is slow.
I've started to quantify this by comparing the time for
InteriorBasis
withMeshTet
andElementTetP1
using.init_tensor
with the same points (and so samebasis.N
but with five times as many tetrahedral elements).The hexahedral case is a hundred times slower.
The text was updated successfully, but these errors were encountered: