-
Notifications
You must be signed in to change notification settings - Fork 93
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
More flexibility for internal types #802
Conversation
… in the constraint handler.
Nice! Ferrite.jl/src/interpolations.jl Line 535 in 383c0c5
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #802 +/- ##
==========================================
- Coverage 93.28% 93.28% -0.01%
==========================================
Files 36 36
Lines 5228 5224 -4
==========================================
- Hits 4877 4873 -4
Misses 351 351 ☔ View full report in Codecov by Sentry. |
Yea, this is why I have left it as a draft. I am not sure how to resolve this one properly, because there are several possibilities. First, we could make the value type part of e.g. the Lagrange struct parametrization. On the other hand, we also might be able to have extra dispatches on e.g. |
I think in most cases it should be as simple as function shape_value(ip::Lagrange{RefQuadrilateral, 1}, ξ::Vec{2}, i::Int)
ξ_x = ξ[1]
ξ_y = ξ[2]
i == 1 && return (1 - ξ_x) * (1 - ξ_y) * 0.25
i == 2 && return (1 + ξ_x) * (1 - ξ_y) * 0.25
i == 3 && return (1 + ξ_x) * (1 + ξ_y) * 0.25
i == 4 && return (1 - ξ_x) * (1 + ξ_y) * 0.25
throw(ArgumentError("no shape function $i for interpolation $ip"))
end to function shape_value(ip::Lagrange{RefQuadrilateral, 1}, ξ::Vec{2,T}, i::Int) where T
ξ_x = ξ[1]
ξ_y = ξ[2]
i == 1 && return (oneunit(T) - ξ_x) * (oneunit(T) - ξ_y) / 4
i == 2 && return (oneunit(T) + ξ_x) * (oneunit(T) - ξ_y) / 4
i == 3 && return (oneunit(T) + ξ_x) * (oneunit(T) + ξ_y) / 4
i == 4 && return (oneunit(T) - ξ_x) * (oneunit(T) + ξ_y) / 4
throw(ArgumentError("no shape function $i for interpolation $ip"))
end (I suppose this is what you meant with the body, but left it here anyways) If supplied a quadrature rule with the correct precision/type of the xi-coordinates, I suppose it should work? But there are probably more entry points in some cases, such as the reference coordinates when using BCValues for Dirichlet boundary conditions. |
Okay, this took longer than it should have taken. :D Interestingly 1 seems to work fine. |
Following the suggestion by Knut in #766 (comment) I also included a change from ArgumentError to BoundsError for interpolations (which might fix the issue in the linked PR). |
Using |
I think this is still interesting to explore. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Quite a lot of detailed changes!
I've tried to go through carefully but especially in the ConstraintHandler, there seem to be several possibilities for Float64
to sneak in.
Not sure if it is necessary to prevent this as long as (a) we have type-stable code and (2) the output types are the correct types. I guess further improvements can be done in the GPU PR if issues arise with internal Float64
then?
In addition to the JET testing, it would be nice to have a few @btime
comparisons with master for usages of the ConstraintHandler
with Float64
.
For example
close!
update!
apply!
- Creation of periodic boundary conditions
Where the 3 first are done for cases including affine constraints to avoid any regressions here. This could also, in addition, be tested with JET, if possible.
Thanks for the detailed review!
I think I would like to fix such issues in this PR.
shows only a difference in the ctor. |
So I guess #818 precedes this. :D |
5106076
to
0abbece
Compare
Co-authored-by: Fredrik Ekre <[email protected]>
c99454c
to
09d5bee
Compare
This PR fixes two weakly related things.
First, it allows to actually pass the matrix type into the sparsity pattern constructor. Currently only SparseMatrixCSC with element type of Float64 was allowed. Now we can also use different element types. Other matrix types are not yet implemented and up to future PRs (also related to FerriteDistributed.jl).
The second thing is that at some code points we fixed the data types to Float64. This constraint has also been removed, allowing e.g. the usage of Float32. This change also opens the possibility to implement an example of a complex-valued problem (e.g. Schrödinger problem).
This PR precedes #766 , because it can be useful to use lower precision on the GPU, e.g. to increase throughput and because not every GPU has dedicated Float64 units.
Closes #195 .