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
0bed8898
Commit
0bed8898
authored
6 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
add functions to pack/unpack arrays of tags.
parent
e2664bf2
No related branches found
No related tags found
1 merge request
!595
Tag only supercells
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cell.c
+71
-0
71 additions, 0 deletions
src/cell.c
src/cell.h
+2
-0
2 additions, 0 deletions
src/cell.h
with
73 additions
and
0 deletions
src/cell.c
+
71
−
0
View file @
0bed8898
...
...
@@ -210,6 +210,40 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc) {
#endif
}
/**
* @brief Pack the tag of the given cell and all it's sub-cells.
*
* @param c The #cell.
* @param tags Pointer to an array of packed tags.
*
* @return The number of packed tags.
*/
int
cell_pack_tags
(
const
struct
cell
*
c
,
int
*
tags
)
{
#ifdef WITH_MPI
/* Start by packing the data of the current cell. */
tags
[
0
]
=
c
->
tag
;
/* Fill in the progeny, depth-first recursion. */
int
count
=
1
;
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
count
+=
cell_pack_tags
(
c
->
progeny
[
k
],
&
tags
[
count
]);
#ifdef SWIFT_DEBUG_CHECKS
if
(
c
->
pcell_size
!=
count
)
error
(
"Inconsistent tag and pcell count!"
);
#endif // SWIFT_DEBUG_CHECKS
/* Return the number of packed tags used. */
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
* @brief Unpack the data of a given cell and its sub-cells.
*
...
...
@@ -283,6 +317,43 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c,
#endif
}
/**
* @brief Unpack the tags of a given cell and its sub-cells.
*
* @param tags An array of tags.
* @param c The #cell in which to unpack the tags.
*
* @return The number of tags created.
*/
int
cell_unpack_tags
(
const
int
*
tags
,
struct
cell
*
restrict
c
)
{
#ifdef WITH_MPI
/* Unpack the current pcell. */
c
->
tag
=
tags
[
0
];
/* Number of new cells created. */
int
count
=
1
;
/* Fill the progeny recursively, depth-first. */
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
c
->
progeny
[
k
]
!=
NULL
)
{
count
+=
cell_unpack_tags
(
&
tags
[
count
],
c
->
progeny
[
k
]);
}
#ifdef SWIFT_DEBUG_CHECKS
if
(
c
->
pcell_size
!=
count
)
error
(
"Inconsistent tag and pcell count!"
);
#endif // SWIFT_DEBUG_CHECKS
/* Return the total number of unpacked tags. */
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
* @brief Pack the time information of the given cell and all it's sub-cells.
*
...
...
This diff is collapsed.
Click to expand it.
src/cell.h
+
2
−
0
View file @
0bed8898
...
...
@@ -484,6 +484,8 @@ int cell_slocktree(struct cell *c);
void
cell_sunlocktree
(
struct
cell
*
c
);
int
cell_pack
(
struct
cell
*
c
,
struct
pcell
*
pc
);
int
cell_unpack
(
struct
pcell
*
pc
,
struct
cell
*
c
,
struct
space
*
s
);
int
cell_pack_tags
(
const
struct
cell
*
c
,
int
*
tags
);
int
cell_unpack_tags
(
const
int
*
tags
,
struct
cell
*
c
);
int
cell_pack_end_step
(
struct
cell
*
c
,
struct
pcell_step
*
pcell
);
int
cell_unpack_end_step
(
struct
cell
*
c
,
struct
pcell_step
*
pcell
);
int
cell_pack_multipoles
(
struct
cell
*
c
,
struct
gravity_tensors
*
m
);
...
...
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