Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SemiSmoothNewton.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
SemiSmoothNewton.jl
Commits
57fb81e4
Commit
57fb81e4
authored
3 years ago
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
add method for computing local approximation error
parent
00fe07b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/image.jl
+60
-0
60 additions, 0 deletions
src/image.jl
with
60 additions
and
0 deletions
src/image.jl
+
60
−
0
View file @
57fb81e4
...
@@ -443,6 +443,66 @@ function project_l2_pixel!(u::FeFunction, img)
...
@@ -443,6 +443,66 @@ function project_l2_pixel!(u::FeFunction, img)
return
u
return
u
end
end
"""
compute_local_error(u::FeFunction, img)
Compute for every cell the squared L2-error between the mesh function `u` and
the image `img`.
Integrals are evaluated with a Lagrange quadrature rule with order dependent on
the current cell diameter. Image point evaluations use bilinear interpolations.
"""
function
compute_local_error
(
u
::
FeFunction
,
img
)
d
=
2
space
=
u
.
space
mesh
=
space
.
mesh
nrdims
=
prod
(
space
.
size
)
# number of element dofs (i.e. local dofs not counting codomain dimensions)
nldofs
=
ndofs
(
space
.
element
)
space_indicator
=
FeSpace
(
mesh
,
DP0
(),
(
1
,))
err
=
FeFunction
(
space_indicator
;
name
=
"err"
)
for
cell
in
cells
(
mesh
)
bind!
(
u
,
cell
)
bind!
(
err
,
cell
)
# cell map is assumed to be constant per cell
delmap
=
jacobian
(
elmap
(
mesh
,
cell
),
SA
[
0.
,
0.
])
delmapinv
=
inv
(
delmap
)
intel
=
abs
(
det
(
delmap
))
p
=
ceil
(
Int
,
diam
(
mesh
,
cell
))
qw
,
qx
=
quadrature_composite_lagrange_midpoint
(
p
)
nqpts
=
length
(
qw
)
# number of quadrature points
qphi
=
zeros
(
nrdims
,
nrdims
,
nldofs
,
nqpts
)
dqphi
=
zeros
(
nrdims
,
d
,
nrdims
,
nldofs
,
nqpts
)
for
k
in
axes
(
qx
,
2
)
for
r
in
1
:
nrdims
qphi
[
r
,
r
,
:
,
k
]
.=
evaluate_basis
(
space
.
element
,
SVector
{
d
}(
view
(
qx
,
:
,
k
)))
dqphi
[
r
,
:
,
r
,
:
,
k
]
.=
transpose
(
jacobian
(
x
->
evaluate_basis
(
space
.
element
,
x
),
SVector
{
d
}(
view
(
qx
,
:
,
k
))))
end
end
# quadrature points
for
k
in
axes
(
qx
,
2
)
xhat
=
SVector
{
d
}(
view
(
qx
,
:
,
k
))
x
=
elmap
(
mesh
,
cell
)(
xhat
)
# TODO: support more dimensions, evaluate_bilinear needs rework
u_val
=
first
(
evaluate
(
u
,
xhat
))
img_val
=
evaluate_bilinear
(
img
,
x
)
err_val
=
qw
[
k
]
*
(
u_val
-
img_val
)
^
2
*
intel
gdofs
=
space
.
dofmap
[
:
,
1
,
cell
]
err
.
data
[
gdofs
]
.=
err_val
end
end
return
err
end
function
save_csv
(
path
,
img
::
AbstractArray
{
<:
Any
,
2
})
function
save_csv
(
path
,
img
::
AbstractArray
{
<:
Any
,
2
})
df
=
DataFrame
()
df
=
DataFrame
()
for
ci
in
CartesianIndices
(
img
)
for
ci
in
CartesianIndices
(
img
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment