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
21d0526d
Commit
21d0526d
authored
5 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added option to allow for tree-gravity below the softening length
parent
f903a6f2
No related branches found
No related tags found
1 merge request
!1077
Improved multipole acceptance criterion (MAC)
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gravity_properties.c
+4
-0
4 additions, 0 deletions
src/gravity_properties.c
src/gravity_properties.h
+3
-0
3 additions, 0 deletions
src/gravity_properties.h
src/multipole_accept.h
+14
-9
14 additions, 9 deletions
src/multipole_accept.h
with
21 additions
and
9 deletions
src/gravity_properties.c
+
4
−
0
View file @
21d0526d
...
...
@@ -110,6 +110,10 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
/* Adaptive opening angle tolerance */
p
->
adaptive_tolerance
=
parser_get_param_float
(
params
,
"Gravity:epsilon_fmm"
);
/* Are we allowing tree use below softening? */
p
->
use_tree_below_softening
=
parser_get_opt_param_int
(
params
,
"Gravity:use_tree_below_softening"
,
1
);
/* Mesh dithering */
if
(
periodic
&&
!
with_external_potential
)
{
p
->
with_dithering
=
...
...
This diff is collapsed.
Click to expand it.
src/gravity_properties.h
+
3
−
0
View file @
21d0526d
...
...
@@ -66,6 +66,9 @@ struct gravity_props {
/*! Tree opening angle (Multipole acceptance criterion) */
double
theta_crit
;
/*! Are we allowing tree gravity below softening? */
int
use_tree_below_softening
;
/* ------------- Properties of the softened gravity ------------------ */
/*! Co-moving softening length for for high-res. DM particles */
...
...
This diff is collapsed.
Click to expand it.
src/multipole_accept.h
+
14
−
9
View file @
21d0526d
...
...
@@ -57,8 +57,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept(
const
float
rho_B
=
use_rebuild_sizes
?
B
->
r_max_rebuild
:
B
->
r_max
;
#ifdef SWIFT_DEBUG_CHECKS
//if (rho_A == 0.) error("Size of multipole A is 0!");
//if (rho_B == 0.) error("Size of multipole B is 0!");
//
if (rho_A == 0.) error("Size of multipole A is 0!");
//
if (rho_B == 0.) error("Size of multipole B is 0!");
#endif
/* Compute the error estimator (without the 1/M_B term that cancels out) */
...
...
@@ -73,7 +73,7 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept(
E_BA_term
/=
(
rho_A
+
rho_B
);
}
/* Compute r^(p+2) */
/* Compute r^(p+2) */
#if SELF_GRAVITY_MULTIPOLE_ORDER % 2 == 1
const
float
r_to_p_plus2
=
integer_powf
(
sqrtf
(
r2
),
(
p
+
2
));
#else
...
...
@@ -108,7 +108,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept(
const
int
cond_1
=
rho_sum
*
rho_sum
<
r2
;
/* Condition 2: We are not below softening */
const
int
cond_2
=
max_softening
*
max_softening
<
r2
;
const
int
cond_2
=
props
->
use_tree_below_softening
||
max_softening
*
max_softening
<
r2
;
/* Condition 3: The contribution is accurate enough
* (E_BA / r^(p+2) < eps * a_min) */
...
...
@@ -122,7 +123,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept(
const
int
cond_1
=
rho_sum
*
rho_sum
<
theta_crit2
*
r2
;
/* Condition 2: We are not below softening */
const
int
cond_2
=
max_softening
*
max_softening
<
r2
;
const
int
cond_2
=
props
->
use_tree_below_softening
||
max_softening
*
max_softening
<
r2
;
return
cond_1
&&
cond_2
;
}
...
...
@@ -173,7 +175,7 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept(
const
float
rho_B
=
B
->
r_max
;
#ifdef SWIFT_DEBUG_CHECKS
//if (rho_B == 0.) error("Size of multipole B is 0!");
//
if (rho_B == 0.) error("Size of multipole B is 0!");
#endif
/* Compute the error estimator (without the 1/M_B term that cancels out) */
...
...
@@ -190,7 +192,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept(
const
float
old_a_grav
=
pa
->
old_a_grav_norm
;
/* Get the maximal softening length in B */
const
float
max_softening
=
B
->
m_pole
.
max_softening
;
const
float
max_softening
=
max
(
B
->
m_pole
.
max_softening
,
gravity_get_softening
(
pa
,
props
));
/* Get the relative tolerance */
const
float
eps
=
props
->
adaptive_tolerance
;
...
...
@@ -211,7 +214,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept(
const
int
cond_1
=
rho_B
*
rho_B
<
r2
;
/* Condition 2: We are not below softening */
const
int
cond_2
=
max_softening
*
max_softening
<
r2
;
const
int
cond_2
=
props
->
use_tree_below_softening
||
max_softening
*
max_softening
<
r2
;
/* Condition 3: The contribution is accurate enough
* (E_BA / r^(p+2) < eps * a) */
...
...
@@ -225,7 +229,8 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept(
const
int
cond_1
=
rho_B
*
rho_B
<
theta_crit2
*
r2
;
/* Condition 2: We are not below softening */
const
int
cond_2
=
max_softening
*
max_softening
<
r2
;
const
int
cond_2
=
props
->
use_tree_below_softening
||
max_softening
*
max_softening
<
r2
;
return
cond_1
&&
cond_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