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
dcc5418b
Commit
dcc5418b
authored
7 years ago
by
Josh Borrow
Browse files
Options
Downloads
Patches
Plain Diff
Attempted to add Balsara Switch
parent
003a318d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!540
Add Pressure-Energy (P-U) SPH
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hydro/PressureEnergy/hydro.h
+20
-0
20 additions, 0 deletions
src/hydro/PressureEnergy/hydro.h
src/hydro/PressureEnergy/hydro_iact.h
+62
-3
62 additions, 3 deletions
src/hydro/PressureEnergy/hydro_iact.h
src/hydro/PressureEnergy/hydro_part.h
+2
-0
2 additions, 0 deletions
src/hydro/PressureEnergy/hydro_part.h
with
84 additions
and
3 deletions
src/hydro/PressureEnergy/hydro.h
+
20
−
0
View file @
dcc5418b
...
...
@@ -312,6 +312,11 @@ __attribute__((always_inline)) INLINE static void hydro_init_part(
p
->
density
.
rho_dh
=
0
.
f
;
p
->
pressure_bar
=
0
.
f
;
p
->
density
.
pressure_bar_dh
=
0
.
f
;
p
->
density
.
div_v
=
0
.
f
;
p
->
density
.
rot_v
[
0
]
=
0
.
f
;
p
->
density
.
rot_v
[
1
]
=
0
.
f
;
p
->
density
.
rot_v
[
2
]
=
0
.
f
;
}
/**
...
...
@@ -401,12 +406,26 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
)
{
const
float
fac_mu
=
cosmo
->
a_factor_mu
;
/* Compute the norm of the curl */
const
float
curl_v
=
sqrtf
(
p
->
density
.
rot_v
[
0
]
*
p
->
density
.
rot_v
[
0
]
+
p
->
density
.
rot_v
[
1
]
*
p
->
density
.
rot_v
[
1
]
+
p
->
density
.
rot_v
[
2
]
*
p
->
density
.
rot_v
[
2
]);
/* Compute the norm of div v */
const
float
abs_div_v
=
fabsf
(
p
->
density
.
div_v
);
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Compute the sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Compute the Balsara switch */
const
float
balsara
=
abs_div_v
/
(
abs_div_v
+
curl_v
+
0
.
0001
f
*
soundspeed
*
fac_mu
/
p
->
h
);
/* Compute the "grad h" term */
const
float
common_factor
=
p
->
h
/
(
hydro_dimension
*
p
->
density
.
wcount
);
const
float
grad_h_term
=
...
...
@@ -417,6 +436,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
p
->
force
.
f
=
grad_h_term
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
balsara
=
balsara
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/hydro/PressureEnergy/hydro_iact.h
+
62
−
3
View file @
dcc5418b
...
...
@@ -52,6 +52,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
struct
part
*
pj
,
float
a
,
float
H
)
{
float
wi
,
wj
,
wi_dx
,
wj_dx
;
float
dv
[
3
],
curlvr
[
3
];
const
float
r
=
sqrtf
(
r2
);
...
...
@@ -84,6 +85,33 @@ __attribute__((always_inline)) INLINE static void runner_iact_density(
mi
*
pi
->
u
*
(
hydro_dimension
*
wj
+
uj
*
wj_dx
);
pj
->
density
.
wcount
+=
wj
;
pj
->
density
.
wcount_dh
-=
(
hydro_dimension
*
wj
+
uj
*
wj_dx
);
/* Now we need to compute the div terms */
const
float
r_inv
=
1
.
f
/
r
;
const
float
faci
=
mj
*
wi_dx
*
r_inv
;
const
float
facj
=
mi
*
wj_dx
*
r_inv
;
/* Compute dv dot r */
dv
[
0
]
=
pi
->
v
[
0
]
-
pj
->
v
[
0
];
dv
[
1
]
=
pi
->
v
[
1
]
-
pj
->
v
[
1
];
dv
[
2
]
=
pi
->
v
[
2
]
-
pj
->
v
[
2
];
const
float
dvdr
=
dv
[
0
]
*
dx
[
0
]
+
dv
[
1
]
*
dx
[
1
]
+
dv
[
2
]
*
dx
[
2
];
pi
->
density
.
div_v
-=
faci
*
dvdr
;
pj
->
density
.
div_v
-=
facj
*
dvdr
;
/* Compute dv cross r */
curlvr
[
0
]
=
dv
[
1
]
*
dx
[
2
]
-
dv
[
2
]
*
dx
[
1
];
curlvr
[
1
]
=
dv
[
2
]
*
dx
[
0
]
-
dv
[
0
]
*
dx
[
2
];
curlvr
[
2
]
=
dv
[
0
]
*
dx
[
1
]
-
dv
[
1
]
*
dx
[
0
];
pi
->
density
.
rot_v
[
0
]
+=
faci
*
curlvr
[
0
];
pi
->
density
.
rot_v
[
1
]
+=
faci
*
curlvr
[
1
];
pi
->
density
.
rot_v
[
2
]
+=
faci
*
curlvr
[
2
];
pj
->
density
.
rot_v
[
0
]
+=
facj
*
curlvr
[
0
];
pj
->
density
.
rot_v
[
1
]
+=
facj
*
curlvr
[
1
];
pj
->
density
.
rot_v
[
2
]
+=
facj
*
curlvr
[
2
];
}
/**
...
...
@@ -103,6 +131,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
const
struct
part
*
pj
,
float
a
,
float
H
)
{
float
wi
,
wi_dx
;
float
dv
[
3
],
curlvr
[
3
];
/* Get the masses. */
const
float
mj
=
pj
->
mass
;
...
...
@@ -121,6 +150,26 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density(
mj
*
pj
->
u
*
(
hydro_dimension
*
wi
+
ui
*
wi_dx
);
pi
->
density
.
wcount
+=
wi
;
pi
->
density
.
wcount_dh
-=
(
hydro_dimension
*
wi
+
ui
*
wi_dx
);
const
float
r_inv
=
1
.
f
/
r
;
const
float
faci
=
mj
*
wi_dx
*
r_inv
;
/* Compute dv dot r */
dv
[
0
]
=
pi
->
v
[
0
]
-
pj
->
v
[
0
];
dv
[
1
]
=
pi
->
v
[
1
]
-
pj
->
v
[
1
];
dv
[
2
]
=
pi
->
v
[
2
]
-
pj
->
v
[
2
];
const
float
dvdr
=
dv
[
0
]
*
dx
[
0
]
+
dv
[
1
]
*
dx
[
1
]
+
dv
[
2
]
*
dx
[
2
];
pi
->
density
.
div_v
-=
faci
*
dvdr
;
/* Compute dv cross r */
curlvr
[
0
]
=
dv
[
1
]
*
dx
[
2
]
-
dv
[
2
]
*
dx
[
1
];
curlvr
[
1
]
=
dv
[
2
]
*
dx
[
0
]
-
dv
[
0
]
*
dx
[
2
];
curlvr
[
2
]
=
dv
[
0
]
*
dx
[
1
]
-
dv
[
1
]
*
dx
[
0
];
pi
->
density
.
rot_v
[
0
]
+=
faci
*
curlvr
[
0
];
pi
->
density
.
rot_v
[
1
]
+=
faci
*
curlvr
[
1
];
pi
->
density
.
rot_v
[
2
]
+=
faci
*
curlvr
[
2
];
}
/**
...
...
@@ -189,9 +238,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
/* Balsara term */
const
float
balsara_i
=
pi
->
force
.
balsara
;
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
5
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
/
rho_ij
;
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Convolve with the kernel */
const
float
visc_acc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
...
@@ -229,7 +283,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
du_dt_i
=
sph_du_term_i
+
visc_du_term
;
const
float
du_dt_j
=
sph_du_term_j
+
visc_du_term
;
/* Internal energy time derivati
b
e */
/* Internal energy time derivati
v
e */
pi
->
u_dt
+=
du_dt_i
*
mj
;
pj
->
u_dt
+=
du_dt_j
*
mi
;
...
...
@@ -309,9 +363,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
/* Balsara term */
const
float
balsara_i
=
pi
->
force
.
balsara
;
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Construct the full viscosity term */
const
float
rho_ij
=
0
.
5
f
*
(
rhoi
+
rhoj
);
const
float
visc
=
-
0
.
5
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
/
rho_ij
;
const
float
visc
=
-
0
.
25
f
*
const_viscosity_alpha
*
v_sig
*
mu_ij
*
(
balsara_i
+
balsara_j
)
/
rho_ij
;
/* Convolve with the kernel */
const
float
visc_acc_term
=
0
.
5
f
*
visc
*
(
wi_dr
+
wj_dr
)
*
r_inv
;
...
...
This diff is collapsed.
Click to expand it.
src/hydro/PressureEnergy/hydro_part.h
+
2
−
0
View file @
dcc5418b
...
...
@@ -160,6 +160,8 @@ struct part {
/*! Time derivative of smoothing length */
float
h_dt
;
/*! Balsara switch */
float
balsara
;
}
force
;
};
...
...
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