Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
Show more breadcrumbs
Jonas Plewinski
pystencils
Commits
ce39e21f
Commit
ce39e21f
authored
6 years ago
by
Stephan Seitz
Committed by
Martin Bauer
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add assignment.assignmetn_from_stencil
parent
e617c781
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignment.py
+16
-1
16 additions, 1 deletion
assignment.py
with
16 additions
and
1 deletion
assignment.py
+
16
−
1
View file @
ce39e21f
...
...
@@ -6,8 +6,9 @@ try:
from
sympy.codegen.ast
import
Assignment
except
ImportError
:
Assignment
=
None
import
numpy
as
np
__all__
=
[
'
Assignment
'
]
__all__
=
[
'
Assignment
'
,
'
assignment_from_stencil
'
]
def
print_assignment_latex
(
printer
,
expr
):
...
...
@@ -48,3 +49,17 @@ else:
__str__
=
assignment_str
_print_Assignment
=
print_assignment_latex
def
assignment_from_stencil
(
stencil_array
,
input_field
,
output_field
,
normalization_factor
=
None
):
stencil_array
=
np
.
array
(
stencil_array
)
rhs
=
0
offset
=
tuple
(
s
//
2
for
s
in
stencil_array
.
shape
)
for
index
,
factor
in
np
.
ndenumerate
(
stencil_array
):
rhs
+=
factor
*
input_field
[
tuple
(
i
-
o
for
i
,
o
in
zip
(
index
,
offset
))]
if
normalization_factor
:
rhs
*=
normalization_factor
return
Assignment
(
output_field
.
center
(),
rhs
)
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