Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grudge
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
Model registry
Operate
Environments
Terraform modules
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
Alexandru Fikl
grudge
Commits
fc99884a
Commit
fc99884a
authored
4 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Fix weak advection example for flake8
parent
adcd20ca
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
examples/advection/weak.py
+3
-21
3 additions, 21 deletions
examples/advection/weak.py
with
3 additions
and
21 deletions
examples/advection/weak.py
+
3
−
21
View file @
fc99884a
...
@@ -32,15 +32,12 @@ from grudge import sym, bind, DGDiscretizationWithBoundaries
...
@@ -32,15 +32,12 @@ from grudge import sym, bind, DGDiscretizationWithBoundaries
import
numpy.linalg
as
la
import
numpy.linalg
as
la
def
main
(
write_output
=
True
,
order
=
4
):
def
main
(
write_output
=
True
,
order
=
4
):
cl_ctx
=
cl
.
create_some_context
()
cl_ctx
=
cl
.
create_some_context
()
queue
=
cl
.
CommandQueue
(
cl_ctx
)
queue
=
cl
.
CommandQueue
(
cl_ctx
)
dim
=
2
dim
=
2
from
meshmode.mesh.generation
import
generate_regular_rect_mesh
from
meshmode.mesh.generation
import
generate_regular_rect_mesh
mesh
=
generate_regular_rect_mesh
(
a
=
(
-
0.5
,
-
0.5
),
b
=
(
0.5
,
0.5
),
mesh
=
generate_regular_rect_mesh
(
a
=
(
-
0.5
,
-
0.5
),
b
=
(
0.5
,
0.5
),
n
=
(
20
,
20
),
order
=
order
)
n
=
(
20
,
20
),
order
=
order
)
...
@@ -50,12 +47,10 @@ def main(write_output=True, order=4):
...
@@ -50,12 +47,10 @@ def main(write_output=True, order=4):
discr
=
DGDiscretizationWithBoundaries
(
cl_ctx
,
mesh
,
order
=
order
)
discr
=
DGDiscretizationWithBoundaries
(
cl_ctx
,
mesh
,
order
=
order
)
c
=
np
.
array
([
0.1
,
0.1
])
c
=
np
.
array
([
0.1
,
0.1
])
norm_c
=
la
.
norm
(
c
)
norm_c
=
la
.
norm
(
c
)
flux_type
=
"
central
"
flux_type
=
"
central
"
def
f
(
x
):
def
f
(
x
):
return
sym
.
sin
(
3
*
x
)
return
sym
.
sin
(
3
*
x
)
...
@@ -64,8 +59,7 @@ def main(write_output=True, order=4):
...
@@ -64,8 +59,7 @@ def main(write_output=True, order=4):
return
f
(
-
np
.
dot
(
c
,
x
)
/
norm_c
+
sym
.
var
(
"
t
"
,
sym
.
DD_SCALAR
)
*
norm_c
)
return
f
(
-
np
.
dot
(
c
,
x
)
/
norm_c
+
sym
.
var
(
"
t
"
,
sym
.
DD_SCALAR
)
*
norm_c
)
from
grudge.models.advection
import
WeakAdvectionOperator
from
grudge.models.advection
import
WeakAdvectionOperator
from
meshmode.mesh
import
BTAG_ALL
,
BTAG_NONE
discr
=
DGDiscretizationWithBoundaries
(
cl_ctx
,
mesh
,
order
=
order
)
discr
=
DGDiscretizationWithBoundaries
(
cl_ctx
,
mesh
,
order
=
order
)
op
=
WeakAdvectionOperator
(
c
,
op
=
WeakAdvectionOperator
(
c
,
inflow_u
=
u_analytic
(
sym
.
nodes
(
dim
,
sym
.
BTAG_ALL
)),
inflow_u
=
u_analytic
(
sym
.
nodes
(
dim
,
sym
.
BTAG_ALL
)),
...
@@ -84,19 +78,14 @@ def main(write_output=True, order=4):
...
@@ -84,19 +78,14 @@ def main(write_output=True, order=4):
nsteps
=
(
final_time
//
dt
)
+
1
nsteps
=
(
final_time
//
dt
)
+
1
dt
=
final_time
/
nsteps
+
1e-15
dt
=
final_time
/
nsteps
+
1e-15
from
grudge.shortcuts
import
set_up_rk4
from
grudge.shortcuts
import
set_up_rk4
dt_stepper
=
set_up_rk4
(
"
u
"
,
dt
,
u
,
rhs
)
dt_stepper
=
set_up_rk4
(
"
u
"
,
dt
,
u
,
rhs
)
last_u
=
None
from
grudge.shortcuts
import
make_visualizer
from
grudge.shortcuts
import
make_visualizer
vis
=
make_visualizer
(
discr
,
vis_order
=
order
)
vis
=
make_visualizer
(
discr
,
vis_order
=
order
)
step
=
0
step
=
0
norm
=
bind
(
discr
,
sym
.
norm
(
2
,
sym
.
var
(
"
u
"
)))
for
event
in
dt_stepper
.
run
(
t_end
=
final_time
):
for
event
in
dt_stepper
.
run
(
t_end
=
final_time
):
if
isinstance
(
event
,
dt_stepper
.
StateComputed
):
if
isinstance
(
event
,
dt_stepper
.
StateComputed
):
...
@@ -104,15 +93,8 @@ def main(write_output=True, order=4):
...
@@ -104,15 +93,8 @@ def main(write_output=True, order=4):
#print(step, event.t, norm(queue, u=event.state_component[0]))
#print(step, event.t, norm(queue, u=event.state_component[0]))
vis
.
write_vtk_file
(
"
fld-weak-%04d.vtu
"
%
step
,
vis
.
write_vtk_file
(
"
fld-weak-%04d.vtu
"
%
step
,
[
(
"
u
"
,
event
.
state_component
)
])
[(
"
u
"
,
event
.
state_component
)])
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
main
()
main
()
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