Skip to content

Commit

Permalink
Generalised the DistrDiscModel API for AbstractDDM
Browse files Browse the repository at this point in the history
- Susbtituted all references to .models and .face_gids
  by a call to the public API of AbstractDistrDiscrModel.
- Changed the input types to AbstractDistDiscrModel.
  • Loading branch information
JordiManyer committed Feb 24, 2023
1 parent 5dc945b commit 8d747ad
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 135 deletions.
64 changes: 35 additions & 29 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.4"

[[deps.Adapt]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "0310e08cb19f5da31d08341c6120c047598f5b9c"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.5.0"

[[deps.ArgCheck]]
git-tree-sha1 = "a3a402a35a2f7e0b87828ccabbd5ebfbebe356b4"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand All @@ -24,11 +30,11 @@ version = "2.3.0"
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"

[[deps.ArrayInterfaceCore]]
deps = ["LinearAlgebra", "SnoopPrecompile", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "e5f08b5689b1aad068e01751889f2f615c7db36d"
uuid = "30b0a656-2188-435a-8636-2ec0e6a096e2"
version = "0.1.29"
[[deps.ArrayInterface]]
deps = ["Adapt", "LinearAlgebra", "Requires", "SnoopPrecompile", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "4d9946e51e24f5e509779e3e2c06281a733914c2"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "7.1.0"

[[deps.ArrayLayouts]]
deps = ["FillArrays", "LinearAlgebra", "SparseArrays"]
Expand Down Expand Up @@ -66,9 +72,9 @@ version = "1.15.7"

[[deps.ChangesOfVariables]]
deps = ["ChainRulesCore", "LinearAlgebra", "Test"]
git-tree-sha1 = "844b061c104c408b24537482469400af6075aae4"
git-tree-sha1 = "485193efd2176b88e6622a39a246f8c5b600e74e"
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
version = "0.1.5"
version = "0.1.6"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
Expand Down Expand Up @@ -100,9 +106,9 @@ version = "1.0.1+0"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "fb21ddd70a051d882a1686a5a550990bbe371a95"
git-tree-sha1 = "45269494fcfa0cc14032b7aa640fa71320e1976e"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.4.1"
version = "1.5.0"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand All @@ -122,9 +128,9 @@ version = "1.1.0"

[[deps.DiffRules]]
deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "c5b6685d53f933c11404a3ae9822afe30d522494"
git-tree-sha1 = "a4ad7ef19d2cdc2eff57abbbe68032b1cd0bd8f8"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.12.2"
version = "1.13.0"

[[deps.Distances]]
deps = ["LinearAlgebra", "SparseArrays", "Statistics", "StatsAPI"]
Expand Down Expand Up @@ -181,10 +187,10 @@ uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.12.8"

[[deps.FiniteDiff]]
deps = ["ArrayInterfaceCore", "LinearAlgebra", "Requires", "Setfield", "SparseArrays", "StaticArrays"]
git-tree-sha1 = "04ed1f0029b6b3af88343e439b995141cb0d0b8d"
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "Setfield", "SparseArrays", "StaticArrays"]
git-tree-sha1 = "ed1b56934a2f7a65035976985da71b6a65b4f2cf"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.17.0"
version = "2.18.0"

[[deps.ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"]
Expand All @@ -198,7 +204,7 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[deps.Gridap]]
deps = ["AbstractTrees", "BSON", "BlockArrays", "Combinatorics", "DataStructures", "DocStringExtensions", "FastGaussQuadrature", "FileIO", "FillArrays", "ForwardDiff", "JLD2", "JSON", "LineSearches", "LinearAlgebra", "NLsolve", "NearestNeighbors", "PolynomialBases", "QuadGK", "Random", "SparseArrays", "SparseMatricesCSR", "StaticArrays", "Test", "WriteVTK"]
git-tree-sha1 = "77101b441907f925062839d071240d11783be94d"
git-tree-sha1 = "7c5ba3e43f245f39c053c633562eecf2eb9cdbb7"
repo-rev = "master"
repo-url = "https://github.com/gridap/Gridap.jl.git"
uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
Expand All @@ -221,9 +227,9 @@ uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.8"

[[deps.IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
git-tree-sha1 = "637b58b3c037d3877f263418de820920b47ceeb5"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.1.1"
version = "0.2.0"

[[deps.IterativeSolvers]]
deps = ["LinearAlgebra", "Printf", "Random", "RecipesBase", "SparseArrays"]
Expand Down Expand Up @@ -299,9 +305,9 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "45b288af6956e67e621c5cbb2d75a261ab58300b"
git-tree-sha1 = "0a1b7c2863e44523180fdb3146534e265a91870b"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.20"
version = "0.3.23"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand Down Expand Up @@ -378,9 +384,9 @@ version = "4.5.1"

[[deps.NaNMath]]
deps = ["OpenLibm_jll"]
git-tree-sha1 = "a7c3d1da1189a1c2fe843a3bfa04d18d20eb3211"
git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "1.0.1"
version = "1.0.2"

[[deps.NearestNeighbors]]
deps = ["Distances", "StaticArrays"]
Expand Down Expand Up @@ -427,9 +433,9 @@ version = "0.12.3"

[[deps.Parsers]]
deps = ["Dates", "SnoopPrecompile"]
git-tree-sha1 = "151d91d63d8d6c1a5789ecb7de51547e00480f1b"
git-tree-sha1 = "6f4fbcd1ad45905a5dee3f4256fabb49aa2110c6"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.5.4"
version = "2.5.7"

[[deps.PartitionedArrays]]
deps = ["Distances", "IterativeSolvers", "LinearAlgebra", "MPI", "Printf", "SparseArrays", "SparseMatricesCSR"]
Expand Down Expand Up @@ -460,9 +466,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "de191bc385072cc6c7ed3ffdc1caeed3f22c74d4"
git-tree-sha1 = "786efa36b7eff813723c4849c90456609cf06661"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.7.0"
version = "2.8.1"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
Expand Down Expand Up @@ -523,15 +529,15 @@ version = "0.6.7"

[[deps.SpecialFunctions]]
deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d"
git-tree-sha1 = "ef28127915f4229c971eb43f3fc075dd3fe91880"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "2.1.7"
version = "2.2.0"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "6954a456979f23d05085727adb17c4551c19ecd1"
git-tree-sha1 = "2d7d9e1ddadc8407ffd460e24218e37ef52dd9a3"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.12"
version = "1.5.16"

[[deps.StaticArraysCore]]
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
Expand Down
22 changes: 11 additions & 11 deletions src/DivConformingFESpaces.jl
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
"""
"""
function FESpaces.FESpace(model::DistributedDiscreteModel,
function FESpaces.FESpace(model::AbstractDistributedDiscreteModel,
reffe::Tuple{RaviartThomas,Any,Any};
conformity=nothing,kwargs...)

cell_reffes = map_parts(model.models) do m
cell_reffes = map_parts(local_views(model)) do m
basis,reffe_args,reffe_kwargs = reffe
cell_reffe = ReferenceFE(m,basis,reffe_args...;reffe_kwargs...)
end
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
end

function FESpace(model::DistributedDiscreteModel,
function FESpace(model::AbstractDistributedDiscreteModel,
reffe::GenericRefFE{RaviartThomas};
conformity=nothing, kwargs...)
cell_reffes = map_parts(model.models) do m
cell_reffes = map_parts(local_views(model)) do m
Fill(reffe,num_cells(m))
end
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
end

function _common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
sign_flips=_generate_sign_flips(model,cell_reffes)
spaces = map_parts(model.models,sign_flips,cell_reffes) do m,sign_flip,cell_reffe
spaces = map_parts(local_views(model),sign_flips,cell_reffes) do m,sign_flip,cell_reffe
conf = Conformity(testitem(cell_reffe),conformity)
cell_fe = CellFE(m,cell_reffe,conf,sign_flip)
FESpace(m, cell_fe; kwargs...)
end
gids = generate_gids(model,spaces)
gids = generate_gids(model,spaces)
vector_type = _find_vector_type(spaces,gids)
DistributedSingleFieldFESpace(spaces,gids,vector_type)
end



function _generate_sign_flips(model,cell_reffes)
cell_gids=get_cell_gids(model)
sign_flips=map_parts(model.models,cell_gids.partition,cell_reffes) do m, p, cell_reffe
cell_gids = get_cell_gids(model)
sign_flips = map_parts(local_views(model),cell_gids.partition,cell_reffes) do m, p, cell_reffe
D = num_cell_dims(model)

gtopo = get_grid_topology(m)
Expand All @@ -62,10 +62,10 @@ function _generate_sign_flips(model,cell_reffes)

for cell in p.oid_to_lid
sign_flip = view(data,ptrs[cell]:ptrs[cell+1]-1)
reffe=cell_reffe[cell]
reffe = cell_reffe[cell]
D = num_dims(reffe)
face_own_dofs = get_face_own_dofs(reffe)
facet_lid = get_offsets(get_polytope(reffe))[D] + 1
face_own_dofs = get_face_own_dofs(reffe)
facet_lid = get_offsets(get_polytope(reffe))[D] + 1
cell_facets_ids = getindex!(cache_cell_wise_facets_ids,
cell_wise_facets_ids,
cell)
Expand Down
5 changes: 3 additions & 2 deletions src/FESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,12 @@ function FESpaces.HomogeneousTrialFESpace(f::DistributedSingleFieldFESpace)
end

function generate_gids(
model::DistributedDiscreteModel{Dc},
model::AbstractDistributedDiscreteModel{Dc},
spaces::AbstractPData{<:SingleFieldFESpace}) where Dc
cell_to_ldofs = map_parts(get_cell_dof_ids,spaces)
nldofs = map_parts(num_free_dofs,spaces)
generate_gids(model.face_gids[Dc+1],cell_to_ldofs,nldofs)
cell_gids = get_cell_gids(model)
generate_gids(cell_gids,cell_to_ldofs,nldofs)
end

function FESpaces.interpolate(u,f::DistributedSingleFieldFESpace)
Expand Down
Loading

0 comments on commit 8d747ad

Please sign in to comment.