Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
41cd3b62
Commit
41cd3b62
authored
Aug 16, 2017
by
Matthieu Schaller
Browse files
Added (unused thus far) M2P kernels.
parent
8632501a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/gravity_properties.c
View file @
41cd3b62
...
...
@@ -60,6 +60,7 @@ void gravity_props_init(struct gravity_props *p,
p
->
epsilon
=
3
.
*
parser_get_param_double
(
params
,
"Gravity:epsilon"
);
p
->
epsilon2
=
p
->
epsilon
*
p
->
epsilon
;
p
->
epsilon_inv
=
1
.
f
/
p
->
epsilon
;
p
->
epsilon_inv3
=
p
->
epsilon_inv
*
p
->
epsilon_inv
*
p
->
epsilon_inv
;
}
void
gravity_props_print
(
const
struct
gravity_props
*
p
)
{
...
...
src/gravity_properties.h
View file @
41cd3b62
...
...
@@ -65,6 +65,9 @@ struct gravity_props {
/*! Inverse of softening length */
float
epsilon_inv
;
/*! Cube of the inverse of softening length */
float
epsilon_inv3
;
};
void
gravity_props_print
(
const
struct
gravity_props
*
p
);
...
...
src/multipole.h
View file @
41cd3b62
...
...
@@ -2344,6 +2344,50 @@ INLINE static void gravity_L2P(const struct grav_tensor *lb,
gp
->
a_grav
[
2
]
+=
a_grav
[
2
];
}
INLINE
static
void
gravity_M2P
(
const
struct
multipole
*
ma
,
const
struct
gravity_props
*
props
,
const
double
loc
[
3
],
struct
gpart
*
gp
)
{
#if SELF_GRAVITY_MULTIPOLE_ORDER > 0
const
float
eps2
=
props
->
epsilon2
;
const
float
eps_inv
=
props
->
epsilon_inv
;
const
float
eps_inv3
=
props
->
epsilon_inv3
;
/* Distance to the multipole */
const
float
dx
=
gp
->
x
[
0
]
-
loc
[
0
];
const
float
dy
=
gp
->
x
[
1
]
-
loc
[
1
];
const
float
dz
=
gp
->
x
[
2
]
-
loc
[
2
];
const
float
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
/* Get the inverse distance */
const
float
r_inv
=
1
.
f
/
sqrtf
(
r2
);
float
f
,
W
;
if
(
r2
>=
eps2
)
{
/* Get Newtonian gravity */
f
=
ma
->
M_000
*
r_inv
*
r_inv
*
r_inv
;
}
else
{
const
float
r
=
r2
*
r_inv
;
const
float
u
=
r
*
eps_inv
;
kernel_grav_eval
(
u
,
&
W
);
/* Get softened gravity */
f
=
ma
->
M_000
*
eps_inv3
*
W
;
}
gp
->
a_grav
[
0
]
-=
f
*
dx
;
gp
->
a_grav
[
1
]
-=
f
*
dy
;
gp
->
a_grav
[
2
]
-=
f
*
dz
;
#endif
}
/**
* @brief Checks whether a cell-cell interaction can be appromixated by a M-M
* interaction using the CoM and cell radius at rebuild.
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment