Skip to content
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

Gridap v0.16 #50

Merged
merged 12 commits into from
Jun 29, 2021
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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.7.0] - 2021-06-28

### Changed

- Switch to Gridap 0.16. Note that we specifically need the fixes introduced in Gridap v0.16.3.

## [0.6.1] - 2021-06-24

### Added
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridapEmbedded"
uuid = "8838a6a3-0006-4405-b874-385995508d5d"
authors = ["Francesc Verdugo <[email protected]>"]
version = "0.6.1"
version = "0.7.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -18,7 +18,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
AbstractTrees = "0.3.3"
Combinatorics = "1"
FillArrays = "0.10, 0.11"
Gridap = "0.15"
Gridap = "0.16.3"
LightGraphs = "1.3.3"
MiniQhull = "0.1.0, 0.2, 0.3"
julia = "1.3"
Expand Down
11 changes: 5 additions & 6 deletions src/AgFEM/AgFEMSpaces.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

function AgFEMSpace(f::SingleFieldFESpace,cell_to_cellin::AbstractVector,g::SingleFieldFESpace=f)
AgFEMSpace(f,cell_to_cellin,get_cell_shapefuns(g),get_cell_dof_basis(g))
AgFEMSpace(f,cell_to_cellin,get_fe_basis(g),get_fe_dof_basis(g))
end

