-
Notifications
You must be signed in to change notification settings - Fork 2
Include rotation matrix in cell values #25
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
Open
DRollin
wants to merge
8
commits into
main
Choose a base branch
from
dr/rotationmatrix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a4d0925
Include rotation matrix in cell values
DRollin 5038a6c
Update test/test_cellvalues.jl
DRollin 12349f7
Updated computation and test of R
DRollin aec6ee6
Minor improvement of tests
DRollin 3fb4172
fixed correct number of quad points
DRollin 580bdff
Fix function for line based interface and added tests for cv
DRollin 0e079b5
Switch from Bool to Val{} in cv constructors
DRollin 3e1d4f0
Merge main
KnutAM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,39 @@ | ||
| module FerriteInterfaceElements | ||
|
|
||
| import Ferrite | ||
| import Ferrite: AbstractCell, AbstractRefShape, AbstractCellValues, | ||
| import Ferrite: Ferrite, AbstractCell, AbstractRefShape, AbstractCellValues, | ||
| RefLine, RefQuadrilateral, RefTriangle, RefPrism, RefHexahedron, | ||
| Line, QuadraticLine, Triangle, QuadraticTriangle, Quadrilateral, QuadraticQuadrilateral, Tetrahedron, Hexahedron, | ||
| ScalarInterpolation, VectorizedInterpolation, Lagrange, | ||
| CellValues, QuadratureRule, CellCache, Grid, ExclusiveTopology, FacetIndex, Vec, | ||
| CellValues, QuadratureRule, CellCache, Grid, ExclusiveTopology, FacetIndex, Vec, Tensor, | ||
| getnbasefunctions, getngeobasefunctions, getorder, n_components, getrefshape, | ||
| vertexdof_indices, edgedof_interior_indices, facedof_interior_indices, volumedof_interior_indices, | ||
| vertices, facets, edges, | ||
| adjust_dofs_during_distribution, default_geometric_interpolation, geometric_interpolation, | ||
| checkbounds, checkquadpoint, function_value_init, function_gradient_init, | ||
| shape_value_type, shape_gradient_type, | ||
| reinit!, getnquadpoints, getdetJdV, shape_value, shape_gradient, function_value, function_gradient, | ||
| getcellset, getcells, getneighborhood | ||
| getcellset, getcells, getneighborhood, | ||
| ×, norm | ||
| import OrderedCollections: OrderedSet | ||
| import StaticArraysCore: SMatrix, SVector | ||
|
|
||
| include("cells.jl") | ||
| export InterfaceCell | ||
|
|
||
| include("interpolations.jl") | ||
| include("cellvalues.jl") | ||
| include("grid.jl") | ||
| export InterfaceCellInterpolation | ||
|
|
||
| export | ||
| InterfaceCell, | ||
| InterfaceCellInterpolation, | ||
| InterfaceCellValues, | ||
| include("cellvalues.jl") | ||
| export InterfaceCellValues, | ||
| get_side_and_baseindex, | ||
| shape_value_average, | ||
| shape_gradient_average, | ||
| shape_value_jump, | ||
| shape_gradient_jump, | ||
| function_value_average, | ||
| function_gradient_average, | ||
| function_value_jump, | ||
| function_gradient_jump, | ||
| getdetJdV_average, | ||
| insert_interfaces | ||
| shape_value_average, shape_gradient_average, | ||
| shape_value_jump, shape_gradient_jump, | ||
| function_value_average, function_gradient_average, | ||
| function_value_jump, function_gradient_jump, | ||
| midplane_rotation, | ||
| getdetJdV_average | ||
|
|
||
| include("grid.jl") | ||
| export insert_interfaces | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,73 @@ | ||
| @testset "InterfaceCellValues" begin | ||
| qr = QuadratureRule{RefTriangle}(1) | ||
| for (fip, gip) in ( (InterfaceCellInterpolation(Lagrange{RefTriangle, 1}()), InterfaceCellInterpolation(Lagrange{RefTriangle, 1}())), | ||
| (InterfaceCellInterpolation(Lagrange{RefTriangle, 2}()), InterfaceCellInterpolation(Lagrange{RefTriangle, 1}())), | ||
| (InterfaceCellInterpolation(Lagrange{RefTriangle, 1}()), InterfaceCellInterpolation(Lagrange{RefTriangle, 2}())), | ||
| (InterfaceCellInterpolation(Lagrange{RefTriangle, 2}()), InterfaceCellInterpolation(Lagrange{RefTriangle, 2}())), | ||
| ) | ||
| @test InterfaceCellValues(qr, fip, gip^3) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip^3, gip^3) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip^3, gip) isa InterfaceCellValues | ||
| qr = | ||
| for (refshape, dim, iporder, giporder) in ( | ||
| (RefTriangle, 3, 1, 1), (RefTriangle, 3, 1, 2), (RefTriangle, 3, 2, 1), (RefTriangle, 3, 2, 2), | ||
| (RefLine, 2, 1, 1), (RefLine, 2, 1, 2), (RefLine, 2, 2, 1), (RefLine, 2, 2, 2)) | ||
| qr = QuadratureRule{refshape}(2) | ||
| fip = InterfaceCellInterpolation(Lagrange{refshape, iporder}()) | ||
| gip = InterfaceCellInterpolation(Lagrange{refshape, giporder}()) | ||
| @test InterfaceCellValues(qr, fip, gip^dim) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip^dim, gip^dim) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip^dim, gip) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip, gip) isa InterfaceCellValues | ||
| @test InterfaceCellValues(Float32, qr, fip) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip) isa InterfaceCellValues | ||
| @test InterfaceCellValues(qr, fip; use_same_cv=false) isa InterfaceCellValues | ||
| end | ||
|
|
||
| ip = InterfaceCellInterpolation(Lagrange{RefTriangle, 1}()) | ||
| cv = InterfaceCellValues(qr, ip) | ||
| for (refshape, dim) in ((RefTriangle,3), (RefLine,2)) | ||
| qr = QuadratureRule{refshape}(2) | ||
| ip = InterfaceCellInterpolation(Lagrange{refshape, 1}()) | ||
| cv = InterfaceCellValues(qr, ip) | ||
|
|
||
| @test getnbasefunctions(cv) == 2*dim | ||
| @test Ferrite.getngeobasefunctions(cv) == 2*dim | ||
|
|
||
| x = repeat([rand(Vec{dim}) for _ in 1:dim], 2) | ||
| reinit!(cv, x) | ||
| nbf = getnbasefunctions(cv) | ||
| here, there = rand(2) | ||
| u = vcat(ones(nbf÷2).*here, ones(nbf÷2).*there) | ||
| for qp in 1:getnquadpoints(cv) | ||
| @test function_value(cv, qp, u, true) ≈ here | ||
| @test function_value(cv, qp, u, false) ≈ there | ||
| @test all(abs.(function_gradient(cv, qp, u, true)) .≤ 1e-14) | ||
| @test all(abs.(function_gradient(cv, qp, u, false)) .≤ 1e-14) | ||
| @test function_value_average(cv, qp, u) ≈ (here + there)/2 | ||
| @test function_value_jump(cv, qp, u) ≈ there - here | ||
| @test all(abs.(function_gradient_average(cv, qp, u)) .≤ 1e-14) | ||
| @test all(abs.(function_gradient_jump(cv, qp, u)) .≤ 1e-14) | ||
| @test getdetJdV_average(cv, qp) == (getdetJdV(cv.here, qp) + getdetJdV(cv.there, qp)) / 2 | ||
| end | ||
| end | ||
|
|
||
| @test getnbasefunctions(cv) == 6 | ||
| @test Ferrite.getngeobasefunctions(cv) == 6 | ||
| qr = QuadratureRule{RefTriangle}(2) | ||
| ip = InterfaceCellInterpolation(Lagrange{RefTriangle, 1}()) | ||
| cv = InterfaceCellValues(qr, ip; include_R=true) | ||
| x = repeat([Vec{3}((1.0,0.0,0.0)), Vec{3}((0.0,1.0,0.0)), Vec{3}((0.0,0.0,1.0))], 2) | ||
| n = Vec{3}(( sqrt(1/3), sqrt(1/3), sqrt(1/3))) | ||
| t₁ = Vec{3}(( sqrt(1/2), 0.0, -sqrt(1/2))) | ||
| t₂ = Vec{3}((-sqrt(1/6), 2*sqrt(1/6), -sqrt(1/6))) | ||
| reinit!(cv, x) | ||
| for qp in 1:getnquadpoints(cv) | ||
| R = midplane_rotation(cv, qp) | ||
| @test tdot(R) ≈ one(R) # Fails e.g. when dx/dξ₁ not perpendicular to dx/ξ₂ | ||
| @test R⋅Vec{3}((1.0,0.0,0.0)) ≈ t₁ | ||
| @test R⋅Vec{3}((0.0,1.0,0.0)) ≈ t₂ | ||
| @test R⋅Vec{3}((0.0,0.0,1.0)) ≈ n | ||
| end | ||
|
|
||
| x = repeat([rand(Vec{3}), rand(Vec{3}), rand(Vec{3})], 2) | ||
| qr = QuadratureRule{RefLine}(2) | ||
| ip = InterfaceCellInterpolation(Lagrange{RefLine, 1}()) | ||
| cv = InterfaceCellValues(qr, ip; include_R=true) | ||
| x = repeat([Vec{2}((1.0,0.0)), Vec{2}((0.0,1.0))], 2) | ||
| n = Vec{2}((-sqrt(1/2), -sqrt(1/2))) | ||
| t = Vec{2}((-sqrt(1/2), sqrt(1/2))) | ||
| reinit!(cv, x) | ||
| nbf = getnbasefunctions(cv) | ||
| here, there = rand(2) | ||
| u = vcat(ones(nbf÷2).*here, ones(nbf÷2).*there) | ||
| for qp in 1:getnquadpoints(cv) | ||
| @test function_value(cv, qp, u, true) ≈ here | ||
| @test function_value(cv, qp, u, false) ≈ there | ||
| @test all(abs.(function_gradient(cv, qp, u, true)) .≤ 1e-14) | ||
| @test all(abs.(function_gradient(cv, qp, u, false)) .≤ 1e-14) | ||
| @test function_value_average(cv, qp, u) ≈ (here + there)/2 | ||
| @test function_value_jump(cv, qp, u) ≈ there - here | ||
| @test all(abs.(function_gradient_average(cv, qp, u)) .≤ 1e-14) | ||
| @test all(abs.(function_gradient_jump(cv, qp, u)) .≤ 1e-14) | ||
| @test getdetJdV_average(cv, qp) == (getdetJdV(cv.here, qp) + getdetJdV(cv.there, qp)) / 2 | ||
| R = midplane_rotation(cv, qp) | ||
| @test tdot(R) ≈ one(R) # Fails e.g. when dx/dξ₁ not perpendicular to dx/ξ₂ | ||
| @test R⋅Vec{2}((1.0,0.0)) ≈ t | ||
| @test R⋅Vec{2}((0.0,1.0)) ≈ n | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I could use some help defining a proper test case...
Not sure if the current one is fine.