Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pairs
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
software
pairs
Commits
d75dc08b
Commit
d75dc08b
authored
4 years ago
by
Rafael Ravedutti Lucio Machado
Browse files
Options
Downloads
Patches
Plain Diff
Finally fixed PBC
Signed-off-by:
Rafael Ravedutti Lucio Machado
<
rafael.r.ravedutti@fau.de
>
parent
c6df6759
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ast/loops.py
+7
-1
7 additions, 1 deletion
ast/loops.py
sim/particle_simulation.py
+2
-7
2 additions, 7 deletions
sim/particle_simulation.py
sim/pbc.py
+11
-23
11 additions, 23 deletions
sim/pbc.py
sim/timestep.py
+14
-9
14 additions, 9 deletions
sim/timestep.py
with
34 additions
and
40 deletions
ast/loops.py
+
7
−
1
View file @
d75dc08b
...
...
@@ -21,11 +21,17 @@ class Iter():
return
Type_Int
def
is_mutable
(
self
):
return
False
# FIXME: This should be set to False, but currently the flattening transformation is reusing
# expressions that are not alive anymore (used first within if, then outside it), causing
# the generated code to be uncompilable
return
True
def
scope
(
self
):
return
self
.
loop
.
block
def
__add__
(
self
,
other
):
return
Expr
(
self
.
sim
,
self
,
other
,
'
+
'
)
def
__sub__
(
self
,
other
):
return
Expr
(
self
.
sim
,
self
,
other
,
'
-
'
)
...
...
This diff is collapsed.
Click to expand it.
sim/particle_simulation.py
+
2
−
7
View file @
d75dc08b
...
...
@@ -175,22 +175,17 @@ class ParticleSimulation:
def
generate
(
self
):
timestep
=
Timestep
(
self
,
self
.
ntimesteps
,
[
(
EnforcePBC
(
self
.
pbc
).
lower
(),
20
),
(
SetupPBC
(
self
.
pbc
).
lower
(),
20
),
UpdatePBC
(
self
.
pbc
).
lower
(),
(
SetupPBC
(
self
.
pbc
).
lower
(),
UpdatePBC
(
self
.
pbc
).
lower
(),
20
),
(
CellListsBuild
(
self
.
cell_lists
).
lower
(),
20
),
PropertiesResetVolatile
(
self
).
lower
(),
self
.
kernels
.
lower
()
])
timestep
.
add
(
Block
(
self
,
VTKWrite
(
self
,
self
.
vtk_file
,
timestep
.
timestep
())))
timestep
.
add
(
Block
(
self
,
VTKWrite
(
self
,
self
.
vtk_file
,
timestep
.
timestep
()
+
1
)))
body
=
Block
.
from_list
(
self
,
[
CellListsStencilBuild
(
self
.
cell_lists
).
lower
(),
self
.
setups
.
lower
(),
EnforcePBC
(
self
.
pbc
).
lower
(),
SetupPBC
(
self
.
pbc
).
lower
(),
UpdatePBC
(
self
.
pbc
).
lower
(),
CellListsBuild
(
self
.
cell_lists
).
lower
(),
Block
(
self
,
VTKWrite
(
self
,
self
.
vtk_file
,
0
)),
timestep
.
as_block
()
])
...
...
This diff is collapsed.
Click to expand it.
sim/pbc.py
+
11
−
23
View file @
d75dc08b
...
...
@@ -95,20 +95,13 @@ class SetupPBC:
if
capacity_exceeded
:
resize
.
set
(
Select
(
sim
,
resize
>
npbc
,
resize
+
1
,
npbc
))
else
:
pbc_map
[
npbc
].
set
(
i
)
pbc_mult
[
npbc
][
d
].
set
(
1
)
positions
[
nlocal
+
npbc
][
d
].
set
(
positions
[
i
][
d
]
+
grid
.
length
(
d
))
for
is_local
in
Branch
(
sim
,
i
<
nlocal
):
# TODO: VecFilter.others generator?
if
is_local
:
pbc_map
[
npbc
].
set
(
i
)
else
:
pbc_map
[
npbc
].
set
(
pbc_map
[
i
-
nlocal
])
for
d_
in
[
x
for
x
in
range
(
0
,
ndims
)
if
x
!=
d
]:
if
is_local
:
pbc_mult
[
npbc
][
d_
].
set
(
0
)
else
:
pbc_mult
[
npbc
][
d_
].
set
(
pbc_mult
[
i
-
nlocal
][
d_
])
for
d_
in
[
x
for
x
in
range
(
0
,
ndims
)
if
x
!=
d
]:
pbc_mult
[
npbc
][
d_
].
set
(
0
)
positions
[
nlocal
+
npbc
][
d_
].
set
(
positions
[
i
][
d_
])
npbc
.
add
(
1
)
...
...
@@ -117,18 +110,13 @@ class SetupPBC:
if
capacity_exceeded
:
resize
.
set
(
Select
(
sim
,
resize
>
npbc
,
resize
+
1
,
npbc
))
else
:
pbc_map
[
npbc
].
set
(
i
)
pbc_mult
[
npbc
][
d
].
set
(
-
1
)
for
is_local
in
Branch
(
sim
,
i
<
nlocal
):
if
is_local
:
pbc_map
[
npbc
].
set
(
i
)
else
:
pbc_map
[
npbc
].
set
(
pbc_map
[
i
-
nlocal
])
for
d_
in
[
x
for
x
in
range
(
0
,
ndims
)
if
x
!=
d
]:
if
is_local
:
pbc_mult
[
npbc
][
d_
].
set
(
0
)
else
:
pbc_mult
[
npbc
][
d_
].
set
(
pbc_mult
[
i
-
nlocal
][
d_
])
positions
[
nlocal
+
npbc
][
d
].
set
(
positions
[
i
][
d
]
-
grid
.
length
(
d
))
for
d_
in
[
x
for
x
in
range
(
0
,
ndims
)
if
x
!=
d
]:
pbc_mult
[
npbc
][
d_
].
set
(
0
)
positions
[
nlocal
+
npbc
][
d_
].
set
(
positions
[
i
][
d_
])
npbc
.
add
(
1
)
...
...
This diff is collapsed.
Click to expand it.
sim/timestep.py
+
14
−
9
View file @
d75dc08b
...
...
@@ -8,29 +8,34 @@ class Timestep:
def
__init__
(
self
,
sim
,
nsteps
,
item_list
=
None
):
self
.
sim
=
sim
self
.
block
=
Block
(
sim
,
[])
self
.
timestep_loop
=
For
(
sim
,
1
,
nsteps
+
1
,
self
.
block
)
self
.
timestep_loop
=
For
(
sim
,
0
,
nsteps
+
1
,
self
.
block
)
if
item_list
is
not
None
:
for
item
in
item_list
:
if
isinstance
(
item
,
tuple
):
self
.
add
(
item
[
0
],
item
[
1
])
if
len
(
item
)
>=
3
:
self
.
add
(
item
[
0
],
item
[
2
],
item
[
1
])
else
:
self
.
add
(
item
[
0
],
item
[
1
])
else
:
self
.
add
(
item
)
def
timestep
(
self
):
return
self
.
timestep_loop
.
iter
()
def
add
(
self
,
item
,
exec_every
=
0
):
assert
exec_every
>=
0
,
\
"
exec_every parameter must be higher or equal than zero!
"
def
add
(
self
,
item
,
exec_every
=
0
,
item_else
=
None
):
assert
exec_every
>=
0
,
"
exec_every parameter must be higher or equal than zero!
"
stmts
=
item
if
not
isinstance
(
item
,
Block
)
else
item
.
statements
()
stmts_else
=
None
ts
=
self
.
timestep_loop
.
iter
()
if
item_else
is
not
None
:
stmts_else
=
item_else
if
not
isinstance
(
item_else
,
Block
)
else
item_else
.
statements
()
if
exec_every
>
0
:
self
.
block
.
add_statement
(
Branch
(
self
.
sim
,
Expr
.
cmp
(
ts
%
exec_every
,
0
),
True
,
Block
(
self
.
sim
,
stmts
),
None
))
Branch
(
self
.
sim
,
Expr
.
cmp
(
ts
%
exec_every
,
0
),
True
if
stmts_else
is
None
else
False
,
Block
(
self
.
sim
,
stmts
),
None
if
stmts_else
is
None
else
Block
(
self
.
sim
,
stmts_else
)))
else
:
self
.
block
.
add_statement
(
stmts
)
...
...
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