From 0b95e0f673906abafbf38583d5da28f96bc5b6e4 Mon Sep 17 00:00:00 2001 From: amartin Date: Wed, 16 Sep 2020 18:39:37 +1000 Subject: [PATCH] Adapted ZeroMeanDistributedFESpaces to latest changes in Gridap.master --- Manifest.toml | 12 +++---- src/ZeroMeanDistributedFESpaces.jl | 29 ++++++++++------ test/DistributedStokesTests.jl | 56 ++++++++++++++---------------- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index bfab8f83..b6fa951a 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -14,9 +14,9 @@ version = "2.12.0" [[ArrayLayouts]] deps = ["FillArrays", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "e3e0a1e7dcbfdb1fc1061bfd889581a1d942cfcb" +git-tree-sha1 = "bd09f450716f55c5a47b24de277a8825e2450729" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" -version = "0.4.5" +version = "0.4.7" [[BSON]] git-tree-sha1 = "dd36d7cf3d185eeaaf64db902c15174b22f5dafb" @@ -135,8 +135,8 @@ version = "0.10.12" [[Gridap]] deps = ["AbstractTrees", "BSON", "BlockArrays", "Combinatorics", "DocStringExtensions", "FastGaussQuadrature", "FileIO", "FillArrays", "ForwardDiff", "JLD2", "JSON", "LineSearches", "LinearAlgebra", "NLsolve", "QuadGK", "SparseArrays", "StaticArrays", "Test", "WriteVTK"] -git-tree-sha1 = "7838554a8092b4e69042be94639f0276a55f3ecb" -repo-rev = "fe_space_with_dof_potentially_removed" +git-tree-sha1 = "d5470611f212c4ca8feda47b384ecda3cd8ec5b6" +repo-rev = "master" repo-url = "https://github.com/gridap/Gridap.jl" uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e" version = "0.14.0" @@ -153,9 +153,9 @@ version = "0.1.14" [[JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e" +git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.0" +version = "0.21.1" [[LibGit2]] deps = ["Printf"] diff --git a/src/ZeroMeanDistributedFESpaces.jl b/src/ZeroMeanDistributedFESpaces.jl index 2221d9b6..c0284132 100644 --- a/src/ZeroMeanDistributedFESpaces.jl +++ b/src/ZeroMeanDistributedFESpaces.jl @@ -49,14 +49,14 @@ end function _generate_zero_mean_funs(dV::ZeroMeanDistributedFESpace, funs) dpartial_sums_fixed_val= DistributedData(dV.spaces, funs, dV.vol_i, dV.vol) do part, V, fun, vol_i, vol - if (get_val_parameter(V.remove_dof)) + if (constant_fixed(V)) fv=get_free_values(fun) dv=get_dirichlet_values(fun) c=Gridap.FESpaces._compute_new_fixedval(fv, dv, vol_i, vol, - V.dof_to_remove) + V.dof_to_fix) else fv=get_free_values(fun) c=-dot(fv,vol_i)/vol @@ -72,7 +72,7 @@ function _generate_zero_mean_funs(dV::ZeroMeanDistributedFESpace, funs) dfuns = DistributedData(dV.spaces, funs, dfixed_val) do part, V, fun, fixed_val free_values=get_free_values(fun) fv=apply(+,free_values, Fill(fixed_val,length(free_values))) - if (get_val_parameter(V.remove_dof)) + if (constant_fixed(V)) dirichlet_values=get_dirichlet_values(fun) dv = dirichlet_values .+ fixed_val return FEFunction(V,fv,dv) @@ -82,6 +82,15 @@ function _generate_zero_mean_funs(dV::ZeroMeanDistributedFESpace, funs) end end +function constant_fixed(V::FESpaceWithConstantFixed{CS,Gridap.FESpaces.FixConstant}) where {CS} + true +end + +function constant_fixed(V::FESpaceWithConstantFixed{CS,CA}) where {CS,CA} + false +end + + function ZeroMeanDistributedFESpace(::Type{V}; model::DistributedDiscreteModel, kwargs...) where V @@ -93,17 +102,17 @@ function ZeroMeanDistributedFESpace(::Type{V}; comm = get_comm(model) spaces = DistributedData(init_local_spaces,comm,model.models) - dof_lid_to_remove = _compute_dof_lid_to_remove(model,spaces) + dof_lid_to_fix = _compute_dof_lid_to_fix(model,spaces) - function init_local_spaces_with_dof_removed(part,lspace,dof_lid_to_remove) - Gridap.FESpaces.FESpaceWithDofPotentiallyRemoved( - lspace, dof_lid_to_remove != -1, dof_lid_to_remove) + function init_local_spaces_with_dof_removed(part,lspace,dof_lid_to_fix) + Gridap.FESpaces.FESpaceWithConstantFixed( + lspace, dof_lid_to_fix != -1, dof_lid_to_fix) end spaces_dof_removed = DistributedData(init_local_spaces_with_dof_removed, comm, spaces, - dof_lid_to_remove) + dof_lid_to_fix) order=Gridap.FESpaces._get_kwarg(:order,kwargs) dvol_i, dvol = _setup_vols(model,spaces,order) @@ -134,7 +143,7 @@ function _setup_vols(model,spaces,order) (dvol_i,dvol) end -function _compute_dof_lid_to_remove(model,spaces) +function _compute_dof_lid_to_fix(model,spaces) dof_lids_candidates=DistributedData(model.gids,spaces) do part, cell_gids, lspace n_free_dofs = num_free_dofs(lspace) lid_to_n_local_minus_ghost=zeros(Int32,n_free_dofs) @@ -167,5 +176,5 @@ function _compute_dof_lid_to_remove(model,spaces) end end - dof_lid_to_remove = scatter(comm,part_dof_lids_candidates) + dof_lid_to_fix = scatter(comm,part_dof_lids_candidates) end diff --git a/test/DistributedStokesTests.jl b/test/DistributedStokesTests.jl index d2aa20d9..31a272c8 100644 --- a/test/DistributedStokesTests.jl +++ b/test/DistributedStokesTests.jl @@ -45,35 +45,33 @@ function run(comm,subdomains,assembly_strategy::AbstractString, global_dofs::Boo add_tag_from_tags!(labels,"neumann",[5]) end - # Build local and global test FE spaces - spaces = DistributedData(comm, model) do part, (model,gids) - labels = get_face_labeling(model) - V = TestFESpace( - reffe=:QLagrangian, - conformity=:H1, - valuetype=VectorValue{2,Float64}, - model=model, - labels=labels, - order=2, - dirichlet_tags=["diri0","diri1"]) - Q = TestFESpace( - reffe=:PLagrangian, - conformity=:L2, - valuetype=Float64, - model=model, - order=1) #, - #constraint=:zeromean) - MultiFieldFESpace([V,Q]) - end - Y=GridapDistributed.DistributedFESpaceFromLocalFESpaces(vector_type,model,spaces) - # Build local and global trial FE spaces - trialspaces = DistributedData(comm, Y) do part, (y,gids) - U=TrialFESpace(y.spaces[1],[u,u]) - P=TrialFESpace(y.spaces[2]) - MultiFieldFESpace([U,P]) - end - X=GridapDistributed.DistributedFESpaceFromLocalFESpaces(vector_type,trialspaces,Y.gids) + # FE Spaces + order = 2 + V = FESpace( + vector_type, + valuetype = VectorValue{2,Float64}, + reffe=:QLagrangian, + order = order, + model = model, + conformity = :H1, + dirichlet_tags=["diri0","diri1"], + ) + + Q = FESpace( + vector_type, + reffe=:PLagrangian, + conformity=:L2, + valuetype=Float64, + model=model, + order=order-1) + #constraint=:zeromean) + + Y=MultiFieldFESpace(model,[V,Q]) + + U=TrialFESpace(V,[u,u]) + P=TrialFESpace(Q) + X=MultiFieldFESpace(Y,[U,P]) if (assembly_strategy == "RowsComputedLocally") strategy = RowsComputedLocally(Y; global_dofs=global_dofs) @@ -113,7 +111,7 @@ function run(comm,subdomains,assembly_strategy::AbstractString, global_dofs::Boo # Assembler assem = SparseMatrixAssembler(matrix_type, vector_type, X, Y, strategy) - # FE solution + # # FE solution op = AffineFEOperator(assem, terms) xh = solve(op)