Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils_autodiff
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
pycodegen
pystencils_autodiff
Commits
703816fe
Commit
703816fe
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Allow adding arrays from fields, warn only if run fails
parent
19116526
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
src/pystencils_autodiff/graph_datahandling.py
+44
-25
44 additions, 25 deletions
src/pystencils_autodiff/graph_datahandling.py
with
44 additions
and
25 deletions
src/pystencils_autodiff/graph_datahandling.py
+
44
−
25
View file @
703816fe
...
...
@@ -15,6 +15,7 @@ import numpy as np
import
pystencils.datahandling
import
pystencils.kernel_wrapper
import
pystencils.timeloop
from
pystencils.data_types
import
create_type
from
pystencils.field
import
FieldType
...
...
@@ -149,7 +150,11 @@ class GraphDataHandling(pystencils.datahandling.SerialDataHandling):
def
run
(
self
,
time_steps
=
1
):
former_call_queue
=
copy
(
self
.
parent
.
call_queue
)
self
.
parent
.
call_queue
=
[]
super
().
run
(
time_steps
)
try
:
super
().
run
(
time_steps
)
except
Exception
as
e
:
import
warnings
warnings
.
warn
(
e
)
self
.
parent
.
call_queue
=
former_call_queue
former_call_queue
.
append
(
TimeloopRun
(
self
,
time_steps
))
...
...
@@ -181,16 +186,8 @@ class GraphDataHandling(pystencils.datahandling.SerialDataHandling):
if
layout
is
None
:
layout
=
self
.
default_layout
rtn
=
super
().
add_array
(
name
,
values_per_cell
,
dtype
,
latex_name
,
ghost_layers
,
layout
,
cpu
,
gpu
,
alignment
,
field_type
)
if
gpu
is
None
:
gpu
=
self
.
default_target
in
self
.
_GPU_LIKE_TARGETS
# Weird code happening in super class
if
not
hasattr
(
values_per_cell
,
'
__len__
'
):
...
...
@@ -198,21 +195,43 @@ class GraphDataHandling(pystencils.datahandling.SerialDataHandling):
if
len
(
values_per_cell
)
==
1
and
values_per_cell
[
0
]
==
1
:
values_per_cell
=
()
if
shape
:
rtn
=
self
.
_fields
[
name
]
=
pystencils
.
Field
.
create_fixed_size
(
name
,
shape
,
index_dimensions
=
len
(
values_per_cell
),
layout
=
layout
,
dtype
=
dtype
,
field_type
=
field_type
)
if
isinstance
(
name
,
pystencils
.
Field
):
rtn
=
name
name
=
name
.
name
super
().
add_array
(
rtn
.
name
,
rtn
.
values_per_cell
(),
rtn
.
dtype
.
numpy_dtype
,
rtn
.
latex_name
,
1
,
cpu
=
cpu
,
gpu
=
gpu
,
field_type
=
rtn
.
field_type
)
else
:
rtn
=
self
.
_fields
[
name
]
=
pystencils
.
Field
.
create_generic
(
name
,
self
.
dim
,
dtype
,
index_dimensions
=
len
(
values_per_cell
),
layout
=
layout
,
index_shape
=
values_per_cell
,
field_type
=
field_type
)
rtn
=
super
().
add_array
(
name
,
values_per_cell
,
dtype
,
latex_name
,
ghost_layers
,
layout
,
cpu
,
gpu
,
alignment
,
field_type
)
if
shape
:
rtn
=
self
.
_fields
[
name
]
=
pystencils
.
Field
.
create_fixed_size
(
name
,
shape
,
index_dimensions
=
len
(
values_per_cell
),
layout
=
layout
,
dtype
=
dtype
,
field_type
=
field_type
)
else
:
rtn
=
self
.
_fields
[
name
]
=
pystencils
.
Field
.
create_generic
(
name
,
self
.
dim
,
dtype
,
index_dimensions
=
len
(
values_per_cell
),
layout
=
layout
,
index_shape
=
values_per_cell
,
field_type
=
field_type
)
rtn
.
latex_name
=
latex_name
...
...
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