Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ScalFMM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
solverstack
ScalFMM
Commits
6a10f6c2
Commit
6a10f6c2
authored
11 years ago
by
Olivier COULAUD
Browse files
Options
Downloads
Patches
Plain Diff
add cuboid geometry
parent
f8ac4638
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Src/Utils/FGenerateDistribution.hpp
+45
-3
45 additions, 3 deletions
Src/Utils/FGenerateDistribution.hpp
with
45 additions
and
3 deletions
Src/Utils/FGenerateDistribution.hpp
+
45
−
3
View file @
6a10f6c2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define FGENERATEDISTRIBUTION_HPP
#define FGENERATEDISTRIBUTION_HPP
#include
<cstdlib>
#include
<cstdlib>
#include
<ctime>
#include
<ctime>
#include
<iostream>
#include
<iostream>
...
@@ -16,12 +17,53 @@
...
@@ -16,12 +17,53 @@
// return drand48();
// return drand48();
//} ;
//} ;
void
initRandom
()
{
void
initRandom
()
{
srand
(
static_cast
<
unsigned
int
>
(
time
(
0
)))
;
srand
48
(
static_cast
<
unsigned
int
>
(
time
(
0
)))
;
}
;
}
;
FReal
getRandom
()
{
FReal
getRandom
()
{
//
return static_cast<FReal>(
r
dand48());
return
static_cast
<
FReal
>
(
d
r
and48
());
return
static_cast
<
FReal
>
(
rand
()
/
FReal
(
RAND_MAX
));
//
return static_cast<FReal>(rand()/FReal(RAND_MAX));
}
;
}
;
//! \fn unifRandonPointsOnUnitCube(const int N , FReal * points)
//! \brief Generate N points uniformly distributed on the unit cube
//!
//! \param N the number of points uniformly randomly sample on the unit cube
//! \param points array of size 4*N and stores data as follow x,y,z,0,x,y,z,0....
//! \example generateDistributions.cpp
void
unifRandonPointsOnUnitCube
(
const
int
N
,
FReal
*
points
)
{
//
initRandom
()
;
int
j
=
0
;
for
(
int
i
=
0
;
i
<
N
;
++
i
,
j
+=
4
)
{
//
points
[
j
]
=
getRandom
()
;
points
[
j
+
1
]
=
getRandom
()
;
points
[
j
+
2
]
=
getRandom
()
;
//
}
};
//! \fn unifRandonPointsOnCube(const int N , FReal * points)
//! \brief Generate N points uniformly distributed on the cube of length R
//!
//! \param N the number of points uniformly randomly sample on the unit cube
//! \param Lx the the X-length of the cube
//! \param Ly the the Y-length of the cube
//! \param Lz the the Z-length of the cube
//! \param points array of size 4*N and stores data as follow x,y,z,0,x,y,z,0....
//! \example generateDistributions.cpp
void
unifRandonPointsOnCube
(
const
int
N
,
const
FReal
Lx
,
const
FReal
Ly
,
const
FReal
Lz
,
FReal
*
points
)
{
//
unifRandonPointsOnUnitCube
(
N
,
points
)
;
int
j
=
0
;
for
(
int
i
=
0
;
i
<
N
;
++
i
,
j
+=
4
)
{
points
[
j
]
*=
Lx
;
points
[
j
+
1
]
*=
Ly
;
points
[
j
+
2
]
*=
Lz
;
}
};
//! \fn unifRandonPointsOnUnitSphere(const int N , FReal * points)
//! \fn unifRandonPointsOnUnitSphere(const int N , FReal * points)
//! \brief Generate N points uniformly distributed on the unit sphere
//! \brief Generate N points uniformly distributed on the unit sphere
...
...
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