Skip to content

Commit

Permalink
Fix issue where mapper tool used input, not output, mapping of paramf…
Browse files Browse the repository at this point in the history
…ile_a.txt

Add test, and notes on generally mapping gadget->grafic ICs (which is the current use case)
  • Loading branch information
apontzen committed Sep 28, 2024
1 parent 793978d commit 1bb23df
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions genetIC/src/ic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,12 @@ class ICGenerator {
#endif
}

//! Removes any input mapper that has been set up.
void clearInputMapper() {
pInputMapper.reset();
pInputMultiLevelContext.reset();
}

/*! \brief Get the grid on which the output is defined for a particular level.
*
* This may differ from the grid on which the fields are defined either because there is an offset or
Expand Down
4 changes: 4 additions & 0 deletions genetIC/src/main_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ int main(int argc, char *argv[]) {
logging::entry() << "Loading IDs from " << idFileInput << std::endl;
generator1.clearCellFlags();
generator2.clearCellFlags();

// the input IDs are relative to the output for generator1, not any input mapper that may be active:
generator1.clearInputMapper();

generator1.loadID(idFileInput);

// generator2.propagateFlagsToRefinedCells(generator1.getMultiLevelContext());
Expand Down
1 change: 1 addition & 0 deletions genetIC/src/simulation/field/field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <memory>
#include <vector>
#include <cassert>
#include <iomanip>
#include <src/simulation/filters/filter.hpp>
#include <src/tools/numerics/fourier.hpp>
#include <execinfo.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
61383
33 changes: 33 additions & 0 deletions genetIC/tests/mapper_test_08_tool_uses_correct_map/paramfile_a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Test that the output mapper, not the input mapper, is used by the mapper tool
#
# This also tests a case of taking a single particle in a gadget file and mapping
# it to grafic grids. Because grafic grids don't specify which zoom level will
# actually be used, this generates flags on *all* levels. Moreover because
# of the use of subsampling, there is a strange effect that one ends up with
# 2^3=8 cells flagged on the 128^3 intermediate res level.



Om 0.279
Ol 0.721
Ob 0.04
s8 0.817
zin 99
random_seed_real_space 8896131
camb ../camb_transfer_kmax40_z0.dat

outdir ./
outname mappertest
outformat gadget3
subsample 2

basegrid 50.0 64

centre 25 25 25
select_sphere 3
zoomgrid 4 64

# leave an input mapper set up, that the mapping tool should ignore
mapper_relative_to ../mapper_test_02a_grafic/paramfile.txt

done
11 changes: 11 additions & 0 deletions genetIC/tests/mapper_test_08_tool_uses_correct_map/reference.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
17968
174240
174241
174304
174305
178336
178337
178400
178401
321333
539883

0 comments on commit 1bb23df

Please sign in to comment.