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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
SemiSmoothNewton.jl
Commits
252e7332
Commit
252e7332
authored
Jun 29, 2021
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
implement DP0 functions
parent
1afa67ce
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/function.jl
+58
-12
58 additions, 12 deletions
src/function.jl
src/mesh.jl
+2
-6
2 additions, 6 deletions
src/mesh.jl
with
60 additions
and
18 deletions
src/function.jl
+
58
−
12
View file @
252e7332
struct
P1Mapper
using
Statistics
:
mean
export
Mapper
,
FeFunction
,
P1
,
DP0
,
DP1
,
interpolate!
struct
P1
end
struct
DP0
end
struct
DP1
end
struct
Mapper
{
T
}
mesh
ndofs
::
Int
map
::
Array
{
Int
,
2
}
end
function
P1Mapper
(
mesh
)
struct
FeFunction
mapper
::
Mapper
data
::
Vector
{
Float64
}
end
function
FeFunction
(
mapper
)
data
=
Vector
{
Float64
}(
undef
,
mapper
.
ndofs
)
return
FeFunction
(
mapper
,
data
)
end
# P1 Elements (1st order Lagrange)
function
Mapper
{
P1
}(
mesh
)
# special case for P1: dofs correspond to vertices
ndofs
=
size
(
mesh
.
vertices
,
2
)
map
=
copy
(
mesh
.
cells
)
return
P1
Mapper
(
mesh
,
ndofs
,
map
)
return
Mapper
{
P1
}
(
mesh
,
ndofs
,
map
)
end
struct
P1Function
mapper
::
P1Mapper
data
::
Vector
{
Float64
}
end
# DP0 Elements (0th order discontinuous Lagrange)
function
P1Function
(
mapper
)
data
=
Vector
{
Float64
}(
undef
,
mapper
.
ndofs
)
return
P1Function
(
mapper
,
data
)
function
Mapper
{
DP0
}(
mesh
)
# special case for DP0: dofs correspond to cells
ndofs
=
size
(
mesh
.
cells
,
2
)
map
=
collect
(
reshape
(
axes
(
mesh
.
cells
,
2
),
1
,
:
))
return
Mapper
{
DP0
}(
mesh
,
ndofs
,
map
)
end
function
interpolate!
(
dst
::
P1Function
,
src
::
Function
)
mapper
=
dst
.
mapper
interpolate!
(
dst
::
FeFunction
,
src
::
Function
)
=
interpolate!
(
dst
,
dst
.
mapper
,
src
)
function
interpolate!
(
dst
::
FeFunction
,
mapper
::
Mapper
{
P1
},
src
::
Function
)
mesh
=
mapper
.
mesh
for
cid
in
axes
(
mesh
.
cells
,
2
)
for
ldof
in
axes
(
mapper
.
map
,
1
)
...
...
@@ -38,3 +57,30 @@ function interpolate!(dst::P1Function, src::Function)
end
end
end
function
interpolate!
(
dst
::
FeFunction
,
mapper
::
Mapper
{
DP0
},
src
::
Function
)
mesh
=
mapper
.
mesh
for
cid
in
axes
(
mesh
.
cells
,
2
)
vertices
=
mesh
.
vertices
[
:
,
mesh
.
cells
[
:
,
cid
]]
centroid
=
mean
(
vertices
,
dims
=
2
)
fx
=
src
(
centroid
)
gdof
=
mapper
.
map
[
1
,
cid
]
dst
.
data
[
gdof
]
=
fx
end
end
append_data!
(
vtkfile
,
f
::
FeFunction
)
=
append_data!
(
vtkfile
,
f
,
f
.
mapper
)
function
append_data!
(
vtkfile
,
f
::
FeFunction
,
::
Mapper
{
P1
})
# FIXME: vector-valued data
fdata
=
reshape
(
f
.
data
,
1
,
:
)
vtk_point_data
(
vtkfile
,
fdata
,
"f"
)
end
function
append_data!
(
vtkfile
,
f
::
FeFunction
,
::
Mapper
{
DP0
})
# FIXME: vector-valued data
fdata
=
reshape
(
f
.
data
,
1
,
:
)
vtk_cell_data
(
vtkfile
,
fdata
,
"f"
)
end
This diff is collapsed.
Click to expand it.
src/mesh.jl
+
2
−
6
View file @
252e7332
export
init_grid
,
save
using
WriteVTK
# 2d, simplex grid
...
...
@@ -25,12 +27,6 @@ function init_grid(n)
return
Mesh
(
vertices
,
cells
)
end
function
append_data!
(
vtkfile
,
f
::
P1Function
)
# FIXME: vector-valued data
fdata
=
reshape
(
f
.
data
,
1
,
:
)
vtk_point_data
(
vtkfile
,
fdata
,
"f"
)
end
function
save
(
filename
,
mesh
::
Mesh
,
fs
...
)
cells
=
[
MeshCell
(
VTKCellTypes
.
VTK_TRIANGLE
,
mesh
.
cells
[
:
,
i
])
for
i
in
axes
(
mesh
.
cells
,
2
)]
#vertices = [mesh.vertices[i, j] for i in axes(mesh.vertices, 1), j in axes(mesh.vertices, 2)]
...
...
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
sign in
to comment