# Note: cell is in fact bgcell in this function since f will usually be an ExtendedFESpace
Expand All @@ -22,8 +22,8 @@ function AgFEMSpace(
trian_a = Triangulation(trian,acell_to_cell)

# Celldata Defined on trian
dofs_f = get_cell_dof_basis(f)
shfns_f = get_cell_shapefuns(f)
dofs_f = get_fe_dof_basis(f)
shfns_f = get_fe_basis(f)
dofs_g = cell_dof_basis_g
shfns_g = cell_shapefuns_g

Expand All @@ -39,10 +39,10 @@ function AgFEMSpace(
acell_to_dof_ids = lazy_map(Reindex(get_cell_dof_ids(f)),acell_to_cell)

#acell_to_dofs = reindex(get_cell_dofs(f),acell_to_cell)
#n_fdofs =
#n_fdofs =
#acell_to_fbasis = reindex(get_cell_basis(f),acell_to_cellin)
#acell_to_gbasis = reindex(cell_shapefuns_g,acell_to_cellin)
#acell_to_dof_fbasis = reindex(get_cell_dof_basis(f),acell_to_cell)
#acell_to_dof_fbasis = reindex(get_fe_dof_basis(f),acell_to_cell)
#acell_to_dof_gbasis = reindex(cell_dof_basis_g,acell_to_cellin)
#@notimplementedif is_in_ref_space(acell_to_dof_fbasis)
#@notimplementedif is_in_ref_space(acell_to_gbasis)
Expand Down Expand Up @@ -149,4 +149,3 @@ function _setup_agfem_constraints(

aggdof_to_fdof, aggdof_to_dofs, aggdof_to_coeffs
end

2 changes: 2 additions & 0 deletions src/Interfaces/Interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import Gridap.Geometry: TriangulationStyle
import Gridap.Geometry: get_background_triangulation
import Gridap.Geometry: get_cell_ref_map
import Gridap.Geometry: get_facet_normal
import Gridap.Geometry: compress_contributions
import Gridap.Geometry: compress_ids

using GridapEmbedded.CSG

Expand Down
12 changes: 11 additions & 1 deletion src/Interfaces/SubCellTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ function _setup_cell_ref_map(st,reffe,cell_types)
cell_to_ref_map
end

function compress_contributions(cell_mat,trian::SubCellTriangulation)
cell_to_bgcell = get_cell_to_bgcell(trian)
ccell_mat = compress_contributions(cell_mat,cell_to_bgcell)
ccell_mat
end

function compress_ids(cell_ids,trian::SubCellTriangulation)
cell_to_bgcell = get_cell_to_bgcell(trian)
compress_ids(cell_ids,cell_to_bgcell)
end

# Triangulation API

get_node_coordinates(trian::SubCellTriangulation) = trian.subcells.point_to_coords
Expand Down Expand Up @@ -81,4 +92,3 @@ function Visualization.visualization_data(st::SubCellData,filename::String;celld
end
(Visualization.VisualizationData(ug,filename,celldata=_celldata),)
end

12 changes: 11 additions & 1 deletion src/Interfaces/SubFacetTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ function _setup_facet_ref_map(st,reffe,facet_types)
facet_to_ref_map
end

function compress_contributions(cell_mat,trian::SubFacetTriangulation)
cell_to_bgcell = get_cell_to_bgcell(trian)
ccell_mat = compress_contributions(cell_mat,cell_to_bgcell)
ccell_mat
end

function compress_ids(cell_ids,trian::SubFacetTriangulation)
cell_to_bgcell = get_cell_to_bgcell(trian)
compress_ids(cell_ids,cell_to_bgcell)
end

# Triangulation API

get_node_coordinates(trian::SubFacetTriangulation) = trian.subfacets.point_to_coords
Expand Down Expand Up @@ -137,4 +148,3 @@ function Base.append!(a::SubFacetData{D},b::SubFacetData{D}) where D

a
end

1 change: 0 additions & 1 deletion src/LevelSetCutters/LevelSetCutters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ using Gridap.Fields
using Gridap.Helpers
using Gridap.Geometry
using Gridap.CellData
using Gridap.Integration
using Gridap.Polynomials
using Gridap.Visualization

Expand Down
20 changes: 20 additions & 0 deletions test/AgFEMTests/AgFEMSpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ dΩ_in = Measure(Ω_in,2)
model = DiscreteModel(cutdisc)
order = 1

# In the physical domain

cell_fe = FiniteElements(PhysicalDomain(),model,lagrangian,Float64,order)
V = FESpace(model,cell_fe)

Expand All @@ -42,6 +44,24 @@ vh = FEFunction(V,rand(num_free_dofs(V)))
vhagg = interpolate(vh,Vagg)
@test sum( ∫(abs2(vh-vhagg))dΩ_in ) < tol

# In the reference space

reffe = ReferenceFE(lagrangian,Float64,order)
V = FESpace(model,reffe)
cell_to_cellin = [0,0,9,8,8,9,8,8,9]
Vagg = AgFEMSpace(V,cell_to_cellin)

v(x) = x[1] + 2*x[2]
vhagg = interpolate(v,Vagg)

tol = 10e-9
@test sum( ∫(abs2(v-vhagg))dΩ ) < tol
@test sum( ∫(abs2(v-vhagg))dΩ_in ) < tol

vh = FEFunction(V,rand(num_free_dofs(V)))
vhagg = interpolate(vh,Vagg)
@test sum( ∫(abs2(vh-vhagg))dΩ_in ) < tol

#cellfields = ["vh"=>vh,"vhagg"=>vhagg,"e"=>vh-vhagg]
#writevtk(Ω_bg,"trian_bg",nsubcells=10,cellfields=cellfields)
#writevtk(Ω_in,"trian_in",nsubcells=10,cellfields=cellfields)
Expand Down
10 changes: 6 additions & 4 deletions test/GridapEmbeddedTests/StokesAgFEMTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ V_cell_fe_ser = FiniteElements(PhysicalDomain(),
lagrangian,
VectorValue{2,Float64},
order,
space=:S)
space=:S,
conformity=:L2)
# RMK: we don't neet to impose continuity since
# we only use the cell dof basis / shapefuns
Vser = FESpace(model,V_cell_fe_ser,conformity=:L2)
Vser = FESpace(model,V_cell_fe_ser)

Q_cell_fe_std = FiniteElements(PhysicalDomain(),
model,
lagrangian,
Float64,
order-1,
space=:P)
Qstd = FESpace(model,Q_cell_fe_std,conformity=:L2)
space=:P,
conformity=:L2)
Qstd = FESpace(model,Q_cell_fe_std)

V = AgFEMSpace(Vstd,aggregates,Vser)
Q = AgFEMSpace(Qstd,aggregates)
Expand Down