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
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
Matt Wala
grudge
Commits
90acbf2e
Commit
90acbf2e
authored
8 years ago
by
Bogdan Enache
Browse files
Options
Downloads
Patches
Plain Diff
Linting locally is way easier
parent
ac8c4816
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
examples/advection/var-velocity.py
+4
-37
4 additions, 37 deletions
examples/advection/var-velocity.py
grudge/models/advection.py
+3
-3
3 additions, 3 deletions
grudge/models/advection.py
with
7 additions
and
40 deletions
examples/advection/var-velocity.py
+
4
−
37
View file @
90acbf2e
...
...
@@ -16,7 +16,6 @@
import
numpy
as
np
import
math
import
pyopencl
as
cl
# noqa
import
pyopencl.array
# noqa
import
pyopencl.clmath
# noqa
...
...
@@ -30,22 +29,15 @@ import logging
logger
=
logging
.
getLogger
(
__name__
)
from
grudge
import
sym
,
bind
,
Discretization
import
numpy.linalg
as
la
from
pytools.obj_array
import
join_fields
def
main
(
write_output
=
True
,
order
=
4
):
cl_ctx
=
cl
.
create_some_context
()
queue
=
cl
.
CommandQueue
(
cl_ctx
)
dim
=
2
from
meshmode.mesh.generation
import
generate_regular_rect_mesh
mesh
=
generate_regular_rect_mesh
(
a
=
(
-
0.5
,
-
0.5
),
b
=
(
0.5
,
0.5
),
n
=
(
15
,
15
),
order
=
order
)
...
...
@@ -55,28 +47,17 @@ def main(write_output=True, order=4):
discr
=
Discretization
(
cl_ctx
,
mesh
,
order
=
order
)
c
=
np
.
array
([
0.1
,
0.1
])
norm_c
=
la
.
norm
(
c
)
sym_x
=
sym
.
nodes
(
2
)
#advec_v = sym.If(sym.Comparison(
#np.dot(sym_x, sym_x), "<", 0.4**2),
#0.4, 0.1)
advec_v
=
sym_v
=
join_fields
(
-
1
*
sym_x
[
1
],
sym_x
[
0
]
)
/
2
omega
=
1
/
2
advec_v
=
join_fields
(
-
1
*
sym_x
[
1
],
sym_x
[
0
])
/
2
flux_type
=
"
central
"
source_center
=
np
.
array
([
0.1
,
0.1
])
source_width
=
0.05
source_omega
=
3
sym_x
=
sym
.
nodes
(
2
)
sym_source_center_dist
=
sym_x
-
source_center
def
f
(
x
):
return
sym
.
exp
(
...
...
@@ -86,12 +67,10 @@ def main(write_output=True, order=4):
def
u_analytic
(
x
):
return
0
from
grudge.models.advection
import
VariableCoefficientAdvectionOperator
,
WeakAdvectionOperator
from
meshmode.mesh
import
BTAG_ALL
,
BTAG_NONE
from
grudge.models.advection
import
VariableCoefficientAdvectionOperator
discr
=
Discretization
(
cl_ctx
,
mesh
,
order
=
order
)
op
=
VariableCoefficientAdvectionOperator
(
2
,
advec_v
,
op
=
VariableCoefficientAdvectionOperator
(
2
,
advec_v
,
inflow_u
=
u_analytic
(
sym
.
nodes
(
dim
,
sym
.
BTAG_ALL
)),
flux_type
=
flux_type
)
...
...
@@ -108,19 +87,14 @@ def main(write_output=True, order=4):
nsteps
=
(
final_time
//
dt
)
+
1
dt
=
final_time
/
nsteps
+
1e-15
from
grudge.shortcuts
import
set_up_rk4
dt_stepper
=
set_up_rk4
(
"
u
"
,
dt
,
u
,
rhs
)
last_u
=
None
from
grudge.shortcuts
import
make_visualizer
vis
=
make_visualizer
(
discr
,
vis_order
=
order
)
step
=
0
norm
=
bind
(
discr
,
sym
.
norm
(
2
,
sym
.
var
(
"
u
"
)))
for
event
in
dt_stepper
.
run
(
t_end
=
final_time
):
if
isinstance
(
event
,
dt_stepper
.
StateComputed
):
...
...
@@ -128,15 +102,8 @@ def main(write_output=True, order=4):
#print(step, event.t, norm(queue, u=event.state_component[0]))
vis
.
write_vtk_file
(
"
fld-%04d.vtu
"
%
step
,
[
(
"
u
"
,
event
.
state_component
)
])
[(
"
u
"
,
event
.
state_component
)])
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
grudge/models/advection.py
+
3
−
3
View file @
90acbf2e
...
...
@@ -177,9 +177,9 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator):
flux
(
sym
.
int_tpair
(
u
))
+
flux
(
sym
.
bv_tpair
(
sym
.
BTAG_ALL
,
u
,
bc_in
))
# FIXME: Add back support for inflow/outflow tags
#+ flux(sym.bv_tpair(self.inflow_tag, u, bc_in))
#+ flux(sym.bv_tpair(self.outflow_tag, u, bc_out))
# FIXME: Add back support for inflow/outflow tags
#+ flux(sym.bv_tpair(self.inflow_tag, u, bc_in))
#+ flux(sym.bv_tpair(self.outflow_tag, u, bc_out))
))
# }}}
...
...
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