Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
3fcb490d
Commit
3fcb490d
authored
Jul 22, 2016
by
Quentin Khan
Browse files
Improve plummer distribution generation
parent
6575d8c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Src/Files/FGenerateDistribution.hpp
View file @
3fcb490d
...
@@ -259,15 +259,17 @@ FReal plummerDist(FSize& cpt, const FReal &R) {
...
@@ -259,15 +259,17 @@ FReal plummerDist(FSize& cpt, const FReal &R) {
*/
*/
template
<
class
FReal
>
template
<
class
FReal
>
void
unifRandomPlummer
(
const
FSize
N
,
const
FReal
R
,
FReal
*
points
)
{
void
unifRandomPlummer
(
const
FSize
N
,
const
FReal
R
,
FReal
*
points
)
{
constexpr
const
FReal
rand_max
=
0.
995
;
constexpr
const
FReal
rand_max
=
0.
8
;
constexpr
const
FReal
r_max
=
std
::
sqrt
(
1.0
/
(
std
::
pow
(
rand_max
,
-
2.0
/
3.0
)
-
1.0
));
constexpr
const
FReal
r_max
=
std
::
sqrt
(
1.0
/
(
std
::
pow
(
rand_max
,
-
2.0
/
3.0
)
-
1.0
));
std
::
cerr
<<
r_max
<<
'\n'
;
std
::
cerr
<<
r_max
<<
'\n'
;
unifRandomPointsOnSphere
<
FReal
>
(
N
,
1
,
points
);
unifRandomPointsOnSphere
<
FReal
>
(
N
,
1
,
points
);
FReal
mc
=
1.0
/
static_cast
<
FReal
>
(
N
);
FReal
mc
=
1.0
/
static_cast
<
FReal
>
(
N
);
for
(
FSize
i
=
0
,
j
=
0
;
i
<
N
;
++
i
,
j
+=
4
)
{
for
(
FSize
i
=
0
,
j
=
0
;
i
<
N
;
++
i
,
j
+=
4
)
{
FReal
m
=
getRandom
<
FReal
>
();
FReal
m
=
getRandom
<
FReal
>
();
m
=
m
>
rand_max
?
rand_max
:
m
;
while
(
m
>
rand_max
)
{
m
=
getRandom
<
FReal
>
();
}
FReal
r
=
FMath
::
Sqrt
(
1.0
/
(
FMath
::
pow
(
m
,
-
2.0
/
3.0
)
-
1.0
))
/
r_max
;
FReal
r
=
FMath
::
Sqrt
(
1.0
/
(
FMath
::
pow
(
m
,
-
2.0
/
3.0
)
-
1.0
))
/
r_max
;
points
[
j
]
*=
r
;
points
[
j
]
*=
r
;
points
[
j
+
1
]
*=
r
;
points
[
j
+
1
]
*=
r
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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