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
be51df56
Commit
be51df56
authored
6 years ago
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
Logger: remove logger_compute_max_chunk_size and simplify a function
parent
81b29f25
No related branches found
No related tags found
1 merge request
!671
Remove logger_parameters and update the header
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/logger.c
+13
-56
13 additions, 56 deletions
src/logger.c
with
13 additions
and
56 deletions
src/logger.c
+
13
−
56
View file @
be51df56
...
...
@@ -157,40 +157,11 @@ int logger_compute_chunk_size(unsigned int mask) {
}
else
{
/* Particle position as three doubles. */
if
(
mask
&
logger_mask_data
[
logger_x
].
mask
)
{
size
+=
logger_mask_data
[
logger_x
].
size
;
}
/* Particle velocity as three floats. */
if
(
mask
&
logger_mask_data
[
logger_v
].
mask
)
{
size
+=
logger_mask_data
[
logger_v
].
size
;
}
/* Particle accelleration as three floats. */
if
(
mask
&
logger_mask_data
[
logger_a
].
mask
)
{
size
+=
logger_mask_data
[
logger_a
].
size
;
}
/* Particle internal energy as a single float. */
if
(
mask
&
logger_mask_data
[
logger_u
].
mask
)
{
size
+=
logger_mask_data
[
logger_u
].
size
;
}
/* Particle smoothing length as a single float. */
if
(
mask
&
logger_mask_data
[
logger_h
].
mask
)
{
size
+=
logger_mask_data
[
logger_h
].
size
;
}
/* Particle density as a single float. */
if
(
mask
&
logger_mask_data
[
logger_rho
].
mask
)
{
size
+=
logger_mask_data
[
logger_rho
].
size
;
}
/* Particle constants, which is a bit more complicated. */
if
(
mask
&
logger_mask_data
[
logger_consts
].
mask
)
{
size
+=
logger_mask_data
[
logger_consts
].
size
;
}
for
(
int
i
=
0
;
i
<
logger_count_mask
;
i
++
)
{
if
(
mask
&
logger_mask_data
[
i
].
mask
)
{
size
+=
logger_mask_data
[
i
].
size
;
}
}
}
return
size
;
...
...
@@ -439,26 +410,6 @@ void logger_ensure_size(struct logger *log, size_t total_nr_parts,
dump_ensure
(
&
log
->
dump
,
limit
,
log
->
buffer_scale
*
limit
);
}
/**
* @brief Compute the maximal size of a chunk.
*
* @param log The #logger.
*/
int
logger_compute_max_chunk_size
(
const
struct
logger
*
log
)
{
int
*
output
=
malloc
(
sizeof
(
int
)
*
logger_count_mask
);
if
(
output
==
NULL
)
error
(
"Unable to allocate memory"
);
int
max_size
=
logger_offset_size
+
logger_mask_size
;
/* Loop over all fields except timestamp */
for
(
int
i
=
0
;
i
<
logger_count_mask
-
1
;
i
++
)
{
max_size
+=
logger_mask_data
[
i
].
size
;
}
free
(
output
);
return
max_size
;
}
/**
* @brief intialize the logger structure
*
...
...
@@ -483,8 +434,14 @@ void logger_init(struct logger *log, struct swift_params *params) {
strcpy
(
logger_name_file
,
log
->
base_name
);
strcat
(
logger_name_file
,
".dump"
);
/* Define some constants */
log
->
max_chunk_size
=
logger_compute_max_chunk_size
(
log
);
/* Compute max size for a particle chunk */
int
max_size
=
logger_offset_size
+
logger_mask_size
;
/* Loop over all fields except timestamp */
for
(
int
i
=
0
;
i
<
logger_count_mask
-
1
;
i
++
)
{
max_size
+=
logger_mask_data
[
i
].
size
;
}
log
->
max_chunk_size
=
max_size
;
/* init dump */
dump_init
(
&
log
->
dump
,
logger_name_file
,
buffer_size
);
...
...
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