Skip to content

Commit

Permalink
Fixed testSelectOutput to work with new scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed May 29, 2020
1 parent cfc435a commit 95b5e0d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
13 changes: 4 additions & 9 deletions tests/selectOutput.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
SelectOutput:
Default:
# Particle Type 0
Coordinates_Gas: 1 # check if written when specified
Velocities_Gas: 0 # check if not written when specified
Masses_Gas: -5 # check warning if not 0 or 1 and if written
Pot_Gas: 1 # check warning if wrong name
Coordinates_Gas: on # check if written when specified
Velocities_Gas: off # check if not written when specified
Pot_Gas: on # check warning if wrong name
# Density_Gas: 1 # check if written when not specified

# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
8 changes: 8 additions & 0 deletions tests/selectOutputParameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.

Snapshots:
select_output_on: 1
select_output: selectOutput.yml
13 changes: 9 additions & 4 deletions tests/testSelectOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
void select_output_engine_init(struct engine *e, struct space *s,
struct cosmology *cosmo,
struct swift_params *params,
struct output_options *output,
struct cooling_function_data *cooling,
struct hydro_props *hydro_properties) {
/* set structures */
e->s = s;
e->cooling_func = cooling;
e->parameter_file = params;
e->output_options = output;
e->cosmology = cosmo;
e->policy = engine_policy_hydro;
e->hydro_properties = hydro_properties;
Expand Down Expand Up @@ -96,9 +98,12 @@ int main(int argc, char *argv[]) {
/* parse parameters */
message("Reading parameters.");
struct swift_params param_file;
const char *input_file = "selectOutput.yml";
const char *input_file = "selectOutputParameters.yml";
parser_read_file(input_file, &param_file);

struct output_options output_options;
output_options_init(&param_file, 0, &output_options);

/* Default unit system */
message("Initialization of the unit system.");
struct unit_system us;
Expand Down Expand Up @@ -149,14 +154,14 @@ int main(int argc, char *argv[]) {
e.physical_constants = &prog_const;
sprintf(e.snapshot_base_name, "testSelectOutput");
sprintf(e.run_name, "Select Output Test");
select_output_engine_init(&e, &s, &cosmo, &param_file, &cooling,
&hydro_properties);
select_output_engine_init(&e, &s, &cosmo, &param_file, &output_options,
&cooling, &hydro_properties);

/* check output selection */
message("Checking output parameters.");
long long N_total[swift_type_count] = {
(long long)Ngas, (long long)Ngpart, 0, 0, (long long)Nspart, 0};
io_check_output_fields(&param_file, N_total, /*with_cosmology=*/1);
io_check_output_fields(&param_file, N_total, /*with_cosmology=*/0);

/* write output file */
message("Writing output.");
Expand Down
42 changes: 21 additions & 21 deletions tests/testSelectOutput.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2015 Bert Vandenbroucke ([email protected])
# Matthieu Schaller ([email protected])
#
# 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/>.
#
##############################################################################
# This file is part of SWIFT.
# Copyright (c) 2015 Bert Vandenbroucke ([email protected])
# Matthieu Schaller ([email protected])
#
# 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/>.
#
##############################################################################

# Check the output done with swift

Expand Down Expand Up @@ -47,8 +47,8 @@
with open(log_filename, "r") as f:
data = f.read()

if "SelectOutput:Masses_Gas" not in data:
raise Exception("Input error in `SelectOuput:Masses_Gas` not detected")
if "Default:Masses_Gas" not in data:
raise Exception("Input error in `Default:Masses_Gas` not detected")

if "SelectOutput:Pot_Gas" not in data:
if "Default:Pot_Gas" not in data:
raise Exception("Parameter name error not detected for `SelectOutput:Pot_Gas`")

0 comments on commit 95b5e0d

Please sign in to comment.