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
c50f33ca
Commit
c50f33ca
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
The Gadget-2 interaction routines are now free from if-statements.
parent
31bacab2
No related branches found
No related tags found
2 merge requests
!136
Master
,
!90
Improved multi-timestep SPH
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hydro/Gadget2/hydro_iact.h
+38
-72
38 additions, 72 deletions
src/hydro/Gadget2/hydro_iact.h
with
38 additions
and
72 deletions
src/hydro/Gadget2/hydro_iact.h
+
38
−
72
View file @
c50f33ca
...
@@ -37,8 +37,6 @@
...
@@ -37,8 +37,6 @@
*errors and interactions
*errors and interactions
* missed by the Gadget-2 tree-code neighbours search.
* missed by the Gadget-2 tree-code neighbours search.
*
*
* The code uses internal energy instead of entropy as a thermodynamical
*variable.
*/
*/
/**
/**
...
@@ -142,9 +140,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
...
@@ -142,9 +140,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
pi
->
density
.
wcount
+=
wi
;
pi
->
density
.
wcount
+=
wi
;
pi
->
density
.
wcount_dh
-=
u
*
wi_dx
;
pi
->
density
.
wcount_dh
-=
u
*
wi_dx
;
/* const float ih3 = h_inv * h_inv * h_inv; */
/* const float ih4 = h_inv * h_inv * h_inv * h_inv; */
const
float
fac
=
mj
*
wi_dx
*
ri
;
const
float
fac
=
mj
*
wi_dx
*
ri
;
/* Compute dv dot r */
/* Compute dv dot r */
...
@@ -154,24 +149,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
...
@@ -154,24 +149,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
const
float
dvdr
=
dv
[
0
]
*
dx
[
0
]
+
dv
[
1
]
*
dx
[
1
]
+
dv
[
2
]
*
dx
[
2
];
const
float
dvdr
=
dv
[
0
]
*
dx
[
0
]
+
dv
[
1
]
*
dx
[
1
]
+
dv
[
2
]
*
dx
[
2
];
pi
->
div_v
-=
fac
*
dvdr
;
pi
->
div_v
-=
fac
*
dvdr
;
/* if(pi->id == 515050 && pj->id == 504849) */
/* message("Interacting with %lld. r=%e hi=%e u=%e W=%e dW/dx=%e dh_drho1=%e
* dh_drho2=%e\n fac=%e dvdr=%e pj->v=[%.3e,%.3e,%.3e]", */
/* pj->id, */
/* r, */
/* hi, */
/* u, */
/* wi * ih3, */
/* wi_dx * ih4, */
/* -mj * (3.f * kernel_igamma * wi) * ih4, */
/* -mj * u * wi_dx * kernel_igamma * ih4, */
/* fac * ih4, */
/* dvdr, */
/* pj->v[0], */
/* pj->v[1], */
/* pj->v[2] */
/* ); */
/* Compute dv cross r */
/* Compute dv cross r */
curlvr
[
0
]
=
dv
[
1
]
*
dx
[
2
]
-
dv
[
2
]
*
dx
[
1
];
curlvr
[
0
]
=
dv
[
1
]
*
dx
[
2
]
-
dv
[
2
]
*
dx
[
1
];
curlvr
[
1
]
=
dv
[
2
]
*
dx
[
0
]
-
dv
[
0
]
*
dx
[
2
];
curlvr
[
1
]
=
dv
[
2
]
*
dx
[
0
]
-
dv
[
0
]
*
dx
[
2
];
...
@@ -225,28 +202,31 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
...
@@ -225,28 +202,31 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/* Compute sound speeds */
/* Compute sound speeds */
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
cj
=
pj
->
force
.
soundspeed
;
float
v_sig
=
ci
+
cj
;
/* Compute dv dot r. */
/* Compute dv dot r. */
const
float
dvdr
=
(
pi
->
v
[
0
]
-
pj
->
v
[
0
])
*
dx
[
0
]
+
const
float
dvdr
=
(
pi
->
v
[
0
]
-
pj
->
v
[
0
])
*
dx
[
0
]
+
(
pi
->
v
[
1
]
-
pj
->
v
[
1
])
*
dx
[
1
]
+
(
pi
->
v
[
1
]
-
pj
->
v
[
1
])
*
dx
[
1
]
+
(
pi
->
v
[
2
]
-
pj
->
v
[
2
])
*
dx
[
2
];
(
pi
->
v
[
2
]
-
pj
->
v
[
2
])
*
dx
[
2
];
/* Artificial viscosity term */
/* Balsara term */
float
visc
=
0
.
f
;
const
float
balsara_i
=
if
(
dvdr
<
0
.
f
)
{
fabsf
(
pi
->
div_v
)
/
const
float
mu_ij
=
fac_mu
*
dvdr
*
r_inv
;
(
fabsf
(
pi
->
div_v
)
+
pi
->
force
.
curl_v
+
0
.
0001
*
ci
/
fac_mu
/
hi
);
v_sig
-=
3
.
f
*
mu_ij
;
const
float
balsara_j
=
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
fabsf
(
pj
->
div_v
)
/
const
float
balsara_i
=
(
fabsf
(
pj
->
div_v
)
+
pj
->
force
.
curl_v
+
0
.
0001
*
cj
/
fac_mu
/
hj
);
fabsf
(
pi
->
div_v
)
/
(
fabsf
(
pi
->
div_v
)
+
pi
->
force
.
curl_v
+
0
.
0001
*
ci
/
fac_mu
/
hi
);
/* Are the particles moving towards each others ? */
const
float
balsara_j
=
const
float
omega_ij
=
fminf
(
dvdr
,
0
.
f
);
fabsf
(
pj
->
div_v
)
/
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
(
fabsf
(
pj
->
div_v
)
+
pj
->
force
.
curl_v
+
0
.
0001
*
cj
/
fac_mu
/
hj
);
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
/
rho_ij
*
/* Signal velocity */
(
balsara_i
+
balsara_j
);
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
}
/* Now construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Now, convolve with the kernel */
/* Now, convolve with the kernel */
const
float
visc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
const
float
visc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
@@ -255,23 +235,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
...
@@ -255,23 +235,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/* Eventually got the acceleration */
/* Eventually got the acceleration */
const
float
acc
=
visc_term
+
sph_term
;
const
float
acc
=
visc_term
+
sph_term
;
/* //if(pi->id == 1000 && pj->id == 1100) */
/* if(pi->id == 515050 && pj->id == 504849) */
/* message("Interacting with %lld. r=%e hi=%e hj=%e dWi/dx=%e dWj/dx=%3e
* dvdr=%e visc=%e sph=%e", */
/* pj->id, */
/* r, */
/* 2*hi, */
/* 2*hj, */
/* wi_dr, */
/* wj_dr, */
/* dvdr, */
/* visc_term, */
/* sph_term */
/* ); */
/* if(pi->id == 1100 && pj->id == 1000) */
/* message("oO"); */
/* Use the force Luke ! */
/* Use the force Luke ! */
pi
->
a_hydro
[
0
]
-=
mj
*
acc
*
dx
[
0
];
pi
->
a_hydro
[
0
]
-=
mj
*
acc
*
dx
[
0
];
pi
->
a_hydro
[
1
]
-=
mj
*
acc
*
dx
[
1
];
pi
->
a_hydro
[
1
]
-=
mj
*
acc
*
dx
[
1
];
...
@@ -337,28 +300,31 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
...
@@ -337,28 +300,31 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/* Compute sound speeds */
/* Compute sound speeds */
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
cj
=
pj
->
force
.
soundspeed
;
float
v_sig
=
ci
+
cj
;
/* Compute dv dot r. */
/* Compute dv dot r. */
const
float
dvdr
=
(
pi
->
v
[
0
]
-
pj
->
v
[
0
])
*
dx
[
0
]
+
const
float
dvdr
=
(
pi
->
v
[
0
]
-
pj
->
v
[
0
])
*
dx
[
0
]
+
(
pi
->
v
[
1
]
-
pj
->
v
[
1
])
*
dx
[
1
]
+
(
pi
->
v
[
1
]
-
pj
->
v
[
1
])
*
dx
[
1
]
+
(
pi
->
v
[
2
]
-
pj
->
v
[
2
])
*
dx
[
2
];
(
pi
->
v
[
2
]
-
pj
->
v
[
2
])
*
dx
[
2
];
/* Artificial viscosity term */
/* Balsara term */
float
visc
=
0
.
f
;
const
float
balsara_i
=
if
(
dvdr
<
0
.
f
)
{
fabsf
(
pi
->
div_v
)
/
const
float
mu_ij
=
fac_mu
*
dvdr
*
r_inv
;
(
fabsf
(
pi
->
div_v
)
+
pi
->
force
.
curl_v
+
0
.
0001
*
ci
/
fac_mu
/
hi
);
v_sig
-=
3
.
f
*
mu_ij
;
const
float
balsara_j
=
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
fabsf
(
pj
->
div_v
)
/
const
float
balsara_i
=
(
fabsf
(
pj
->
div_v
)
+
pj
->
force
.
curl_v
+
0
.
0001
*
cj
/
fac_mu
/
hj
);
fabsf
(
pi
->
div_v
)
/
(
fabsf
(
pi
->
div_v
)
+
pi
->
force
.
curl_v
+
0
.
0001
*
ci
/
fac_mu
/
hi
);
/* Are the particles moving towards each others ? */
const
float
balsara_j
=
const
float
omega_ij
=
fminf
(
dvdr
,
0
.
f
);
fabsf
(
pj
->
div_v
)
/
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
(
fabsf
(
pj
->
div_v
)
+
pj
->
force
.
curl_v
+
0
.
0001
*
cj
/
fac_mu
/
hj
);
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
/
rho_ij
*
/* Signal velocity */
(
balsara_i
+
balsara_j
);
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
}
/* Now construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Now, convolve with the kernel */
/* Now, convolve with the kernel */
const
float
visc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
const
float
visc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
...
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