Skip to content

Commit

Permalink
Initial commit v1.2B alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
con-f-use committed Jul 28, 2015
0 parents commit 66f0b1a
Show file tree
Hide file tree
Showing 49 changed files with 13,413 additions and 0 deletions.
3 changes: 3 additions & 0 deletions INSTALL_NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sudo apt-get install libcgal-dev libgsl-dev libboost-filesystem-dev libboost-system-dev

add as "-lgmp" CFLAG
175 changes: 175 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Makefile for compiling the DTFE code on Linux systems


# Path to the GSL, Boost C++ and CGAL libraries - must be set by user (only if they aren't installed in the default system path) -- (NOTE: You must add only the directory where the libraries are installed, the program will add the '/lib' and '/include' parts automatically); C++ compiler - preferably a version that supports OpenMP
GSL_PATH =
BOOST_PATH =
CGAL_PATH =
CC = g++
# set the following if you have installed the HDF5 library and would like to read in HDF5 gadget files
HDF5_PATH =


# paths to where to put the object files and the executables files. If you build the DTFE library than you also need to specify the directory where to put the library and the directory where to copy the header files needed by the library (choose an empty directory for the header files).
OBJ_DIR = ./o
BIN_DIR = ./
LIB_DIR = ./
INC_DIR = ./DTFE_include



############################# Choose the compiler directives ##################################

############################# Overall options ##################################
#OPTIONS = -g
#------------------------ set the number of spatial dimensions (2 or 3 dimensions)
OPTIONS += -DNO_DIM=3
#------------------------ set type of variables - float (comment the next line) or double (uncomment the next line)
#OPTIONS += -DDOUBLE

############################# Quantities to be computed ##################################
#------------------------ set which quantities can be computed (can save memory by leaving some out)
# Comment this line if you don't need to compute velocity and velocity related components
OPTIONS += -DVELOCITY
# Comment this line if you don't need to interpolate additional fields stored in the scalar variable
OPTIONS += -DSCALAR
# number of components of the scalar variable
OPTIONS += -DNO_SCALARS=1

############################# Input and output operations default settings ##################################
#------------------------ set which are the default input and output functions for doing data io
# default function to read the input data (101-multiple gadget file, 102-single gadget file, 105-HDF5 gadget file, 111-text file, ... see documentation for more options). The input file type can be set during runtime using the option '--input'. This makefile option only sets a default input file in the case none is given via the program options.
OPTIONS += -DINPUT_FILE_DEFAULT=101
# default value for the units of the input data (value=what is 1 Mpc in the units of the data - in this example the data is in kpc). You can change this also during runtime using the program option '--MpcUnit'.
OPTIONS += -DMPC_UNIT=1000.
# default function to write the output data (101-binary file, 111-text file, ... see documentation for more options). The output file type can be set during runtime using the option '--output'. This makefile option only sets a default output file in the case none is given via the program options.
OPTIONS += -DOUTPUT_FILE_DEFAULT=101
#101 for binary file, 100 my density file

############################# additional compiler options ##################################
# enable this option if to use OpenMP (share the workload between CPU cores sharing the same RAM)
OPTIONS += -DOPEN_MP
# enable to check if the padding gives a complete Delaunay Tesselation of the region of interest
# OPTIONS += -DTEST_PADDING
# enable this option to shift from position space to redshift space; You also need to activate this option during run-time using '--redshift-space arguments'
OPTIONS += -DREDSHIFT_SPACE

#------------------------ options usefull when using DTFE as a library
# uncomment the line to get access to a function that returns the Delaunay triangulation of the point set
# OPTIONS += -DTRIANGULATION


############################# Help menu messages options ##################################
#------------------------ compiler directive that affect only the help messages when using the '-h / --help' option (it does not affect the program in any other way)- if the option is uncommented, than it will show that set of options in the help menu
OPTIONS += -DFIELD_OPTIONS
OPTIONS += -DREGION_OPTIONS
# OPTIONS += -DPARTITION_OPTIONS
# OPTIONS += -DPADDING_OPTIONS
OPTIONS += -DAVERAGING_OPTIONS
# OPTIONS += -DREDSHIFT_CONE_OPTIONS
OPTIONS += -DADDITIONAL_OPTIONS








