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
aec32336
Commit
aec32336
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Make use of the EoS functions everywhere in Gadget2-SPH.
parent
678d414c
No related branches found
No related tags found
1 merge request
!255
Cleanup rho dh and use of the EoS functions
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/const.h
+2
-2
2 additions, 2 deletions
src/const.h
src/hydro/Gadget2/hydro.h
+29
-23
29 additions, 23 deletions
src/hydro/Gadget2/hydro.h
with
31 additions
and
25 deletions
src/const.h
+
2
−
2
View file @
aec32336
...
@@ -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/Gadget2/hydro.h
+
29
−
23
View file @
aec32336
...
@@ -127,12 +127,13 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
...
@@ -127,12 +127,13 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
p
->
entropy
=
gas_entropy_from_internal_energy
(
p
->
rho
,
u
);
p
->
entropy
=
gas_entropy_from_internal_energy
(
p
->
rho
,
u
);
/* Compute the pressure */
/* Compute the new pressure */
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
const
float
pressure
=
gas_pressure_from_internal_energy
(
p
->
rho
,
u
);
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Compute the sound speed from the pressure*/
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
...
@@ -155,9 +156,10 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
...
@@ -155,9 +156,10 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
/* Compute the sound speed from the pressure*/
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
...
@@ -290,14 +292,13 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
...
@@ -290,14 +292,13 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
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
;
/* Compute the sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Divide the pressure by the density and density gradient */
/* Divide the pressure by the density squared to get the SPH term */
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
/* Compute the sound speed */
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
/* Compute the Balsara switch */
/* Compute the Balsara switch */
const
float
balsara
=
const
float
balsara
=
abs_div_v
/
(
abs_div_v
+
curl_v
+
0
.
0001
f
*
soundspeed
/
fac_mu
/
p
->
h
);
abs_div_v
/
(
abs_div_v
+
curl_v
+
0
.
0001
f
*
soundspeed
/
fac_mu
/
p
->
h
);
...
@@ -371,17 +372,16 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
...
@@ -371,17 +372,16 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
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
;
const
float
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
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Divide the pressure by the density and density gradient */
/* Divide the pressure by the density squared to get the SPH term */
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
/* Compute the new sound speed */
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
);
/* Update variables */
/* Update variables */
p
->
force
.
P_over_rho2
=
P_over_rho2
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
P_over_rho2
;
}
}
/**
/**
...
@@ -426,12 +426,15 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
...
@@ -426,12 +426,15 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
/* Compute the sound speed from the pressure*/
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Divide the pressure by the density squared to get the SPH term */
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
)
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
P_over_rho2
=
P_over_rho2
;
}
}
/**
/**
...
@@ -450,12 +453,15 @@ __attribute__((always_inline)) INLINE static void hydro_convert_quantities(
...
@@ -450,12 +453,15 @@ __attribute__((always_inline)) INLINE static void hydro_convert_quantities(
/* Compute the pressure */
/* Compute the pressure */
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
const
float
pressure
=
gas_pressure_from_entropy
(
p
->
rho
,
p
->
entropy
);
/* Compute the sound speed from the pressure*/
/* Compute the sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Divide the pressure by the density squared to get the SPH term */
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
const
float
soundspeed
=
sqrtf
(
hydro_gamma
*
pressure
*
rho_inv
)
;
const
float
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
P_over_rho2
=
P_over_rho2
;
}
}
#endif
/* SWIFT_GADGET2_HYDRO_H */
#endif
/* SWIFT_GADGET2_HYDRO_H */
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