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
af3f90f0
Commit
af3f90f0
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Post-merge fixes
parent
af5593cd
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!212
Gravity infrastructure
,
!172
[WIP] Self gravity (Barnes-Hut version)
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cell.c
+2
-2
2 additions, 2 deletions
src/cell.c
src/engine.c
+1
-1
1 addition, 1 deletion
src/engine.c
src/runner_doiact_grav.h
+19
-19
19 additions, 19 deletions
src/runner_doiact_grav.h
with
22 additions
and
22 deletions
src/cell.c
+
2
−
2
View file @
af3f90f0
...
@@ -721,11 +721,11 @@ int cell_are_neighbours(const struct cell *restrict ci,
...
@@ -721,11 +721,11 @@ int cell_are_neighbours(const struct cell *restrict ci,
const
struct
cell
*
restrict
cj
)
{
const
struct
cell
*
restrict
cj
)
{
#ifdef SWIFT_DEBUG_CHECKS
#ifdef SWIFT_DEBUG_CHECKS
if
(
ci
->
h
[
0
]
!=
cj
->
h
[
0
])
error
(
"Cells of different size !"
);
if
(
ci
->
widt
h
[
0
]
!=
cj
->
widt
h
[
0
])
error
(
"Cells of different size !"
);
#endif
#endif
/* Maximum allowed distance */
/* Maximum allowed distance */
const
double
min_dist
=
1
.
2
*
ci
->
h
[
0
];
/* 1.2 accounts for rounding errors */
const
double
min_dist
=
1
.
2
*
ci
->
widt
h
[
0
];
/* 1.2 accounts for rounding errors */
/* (Manhattan) Distance between the cells */
/* (Manhattan) Distance between the cells */
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
...
...
This diff is collapsed.
Click to expand it.
src/engine.c
+
1
−
1
View file @
af3f90f0
...
@@ -2646,7 +2646,7 @@ void engine_step(struct engine *e) {
...
@@ -2646,7 +2646,7 @@ void engine_step(struct engine *e) {
/* Check the gravity accelerations */
/* Check the gravity accelerations */
struct
gpart
*
temp
=
malloc
(
s
->
nr_gparts
*
sizeof
(
struct
gpart
));
struct
gpart
*
temp
=
malloc
(
s
->
nr_gparts
*
sizeof
(
struct
gpart
));
memcpy
(
temp
,
s
->
gparts
,
s
->
nr_gparts
*
sizeof
(
struct
gpart
));
memcpy
(
temp
,
s
->
gparts
,
s
->
nr_gparts
*
sizeof
(
struct
gpart
));
const
double
rlr
=
const_gravity_a_smooth
*
s
->
cells
[
0
].
h
[
0
];
const
double
rlr
=
const_gravity_a_smooth
*
s
->
cells
[
0
].
widt
h
[
0
];
gravity_n2
(
temp
,
s
->
nr_gparts
,
e
->
physical_constants
,
rlr
);
gravity_n2
(
temp
,
s
->
nr_gparts
,
e
->
physical_constants
,
rlr
);
file
=
fopen
(
"grav_brute.dat"
,
"w"
);
file
=
fopen
(
"grav_brute.dat"
,
"w"
);
for
(
size_t
k
=
0
;
k
<
s
->
nr_gparts
;
++
k
)
{
for
(
size_t
k
=
0
;
k
<
s
->
nr_gparts
;
++
k
)
{
...
...
This diff is collapsed.
Click to expand it.
src/runner_doiact_grav.h
+
19
−
19
View file @
af3f90f0
...
@@ -72,7 +72,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
...
@@ -72,7 +72,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
struct
gpart
*
restrict
gparts
=
ci
->
gparts
;
struct
gpart
*
restrict
gparts
=
ci
->
gparts
;
const
struct
multipole
multi
=
cj
->
multipole
;
const
struct
multipole
multi
=
cj
->
multipole
;
const
int
ti_current
=
e
->
ti_current
;
const
int
ti_current
=
e
->
ti_current
;
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
ci
->
super
->
h
[
0
]);
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
ci
->
super
->
widt
h
[
0
]);
TIMER_TIC
;
TIMER_TIC
;
...
@@ -95,7 +95,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
...
@@ -95,7 +95,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pm(
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
cj
->
h
[
0
],
cj
->
gcount
);
cj
->
widt
h
[
0
],
cj
->
gcount
);
}
}
#endif
#endif
...
@@ -139,13 +139,13 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
...
@@ -139,13 +139,13 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
struct
gpart
*
restrict
gparts_i
=
ci
->
gparts
;
struct
gpart
*
restrict
gparts_i
=
ci
->
gparts
;
struct
gpart
*
restrict
gparts_j
=
cj
->
gparts
;
struct
gpart
*
restrict
gparts_j
=
cj
->
gparts
;
const
int
ti_current
=
e
->
ti_current
;
const
int
ti_current
=
e
->
ti_current
;
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
ci
->
super
->
h
[
0
]);
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
ci
->
super
->
widt
h
[
0
]);
TIMER_TIC
;
TIMER_TIC
;
#ifdef SWIFT_DEBUG_CHECKS
#ifdef SWIFT_DEBUG_CHECKS
if
(
ci
->
h
[
0
]
!=
cj
->
h
[
0
])
// MATTHIEU sanity check
if
(
ci
->
widt
h
[
0
]
!=
cj
->
widt
h
[
0
])
// MATTHIEU sanity check
error
(
"Non matching cell sizes !! h_i=%f h_j=%f"
,
ci
->
h
[
0
],
cj
->
h
[
0
]);
error
(
"Non matching cell sizes !! h_i=%f h_j=%f"
,
ci
->
widt
h
[
0
],
cj
->
widt
h
[
0
]);
#endif
#endif
/* Anything to do here? */
/* Anything to do here? */
...
@@ -160,7 +160,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
...
@@ -160,7 +160,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
cj
->
h
[
0
],
cj
->
gcount
);
cj
->
widt
h
[
0
],
cj
->
gcount
);
}
}
for
(
int
pid
=
0
;
pid
<
gcount_j
;
pid
++
)
{
for
(
int
pid
=
0
;
pid
<
gcount_j
;
pid
++
)
{
...
@@ -171,7 +171,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
...
@@ -171,7 +171,7 @@ __attribute__((always_inline)) INLINE static void runner_dopair_grav_pp(
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count=%d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count=%d"
,
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
ci
->
h
[
0
],
ci
->
gcount
);
ci
->
widt
h
[
0
],
ci
->
gcount
);
}
}
#endif
#endif
...
@@ -233,7 +233,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
...
@@ -233,7 +233,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
const
int
gcount
=
c
->
gcount
;
const
int
gcount
=
c
->
gcount
;
struct
gpart
*
restrict
gparts
=
c
->
gparts
;
struct
gpart
*
restrict
gparts
=
c
->
gparts
;
const
int
ti_current
=
e
->
ti_current
;
const
int
ti_current
=
e
->
ti_current
;
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
c
->
super
->
h
[
0
]);
const
float
rlr_inv
=
1
.
/
(
const_gravity_a_smooth
*
c
->
super
->
widt
h
[
0
]);
TIMER_TIC
;
TIMER_TIC
;
...
@@ -253,7 +253,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
...
@@ -253,7 +253,7 @@ __attribute__((always_inline)) INLINE static void runner_doself_grav_pp(
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
c
->
loc
[
0
],
c
->
loc
[
1
],
c
->
loc
[
2
],
c
->
h
[
0
],
gp
->
id_or_neg_offset
,
c
->
loc
[
0
],
c
->
loc
[
1
],
c
->
loc
[
2
],
c
->
widt
h
[
0
],
c
->
gcount
);
c
->
gcount
);
}
}
#endif
#endif
...
@@ -324,8 +324,8 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
...
@@ -324,8 +324,8 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
if
(
gcount_i
==
0
||
gcount_j
==
0
)
error
(
"Empty cell !"
);
if
(
gcount_i
==
0
||
gcount_j
==
0
)
error
(
"Empty cell !"
);
/* Bad stuff will happen if cell sizes are different */
/* Bad stuff will happen if cell sizes are different */
if
(
ci
->
h
[
0
]
!=
cj
->
h
[
0
])
if
(
ci
->
widt
h
[
0
]
!=
cj
->
widt
h
[
0
])
error
(
"Non matching cell sizes !! h_i=%f h_j=%f"
,
ci
->
h
[
0
],
cj
->
h
[
0
]);
error
(
"Non matching cell sizes !! h_i=%f h_j=%f"
,
ci
->
widt
h
[
0
],
cj
->
widt
h
[
0
]);
/* Sanity check */
/* Sanity check */
if
(
ci
==
cj
)
if
(
ci
==
cj
)
...
@@ -336,10 +336,10 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
...
@@ -336,10 +336,10 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
/* Are the cells direct neighbours? */
/* Are the cells direct neighbours? */
if
(
!
cell_are_neighbours
(
ci
,
cj
))
if
(
!
cell_are_neighbours
(
ci
,
cj
))
error
(
error
(
"Non-neighbouring cells ! ci->x=[%f %f %f] ci->h=%f cj->loc=[%f %f %f] "
"Non-neighbouring cells ! ci->x=[%f %f %f] ci->
widt
h=%f cj->loc=[%f %f %f] "
"cj->h=%f"
,
"cj->
widt
h=%f"
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
ci
->
h
[
0
],
cj
->
loc
[
0
],
cj
->
loc
[
1
],
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
ci
->
widt
h
[
0
],
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
cj
->
h
[
0
]);
cj
->
loc
[
2
],
cj
->
widt
h
[
0
]);
#endif
#endif
...
@@ -352,7 +352,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
...
@@ -352,7 +352,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
gp
->
id_or_neg_offset
,
cj
->
loc
[
0
],
cj
->
loc
[
1
],
cj
->
loc
[
2
],
cj
->
h
[
0
],
cj
->
gcount
);
cj
->
widt
h
[
0
],
cj
->
gcount
);
}
}
for
(
int
pid
=
0
;
pid
<
cj
->
gcount
;
pid
++
)
{
for
(
int
pid
=
0
;
pid
<
cj
->
gcount
;
pid
++
)
{
...
@@ -363,7 +363,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
...
@@ -363,7 +363,7 @@ static void runner_dopair_grav(struct runner *r, struct cell *ci,
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
ci
->
h
[
0
],
ci
->
gcount
);
ci
->
widt
h
[
0
],
ci
->
gcount
);
}
}
#endif
#endif
...
@@ -479,7 +479,7 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) {
...
@@ -479,7 +479,7 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) {
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
if
(
gp
->
id_or_neg_offset
==
ICHECK
)
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
message
(
"id=%lld loc=[ %f %f %f ] size= %f count= %d"
,
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
gp
->
id_or_neg_offset
,
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
],
ci
->
h
[
0
],
ci
->
gcount
);
ci
->
widt
h
[
0
],
ci
->
gcount
);
}
}
#endif
#endif
...
@@ -488,7 +488,7 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) {
...
@@ -488,7 +488,7 @@ static void runner_do_grav_mm(struct runner *r, struct cell *ci, int timer) {
struct
cell
*
cells
=
e
->
s
->
cells
;
struct
cell
*
cells
=
e
->
s
->
cells
;
const
int
nr_cells
=
e
->
s
->
nr_cells
;
const
int
nr_cells
=
e
->
s
->
nr_cells
;
const
int
ti_current
=
e
->
ti_current
;
const
int
ti_current
=
e
->
ti_current
;
const
double
max_d
=
const_gravity_a_smooth
*
const_gravity_r_cut
*
ci
->
h
[
0
];
const
double
max_d
=
const_gravity_a_smooth
*
const_gravity_r_cut
*
ci
->
widt
h
[
0
];
const
double
max_d2
=
max_d
*
max_d
;
const
double
max_d2
=
max_d
*
max_d
;
const
double
pos_i
[
3
]
=
{
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
]};
const
double
pos_i
[
3
]
=
{
ci
->
loc
[
0
],
ci
->
loc
[
1
],
ci
->
loc
[
2
]};
...
...
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