Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
72ae8ff1
Commit
72ae8ff1
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
space_init now properly handles gparts
parent
dfdbd305
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!116
Basic implementation of gparts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/space.c
+28
-32
28 additions, 32 deletions
src/space.c
with
28 additions
and
32 deletions
src/space.c
+
28
−
32
View file @
72ae8ff1
...
...
@@ -1189,7 +1189,7 @@ struct cell *space_getcell(struct space *s) {
*/
void
space_init
(
struct
space
*
s
,
double
dim
[
3
],
struct
part
*
parts
,
struct
gpart
*
gparts
,
size_t
N
,
size_t
Ngpart
,
int
periodic
,
struct
gpart
*
gparts
,
size_t
N
gas
,
size_t
Ngpart
,
int
periodic
,
double
h_max
,
int
verbose
)
{
/* Store everything in the space. */
...
...
@@ -1197,54 +1197,50 @@ void space_init(struct space *s, double dim[3], struct part *parts,
s
->
dim
[
1
]
=
dim
[
1
];
s
->
dim
[
2
]
=
dim
[
2
];
s
->
periodic
=
periodic
;
s
->
nr_parts
=
N
;
s
->
size_parts
=
N
;
s
->
nr_parts
=
N
gas
;
s
->
size_parts
=
N
gas
;
s
->
parts
=
parts
;
s
->
nr_gparts
=
Ngpart
;
s
->
size_gparts
=
Ngpart
;
s
->
gparts
=
gparts
;
s
->
cell_min
=
h_max
;
s
->
nr_queues
=
1
;
s
->
size_parts_foreign
=
0
;
/* Check that all the particle positions are reasonable, wrap if periodic. */
/* Check that all the gas particle positions are reasonable, wrap if periodic.
*/
if
(
periodic
)
{
for
(
int
k
=
0
;
k
<
N
;
k
++
)
for
(
int
k
=
0
;
k
<
N
gas
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
while
(
parts
[
k
].
x
[
j
]
<
0
)
parts
[
k
].
x
[
j
]
+=
dim
[
j
];
while
(
parts
[
k
].
x
[
j
]
>=
dim
[
j
])
parts
[
k
].
x
[
j
]
-=
dim
[
j
];
}
}
else
{
for
(
int
k
=
0
;
k
<
N
;
k
++
)
for
(
int
k
=
0
;
k
<
N
gas
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
parts
[
k
].
x
[
j
]
<
0
||
parts
[
k
].
x
[
j
]
>=
dim
[
j
])
error
(
"Not all particles are within the specified domain."
);
}
/* Allocate the xtra parts array. */
if
(
posix_memalign
((
void
*
)
&
s
->
xparts
,
part_align
,
N
*
sizeof
(
struct
xpart
))
!=
0
)
error
(
"Failed to allocate xparts."
);
bzero
(
s
->
xparts
,
N
*
sizeof
(
struct
xpart
));
/* For now, clone the parts to make gparts. */
if
(
posix_memalign
((
void
*
)
&
s
->
gparts
,
part_align
,
N
*
sizeof
(
struct
gpart
))
!=
0
)
error
(
"Failed to allocate gparts."
);
bzero
(
s
->
gparts
,
N
*
sizeof
(
struct
gpart
));
/* for ( int k = 0 ; k < N ; k++ ) {
s->gparts[k].x[0] = s->parts[k].x[0];
s->gparts[k].x[1] = s->parts[k].x[1];
s->gparts[k].x[2] = s->parts[k].x[2];
s->gparts[k].v[0] = s->parts[k].v[0];
s->gparts[k].v[1] = s->parts[k].v[1];
s->gparts[k].v[2] = s->parts[k].v[2];
s->gparts[k].mass = s->parts[k].mass;
s->gparts[k].dt = s->parts[k].dt;
s->gparts[k].id = s->parts[k].id;
s->gparts[k].part = &s->parts[k];
s->parts[k].gpart = &s->gparts[k];
/* Same for the gparts */
if
(
periodic
)
{
for
(
int
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
while
(
gparts
[
k
].
x
[
j
]
<
0
)
gparts
[
k
].
x
[
j
]
+=
dim
[
j
];
while
(
gparts
[
k
].
x
[
j
]
>=
dim
[
j
])
gparts
[
k
].
x
[
j
]
-=
dim
[
j
];
}
s->nr_gparts = s->nr_parts; */
s
->
nr_gparts
=
0
;
s
->
size_gparts
=
s
->
size_parts
;
}
else
{
for
(
int
k
=
0
;
k
<
Ngpart
;
k
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
gparts
[
k
].
x
[
j
]
<
0
||
gparts
[
k
].
x
[
j
]
>=
dim
[
j
])
error
(
"Not all particles are within the specified domain."
);
}
/* Allocate the extra parts array. */
if
(
posix_memalign
((
void
*
)
&
s
->
xparts
,
xpart_align
,
Ngas
*
sizeof
(
struct
xpart
))
!=
0
)
error
(
"Failed to allocate xparts."
);
bzero
(
s
->
xparts
,
Ngas
*
sizeof
(
struct
xpart
));
/* Init the space lock. */
if
(
lock_init
(
&
s
->
lock
)
!=
0
)
error
(
"Failed to create space spin-lock."
);
...
...
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