############### DO NOT MODIFY BELOW THIS LINE ###########################
# do not modify below this line
SRC = ./src
INCLUDES =
LIBRARIES =

ifneq ($(strip $(GSL_PATH)),)
INCLUDES += -I/$(strip $(GSL_PATH))/include
LIBRARIES += -L/$(strip $(GSL_PATH))/lib
endif
ifneq ($(strip $(BOOST_PATH)),)
INCLUDES += -I/$(strip $(BOOST_PATH))/include
LIBRARIES += -L/$(strip $(BOOST_PATH))/lib
endif
ifneq ($(strip $(CGAL_PATH)),)
INCLUDES += -I/$(strip $(CGAL_PATH))/include
LIBRARIES += -L/$(strip $(CGAL_PATH))/lib
endif
ifneq ($(strip $(HDF5_PATH)),)
INCLUDES += -I/$(strip $(HDF5_PATH))/include
LIBRARIES += -L/$(strip $(HDF5_PATH))/lib -lhdf5 -lhdf5_cpp
OPTIONS += -DHDF5
endif



COMPILE_FLAGS = -O2 -march=native -fopenmp -DNDEBUG $(OPTIONS) #-frounding-math -O3
DTFE_INC = $(INCLUDES)
# the following libraries should work in most cases
DTFE_LIB = -rdynamic $(LIBRARIES) -lCGAL -lboost_thread -lboost_filesystem -lboost_program_options -lgsl -lgslcblas -lm -lboost_system -lgmp
# the following libraries work on "Fedora 15"
# DTFE_LIB = -rdynamic $(LIBRARIES) -lCGAL -lboost_thread-mt -lboost_filesystem -lboost_program_options -lgsl -lgslcblas -lgmp -lboost_system



IO_SOURCES = $(addprefix io/, input_output.h gadget_reader.cc text_io.cc binary_io.cc my_io.cc)
MAIN_SOURCES = main.cpp DTFE.h message.h user_options.h input_output.cc $(IO_SOURCES)
DTFE_SOURCES = DTFE.cpp define.h particle_data.h user_options.h box.h quantities.h user_options.cc quantities.cc subpartition.h random.cc CIC_interpolation.cc TSC_interpolation.cc SPH_interpolation.cc kdtree/kdtree2.hpp Pvector.h message.h miscellaneous.h
TRIANG_SOURCES = $(addprefix CGAL_triangulation/, triangulation.cpp triangulation_miscellaneous.cc unaveraged_interpolation.cc averaged_interpolation_1.cc averaged_interpolation_2.cc padding_test.cc CGAL_include_2D.h CGAL_include_3D.h vertexData.h particle_data_traits.h) define.h particle_data.h user_options.h box.h quantities.h Pvector.h message.h math_functions.h

ALL_FILES = $(DTFE_SOURCES) $(TRIANG_SOURCES) $(MAIN_SOURCES) kdtree/kdtree2.hpp kdtree/kdtree2.cpp
LIB_FILES = $(DTFE_SOURCES) $(TRIANG_SOURCES)

HEADERS_1 = DTFE.h define.h user_options.h particle_data.h quantities.h Pvector.h math_functions.h message.h box.h miscellaneous.h
HEADERS_2 = $(addprefix CGAL_triangulation/, CGAL_include_2D.h CGAL_include_3D.h vertexData.h particle_data_traits.h)



DTFE: set_directories $(OBJ_DIR)/DTFE.o $(OBJ_DIR)/triangulation.o $(OBJ_DIR)/main.o $(OBJ_DIR)/kdtree2.o Makefile
$(CC) $(COMPILE_FLAGS) $(OBJ_DIR)/DTFE.o $(OBJ_DIR)/triangulation.o $(OBJ_DIR)/main.o $(OBJ_DIR)/kdtree2.o $(DTFE_LIB) -o $(BIN_DIR)/DTFE


