From 4fbb97eb664f9fbc8e70a7c8666a0f1e09eab12d Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Tue, 21 Nov 2023 23:35:36 +1100 Subject: [PATCH 1/4] Added missing API --- src/FESpaces.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/FESpaces.jl b/src/FESpaces.jl index 21aedf42..5d4fdcd4 100644 --- a/src/FESpaces.jl +++ b/src/FESpaces.jl @@ -293,6 +293,18 @@ function FESpaces.get_free_dof_ids(fs::DistributedSingleFieldFESpace) fs.gids end +function FESpaces.get_dof_value_type(cell_shapefuns::DistributedCellField,cell_dof_basis::DistributedCellDof) + vt = map(local_views(cell_shapefuns),local_views(cell_dof_basis)) do cell_shapefuns, cell_dof_basis + FESpaces.get_dof_value_type(cell_shapefuns,cell_dof_basis) + end + # Jordi: is this always consistent between processors? It should, I think... + return PartitionedArrays.getany(vt) +end + +function FESpaces.ConstraintStyle(::Type{<:DistributedSingleFieldFESpace{A}}) where A + return FESpaces.ConstraintStyle(eltype(A)) +end + function FESpaces.get_dirichlet_dof_values(U::DistributedSingleFieldFESpace) map(get_dirichlet_dof_values,U.spaces) end From b6d394a81d96dd4a1997135a979b26876c3c983f Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Wed, 22 Nov 2023 23:12:23 +1100 Subject: [PATCH 2/4] Added missing dispatches --- src/TransientDistributedCellField.jl | 6 +++ test/myTests.jl | 72 ++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 test/myTests.jl diff --git a/src/TransientDistributedCellField.jl b/src/TransientDistributedCellField.jl index 9f0d3ef9..8934f40f 100644 --- a/src/TransientDistributedCellField.jl +++ b/src/TransientDistributedCellField.jl @@ -70,6 +70,12 @@ outer(::typeof(∇),f::TransientDistributedCellField) = outer(∇,f.cellfield) outer(f::TransientDistributedCellField,::typeof(∇)) = outer(f.cellfield,∇) cross(::typeof(∇),f::TransientDistributedCellField) = cross(∇,f.cellfield) +Gridap.Arrays.evaluate!(cache,k::Operation,a::TransientDistributedCellField,b::DistributedCellField) = evaluate!(cache,k,a.cellfield,b) +Gridap.Arrays.evaluate!(cache,k::Operation,a::DistributedCellField,b::TransientDistributedCellField) = evaluate!(cache,k,a,b.cellfield) + +Base.:(∘)(f::Function,g::Tuple{TransientDistributedCellField,DistributedCellField}) = Operation(f)(g[1],g[2]) +Base.:(∘)(f::Function,g::Tuple{DistributedCellField,TransientDistributedCellField}) = Operation(f)(g[1],g[2]) + # Skeleton related function Base.getproperty(f::TransientDistributedCellField, sym::Symbol) if sym in (:⁺,:plus,:⁻, :minus) diff --git a/test/myTests.jl b/test/myTests.jl new file mode 100644 index 00000000..fcec4ad7 --- /dev/null +++ b/test/myTests.jl @@ -0,0 +1,72 @@ + +using Gridap +using GridapDistributed +using PartitionedArrays + +np = (2,2) +ranks = with_debug() do distribute + distribute(LinearIndices((prod(np),))) +end + + +n = 50 +domain = (0,1,0,1) +partition = (n,n) +model = CartesianDiscreteModel(ranks,np,domain,partition) + +labels = get_face_labeling(model); +add_tag_from_tags!(labels,"diri0",[6,]) +add_tag_from_tags!(labels,"diri1",[1,2,3,4,5,7,8]) + +order = 2 +reffeᵤ = ReferenceFE(lagrangian,VectorValue{2,Float64},order) +reffeₚ = ReferenceFE(lagrangian,Float64,order-1) + +V = TestFESpace(model,reffeᵤ,conformity=:H1,dirichlet_tags=["diri0","diri1"]) +Q = TestFESpace(model,reffeₚ,conformity=:H1,constraint=:zeromean) + +u0(x,t::Real) = t*VectorValue(1,0) +u0(t::Real) = x -> u0(x,t) + +u1(x,t::Real) = VectorValue(0.0,0.0) +u1(t::Real) = x -> u1(x,t) + +U = TransientTrialFESpace(V,[u0,u1]) +P = TrialFESpace(Q) + +Y = MultiFieldFESpace([V, Q]) +X = TransientMultiFieldFESpace([U, P]) + +degree = 2*order +Ω = Triangulation(model) +dΩ = Measure(Ω,degree) + +f = VectorValue(0.0,0.0) + +m(t,(ut,p),(v,q)) = ∫( ut⋅v )*dΩ +a(t,(u,p),(v,q)) = ∫( ∇(u)⊙∇(v) - (∇⋅v)*p + q*(∇⋅u) )*dΩ +b(t,(v,q)) = ∫( f⋅v )*dΩ + +op = TransientAffineFEOperator(m,a,b,X,Y) + +dt = 0.1 +θ = 0.5 +ode_solver = ThetaMethod(LUSolver(),dt,θ) + +a₀((u,p),(v,q)) = a(0.0,(u,p),(v,q)) +b₀((v,q)) = b(0.0,(v,q)) +op₀ = AffineFEOperator(a₀,b₀,X(0.0),Y) +u₀, p₀ = solve(op₀) + +x₀ = interpolate_everywhere([u₀,p₀],X(0.0)) +t₀ = 0.0 +T = 1.0 +xₕₜ = solve(ode_solver,op,x₀,t₀,T) + +dir = "output/stokes" +!isdir(dir) && mkdir(dir) +for (xₕ,t) in xₕₜ + (uₕ,pₕ) = xₕ + file = "output/tmp_stokes_transient_$t.vtu" + createvtk(Ω,file,cellfields=["uh"=>uₕ,"ph"=>pₕ]) +end From bb4d7bfb919c9d1b0d4a630c6595fd0b134fbaa9 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Wed, 22 Nov 2023 23:17:12 +1100 Subject: [PATCH 3/4] Updated NEWS.md --- NEWS.md | 6 +++++ src/FESpaces.jl | 1 - test/myTests.jl | 72 ------------------------------------------------- 3 files changed, 6 insertions(+), 73 deletions(-) delete mode 100644 test/myTests.jl diff --git a/NEWS.md b/NEWS.md index de1701d0..7b2810bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.3] - 2023-11-22 + +### Added + +- Added missing methods for `DistributedTransientFESpace`s. Since [PR 135](https://github.com/gridap/GridapDistributed.jl/pull/135). + ## [0.3.2] - 2023-11-01 ### Added diff --git a/src/FESpaces.jl b/src/FESpaces.jl index 5d4fdcd4..cd922ddd 100644 --- a/src/FESpaces.jl +++ b/src/FESpaces.jl @@ -297,7 +297,6 @@ function FESpaces.get_dof_value_type(cell_shapefuns::DistributedCellField,cell_d vt = map(local_views(cell_shapefuns),local_views(cell_dof_basis)) do cell_shapefuns, cell_dof_basis FESpaces.get_dof_value_type(cell_shapefuns,cell_dof_basis) end - # Jordi: is this always consistent between processors? It should, I think... return PartitionedArrays.getany(vt) end diff --git a/test/myTests.jl b/test/myTests.jl deleted file mode 100644 index fcec4ad7..00000000 --- a/test/myTests.jl +++ /dev/null @@ -1,72 +0,0 @@ - -using Gridap -using GridapDistributed -using PartitionedArrays - -np = (2,2) -ranks = with_debug() do distribute - distribute(LinearIndices((prod(np),))) -end - - -n = 50 -domain = (0,1,0,1) -partition = (n,n) -model = CartesianDiscreteModel(ranks,np,domain,partition) - -labels = get_face_labeling(model); -add_tag_from_tags!(labels,"diri0",[6,]) -add_tag_from_tags!(labels,"diri1",[1,2,3,4,5,7,8]) - -order = 2 -reffeᵤ = ReferenceFE(lagrangian,VectorValue{2,Float64},order) -reffeₚ = ReferenceFE(lagrangian,Float64,order-1) - -V = TestFESpace(model,reffeᵤ,conformity=:H1,dirichlet_tags=["diri0","diri1"]) -Q = TestFESpace(model,reffeₚ,conformity=:H1,constraint=:zeromean) - -u0(x,t::Real) = t*VectorValue(1,0) -u0(t::Real) = x -> u0(x,t) - -u1(x,t::Real) = VectorValue(0.0,0.0) -u1(t::Real) = x -> u1(x,t) - -U = TransientTrialFESpace(V,[u0,u1]) -P = TrialFESpace(Q) - -Y = MultiFieldFESpace([V, Q]) -X = TransientMultiFieldFESpace([U, P]) - -degree = 2*order -Ω = Triangulation(model) -dΩ = Measure(Ω,degree) - -f = VectorValue(0.0,0.0) - -m(t,(ut,p),(v,q)) = ∫( ut⋅v )*dΩ -a(t,(u,p),(v,q)) = ∫( ∇(u)⊙∇(v) - (∇⋅v)*p + q*(∇⋅u) )*dΩ -b(t,(v,q)) = ∫( f⋅v )*dΩ - -op = TransientAffineFEOperator(m,a,b,X,Y) - -dt = 0.1 -θ = 0.5 -ode_solver = ThetaMethod(LUSolver(),dt,θ) - -a₀((u,p),(v,q)) = a(0.0,(u,p),(v,q)) -b₀((v,q)) = b(0.0,(v,q)) -op₀ = AffineFEOperator(a₀,b₀,X(0.0),Y) -u₀, p₀ = solve(op₀) - -x₀ = interpolate_everywhere([u₀,p₀],X(0.0)) -t₀ = 0.0 -T = 1.0 -xₕₜ = solve(ode_solver,op,x₀,t₀,T) - -dir = "output/stokes" -!isdir(dir) && mkdir(dir) -for (xₕ,t) in xₕₜ - (uₕ,pₕ) = xₕ - file = "output/tmp_stokes_transient_$t.vtu" - createvtk(Ω,file,cellfields=["uh"=>uₕ,"ph"=>pₕ]) -end From 0c9e891672083a38806d1ee3bb5fcca9c0106a7f Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Wed, 22 Nov 2023 23:18:05 +1100 Subject: [PATCH 4/4] Bump up to version 0.3.3 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a0335d83..57f9a3b1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GridapDistributed" uuid = "f9701e48-63b3-45aa-9a63-9bc6c271f355" authors = ["S. Badia ", "A. F. Martin ", "F. Verdugo "] -version = "0.3.2" +version = "0.3.3" [deps] BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"