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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
43abff62
Commit
43abff62
authored
Mar 30, 2016
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Add the option to choose a velocity field for the 27 cells test case.
parent
b3b13e6a
No related branches found
No related tags found
1 merge request
!138
More physical definition of SPH kernel functions
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test27cells.c
+48
-14
48 additions, 14 deletions
tests/test27cells.c
tests/tolerance.dat
+2
-2
2 additions, 2 deletions
tests/tolerance.dat
with
50 additions
and
16 deletions
tests/test27cells.c
+
48
−
14
View file @
43abff62
...
@@ -24,8 +24,15 @@
...
@@ -24,8 +24,15 @@
#include
<unistd.h>
#include
<unistd.h>
#include
"swift.h"
#include
"swift.h"
enum
velocity_types
{
velocity_zero
,
velocity_random
,
velocity_divergent
,
velocity_rotating
};
/**
/**
* Returns a random number (uniformly distributed) in [a,b[
*
@breif
Returns a random number (uniformly distributed) in [a,b[
*/
*/
double
random_uniform
(
double
a
,
double
b
)
{
double
random_uniform
(
double
a
,
double
b
)
{
return
(
rand
()
/
(
double
)
RAND_MAX
)
*
(
b
-
a
)
+
a
;
return
(
rand
()
/
(
double
)
RAND_MAX
)
*
(
b
-
a
)
+
a
;
...
@@ -35,7 +42,8 @@ double random_uniform(double a, double b) {
...
@@ -35,7 +42,8 @@ double random_uniform(double a, double b) {
* particles are generated on a mesh with unit spacing
* particles are generated on a mesh with unit spacing
*/
*/
struct
cell
*
make_cell
(
size_t
n
,
double
*
offset
,
double
size
,
double
h
,
struct
cell
*
make_cell
(
size_t
n
,
double
*
offset
,
double
size
,
double
h
,
double
density
,
long
long
*
partId
,
double
pert
)
{
double
density
,
long
long
*
partId
,
double
pert
,
enum
velocity_types
vel
)
{
const
size_t
count
=
n
*
n
*
n
;
const
size_t
count
=
n
*
n
*
n
;
const
double
volume
=
size
*
size
*
size
;
const
double
volume
=
size
*
size
*
size
;
struct
cell
*
cell
=
malloc
(
sizeof
(
struct
cell
));
struct
cell
*
cell
=
malloc
(
sizeof
(
struct
cell
));
...
@@ -61,12 +69,28 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
...
@@ -61,12 +69,28 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
part
->
x
[
2
]
=
part
->
x
[
2
]
=
offset
[
2
]
+
offset
[
2
]
+
size
*
(
z
+
0
.
5
+
random_uniform
(
-
0
.
5
,
0
.
5
)
*
pert
)
/
(
float
)
n
;
size
*
(
z
+
0
.
5
+
random_uniform
(
-
0
.
5
,
0
.
5
)
*
pert
)
/
(
float
)
n
;
part
->
v
[
0
]
=
part
->
x
[
0
]
-
1
.
5
;
switch
(
vel
)
{
part
->
v
[
1
]
=
part
->
x
[
1
]
-
1
.
5
;
case
velocity_zero
:
part
->
v
[
2
]
=
part
->
x
[
2
]
-
1
.
5
;
part
->
v
[
0
]
=
0
.
f
;
//part->v[0] = random_uniform(-0.05, 0.05);
part
->
v
[
1
]
=
0
.
f
;
//part->v[1] = random_uniform(-0.05, 0.05);
part
->
v
[
2
]
=
0
.
f
;
//part->v[2] = random_uniform(-0.05, 0.05);
break
;
case
velocity_random
:
part
->
v
[
0
]
=
random_uniform
(
-
0
.
05
,
0
.
05
);
part
->
v
[
1
]
=
random_uniform
(
-
0
.
05
,
0
.
05
);
part
->
v
[
2
]
=
random_uniform
(
-
0
.
05
,
0
.
05
);
break
;
case
velocity_divergent
:
part
->
v
[
0
]
=
part
->
x
[
0
]
-
1
.
5
*
size
;
part
->
v
[
1
]
=
part
->
x
[
1
]
-
1
.
5
*
size
;
part
->
v
[
2
]
=
part
->
x
[
2
]
-
1
.
5
*
size
;
break
;
case
velocity_rotating
:
part
->
v
[
0
]
=
part
->
x
[
1
];
part
->
v
[
1
]
=
-
part
->
x
[
0
];
part
->
v
[
2
]
=
0
.
f
;
break
;
}
part
->
h
=
size
*
h
/
(
float
)
n
;
part
->
h
=
size
*
h
/
(
float
)
n
;
part
->
id
=
++
(
*
partId
);
part
->
id
=
++
(
*
partId
);
part
->
mass
=
density
*
volume
/
count
;
part
->
mass
=
density
*
volume
/
count
;
...
@@ -213,6 +237,7 @@ int main(int argc, char *argv[]) {
...
@@ -213,6 +237,7 @@ int main(int argc, char *argv[]) {
double
perturbation
=
0
.;
double
perturbation
=
0
.;
char
outputFileNameExtension
[
200
]
=
""
;
char
outputFileNameExtension
[
200
]
=
""
;
char
outputFileName
[
200
]
=
""
;
char
outputFileName
[
200
]
=
""
;
int
vel
=
velocity_zero
;
/* Initialize CPU frequency, this also starts time. */
/* Initialize CPU frequency, this also starts time. */
unsigned
long
long
cpufreq
=
0
;
unsigned
long
long
cpufreq
=
0
;
...
@@ -222,7 +247,7 @@ int main(int argc, char *argv[]) {
...
@@ -222,7 +247,7 @@ int main(int argc, char *argv[]) {
srand
(
0
);
srand
(
0
);
char
c
;
char
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"m:s:h:p:r:t:d:f:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"m:s:h:p:r:t:d:f:
v:
"
))
!=
-
1
)
{
switch
(
c
)
{
switch
(
c
)
{
case
'h'
:
case
'h'
:
sscanf
(
optarg
,
"%lf"
,
&
h
);
sscanf
(
optarg
,
"%lf"
,
&
h
);
...
@@ -245,6 +270,9 @@ int main(int argc, char *argv[]) {
...
@@ -245,6 +270,9 @@ int main(int argc, char *argv[]) {
case
'f'
:
case
'f'
:
strcpy
(
outputFileNameExtension
,
optarg
);
strcpy
(
outputFileNameExtension
,
optarg
);
break
;
break
;
case
'v'
:
sscanf
(
optarg
,
"%d"
,
&
vel
);
break
;
case
'?'
:
case
'?'
:
error
(
"Unknown option."
);
error
(
"Unknown option."
);
break
;
break
;
...
@@ -261,15 +289,21 @@ int main(int argc, char *argv[]) {
...
@@ -261,15 +289,21 @@ int main(int argc, char *argv[]) {
"
\n
-m rho - Physical density in the cell"
"
\n
-m rho - Physical density in the cell"
"
\n
-s size - Physical size of the cell"
"
\n
-s size - Physical size of the cell"
"
\n
-d pert - Perturbation to apply to the particles [0,1["
"
\n
-d pert - Perturbation to apply to the particles [0,1["
"
\n
-v type (0,1,2,3) - Velocity field: (zero, random, divergent, "
"rotating)"
"
\n
-f fileName - Part of the file name used to save the dumps
\n
"
,
"
\n
-f fileName - Part of the file name used to save the dumps
\n
"
,
argv
[
0
]);
argv
[
0
]);
exit
(
1
);
exit
(
1
);
}
}
/* Help users... */
/* Help users... */
message
(
"Smoothing length: h = %f"
,
h
);
message
(
"Smoothing length: h = %f"
,
h
*
size
);
message
(
"Kernel: %s"
,
kernel_name
);
message
(
"Kernel: %s"
,
kernel_name
);
message
(
"Neighbour target: N = %f"
,
kernel_nwneigh
);
message
(
"Neighbour target: N = %f"
,
h
*
h
*
h
*
kernel_nwneigh
/
1
.
88273
);
message
(
"Density target: rho = %f"
,
rho
);
message
(
"div_v target: div = %f"
,
vel
==
2
?
3
.
f
:
0
.
f
);
message
(
"curl_v target: curl = [0., 0., %f]"
,
vel
==
3
?
-
2
.
f
:
0
.
f
);
printf
(
"
\n
"
);
/* Build the infrastructure */
/* Build the infrastructure */
struct
space
space
;
struct
space
space
;
...
@@ -293,8 +327,8 @@ int main(int argc, char *argv[]) {
...
@@ -293,8 +327,8 @@ int main(int argc, char *argv[]) {
for
(
int
k
=
0
;
k
<
3
;
++
k
)
{
for
(
int
k
=
0
;
k
<
3
;
++
k
)
{
double
offset
[
3
]
=
{
i
*
size
,
j
*
size
,
k
*
size
};
double
offset
[
3
]
=
{
i
*
size
,
j
*
size
,
k
*
size
};
cells
[
i
*
9
+
j
*
3
+
k
]
=
cells
[
i
*
9
+
j
*
3
+
k
]
=
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
&
partId
,
perturbation
);
&
partId
,
perturbation
,
vel
);
}
}
}
}
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/tolerance.dat
+
2
−
2
View file @
43abff62
# ID pos_x pos_y pos_z v_x v_y v_z rho rho_dh wcount wcount_dh div_v curl_vx curl_vy curl_vz
# ID pos_x pos_y pos_z v_x v_y v_z rho rho_dh wcount wcount_dh div_v curl_vx curl_vy curl_vz
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-5 1e-5 2e-5 3e-
4
1e-5 1e-5 1e-5 1e-5
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-5 1e-5 2e-5 3e-
2
1e-5 1e-5 1e-5 1e-5
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-5 1.2e-5 1e-5 1e-
5
1e-4 1e-4 1e-4 1e-4
0 1e-6 1e-6 1e-6 1e-6 1e-6 1e-6 1e-5 1.2e-5 1e-5 1e-
2
1e-4 1e-4 1e-4 1e-4
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
sign in
to comment