Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dune-fem-dg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
dune-fem
dune-fem-dg
Commits
32e622d2
Commit
32e622d2
authored
6 years ago
by
Andreas Dedner
Browse files
Options
Downloads
Patches
Plain Diff
simplified the main script for the shallow water example
parent
e02a7b8c
No related branches found
No related tags found
1 merge request
!4
Latest features added to dune-fem-dg.
Pipeline
#11901
failed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pydemo/shallowWater/main.py
+34
-48
34 additions, 48 deletions
pydemo/shallowWater/main.py
pydemo/shallowWater/shallowwater.py
+5
-5
5 additions, 5 deletions
pydemo/shallowWater/shallowwater.py
with
39 additions
and
53 deletions
pydemo/shallowWater/main.py
+
34
−
48
View file @
32e622d2
...
...
@@ -3,7 +3,6 @@ from dune.grid import structuredGrid, cartesianDomain
from
dune.fem
import
parameter
import
dune.create
as
create
from
dune.femdg
import
createFemDGSolver
# from ufl import *
from
shallowwater
import
leVeque
as
problem
...
...
@@ -12,54 +11,41 @@ Model, initial, x0,x1,N, endTime, name = problem()
parameter
.
append
({
"
fem.verboserank
"
:
-
1
})
parameter
.
append
(
"
parameter
"
)
grid
=
structuredGrid
(
x0
,
x1
,
N
)
dimR
=
grid
.
dimension
+
1
grid
=
structuredGrid
(
x0
,
x1
,
N
)
dimR
=
Model
.
dimension
t
=
0
count
=
0
saveStep
=
0.01
saveTime
=
saveStep
def
initialize
(
space
):
return
space
.
interpolate
(
Model
.
toCons
(
initial
),
name
=
'
u_h
'
)
def
useODESolver
(
polOrder
=
2
,
limiter
=
'
default
'
):
global
count
,
t
,
saveTime
polOrder
=
polOrder
space
=
create
.
space
(
"
dgonb
"
,
grid
,
order
=
polOrder
,
dimrange
=
dimR
)
u_h
=
initialize
(
space
)
eta
,
v
=
Model
.
toPrim
(
u_h
)
operator
=
createFemDGSolver
(
Model
,
space
,
limiter
=
limiter
)
operator
.
applyLimiter
(
u_h
);
print
(
"
number of elements:
"
,
grid
.
size
(
0
),
flush
=
True
)
grid
.
writeVTK
(
name
,
celldata
=
[
u_h
],
pointdata
=
{
"
freeSurface
"
:
eta
},
cellvector
=
{
"
velocity
"
:
v
},
number
=
count
,
subsampling
=
2
)
start
=
time
.
time
()
tcount
=
0
while
t
<
endTime
:
operator
.
solve
(
target
=
u_h
)
dt
=
operator
.
deltaT
()
t
+=
dt
tcount
+=
1
if
tcount
%
100
==
0
:
print
(
'
[
'
,
tcount
,
'
]
'
,
'
dt =
'
,
dt
,
'
time =
'
,
t
,
'
count =
'
,
count
,
flush
=
True
)
if
t
>
saveTime
:
count
+=
1
grid
.
writeVTK
(
name
,
celldata
=
[
u_h
],
pointdata
=
{
"
freeSurface
"
:
eta
},
cellvector
=
{
"
velocity
"
:
v
},
number
=
count
,
subsampling
=
2
)
saveTime
+=
saveStep
print
(
"
time loop:
"
,
time
.
time
()
-
start
)
print
(
"
number of time steps
"
,
tcount
)
grid
.
writeVTK
(
name
,
celldata
=
[
u_h
],
pointdata
=
{
"
freeSurface
"
:
eta
},
cellvector
=
{
"
velocity
"
:
v
},
number
=
count
,
subsampling
=
2
)
useODESolver
(
2
,
'
default
'
)
# third order with limiter
polOrder
=
2
limiter
=
"
default
"
space
=
create
.
space
(
"
dgonb
"
,
grid
,
order
=
polOrder
,
dimrange
=
dimR
)
u_h
=
space
.
interpolate
(
Model
.
toCons
(
initial
),
name
=
'
u_h
'
)
eta
,
v
=
Model
.
toPrim
(
u_h
)
operator
=
createFemDGSolver
(
Model
,
space
,
limiter
=
limiter
)
operator
.
applyLimiter
(
u_h
);
print
(
"
number of elements:
"
,
grid
.
size
(
0
),
flush
=
True
)
vtk
=
grid
.
writeVTK
(
name
,
subsampling
=
2
,
write
=
False
,
celldata
=
[
u_h
],
pointdata
=
{
"
freeSurface
"
:
eta
},
cellvector
=
{
"
velocity
"
:
v
}
)
vtk
.
write
(
name
,
count
)
start
=
time
.
time
()
tcount
=
0
while
t
<
endTime
:
operator
.
solve
(
target
=
u_h
)
dt
=
operator
.
deltaT
()
t
+=
dt
tcount
+=
1
if
tcount
%
100
==
0
:
print
(
'
[
'
,
tcount
,
'
]
'
,
'
dt =
'
,
dt
,
'
time =
'
,
t
,
'
count =
'
,
count
,
flush
=
True
)
if
t
>
saveTime
:
count
+=
1
vtk
.
write
(
name
,
count
)
saveTime
+=
saveStep
print
(
"
time loop:
"
,
time
.
time
()
-
start
)
print
(
"
number of time steps
"
,
tcount
)
vtk
.
write
(
name
,
count
)
This diff is collapsed.
Click to expand it.
pydemo/shallowWater/shallowwater.py
+
5
−
5
View file @
32e622d2
...
...
@@ -7,7 +7,7 @@ def ShallowWater(topography):
x
=
SpatialCoordinate
(
space
.
cell
())
g
=
9.81
class
Model
:
dimension
=
dim
+
2
dimension
=
dim
+
1
def
velo
(
U
):
return
as_vector
(
[
U
[
i
]
/
U
[
0
]
for
i
in
range
(
1
,
dim
+
1
)]
)
def
toCons
(
U
,
x
=
x
):
...
...
@@ -38,8 +38,8 @@ def ShallowWater(topography):
return
(
hL
-
hR
)
/
(
0.5
*
(
hL
+
hR
))
def
S_ns
(
t
,
x
,
U
,
DU
):
# or S_s for a stiff source
return
as_vector
(
[
0
,
*
(
-
U
[
0
]
*
g
*
grad
(
topography
(
x
)))
])
boundary
=
{
range
(
1
,
5
):
lambda
t
,
x
,
u
,
n
:
Model
.
F_c
(
t
,
x
,
u
)
*
n
}
#
boundary = {range(1,5): lambda t,x,u: u}
#
boundary = {range(1,5): lambda t,x,u,n: Model.F_c(t,x,u)*n}
boundary
=
{
range
(
1
,
5
):
lambda
t
,
x
,
u
:
u
}
return
Model
def
leVeque
():
...
...
@@ -48,7 +48,7 @@ def leVeque():
space
=
Space
(
2
,
3
)
x
=
SpatialCoordinate
(
space
.
cell
())
initial
=
conditional
(
x
[
0
]
<
0.1
,
1
,
conditional
(
x
[
0
]
<
0.2
,
1.2
,
1
))
return
ShallowWater
(
topography
)
,
\
as_vector
(
[
initial
,
0
,
0
]
)
,
\
return
ShallowWater
(
topography
),
\
as_vector
(
[
initial
,
0
,
0
]
),
\
[
0
,
0
],
[
1
,
0.25
],
[
64
,
16
],
0.1
,
\
"
leVeque
"
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