$(OBJ_DIR)/main.o: $(addprefix $(SRC)/, $(MAIN_SOURCES)) Makefile
$(CC) $(COMPILE_FLAGS) $(DTFE_INC) -o $(OBJ_DIR)/main.o -c $(SRC)/main.cpp

$(OBJ_DIR)/DTFE.o: $(addprefix $(SRC)/, $(DTFE_SOURCES)) Makefile
$(CC) $(COMPILE_FLAGS) $(DTFE_INC) -o $(OBJ_DIR)/DTFE.o -c $(SRC)/DTFE.cpp

$(OBJ_DIR)/kdtree2.o: $(SRC)/kdtree/kdtree2.hpp $(SRC)/kdtree/kdtree2.cpp Makefile
$(CC) -O2 -pipe $(DTFE_INC) -o $(OBJ_DIR)/kdtree2.o -c $(SRC)/kdtree/kdtree2.cpp #-ffast-math -fomit-frame-pointer -O3

$(OBJ_DIR)/triangulation.o: $(addprefix $(SRC)/, $(TRIANG_SOURCES)) Makefile
$(CC) $(COMPILE_FLAGS) $(DTFE_INC) -o $(OBJ_DIR)/triangulation.o -c $(SRC)/CGAL_triangulation/triangulation.cpp


library: set_directories set_directories_2 $(addprefix $(SRC)/, $(LIB_FILES) ) copy_headers Makefile
$(CC) $(COMPILE_FLAGS) -fPIC $(DTFE_INC) -o $(OBJ_DIR)/DTFE_l.o -c $(SRC)/DTFE.cpp
$(CC) -O2 -pipe -fPIC $(DTFE_INC) -o $(OBJ_DIR)/kdtree2_l.o -c $(SRC)/kdtree/kdtree2.cpp #-ffast-math -fomit-frame-pointer -O3
$(CC) $(COMPILE_FLAGS) -fPIC $(DTFE_INC) -o $(OBJ_DIR)/triangulation_l.o -c $(SRC)/CGAL_triangulation/triangulation.cpp
$(CC) $(COMPILE_FLAGS) -shared $(OBJ_DIR)/DTFE_l.o $(OBJ_DIR)/triangulation_l.o $(OBJ_DIR)/kdtree2_l.o $(DTFE_LIB) -o $(LIB_DIR)/libDTFE.so


