Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
37baeabb
Commit
37baeabb
authored
Sep 11, 2018
by
Matthieu Schaller
Browse files
Prevent the user from running with a mesh that is too small given r_cut_max.
parent
4e8b4efd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gravity_properties.c
View file @
37baeabb
...
...
@@ -58,12 +58,17 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
p
->
r_cut_min_ratio
=
parser_get_opt_param_float
(
params
,
"Gravity:r_cut_min"
,
gravity_props_default_r_cut_min
);
/* Some basic checks */
if
(
p
->
mesh_size
%
2
!=
0
)
error
(
"The mesh side-length must be an even number."
);
if
(
p
->
a_smooth
<=
0
.)
error
(
"The mesh smoothing scale 'a_smooth' must be > 0."
);
if
(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
>
p
->
mesh_size
)
error
(
"Mesh too small given r_cut_max. Should be at least %d cells wide."
,
(
int
)(
2
.
*
p
->
a_smooth
*
p
->
r_cut_max_ratio
)
+
1
);
/* Time integration */
p
->
eta
=
parser_get_param_float
(
params
,
"Gravity:eta"
);
...
...
src/mesh_gravity.c
View file @
37baeabb
...
...
@@ -574,7 +574,7 @@ void pm_mesh_init(struct pm_mesh* mesh, const struct gravity_props* props,
#ifdef HAVE_FFTW
if
(
dim
[
0
]
!=
dim
[
1
]
||
dim
[
0
]
!=
dim
[
1
])
if
(
dim
[
0
]
!=
dim
[
1
]
||
dim
[
0
]
!=
dim
[
2
])
error
(
"Doing mesh-gravity on a non-cubic domain"
);
const
int
N
=
props
->
mesh_size
;
...
...
@@ -591,6 +591,9 @@ void pm_mesh_init(struct pm_mesh* mesh, const struct gravity_props* props,
mesh
->
r_cut_max
=
mesh
->
r_s
*
props
->
r_cut_max_ratio
;
mesh
->
r_cut_min
=
mesh
->
r_s
*
props
->
r_cut_min_ratio
;
if
(
2
.
*
mesh
->
r_cut_max
>
box_size
)
error
(
"Mesh too small or r_cut_max too big for this box size"
);
/* Allocate the memory for the combined density and potential array */
mesh
->
potential
=
(
double
*
)
fftw_malloc
(
sizeof
(
double
)
*
N
*
N
*
N
);
if
(
mesh
->
potential
==
NULL
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment