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
47d7db53
Commit
47d7db53
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Correct generation of ICs.
Former-commit-id: 91a42bc3df43b74da9505398a2ed029204a57521
parent
7c1242b1
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
examples/test.c
+18
-17
18 additions, 17 deletions
examples/test.c
with
18 additions
and
17 deletions
examples/test.c
+
18
−
17
View file @
47d7db53
...
...
@@ -548,6 +548,8 @@ void factor(int value, int *f1, int *f2) {
void
generateICs
(
double
dim
[
3
],
struct
part
**
parts
,
int
*
N
,
int
*
periodic
,
int
mpi_rank
,
int
mpi_size
,
MPI_Comm
comm
,
MPI_Info
info
)
{
MPI_Barrier
(
comm
);
(
*
periodic
)
=
1
;
double
boxSize
=
1
.;
long
long
L
=
100
;
/* Number of particles along one axis */
...
...
@@ -558,7 +560,7 @@ void generateICs(double dim[3], struct part **parts, int *N, int *periodic,
/* Number of particles */
long
long
N_total
=
L
*
L
*
L
;
long
long
offset
=
0
;
double
mass
=
boxSize
*
boxSize
*
boxSize
*
rho
/
(
*
N
);
double
mass
=
boxSize
*
boxSize
*
boxSize
*
rho
/
(
N
_total
);
double
internalEnergy
=
P
/
((
gamma
-
1
.)
*
rho
);
/* Divide the particles among the tasks. */
...
...
@@ -574,7 +576,7 @@ void generateICs(double dim[3], struct part **parts, int *N, int *periodic,
/* Now generate particles */
message
(
"### MPI_Rank= %d Offset=%lld
\n
"
,
mpi_rank
,
offset
);
int
i
,
j
,
k
;
int
i
,
j
,
k
,
count
=
0
;
for
(
i
=
0
;
i
<
L
;
++
i
)
for
(
j
=
0
;
j
<
L
;
++
j
)
for
(
k
=
0
;
k
<
L
;
++
k
)
{
...
...
@@ -583,26 +585,28 @@ void generateICs(double dim[3], struct part **parts, int *N, int *periodic,
if
(
index
>=
offset
&&
index
<
offset
+
(
*
N
))
{
/* Position */
(
*
parts
)[
index
].
x
[
0
]
=
i
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
(
*
parts
)[
index
].
x
[
1
]
=
j
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
(
*
parts
)[
index
].
x
[
2
]
=
k
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
(
*
parts
)[
count
].
x
[
0
]
=
i
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
(
*
parts
)[
count
].
x
[
1
]
=
j
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
(
*
parts
)[
count
].
x
[
2
]
=
k
*
boxSize
/
L
+
boxSize
/
(
2
*
L
);
/* Velocity */
(
*
parts
)[
index
].
v
[
0
]
=
0
.;
(
*
parts
)[
index
].
v
[
1
]
=
0
.;
(
*
parts
)[
index
].
v
[
2
]
=
0
.;
(
*
parts
)[
count
].
v
[
0
]
=
0
.;
(
*
parts
)[
count
].
v
[
1
]
=
0
.;
(
*
parts
)[
count
].
v
[
2
]
=
0
.;
(
*
parts
)[
index
].
mass
=
mass
;
(
*
parts
)[
index
].
h
=
2
.
251
*
boxSize
/
L
;
(
*
parts
)[
index
].
u
=
internalEnergy
;
(
*
parts
)[
index
].
id
=
index
;
(
*
parts
)[
count
].
mass
=
mass
;
(
*
parts
)[
count
].
h
=
2
.
251
*
boxSize
/
L
;
(
*
parts
)[
count
].
u
=
internalEnergy
;
(
*
parts
)[
count
].
id
=
index
;
count
++
;
}
}
MPI_Barrier
(
MPI_COMM_WORLD
);
fflush
(
stdout
);
MPI_Barrier
(
comm
);
message
(
"Done generating ICs"
);
}
#endif
...
...
@@ -880,9 +884,6 @@ int main(int argc, char *argv[]) {
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
error
(
"done"
);
/* Init the runner history. */
#ifdef HIST
for
(
k
=
0
;
k
<
runner_hist_N
;
k
++
)
runner_hist_bins
[
k
]
=
0
;
...
...
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