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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Andreas Klöckner
grudge
Commits
be9620fb
Unverified
Commit
be9620fb
authored
4 years ago
by
Andreas Klöckner
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #29 from inducer/dofarray-not-ndarray-subclass
Dofarray not ndarray subclass
parents
3d9039d0
80e6d88a
No related branches found
No related tags found
No related merge requests found
Pipeline
#95800
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/dagrt-fusion.py
+2
-0
2 additions, 0 deletions
examples/dagrt-fusion.py
grudge/eager.py
+7
-19
7 additions, 19 deletions
grudge/eager.py
grudge/execution.py
+2
-2
2 additions, 2 deletions
grudge/execution.py
with
11 additions
and
21 deletions
examples/dagrt-fusion.py
+
2
−
0
View file @
be9620fb
...
...
@@ -107,6 +107,8 @@ def dof_array_nbytes(ary: np.ndarray):
return
sum
(
dof_array_nbytes
(
ary
[
idx
])
for
idx
in
np
.
ndindex
(
ary
.
shape
))
elif
isinstance
(
ary
,
DOFArray
):
return
sum
(
dof_array_nbytes
(
ary_i
)
for
ary_i
in
ary
)
else
:
return
ary
.
nbytes
...
...
This diff is collapsed.
Click to expand it.
grudge/eager.py
+
7
−
19
View file @
be9620fb
...
...
@@ -28,7 +28,7 @@ import pyopencl.array as cla # noqa
from
grudge
import
sym
,
bind
from
meshmode.mesh
import
BTAG_ALL
,
BTAG_NONE
,
BTAG_PARTITION
# noqa
from
meshmode.dof_array
import
freeze
,
DOFArray
,
flatten
,
unflatten
from
meshmode.dof_array
import
freeze
,
flatten
,
unflatten
from
grudge.discretization
import
DGDiscretizationWithBoundaries
from
grudge.symbolic.primitives
import
TracePair
...
...
@@ -83,9 +83,7 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
:arg tgt: a :class:`~grudge.sym.DOFDesc`, or a value convertible to one
:arg vec: a :class:`~meshmode.dof_array.DOFArray`
"""
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
return
obj_array_vectorize
(
lambda
el
:
self
.
project
(
src
,
tgt
,
el
),
vec
)
...
...
@@ -270,9 +268,7 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
local_only
=
True
)
def
inverse_mass
(
self
,
vec
):
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
return
obj_array_vectorize
(
lambda
el
:
self
.
inverse_mass
(
el
),
vec
)
...
...
@@ -292,9 +288,7 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
else
:
raise
TypeError
(
"
invalid number of arguments
"
)
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
return
obj_array_vectorize
(
lambda
el
:
self
.
face_mass
(
dd
,
el
),
vec
)
...
...
@@ -312,9 +306,7 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
dd
=
sym
.
as_dofdesc
(
dd
)
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
if
p
==
2
:
return
sum
(
self
.
norm
(
vec
[
idx
],
dd
=
dd
)
**
2
...
...
@@ -350,9 +342,7 @@ class EagerDGDiscretization(DGDiscretizationWithBoundaries):
def
interior_trace_pair
(
discrwb
,
vec
):
i
=
discrwb
.
project
(
"
vol
"
,
"
int_faces
"
,
vec
)
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
e
=
obj_array_vectorize
(
lambda
el
:
discrwb
.
opposite_face_connection
()(
el
),
i
)
...
...
@@ -412,9 +402,7 @@ def _cross_rank_trace_pairs_scalar_field(discrwb, vec, tag=None):
def
cross_rank_trace_pairs
(
discrwb
,
vec
,
tag
=
None
):
if
(
isinstance
(
vec
,
np
.
ndarray
)
and
vec
.
dtype
.
char
==
"
O
"
and
not
isinstance
(
vec
,
DOFArray
)):
if
isinstance
(
vec
,
np
.
ndarray
):
n
,
=
vec
.
shape
result
=
{}
...
...
This diff is collapsed.
Click to expand it.
grudge/execution.py
+
2
−
2
View file @
be9620fb
...
...
@@ -281,7 +281,7 @@ class ExecutionMapper(mappers.Evaluator,
for
in_grp
,
out_grp
in
zip
(
in_discr
.
groups
,
out_discr
.
groups
):
cache_key
=
"
elwise_linear
"
,
in_grp
,
out_grp
,
op
,
field
.
dtype
cache_key
=
"
elwise_linear
"
,
in_grp
,
out_grp
,
op
,
field
.
entry_
dtype
try
:
matrix
=
self
.
bound_op
.
operator_data_cache
[
cache_key
]
except
KeyError
:
...
...
@@ -347,7 +347,7 @@ class ExecutionMapper(mappers.Evaluator,
assert
len
(
all_faces_discr
.
groups
)
==
len
(
vol_discr
.
groups
)
for
afgrp
,
volgrp
in
zip
(
all_faces_discr
.
groups
,
vol_discr
.
groups
):
cache_key
=
"
face_mass
"
,
afgrp
,
op
,
field
.
dtype
cache_key
=
"
face_mass
"
,
afgrp
,
op
,
field
.
entry_
dtype
nfaces
=
volgrp
.
mesh_el_group
.
nfaces
...
...
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