@@ -43,20 +43,13 @@ partition = (5,5)
4343# obtain the `FEFunction` in the new space from the old one by
4444# evaluating the appropriate degrees of freedom. Interpolation works
4545# using the composite type `Interpolable` to tell `Gridap` that the
46- # argument can be interpolated between triangulations. This can be
47- # done using any of the methods
48- # ```julia
49- # interpolate(ifₕ::Interpolable, new_fe_space::FESpace)
50- # interpolate_everywhere(ifₕ::Interpolable, new_fe_space::FESpace)
51- # interpolate_dirichlet(ifₕ::Interpolable, new_fe_space::FESpace)
52- # ```
53- # available in `Gridap`
46+ # argument can be interpolated between triangulations.
5447
5548# ## Interpolating between Lagrangian FE Spaces
5649
5750# Let us define the infinite dimensional function
5851
59- f₁ (x) = x[1 ] + x[2 ]
52+ f (x) = x[1 ] + x[2 ]
6053
6154# This function will be interpolated to the source `FESpace`
6255# $V_1$. The space can be built using
@@ -66,7 +59,7 @@ V₁ = FESpace(𝒯₁, reffe₁)
6659
6760# Finally to build the function $f_h$, we do
6861
69- fₕ = interpolate_everywhere (f₁ ,V₁)
62+ fₕ = interpolate_everywhere (f,V₁)
7063
7164# To construct arbitrary points in the domain, we use `Random` package:
7265
@@ -81,8 +74,8 @@ fₕ(pt), fₕ.(pts)
8174
8275# We can also check our results using
8376
84- @test fₕ (pt) ≈ f₁ (pt)
85- @test fₕ .(pts) ≈ f₁ .(pts)
77+ @test fₕ (pt) ≈ f (pt)
78+ @test fₕ .(pts) ≈ f .(pts)
8679
8780# Now let us define the new triangulation $\mathcal{T}_2$ of
8881# $\Omega$. We define the map
@@ -119,10 +112,31 @@ ifₕ = Interpolable(fₕ)
119112
120113gₕ = interpolate_everywhere (if ₕ, V₂)
121114
122- # Like earlier we can check our results
115+ # We can also use
116+ # `interpolate` if interpolating only on the free dofs or
117+ # `interpolate_dirichlet` if interpolating the Dirichlet dofs of the
118+ # `FESpace`.
119+
120+ ḡₕ = interpolate (if ₕ, V₂)
121+
122+ # The finite element function $\bar{g}_h$ is the same as $g_h$ in this
123+ # example since all the dofs are free.
124+
125+ @test gₕ. cell_dof_values == ḡₕ. cell_dof_values
126+
127+ # Now we obtain a finite element function using `interpolate_dirichlet`
128+
129+ g̃ₕ = interpolate_dirichlet (if ₕ, V₂)
130+
131+ # Now $\tilde{g}_h$ will be equal to 0 since there are
132+ # no Dirichlet nodes defined in the `FESpace`. We can check by running
133+
134+ g̃ₕ. cell_dof_values
135+
136+ # Like earlier we can check our results for `gₕ`:
123137
124- @test fₕ (pt) ≈ gₕ (pt) ≈ f₁ (pt)
125- @test fₕ .(pts) ≈ gₕ .(pts) ≈ f₁ .(pts)
138+ @test fₕ (pt) ≈ gₕ (pt) ≈ f (pt)
139+ @test fₕ .(pts) ≈ gₕ .(pts) ≈ f .(pts)
126140
127141# We can visualize the results using Paraview
128142
@@ -131,7 +145,7 @@ writevtk(get_triangulation(gₕ), "target", cellfields=["gₕ"=>gₕ])
131145
132146# which produces the following output
133147
134- # 
148+ # 
135149
136150# ## Interpolating between Raviart-Thomas FESpaces
137151
@@ -146,14 +160,14 @@ writevtk(get_triangulation(gₕ), "target", cellfields=["gₕ"=>gₕ])
146160
147161# Assuming a function
148162
149- f₂ (x) = VectorValue ([x[1 ], x[2 ]])
163+ f (x) = VectorValue ([x[1 ], x[2 ]])
150164
151165# on the domain, we build the associated finite dimensional version
152166# $f_h \in V_1$.
153167
154168reffe₁ = ReferenceFE (raviart_thomas, Float64, 1 ) # RT space of order 1
155169V₁ = FESpace (𝒯₁, reffe₁)
156- fₕ = interpolate_everywhere (f₂ , V₁)
170+ fₕ = interpolate_everywhere (f, V₁)
157171
158172# As before, we can evaluate the RT function on any arbitrary point in
159173# the domain.
@@ -163,7 +177,7 @@ fₕ(pt), fₕ.(pts)
163177# Constructing the target RT space and building the `Interpolable`
164178# object,
165179
166- reffe₂ = ReferenceFE (raviart_thomas, Float64, 2 ) # RT space of order 2
180+ reffe₂ = ReferenceFE (raviart_thomas, Float64, 1 ) # RT space of order 1
167181V₂ = FESpace (𝒯₂, reffe₂)
168182if ₕ = Interpolable (fₕ)
169183
@@ -173,4 +187,4 @@ gₕ = interpolate_everywhere(ifₕ, V₂)
173187
174188# Like earlier we can check our results
175189
176- gₕ (pt), f₂ (pt)
190+ gₕ (pt), f (pt)
0 commit comments