clean:
rm -f $(BIN_DIR)/DTFE $(OBJ_DIR)/*.o

copy_headers:
cp $(addprefix $(SRC)/, $(HEADERS_1)) $(INC_DIR)
cp $(addprefix $(SRC)/, $(HEADERS_2)) $(INC_DIR)/CGAL_triangulation

set_directories:
@ if !( test -d $(OBJ_DIR) ); \
then mkdir $(OBJ_DIR); \
fi
@ if !( test -d $(BIN_DIR) ); \
then mkdir $(BIN_DIR); \
fi

set_directories_2:
@ if !( test -d $(LIB_DIR) ); \
then mkdir $(LIB_DIR); \
fi
@ if !( test -d $(INC_DIR) ); \
then mkdir $(INC_DIR); \
fi
@ if !( test -d $(INC_DIR)/CGAL_triangulation ); \
then mkdir $(INC_DIR)/CGAL_triangulation; \
fi
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Rehost -> DTFE 1.2B
==================

This is a more stable but unofficial version of DTFE 1.2 (see the change log). Most notably there have been a few bug fixes in the file IO. The owner of this repository is not affiliated with the original authors of DTFE. The following text was taken directly from the [DTFE](http://www.astro.rug.nl/~voronoi/DTFE/dtfe.html) website.

The DTFE method
==================

![](./docs/steps.png)

The Delaunay Tessellation Field Interpolation (DTFE) method represents the natural way of going from discrete samples/measurements to values on a periodic grid using the maximum of information contained in the points set (that is the measurements points or particle distribution).

The DTFE method is especially suitable for astronomical data due to the following reasons:

- Preserves the multi-scale character of the point distribution. This is the case in numerical simulations of large scale structure (LSS) where the density varies over more than 6 orders of magnitude.
- Preserves the local geometry of the point distribution. This is important in recovering sharp features like the different components of the LSS (i.e. clusters, filaments, walls and voids).
- DTFE does not depend on user defined parameters or choices.
- The interpolated fields are volume weighted (versus mass weighted quantities in most other interpolation schemes). This can have a significant effect especially when comparing with analytical predictions which are volume weighted.

For detailed information about the DTFE method see the [Papers](http://www.astro.rug.nl/~voronoi/DTFE/papers.html) section.

The DTFE public software
==================

DTFE is free software, distributed under the [GNU General Public License](http://www.gnu.org/copyleft/gpl.html). This implies that you may freely distribute and copy the software. You may also modify it as you wish, and distribute these modified versions as long as you indicate prominently any changes you made in the original code, and as long as you leave the copyright notices, and the no-warranty notice intact. Please read the General Public License for more details. Note that the authors retain their copyright on the code.

The DTFE public code is a C++ implementation of the DTFE grid interpolation method. The code was written by Marius Cautun at the Kapteyn Astronomical Institute, Netherlands, with the purpose of analyzing cosmological numerical simulations and galaxy redshift survey. Even though the code was designed with astrophysics in mind, it can be used for problems in a wide range of fields where one needs to interpolate from a discrete set of points to a grid.

The code was designed using a modular philosophy and with a wide set of features that can easily be selected using the different program options. The DTFE code is also written using OpenMP directives which allow it to run in parallel on shared-memory architectures.

The code comes with a complete documentation and with a multitude of examples that detail the program features. Moreover, a help desk is available for information and assistance for troubleshooting problems.


Current features in the DTFE code
==================

- Works in both 2 and 3 spatial dimensions.
- Interpolates the fields to three different grids:
- Regular rectangular grid.
- Redshift cone grid.
- User given sampling points - these can describe any complex geometry.
- Uses the point distribution itself to compute the density and interpolates the result to grid.
- Each sample point has a weight associated to it to represent multiple resolution N-body simulations and observational biases for galaxy redshift surveys.
- Interpolates the velocity, velocity gradient, velocity divergence, velocity shear and velocity vorticity.
- Interpolates any additional number of fields and their gradients to grid.
- Periodic boundary conditions.
- Zoom in option for regions of interest.
- Splitting the full data in smaller computational chunks when dealing with limited CPU resources.
- The computation can be distributed in parallel on shared-memory architectures.
- Also comes with the TSC and the SPH interpolation methods.
- Can return the Delaunay tessellation of the given point set.
- Easy change of input/output data format.
- Easy to use as an external library.
- Extensive documentation of each feature.

At the moment the code comes with a Gadget snapshot reader for the input data, as well as with examples on how to load data from binary and text files. There are plans to offer input data readers for other types of input files (especially those specific to N-body codes), so if you are using the DTFE program with another reader, you can contact the help desk if you would like to include that reader in the official distribution. At the same time we are also looking for output data writing functions (especially to formats used in analysis and visualization programs) - at the moment the programs writes the output data to a binary or text file.
53 changes: 53 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
VERSION 1.2B
(version modified by con-f-use. Known issues: 3D-scalars, e.g. acceleration is not read out yet)
- fixed minor bug causing segmentation faults when reading gadget snapshots
- fixed an issue with skipping blocks of data in gadget snapshots
- the gadget reader now checks the block delimeter (size of block) for every block as opposed to just the header
- implemented better handling of scalar fields for gadget snapshots: the `--input`-option now knows one additional data type to read:
8 - internal energy
16 - unknown other block (if internal energy is not present - else this will also be dedicated to internal energy and the other block will be 32)
32 - unknown other block (if internal energy is present and not read read by user option)
so `--input 101 8 1` would now map the internal energy to an output file. Additional blocks after that can be read. Internal energy is a special block as its value must be multiplied by the mass. If you don't read internal energy but a later block the later block will usually correspond to 16. That is if no internal energy block is present. If an internal energy block is present and not read by user option, a later block will correspond to 32 (not 16) since internal energy will be read (skipped) by the program as 16 "unknown gas block".
- edited the `--full_help`-option to reflect the changes
- fixed error in the binary io, all data was read into the positions array, also velocities are not mandatory anymore


VERSION 1.2
Added some new features:
- added code for reading data from an HDF5 Gadget file

- added a new option called '--input' or '-i' that can be used to specify the input file type, the data to read from the input file and for what species. The '--input' option has the form: '--input input_file_type data_to_read particle_species_to_read' where the last two make sense only for Gadget files. The DEFAULT values are: '--input 101 7 2'
- the new option '--input' or '-i' needs to be followed by an integer specifying the input file type. By default it understands the following options:
101 - gadget binary snapshot saved as single or multiple files type I or II [ DEFAULT choice unsless specified otherwise in the Makefile ]
105 - gadget HDF5 file/files
111 - reads particles positions and masses (weights) from a text file. First line gives particle number followed by 6 coordinates giving the box dimensions: "xMin xMax yMin yMax zMin zMax". After this each row 'i' in the file gives positions X, Y, Z and weight for particle 'i'.
112 - reads particles positions from a text file. First line gives particle number followed by 6 coordinates giving the box dimensions: "xMin xMax yMin yMax zMin zMax". After this each row 'i' in the file gives positions X, Y and Z for particle 'i'. (note that each particle is assumed to have the same mass/weight)
121 - read particle positions, mass and velocities from a binary file. Modify this function in file 'src/io/binary_io.cc'
131 - read particle positions, mass and velocities from your custom file. Modify this function in file 'src/io/my_io.cc'
you can set the default output file in the Makefile by changing the values assigned to the '-DINPUT_FILE_DEFAULT' option.
- added a second integer value to the '--input' option to specify what which data to read. At the moment works only for gadget files and you can select to read the following:
1 - read particle positions
2 - read particle weights
4 - read particle velocities
to read multiple data add the number corresponding to each data set, for example 3=1+2 - specifies to read only particle positions and weights/masses, while a value of 7=1+2+4 specifies to read positions, weights and velocities [ DEFAULT = 7 -read positions, weights and velocities ]
- added an additional third option after for the '--input' parameter which specifies for which gadget particle species to read the data. You can select the following:
1 - read the data for gadget species 1 (normally gas particles)
2 - read the data for gadget species 2 (normally dark matter particles) [DEFAULT]
4 - read the data for gadget species 3 (usually stars or different mass DM particles in multiple resolution simulations)
8 - read the data for gadget species 4
16 - read the data for gadget species 5
32 - read the data for gadget species 6
to read data for multiple species just add the number corresponding to each particle type, for example 7=1+2+4 - specifies to read the data for both particle types 1, 2 and 3.

- added the '--output' or '-o' option to specify the output file type. Available options:
101 - the default binary output
100 - binary file with my own custom header and file structure
you can set the default output file in the Makefile by changing the values assigned to the '-DOUTPUT_FILE_DEFAULT' option.

- added option '--resdhiftSpace' that can be used to tranform the particle positions from position-space to redshift-space. For the option to work you need to enable the '-DREDSHIFT_SPACE' option in the Makefile. Than you need to call the '--resdhiftSpace d1 d2 d3' during runtime with (d1,d2,d3) the direction along which to use the velocity for the transformation to redshift space. The (d1,d2,d3) direction will be normalized to a unit vector by the program!




VERSION 1.1.2
- fixed bug when using the '--partition nx ny nz' with nx*ny*nz>=27
Binary file added docs/DTFE_user_guide_1.0.pdf
Binary file not shown.
Binary file added docs/delauny lecture notes.pdf
Binary file not shown.
Binary file added docs/steps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 66f0b1a

Please sign in to comment.