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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
c40f411d
Commit
c40f411d
authored
Apr 19, 2018
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Added a naive implementation of a 3D FOF.
parent
2643736b
No related branches found
No related tags found
1 merge request
!543
Fof
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Makefile.am
+2
-2
2 additions, 2 deletions
src/Makefile.am
src/fof.c
+112
-0
112 additions, 0 deletions
src/fof.c
src/fof.h
+39
-0
39 additions, 0 deletions
src/fof.h
with
153 additions
and
2 deletions
src/Makefile.am
+
2
−
2
View file @
c40f411d
...
@@ -47,7 +47,7 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
...
@@ -47,7 +47,7 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h
\
sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h
\
dump.h logger.h active.h timeline.h xmf.h gravity_properties.h gravity_derivatives.h
\
dump.h logger.h active.h timeline.h xmf.h gravity_properties.h gravity_derivatives.h
\
gravity_softened_derivatives.h vector_power.h collectgroup.h hydro_space.h sort_part.h
\
gravity_softened_derivatives.h vector_power.h collectgroup.h hydro_space.h sort_part.h
\
chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h
chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h
fof.h
# Common source files
# Common source files
AM_SOURCES
=
space.c runner.c queue.c task.c cell.c engine.c
\
AM_SOURCES
=
space.c runner.c queue.c task.c cell.c engine.c
\
...
@@ -59,7 +59,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
...
@@ -59,7 +59,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
statistics.c runner_doiact_vec.c profiler.c dump.c logger.c
\
statistics.c runner_doiact_vec.c profiler.c dump.c logger.c
\
part_type.c xmf.c gravity_properties.c gravity.c
\
part_type.c xmf.c gravity_properties.c gravity.c
\
collectgroup.c hydro_space.c equation_of_state.c
\
collectgroup.c hydro_space.c equation_of_state.c
\
chemistry.c cosmology.c restart.c
chemistry.c cosmology.c restart.c
fof.c
# Include files for distribution, not installation.
# Include files for distribution, not installation.
nobase_noinst_HEADERS
=
align.h approx_math.h atomic.h barrier.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h
\
nobase_noinst_HEADERS
=
align.h approx_math.h atomic.h barrier.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h
\
...
...
...
...
This diff is collapsed.
Click to expand it.
src/fof.c
0 → 100644
+
112
−
0
View file @
c40f411d
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 James Willis (james.s.willis@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
/* Config parameters. */
#include
"../config.h"
/* This object's header. */
#include
"fof.h"
/* Local headers. */
//#include "active.h"
void
fof_search
(
struct
engine
*
e
)
{
const
size_t
nr_gparts
=
e
->
s
->
nr_gparts
;
struct
gpart
*
gparts
=
e
->
s
->
gparts
;
const
double
dim
[
3
]
=
{
e
->
s
->
dim
[
0
],
e
->
s
->
dim
[
1
],
e
->
s
->
dim
[
2
]};
const
double
l_x
=
0
.
2
*
(
dim
[
0
]
/
pow
(
nr_gparts
,
1
.
/
3
.));
const
double
l_x2
=
l_x
*
l_x
;
int
*
pid
;
int
*
num_in_groups
;
int
num_groups
=
nr_gparts
;
message
(
"Searching %ld gravity particles for links with l_x2: %lf"
,
nr_gparts
,
l_x2
);
/* Allocate and populate array of particle group IDs. */
if
(
posix_memalign
((
void
**
)
&
pid
,
32
,
nr_gparts
*
sizeof
(
int
))
!=
0
)
error
(
"Failed to allocate list of particle group IDs for FOF search."
);
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
pid
[
i
]
=
i
;
if
(
posix_memalign
((
void
**
)
&
num_in_groups
,
32
,
nr_gparts
*
sizeof
(
int
))
!=
0
)
error
(
"Failed to allocate list of number in groups for FOF search."
);
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
num_in_groups
[
i
]
=
1
;
/* Loop over particles and find which particles belong in the same group. */
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
//message("Searching for particle: %ld groups.", i);
struct
gpart
*
pi
=
&
gparts
[
i
];
const
double
pix
=
pi
->
x
[
0
];
const
double
piy
=
pi
->
x
[
1
];
const
double
piz
=
pi
->
x
[
2
];
for
(
size_t
j
=
0
;
j
<
nr_gparts
;
j
++
)
{
/* Skip yourself. */
if
(
i
==
j
)
continue
;
struct
gpart
*
pj
=
&
gparts
[
j
];
const
double
pjx
=
pj
->
x
[
0
];
const
double
pjy
=
pj
->
x
[
1
];
const
double
pjz
=
pj
->
x
[
2
];
/* Compute pairwise distance, remembering to account for boundary conditions. */
float
dx
[
3
],
r2
=
0
.
0
f
;
dx
[
0
]
=
pix
-
pjx
;
dx
[
1
]
=
piy
-
pjy
;
dx
[
2
]
=
piz
-
pjz
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
nearest
(
dx
[
k
],
dim
[
k
]);
r2
+=
dx
[
k
]
*
dx
[
k
];
}
/* Hit or miss? */
if
(
r2
<
l_x2
&&
pid
[
j
]
<
pid
[
i
])
{
pid
[
i
]
=
pid
[
j
];
num_in_groups
[
i
]
--
;
num_in_groups
[
j
]
++
;
num_groups
--
;
}
}
}
int
num_parts_in_groups
=
0
;
int
max_group_size
=
0
,
max_group_id
=
0
;
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
if
(
num_in_groups
[
i
]
>
1
)
num_parts_in_groups
+=
num_in_groups
[
i
];
if
(
num_in_groups
[
i
]
>
max_group_size
)
{
max_group_size
=
num_in_groups
[
i
];
max_group_id
=
i
;
}
}
message
(
"No. of groups: %d. No. of particles in groups: %d. No. of particles not in groups: %d."
,
num_groups
,
num_parts_in_groups
,
nr_gparts
-
num_parts_in_groups
);
message
(
"Biggest group size: %d with ID: %d"
,
max_group_size
,
max_group_id
);
free
(
pid
);
free
(
num_in_groups
);
}
This diff is collapsed.
Click to expand it.
src/fof.h
0 → 100644
+
39
−
0
View file @
c40f411d
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 James Willis (james.s.willis@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_FOF_H
#define SWIFT_FOF_H
/* Config parameters. */
#include
"../config.h"
/* Local headers */
//#include "active.h"
//#include "cell.h"
#include
"engine.h"
//#include "hydro.h"
//#include "part.h"
//#include "runner.h"
//#include "timers.h"
//#include "vector.h"
/* Function prototypes. */
void
fof_search
(
struct
engine
*
e
);
#endif
/* SWIFT_FOF_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
sign in
to comment