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
5da4b6ce
Commit
5da4b6ce
authored
6 years ago
by
Jacob Kegerreis
Committed by
Matthieu Schaller
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Tidy EoS file loading checks
parent
f4e33282
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/equation_of_state/planetary/hm80.h
+4
-8
4 additions, 8 deletions
src/equation_of_state/planetary/hm80.h
src/equation_of_state/planetary/sesame.h
+8
-20
8 additions, 20 deletions
src/equation_of_state/planetary/sesame.h
with
12 additions
and
28 deletions
src/equation_of_state/planetary/hm80.h
+
4
−
8
View file @
5da4b6ce
...
@@ -86,21 +86,19 @@ INLINE static void load_table_HM80(struct HM80_params *mat, char *table_file) {
...
@@ -86,21 +86,19 @@ INLINE static void load_table_HM80(struct HM80_params *mat, char *table_file) {
// Load table contents from file
// Load table contents from file
FILE
*
f
=
fopen
(
table_file
,
"r"
);
FILE
*
f
=
fopen
(
table_file
,
"r"
);
if
(
f
==
NULL
)
error
(
"
Impossib
le to open HM80 EoS file '%s'"
,
table_file
);
if
(
f
==
NULL
)
error
(
"
Fai
le
d
to open
the
HM80 EoS file '%s'"
,
table_file
);
// Ignore header lines
// Ignore header lines
char
buffer
[
100
];
char
buffer
[
100
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
if
(
fgets
(
buffer
,
100
,
f
)
==
NULL
)
if
(
fgets
(
buffer
,
100
,
f
)
==
NULL
)
error
(
"
Something incorrect happening with the file header."
);
error
(
"
Failed to read the HM80 EoS file header %s"
,
table_file
);
}
}
// Table properties
// Table properties
int
c
=
fscanf
(
f
,
"%f %f %d %f %f %d"
,
&
mat
->
log_rho_min
,
&
mat
->
log_rho_max
,
int
c
=
fscanf
(
f
,
"%f %f %d %f %f %d"
,
&
mat
->
log_rho_min
,
&
mat
->
log_rho_max
,
&
mat
->
num_rho
,
&
mat
->
log_u_min
,
&
mat
->
log_u_max
,
&
mat
->
num_u
);
&
mat
->
num_rho
,
&
mat
->
log_u_min
,
&
mat
->
log_u_max
,
&
mat
->
num_u
);
if
(
c
!=
6
)
{
if
(
c
!=
6
)
error
(
"Failed to read the HM80 EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
mat
->
log_rho_step
=
mat
->
log_rho_step
=
(
mat
->
log_rho_max
-
mat
->
log_rho_min
)
/
(
mat
->
num_rho
-
1
);
(
mat
->
log_rho_max
-
mat
->
log_rho_min
)
/
(
mat
->
num_rho
-
1
);
mat
->
log_u_step
=
(
mat
->
log_u_max
-
mat
->
log_u_min
)
/
(
mat
->
num_u
-
1
);
mat
->
log_u_step
=
(
mat
->
log_u_max
-
mat
->
log_u_min
)
/
(
mat
->
num_u
-
1
);
...
@@ -115,9 +113,7 @@ INLINE static void load_table_HM80(struct HM80_params *mat, char *table_file) {
...
@@ -115,9 +113,7 @@ INLINE static void load_table_HM80(struct HM80_params *mat, char *table_file) {
for
(
int
i_rho
=
0
;
i_rho
<
mat
->
num_rho
;
i_rho
++
)
{
for
(
int
i_rho
=
0
;
i_rho
<
mat
->
num_rho
;
i_rho
++
)
{
for
(
int
i_u
=
0
;
i_u
<
mat
->
num_u
;
i_u
++
)
{
for
(
int
i_u
=
0
;
i_u
<
mat
->
num_u
;
i_u
++
)
{
c
=
fscanf
(
f
,
"%f"
,
&
mat
->
table_log_P_rho_u
[
i_rho
*
mat
->
num_u
+
i_u
]);
c
=
fscanf
(
f
,
"%f"
,
&
mat
->
table_log_P_rho_u
[
i_rho
*
mat
->
num_u
+
i_u
]);
if
(
c
!=
1
)
{
if
(
c
!=
1
)
error
(
"Failed to read the HM80 EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table"
);
}
}
}
}
}
fclose
(
f
);
fclose
(
f
);
...
...
This diff is collapsed.
Click to expand it.
src/equation_of_state/planetary/sesame.h
+
8
−
20
View file @
5da4b6ce
...
@@ -82,21 +82,19 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
...
@@ -82,21 +82,19 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
// Load table contents from file
// Load table contents from file
FILE
*
f
=
fopen
(
table_file
,
"r"
);
FILE
*
f
=
fopen
(
table_file
,
"r"
);
if
(
f
==
NULL
)
error
(
"
Impossib
le to open SESAME EoS file '%s'"
,
table_file
);
if
(
f
==
NULL
)
error
(
"
Fai
le
d
to open
the
SESAME EoS file '%s'"
,
table_file
);
// Ignore header lines
// Ignore header lines
char
buffer
[
100
];
char
buffer
[
100
];
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
if
(
fgets
(
buffer
,
100
,
f
)
==
NULL
)
if
(
fgets
(
buffer
,
100
,
f
)
==
NULL
)
error
(
"
Something incorrect happening with the file header."
);
error
(
"
Failed to read the SESAME EoS file header %s"
,
table_file
);
}
}
float
ignore
;
float
ignore
;
// Table properties
// Table properties
int
c
=
fscanf
(
f
,
"%d %d"
,
&
mat
->
num_rho
,
&
mat
->
num_T
);
int
c
=
fscanf
(
f
,
"%d %d"
,
&
mat
->
num_rho
,
&
mat
->
num_T
);
if
(
c
!=
2
)
{
if
(
c
!=
2
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
// Ignore the first elements of rho = 0, T = 0
// Ignore the first elements of rho = 0, T = 0
mat
->
num_rho
--
;
mat
->
num_rho
--
;
...
@@ -118,23 +116,17 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
...
@@ -118,23 +116,17 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
// Ignore the first elements of rho = 0, T = 0
// Ignore the first elements of rho = 0, T = 0
if
(
i_rho
==
-
1
)
{
if
(
i_rho
==
-
1
)
{
c
=
fscanf
(
f
,
"%f"
,
&
ignore
);
c
=
fscanf
(
f
,
"%f"
,
&
ignore
);
if
(
c
!=
1
)
{
if
(
c
!=
1
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
}
else
{
}
else
{
c
=
fscanf
(
f
,
"%f"
,
&
mat
->
table_log_rho
[
i_rho
]);
c
=
fscanf
(
f
,
"%f"
,
&
mat
->
table_log_rho
[
i_rho
]);
if
(
c
!=
1
)
{
if
(
c
!=
1
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
}
}
}
}
// Temperatures (ignored)
// Temperatures (ignored)
for
(
int
i_T
=
-
1
;
i_T
<
mat
->
num_T
;
i_T
++
)
{
for
(
int
i_T
=
-
1
;
i_T
<
mat
->
num_T
;
i_T
++
)
{
c
=
fscanf
(
f
,
"%f"
,
&
ignore
);
c
=
fscanf
(
f
,
"%f"
,
&
ignore
);
if
(
c
!=
1
)
{
if
(
c
!=
1
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
}
}
// Sp. int. energies (not log yet), pressures, sound speeds, and entropies
// Sp. int. energies (not log yet), pressures, sound speeds, and entropies
...
@@ -143,18 +135,14 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
...
@@ -143,18 +135,14 @@ INLINE static void load_table_SESAME(struct SESAME_params *mat,
// Ignore the first elements of rho = 0, T = 0
// Ignore the first elements of rho = 0, T = 0
if
((
i_T
==
-
1
)
||
(
i_rho
==
-
1
))
{
if
((
i_T
==
-
1
)
||
(
i_rho
==
-
1
))
{
c
=
fscanf
(
f
,
"%f %f %f %f"
,
&
ignore
,
&
ignore
,
&
ignore
,
&
ignore
);
c
=
fscanf
(
f
,
"%f %f %f %f"
,
&
ignore
,
&
ignore
,
&
ignore
,
&
ignore
);
if
(
c
!=
4
)
{
if
(
c
!=
4
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
}
else
{
}
else
{
c
=
fscanf
(
f
,
"%f %f %f %f"
,
c
=
fscanf
(
f
,
"%f %f %f %f"
,
&
mat
->
table_log_u_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_log_u_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_P_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_P_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_c_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_c_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
],
&
mat
->
table_s_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
]);
&
mat
->
table_s_rho_T
[
i_rho
*
mat
->
num_T
+
i_T
]);
if
(
c
!=
4
)
{
if
(
c
!=
4
)
error
(
"Failed to read the SESAME EoS table %s"
,
table_file
);
error
(
"Failed to read EOS table %s"
,
table_file
);
}
}
}
}
}
}
}
...
...
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