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
2d70404f
Commit
2d70404f
authored
5 years ago
by
Stuart Mcalpine
Browse files
Options
Downloads
Patches
Plain Diff
Split if up to make more readable
parent
d8214473
No related branches found
No related tags found
1 merge request
!1014
Gravity brute force checks, extra options
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/engine.c
+46
-27
46 additions, 27 deletions
src/engine.c
with
46 additions
and
27 deletions
src/engine.c
+
46
−
27
View file @
2d70404f
...
...
@@ -2339,26 +2339,38 @@ void engine_step(struct engine *e) {
#endif
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Check how many gparts are active this timestep. */
size_t
nr_gparts
=
e
->
s
->
nr_gparts
;
size_t
gpart_active_count
=
0
;
/* Do we need to check the number of active gparts? */
if
(
e
->
force_checks_only_all_active
)
{
size_t
nr_gparts
=
e
->
s
->
nr_gparts
;
size_t
gpart_active_count
=
0
;
/* Count active gparts */
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
++
i
)
{
struct
gpart
*
gp
=
&
e
->
s
->
gparts
[
i
];
if
(
gpart_is_active
(
gp
,
e
))
gpart_active_count
+=
1
;
}
/*
Count active gparts
*/
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
++
i
)
{
struct
gpart
*
gp
=
&
e
->
s
->
gparts
[
i
];
if
(
gpart_is_active
(
gp
,
e
))
gpart_active
_count
+
=
1
;
/*
Are all gparts active?
*/
e
->
all_gparts_active
=
gpart_active_count
==
nr_gparts
;
}
else
{
e
->
all_
gpart
s
_active
=
0
;
}
/* Are all gparts active? */
e
->
all_gparts_active
=
gpart_active_count
==
nr_gparts
;
/* Run the brute-force gravity calculation for some gparts */
if
(
e
->
policy
&
engine_policy_self_gravity
&&
((
e
->
all_gparts_active
&&
e
->
force_checks_only_all_active
)
||
!
e
->
force_checks_only_all_active
)
&&
((
e
->
brute_force_gravity_flag
==
1
&&
e
->
force_checks_only_at_snapshots
)
||
!
e
->
force_checks_only_at_snapshots
))
gravity_exact_force_compute
(
e
->
s
,
e
);
/* Check if we want to run force checks this timestep. */
if
(
e
->
policy
&
engine_policy_self_gravity
)
{
/* Are all gparts active (and the option is selected)? */
if
((
e
->
all_gparts_active
&&
e
->
force_checks_only_all_active
)
||
!
e
->
force_checks_only_all_active
)
{
/* Is this a snapshot timestep (and the option is selected)? */
if
((
e
->
brute_force_gravity_flag
==
1
&&
e
->
force_checks_only_at_snapshots
)
||
!
e
->
force_checks_only_at_snapshots
)
{
/* Do checks */
gravity_exact_force_compute
(
e
->
s
,
e
);
}
}
}
#endif
/* Start all the tasks. */
...
...
@@ -2377,16 +2389,23 @@ void engine_step(struct engine *e) {
}
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Check the accuracy of the gravity calculation */
if
(
e
->
policy
&
engine_policy_self_gravity
&&
((
e
->
all_gparts_active
&&
e
->
force_checks_only_all_active
)
||
!
e
->
force_checks_only_all_active
)
&&
((
e
->
brute_force_gravity_flag
==
1
&&
e
->
force_checks_only_at_snapshots
)
||
!
e
->
force_checks_only_at_snapshots
))
{
gravity_exact_force_check
(
e
->
s
,
e
,
1e-1
);
/* Reset flag waiting for next output time */
e
->
brute_force_gravity_flag
=
0
;
/* Check if we want to run force checks this timestep. */
if
(
e
->
policy
&
engine_policy_self_gravity
)
{
/* Are all gparts active (and the option is selected)? */
if
((
e
->
all_gparts_active
&&
e
->
force_checks_only_all_active
)
||
!
e
->
force_checks_only_all_active
)
{
/* Is this a snapshot timestep (and the option is selected)? */
if
((
e
->
brute_force_gravity_flag
==
1
&&
e
->
force_checks_only_at_snapshots
)
||
!
e
->
force_checks_only_at_snapshots
)
{
/* Do checks */
gravity_exact_force_check
(
e
->
s
,
e
,
1e-1
);
/* Reset flag waiting for next output time */
e
->
brute_force_gravity_flag
=
0
;
}
}
}
#endif
...
...
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