Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DG1d.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
Model registry
Operate
Environments
Monitor
Incidents
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
DG
DG1d.jl
Commits
839a6a95
Commit
839a6a95
authored
2 years ago
by
Florian Atteneder
Browse files
Options
Downloads
Patches
Plain Diff
add SubVolumeElement
parent
41cd4db7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dg1d.jl
+1
-0
1 addition, 0 deletions
src/dg1d.jl
src/subvolumeelement.jl
+67
-0
67 additions, 0 deletions
src/subvolumeelement.jl
with
68 additions
and
0 deletions
src/dg1d.jl
+
1
−
0
View file @
839a6a95
...
...
@@ -41,6 +41,7 @@ module dg1d
include
(
"glgl.jl"
)
include
(
"lgl.jl"
)
include
(
"spectralelement.jl"
)
include
(
"subvolumeelement.jl"
)
include
(
"mesh.jl"
)
# custom evolution
...
...
This diff is collapsed.
Click to expand it.
src/subvolumeelement.jl
0 → 100644
+
67
−
0
View file @
839a6a95
export
SubVolumeElement
struct
SubVolumeElement
Npts
::
Int64
z
::
Vector
{
Float64
}
# flux nodes ∈ [-1,1], include boundary points
w
::
Vector
{
Float64
}
# cell widths defined by z
Cs_lhs
::
Vector
{
Float64
}
# correction coefficients lhs
Cs_rhs
::
Vector
{
Float64
}
# correction coefficients rhs
end
function
SubVolumeElement
(
Npts
)
@assert
Npts
>
0
dz
=
2
/
(
Npts
-
1
)
z
=
[
-
1
+
dz
*
(
i
-
1
)
for
i
=
1
:
Npts
]
# include boundary points
w
=
dz
*
ones
(
Npts
-
1
)
# equidistant grid is equally weighted
Cs_lhs
,
Cs_rhs
=
correction_coefficients
(
z
)
return
SubVolumeElement
(
Npts
,
z
,
w
,
Cs_lhs
,
Cs_rhs
)
end
function
SubVolumeElement_from_nodes
(
z
)
Npts
=
length
(
z
)
zmin
,
zmax
=
extrema
(
z
)
@assert
-
1
==
zmin
&&
zmax
==
1
@assert
all
(
isapprox
.
(
z
.+
z
[
end
:-
1
:
1
],
0.0
,
atol
=
1e-15
))
"""
Sub-volume nodes must be symmetric across z = 0.
"""
w
=
diff
(
z
)
Cs_lhs
,
Cs_rhs
=
correction_coefficients
(
z
)
return
SubVolumeElement
(
Npts
,
z
,
w
,
Cs_lhs
,
Cs_rhs
)
end
function
SubVolumeElement_weights
(
node_w
)
Npts
=
length
(
node_w
)
@assert
all
(
node_w
.>
0
)
"""
Sub-volume node weights must be positive.
"""
# construct cell widths from node weights
w
=
1
./
abs
.
(
diff
(
w
))
# inverse weighting makes higher weighted nodes have smaller cells
w
=
w
.*
2
./
sum
(
w
)
# normalize weights such that sum(w) = 2
# construct flux nodes
z
=
[
-
1
,
(
-
1
+
cumsum
(
w
[
1
:
end
]))
...
,
1
]
Cs_lhs
,
Cs_rhs
=
correction_coefficients
(
z
)
return
SubVolumeElement
(
Npts
,
z
,
w
,
Cs_lhs
,
Cs_rhs
)
end
function
SubVolumeElement
(
element
::
SpectralElement
,
divider_wrt_quadrature
=
false
)
if
divider_wrt_quadrature
return
SubVolumeElement_from_weights
(
element
.
w
)
else
return
SubVolumeElement_from_nodes
(
element
.
z
)
end
end
function
correction_coefficients
(
z
)
Npts
=
length
(
z
)
B
=
[
(
-
1
)
^
(
j
+
1
)
*
binomial
(
Npts
-
1
+
j
,
j
)
*
binomial
(
Npts
,
j
)
for
j
=
1
:
Npts
]
xis
=
[
(
zi
+
1
)
/
2
for
zi
in
z
]
# map [-1,1] to [0,1]
monomials_xi
=
[
xis
[
j
]
^
i
for
i
=
1
:
Npts
,
j
=
1
:
Npts
]
Cs
=
1
.-
transpose
(
monomials_xi
)
*
B
return
Cs
,
Cs
[
end
:-
1
:
1
]
end
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