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
c62fe635
Commit
c62fe635
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added a 'sound speed' variable to the Minimal SPH particle to save redundant calculations.
parent
6f8b4ff5
No related branches found
No related tags found
1 merge request
!255
Cleanup rho dh and use of the EoS functions
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/const.h
+2
-2
2 additions, 2 deletions
src/const.h
src/hydro/Minimal/hydro.h
+33
-1
33 additions, 1 deletion
src/hydro/Minimal/hydro.h
src/hydro/Minimal/hydro_iact.h
+4
-4
4 additions, 4 deletions
src/hydro/Minimal/hydro_iact.h
src/hydro/Minimal/hydro_part.h
+3
-0
3 additions, 0 deletions
src/hydro/Minimal/hydro_part.h
with
42 additions
and
7 deletions
src/const.h
+
2
−
2
View file @
c62fe635
...
@@ -63,8 +63,8 @@
...
@@ -63,8 +63,8 @@
//#define WENDLAND_C6_KERNEL
//#define WENDLAND_C6_KERNEL
/* SPH variant to use */
/* SPH variant to use */
//
#define MINIMAL_SPH
#define MINIMAL_SPH
#define GADGET2_SPH
//
#define GADGET2_SPH
//#define HOPKINS_PE_SPH
//#define HOPKINS_PE_SPH
//#define DEFAULT_SPH
//#define DEFAULT_SPH
//#define GIZMO_SPH
//#define GIZMO_SPH
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro.h
+
33
−
1
View file @
c62fe635
...
@@ -141,6 +141,12 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
...
@@ -141,6 +141,12 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Compute the sound speed from the pressure*/
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
pressure
=
pressure
;
}
}
...
@@ -160,6 +166,12 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
...
@@ -160,6 +166,12 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Compute the sound speed from the pressure*/
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
pressure
=
pressure
;
}
}
...
@@ -277,10 +289,15 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
...
@@ -277,10 +289,15 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
int
ti_current
,
struct
part
*
restrict
p
,
struct
xpart
*
restrict
xp
,
int
ti_current
,
double
timeBase
)
{
double
timeBase
)
{
/* Compute the pressure */
const
float
half_dt
=
(
ti_current
-
(
p
->
ti_begin
+
p
->
ti_end
)
/
2
)
*
timeBase
;
const
float
half_dt
=
(
ti_current
-
(
p
->
ti_begin
+
p
->
ti_end
)
/
2
)
*
timeBase
;
const
float
pressure
=
hydro_get_pressure
(
p
,
half_dt
);
const
float
pressure
=
hydro_get_pressure
(
p
,
half_dt
);
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
/* Compute the sound speed */
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
/* Compute the "grad h" term */
/* Compute the "grad h" term */
const
float
grad_h_term
=
const
float
grad_h_term
=
1
.
f
/
(
1
.
f
+
hydro_dimension_inv
*
p
->
h
*
p
->
density
.
rho_dh
*
rho_inv
);
1
.
f
/
(
1
.
f
+
hydro_dimension_inv
*
p
->
h
*
p
->
density
.
rho_dh
*
rho_inv
);
...
@@ -288,6 +305,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
...
@@ -288,6 +305,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Update variables. */
/* Update variables. */
p
->
force
.
f
=
grad_h_term
;
p
->
force
.
f
=
grad_h_term
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
soundspeed
=
soundspeed
;
}
}
/**
/**
...
@@ -347,7 +365,15 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
...
@@ -347,7 +365,15 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
/* Drift the pressure */
/* Drift the pressure */
const
float
dt_entr
=
(
t1
-
(
p
->
ti_begin
+
p
->
ti_end
)
/
2
)
*
timeBase
;
const
float
dt_entr
=
(
t1
-
(
p
->
ti_begin
+
p
->
ti_end
)
/
2
)
*
timeBase
;
p
->
force
.
pressure
=
hydro_get_pressure
(
p
,
dt_entr
);
const
float
pressure
=
hydro_get_pressure
(
p
,
dt_entr
);
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
/* Compute the new sound speed */
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
pressure
=
pressure
;
p
->
force
.
soundspeed
=
soundspeed
;
}
}
/**
/**
...
@@ -392,6 +418,12 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
...
@@ -392,6 +418,12 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Compute the sound speed from the pressure*/
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
pressure
=
pressure
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro_iact.h
+
4
−
4
View file @
c62fe635
...
@@ -165,8 +165,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
...
@@ -165,8 +165,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Compute sound speeds and signal velocity */
/* Compute sound speeds and signal velocity */
const
float
ci
=
sqrtf
(
hydro_gamma
*
pressurei
/
rhoi
)
;
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
cj
=
sqrtf
(
hydro_gamma
*
pressurej
/
rhoj
)
;
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
/* Construct the full viscosity term */
/* Construct the full viscosity term */
...
@@ -276,8 +276,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
...
@@ -276,8 +276,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Compute sound speeds and signal velocity */
/* Compute sound speeds and signal velocity */
const
float
ci
=
sqrtf
(
hydro_gamma
*
pressurei
/
rhoi
)
;
const
float
ci
=
pi
->
force
.
soundspeed
;
const
float
cj
=
sqrtf
(
hydro_gamma
*
pressurej
/
rhoj
)
;
const
float
cj
=
pj
->
force
.
soundspeed
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
const
float
v_sig
=
ci
+
cj
-
3
.
f
*
mu_ij
;
/* Construct the full viscosity term */
/* Construct the full viscosity term */
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro_part.h
+
3
−
0
View file @
c62fe635
...
@@ -131,6 +131,9 @@ struct part {
...
@@ -131,6 +131,9 @@ struct part {
/*! Particle pressure. */
/*! Particle pressure. */
float
pressure
;
float
pressure
;
/*! Particle soundspeed. */
float
soundspeed
;
/*! Particle signal velocity */
/*! Particle signal velocity */
float
v_sig
;
float
v_sig
;
...
...
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