From b09aa85e5b4750aaa44261dfab98def15083709a Mon Sep 17 00:00:00 2001 From: janmodderman Date: Mon, 2 Dec 2024 10:21:14 +0100 Subject: [PATCH 1/3] add get_dof_value_type to FESpacesWithLinearConstraints --- src/FESpaces/FESpacesWithLinearConstraints.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FESpaces/FESpacesWithLinearConstraints.jl b/src/FESpaces/FESpacesWithLinearConstraints.jl index d89a98926..a1a5771fd 100644 --- a/src/FESpaces/FESpacesWithLinearConstraints.jl +++ b/src/FESpaces/FESpacesWithLinearConstraints.jl @@ -297,6 +297,8 @@ function get_fe_dof_basis(f::FESpaceWithLinearConstraints) get_fe_dof_basis(f.space) end +get_dof_value_type(f::FESpaceWithLinearConstraints) = get_dof_value_type(f.space) + get_dirichlet_dof_ids(f::FESpaceWithLinearConstraints) = Base.OneTo(length(f.mDOF_to_DOF) - f.n_fmdofs) num_dirichlet_tags(f::FESpaceWithLinearConstraints) = num_dirichlet_tags(f.space) From 7b5c91756977fd0e6f0742076b36e1c9ef972843 Mon Sep 17 00:00:00 2001 From: janmodderman Date: Mon, 2 Dec 2024 14:26:43 +0100 Subject: [PATCH 2/3] added reproduction file --- test/repro.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/repro.jl diff --git a/test/repro.jl b/test/repro.jl new file mode 100644 index 000000000..5b2822099 --- /dev/null +++ b/test/repro.jl @@ -0,0 +1,28 @@ +module reproduction_file +using Gridap +using Gridap.Geometry +using Gridap.TensorValues +using Gridap.Fields +using GridapEmbedded +using Gridap.Arrays +using Gridap.FESpaces + +model = CartesianDiscreteModel(Point(0.0, 0.0), Point(1.0, 1.0), (5,5)) +Ω = Interior(model) +dΩ = Measure(Ω,2) +geo = disk(0.1, x0=Point(0.5,0.5)) +cutgeo = cut(model, !geo) + +W1 = FESpace(Ω, ReferenceFE(lagrangian, Float64, 1), vector_type=Vector{ComplexF64}) +@show get_dof_value_type(W1) + +W2 = AgFEMSpace(W1,aggregate(AggregateCutCellsByThreshold(1.0), cutgeo, geo, OUT)) # AgFEMSpace returns a FESpaceWithLinearConstraints +@show get_dof_value_type(W2) +Φ = TrialFESpace(W2) +@show get_dof_value_type(Φ) + +a_wϕ(ϕ, w) = ∫( im*∇(ϕ)⋅∇(w) )dΩ # if we do NOT include the imaginary operator im here, then the code will pass, but the FE Spaces will be of type Float64 +A_wϕ1 = assemble_matrix(a_wϕ, Φ, W1) # function will NOT fail here, due to get_dof_value_type function being implemented +A_wϕ2 = assemble_matrix(a_wϕ, Φ, W2) # function will fail here, because W2 should be ComplexF64, but is Float64 due to missing get_dof_value_type function + +end # module \ No newline at end of file From 7a8e05dd21dd01613674989d863b956a52cc8b97 Mon Sep 17 00:00:00 2001 From: janmodderman Date: Mon, 2 Dec 2024 16:36:58 +0100 Subject: [PATCH 3/3] clean up for PR --- NEWS.md | 1 + .../FESpacesWithLinearConstraintsTests.jl | 11 ++++++++ test/repro.jl | 28 ------------------- 3 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 test/repro.jl diff --git a/NEWS.md b/NEWS.md index 7cbffd2b2..e9287dbdc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added get_dof_value_type for FESpacesWithLinearConstraints. Since PR[#1062](https://github.com/gridap/Gridap.jl/pull/1062). - Added Xiao-Gimbutas quadratures for simplices. Since PR[#1058](https://github.com/gridap/Gridap.jl/pull/1058). - Small improvements of the documentation of `Gridap.TensorValues`. Since PR[#1051](https://github.com/gridap/Gridap.jl/pull/1051). diff --git a/test/FESpacesTests/FESpacesWithLinearConstraintsTests.jl b/test/FESpacesTests/FESpacesWithLinearConstraintsTests.jl index 662e5f72b..fc5f6222d 100644 --- a/test/FESpacesTests/FESpacesWithLinearConstraintsTests.jl +++ b/test/FESpacesTests/FESpacesWithLinearConstraintsTests.jl @@ -90,4 +90,15 @@ tol = 1.e-9 @test e_l2 < tol @test e_h1 < tol +V2 = FESpace( + model,ReferenceFE(lagrangian,Float64,1), conformity=:H1, dirichlet_tags="dirichlet", vector_type=ComplexF64) + +Vc2 = FESpaceWithLinearConstraints( + sDOF_to_dof, + sDOF_to_dofs, + sDOF_to_coeffs, + V2) + +@test get_dof_value_type(Vc2) <: ComplexF64 + end # module diff --git a/test/repro.jl b/test/repro.jl deleted file mode 100644 index 5b2822099..000000000 --- a/test/repro.jl +++ /dev/null @@ -1,28 +0,0 @@ -module reproduction_file -using Gridap -using Gridap.Geometry -using Gridap.TensorValues -using Gridap.Fields -using GridapEmbedded -using Gridap.Arrays -using Gridap.FESpaces - -model = CartesianDiscreteModel(Point(0.0, 0.0), Point(1.0, 1.0), (5,5)) -Ω = Interior(model) -dΩ = Measure(Ω,2) -geo = disk(0.1, x0=Point(0.5,0.5)) -cutgeo = cut(model, !geo) - -W1 = FESpace(Ω, ReferenceFE(lagrangian, Float64, 1), vector_type=Vector{ComplexF64}) -@show get_dof_value_type(W1) - -W2 = AgFEMSpace(W1,aggregate(AggregateCutCellsByThreshold(1.0), cutgeo, geo, OUT)) # AgFEMSpace returns a FESpaceWithLinearConstraints -@show get_dof_value_type(W2) -Φ = TrialFESpace(W2) -@show get_dof_value_type(Φ) - -a_wϕ(ϕ, w) = ∫( im*∇(ϕ)⋅∇(w) )dΩ # if we do NOT include the imaginary operator im here, then the code will pass, but the FE Spaces will be of type Float64 -A_wϕ1 = assemble_matrix(a_wϕ, Φ, W1) # function will NOT fail here, due to get_dof_value_type function being implemented -A_wϕ2 = assemble_matrix(a_wϕ, Φ, W2) # function will fail here, because W2 should be ComplexF64, but is Float64 due to missing get_dof_value_type function - -end # module \ No newline at end of file