Skip to content

Commit c7fe919

Browse files
Adding a mock test in FineToCoarseFieldsTests
1 parent b4c3619 commit c7fe919

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

test/AdaptivityTests/FineToCoarseFieldsTests.jl

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,91 @@ xHh = change_domain(xH,get_triangulation(modelh),ReferenceDomain())
100100
evaluate(Gridap.CellData.get_data(xHh)[1],[Point(0.0,0.0),Point(0.5,0.5)])
101101
evaluate(Gridap.CellData.get_data(xHh)[1],Point(0.5,0.5))
102102

103+
function test_PR_1074()
104+
105+
function setup_coarse_discrete_model()
106+
ptr = [ 1, 5 ]
107+
data = [ 1,2,3,4 ]
108+
cell_vertex_lids = Gridap.Arrays.Table(data,ptr)
109+
node_coordinates = Vector{Point{2,Float64}}(undef,4)
110+
node_coordinates[1]=Point{2,Float64}(0.0,0.0)
111+
node_coordinates[2]=Point{2,Float64}(1.0,0.0)
112+
node_coordinates[3]=Point{2,Float64}(0.0,1.0)
113+
node_coordinates[4]=Point{2,Float64}(1.0,1.0)
114+
115+
polytope=QUAD
116+
scalar_reffe=Gridap.ReferenceFEs.ReferenceFE(polytope,Gridap.ReferenceFEs.lagrangian,Float64,1)
117+
cell_types=collect(Fill(1,length(cell_vertex_lids)))
118+
cell_reffes=[scalar_reffe]
119+
grid = Gridap.Geometry.UnstructuredGrid(node_coordinates,
120+
cell_vertex_lids,
121+
cell_reffes,
122+
cell_types,
123+
Gridap.Geometry.NonOriented())
124+
Gridap.Geometry.UnstructuredDiscreteModel(grid)
125+
end
126+
127+
function setup_adapted_discrete_model(parent)
128+
ptr = [ 1, 5, 9 ]
129+
data = [ 1,2,3,4, 2,5,4,6 ]
130+
cell_vertex_lids = Gridap.Arrays.Table(data,ptr)
131+
node_coordinates = Vector{Point{2,Float64}}(undef,6)
132+
node_coordinates[1]=Point{2,Float64}(0.0,0.5)
133+
node_coordinates[2]=Point{2,Float64}(0.5,0.5)
134+
node_coordinates[3]=Point{2,Float64}(0.0,1.0)
135+
node_coordinates[4]=Point{2,Float64}(0.5,1.0)
136+
node_coordinates[5]=Point{2,Float64}(1.0,0.5)
137+
node_coordinates[6]=Point{2,Float64}(1.0,1.0)
138+
139+
polytope=QUAD
140+
scalar_reffe=Gridap.ReferenceFEs.ReferenceFE(polytope,Gridap.ReferenceFEs.lagrangian,Float64,1)
141+
cell_types=collect(Fill(1,length(cell_vertex_lids)))
142+
cell_reffes=[scalar_reffe]
143+
grid = Gridap.Geometry.UnstructuredGrid(node_coordinates,
144+
cell_vertex_lids,
145+
cell_reffes,
146+
cell_types,
147+
Gridap.Geometry.NonOriented())
148+
model=Gridap.Geometry.UnstructuredDiscreteModel(grid)
149+
150+
n2o_faces_map=Vector{Vector{Int64}}(undef,3)
151+
n2o_faces_map[3]=[1,1]
152+
n2o_cell_to_child_id=[2,3]
153+
154+
ref_rules = [Gridap.Adaptivity.RefinementRule(Gridap.ReferenceFEs.LagrangianRefFE(Float64,QUAD,1),2)]
155+
156+
glue=Gridap.Adaptivity.AdaptivityGlue(Gridap.Adaptivity.RefinementGlue(),
157+
n2o_faces_map,
158+
n2o_cell_to_child_id,
159+
ref_rules)
160+
Gridap.Adaptivity.AdaptedDiscreteModel(model,parent,glue)
161+
end
162+
163+
coarse_model=setup_coarse_discrete_model()
164+
fine_model=setup_adapted_discrete_model(coarse_model)
165+
166+
order=0
167+
168+
VH = FESpace(coarse_model,
169+
ReferenceFE(raviart_thomas,Float64,order),
170+
conformity=:Hdiv)
171+
172+
UH = TrialFESpace(VH)
173+
174+
Vh = FESpace(fine_model,
175+
ReferenceFE(raviart_thomas,Float64,order),
176+
conformity=:Hdiv)
177+
178+
Uh = TrialFESpace(Vh)
179+
180+
u(x) = VectorValue(x[1],x[2])
181+
uh = interpolate(u,Uh)
182+
uH = interpolate(u,UH)
183+
uhH = interpolate(uh,UH)
184+
185+
@test get_free_dof_values(uhH)[2] 1.0
186+
end
187+
188+
test_PR_1074()
189+
103190
end

0 commit comments

Comments
 (0)