mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-07 16:51:13 +00:00
Update cosmotool
This commit is contained in:
parent
387dc4d853
commit
64e05fc180
148 changed files with 1064 additions and 19378 deletions
80
external/cosmotool/src/CMakeLists.txt
vendored
80
external/cosmotool/src/CMakeLists.txt
vendored
|
@ -1,32 +1,46 @@
|
|||
SET(CosmoTool_SRCS
|
||||
fortran.cpp
|
||||
interpolate.cpp
|
||||
load_data.cpp
|
||||
loadGadget.cpp
|
||||
loadRamses.cpp
|
||||
octTree.cpp
|
||||
powerSpectrum.cpp
|
||||
miniargs.cpp
|
||||
growthFactor.cpp
|
||||
cosmopower.cpp
|
||||
)
|
||||
|
||||
IF(FOUND_NETCDF3)
|
||||
SET(CosmoTool_SRCS
|
||||
fortran.cpp
|
||||
interpolate.cpp
|
||||
load_data.cpp
|
||||
loadRamses.cpp
|
||||
powerSpectrum.cpp
|
||||
miniargs.cpp
|
||||
growthFactor.cpp
|
||||
cosmopower.cpp
|
||||
cic.cpp
|
||||
)
|
||||
|
||||
IF (Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
SET(CosmoTool_SRCS
|
||||
${CosmoTool_SRCS}
|
||||
loadGadget.cpp
|
||||
)
|
||||
ENDIF (Boost_FOUND)
|
||||
|
||||
IF (ENABLE_OPENMP)
|
||||
ENDIF (ENABLE_OPENMP)
|
||||
|
||||
IF (YORICK_SUPPORT)
|
||||
IF(FOUND_NETCDF3)
|
||||
SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc3.cpp)
|
||||
ELSE(FOUND_NETCDF3)
|
||||
IF(FOUND_NETCDF4)
|
||||
ELSE(FOUND_NETCDF3)
|
||||
IF(FOUND_NETCDF4)
|
||||
SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc4.cpp)
|
||||
ENDIF(FOUND_NETCDF4)
|
||||
ENDIF(FOUND_NETCDF3)
|
||||
ENDIF(FOUND_NETCDF4)
|
||||
ENDIF(FOUND_NETCDF3)
|
||||
ENDIF(YORICK_SUPPORT)
|
||||
|
||||
|
||||
if (HDF5_FOUND)
|
||||
set(CosmoTool_SRCS ${CosmoTool_SRCS}
|
||||
add_library(CosmoHDF5 OBJECT
|
||||
h5_readFlash.cpp
|
||||
loadFlash.cpp
|
||||
)
|
||||
target_include_directories(CosmoHDF5 BEFORE PRIVATE ${HDF5_INCLUDE_DIR})
|
||||
else(HDF5_FOUND)
|
||||
set(CosmoTool_SRCS ${CosmoTool_SRCS}
|
||||
add_library(CosmoHdf5 OBJECT
|
||||
loadFlash_dummy.cpp
|
||||
)
|
||||
endif (HDF5_FOUND)
|
||||
|
@ -55,27 +69,33 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS}
|
|||
growthFactor.hpp
|
||||
)
|
||||
|
||||
include_directories(${Boost_INCLUDE_DIRS} ${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src)
|
||||
include_directories(${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src)
|
||||
|
||||
set(CosmoTool_LIBS ${GSL_LIBRARIES})
|
||||
if(YORICK_SUPPORT)
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES})
|
||||
include_directories(${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH})
|
||||
endif(YORICK_SUPPORT)
|
||||
|
||||
set(CosmoTool_LIBS ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES})
|
||||
message("HDF5: ${HDF5_LIBRARIES} ${HDF5_INCLUDE_DIRS}")
|
||||
if (HDF5_FOUND)
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_CXX_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES})
|
||||
include_directories(${HDF5_INCLUDE_DIRS})
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_CXX_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES} ${ZLIB})
|
||||
message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}")
|
||||
endif (HDF5_FOUND)
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${ZLIB} ${LDLIB})
|
||||
|
||||
set(CosmoTool_LIBS ${CosmoTool_LIBS} PARENT_SCOPE)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_library(CosmoTool SHARED ${CosmoTool_SRCS})
|
||||
add_library(CosmoTool SHARED ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool ${CosmoTool_LIBS})
|
||||
|
||||
if (BUILD_STATIC_LIBS)
|
||||
add_library(CosmoTool_static STATIC ${CosmoTool_SRCS})
|
||||
add_library(CosmoTool_static STATIC ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool_static)
|
||||
set_property(TARGET CosmoTool_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif(BUILD_STATIC_LIBS)
|
||||
else (BUILD_SHARED_LIBS)
|
||||
add_library(CosmoTool STATIC ${CosmoTool_SRCS})
|
||||
add_library(CosmoTool STATIC ${CosmoTool_SRCS} $<TARGET_OBJECTS:CosmoHDF5>)
|
||||
target_link_libraries(CosmoTool)
|
||||
set_property(TARGET CosmoTool PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif (BUILD_SHARED_LIBS)
|
||||
|
||||
install(TARGETS CosmoTool
|
||||
|
@ -90,5 +110,7 @@ endif (BUILD_SHARED_LIBS)
|
|||
|
||||
install(DIRECTORY . DESTINATION include/CosmoTool
|
||||
FILES_MATCHING PATTERN "*.hpp")
|
||||
install(DIRECTORY ${OMPTL_BUILD_DIR}
|
||||
DESTINATION include/CosmoTool)
|
||||
install(DIRECTORY . DESTINATION include/CosmoTool
|
||||
FILES_MATCHING PATTERN "*.tcc")
|
||||
|
|
2
external/cosmotool/src/algo.hpp
vendored
2
external/cosmotool/src/algo.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/algo.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/algo.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/bqueue.hpp
vendored
2
external/cosmotool/src/bqueue.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/bqueue.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/bqueue.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/bsp_simple.hpp
vendored
2
external/cosmotool/src/bsp_simple.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/bsp_simple.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/bsp_simple.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
139
external/cosmotool/src/cic.cpp
vendored
139
external/cosmotool/src/cic.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/cic.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/cic.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -32,12 +32,14 @@ same conditions as regards security.
|
|||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
+*/
|
||||
|
||||
#include "openmp.hpp"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include "cic.hpp"
|
||||
|
||||
using namespace CosmoTool;
|
||||
|
||||
CICFilter::CICFilter(uint32_t N, double len)
|
||||
{
|
||||
spatialLen = len;
|
||||
|
@ -60,89 +62,29 @@ void CICFilter::resetMesh()
|
|||
|
||||
void CICFilter::putParticles(CICParticles *particles, uint32_t N)
|
||||
{
|
||||
#if 0
|
||||
uint32_t numCorners = 1 << NUMDIMS;
|
||||
int threadUsed = smp_get_max_threads();
|
||||
double *threadedDensity[threadUsed];
|
||||
bool threadActivated[threadUsed];
|
||||
uint32_t tUsedMin[threadUsed], tUsedMax[threadUsed];
|
||||
|
||||
for (uint32_t i = 0; i < N; i++)
|
||||
{
|
||||
Coordinates xyz;
|
||||
int32_t ixyz[NUMDIMS];
|
||||
int32_t rxyz[NUMDIMS];
|
||||
CICType alpha[NUMDIMS];
|
||||
CICType beta[NUMDIMS];
|
||||
for (int j = 0; j < NUMDIMS; j++)
|
||||
{
|
||||
xyz[j] = (particles[i].coords[j] / spatialLen * szGrid);
|
||||
ixyz[j] = (int32_t)floor(xyz[j] - 0.5);
|
||||
beta[j] = xyz[j] - ixyz[j] - 0.5;
|
||||
alpha[j] = 1 - beta[j];
|
||||
if (ixyz[j] < 0)
|
||||
ixyz[j] = szGrid-1;
|
||||
}
|
||||
for (int t = 0; t < threadUsed; t++)
|
||||
{
|
||||
threadedDensity[t] = new double[totalSize];
|
||||
std::fill(threadedDensity[t], threadedDensity[t]+totalSize, 0);
|
||||
}
|
||||
|
||||
CICType tot_mass = 0;
|
||||
for (int j = 0; j < numCorners; j++)
|
||||
{
|
||||
CICType rel_mass = 1;
|
||||
uint32_t idx = 0;
|
||||
uint32_t mul = 1;
|
||||
uint32_t mul2 = 1;
|
||||
std::fill(threadActivated, threadActivated+threadUsed, false);
|
||||
std::fill(tUsedMin, tUsedMin+threadUsed, totalSize);
|
||||
std::fill(tUsedMax, tUsedMax+threadUsed, 0);
|
||||
|
||||
for (int k = 0; k < NUMDIMS; k++)
|
||||
{
|
||||
uint32_t ipos = ((j & mul2) != 0);
|
||||
|
||||
if (ipos == 1)
|
||||
{
|
||||
rel_mass *= beta[k];
|
||||
}
|
||||
else
|
||||
{
|
||||
rel_mass *= alpha[k];
|
||||
}
|
||||
|
||||
rxyz[k] = ixyz[k] + ipos;
|
||||
|
||||
if (rxyz[k] >= szGrid)
|
||||
idx += (rxyz[k] - szGrid) * mul;
|
||||
else
|
||||
idx += rxyz[k] * mul;
|
||||
|
||||
mul2 *= 2;
|
||||
mul *= szGrid;
|
||||
}
|
||||
|
||||
assert(rel_mass > 0);
|
||||
assert(rel_mass < 1);
|
||||
assert(idx < totalSize);
|
||||
densityGrid[idx] += rel_mass * particles[i].mass;
|
||||
tot_mass += rel_mass;
|
||||
}
|
||||
assert(tot_mass < 1.1);
|
||||
assert(tot_mass > 0.9);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
for (uint32_t i = 0; i < N; i++)
|
||||
{
|
||||
Coordinates xyz;
|
||||
int32_t ixyz[NUMDIMS];
|
||||
for (int j = 0; j < NUMDIMS; j++)
|
||||
{
|
||||
xyz[j] = (particles[i].coords[j] / spatialLen * szGrid);
|
||||
ixyz[j] = (int32_t)round(xyz[j] - 0.5);
|
||||
if (ixyz[j] < 0)
|
||||
ixyz[j] = szGrid-1;
|
||||
else if (ixyz[j] >= szGrid)
|
||||
ixyz[j] = 0;
|
||||
}
|
||||
|
||||
uint32_t idx = ixyz[0] + ixyz[1] * szGrid + ixyz[2] * szGrid * szGrid;
|
||||
densityGrid[idx] += particles[i].mass;
|
||||
}
|
||||
|
||||
#endif
|
||||
#pragma omp parallel
|
||||
{
|
||||
int thisThread = smp_get_thread_id();
|
||||
double *dg = threadedDensity[thisThread];
|
||||
|
||||
threadActivated[thisThread] = true;
|
||||
|
||||
#pragma omp for schedule(static)
|
||||
for (uint32_t i = 0; i < N; i++)
|
||||
{
|
||||
CICType x, y, z;
|
||||
|
@ -193,44 +135,62 @@ void CICFilter::putParticles(CICParticles *particles, uint32_t N)
|
|||
|
||||
// 000
|
||||
idx = ix + (iy + iz * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * beta_x * beta_y * beta_z;
|
||||
|
||||
// 100
|
||||
idx = ix2 + (iy + iz * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * alpha_x * beta_y * beta_z;
|
||||
|
||||
// 010
|
||||
idx = ix + (iy2 + iz * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * beta_x * alpha_y * beta_z;
|
||||
|
||||
// 110
|
||||
idx = ix2 + (iy2 + iz * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * alpha_x * alpha_y * beta_z;
|
||||
|
||||
// 001
|
||||
idx = ix + (iy + iz2 * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * beta_x * beta_y * alpha_z;
|
||||
|
||||
// 101
|
||||
idx = ix2 + (iy + iz2 * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * alpha_x * beta_y * alpha_z;
|
||||
|
||||
// 011
|
||||
idx = ix + (iy2 + iz2 * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * beta_x * alpha_y * alpha_z;
|
||||
|
||||
// 111
|
||||
idx = ix2 + (iy2 + iz2 * szGrid) * szGrid;
|
||||
densityGrid[idx] +=
|
||||
dg[idx] +=
|
||||
mass * alpha_x * alpha_y * alpha_z;
|
||||
|
||||
tUsedMin[thisThread] = std::min(tUsedMin[thisThread], idx);
|
||||
tUsedMax[thisThread] = std::max(tUsedMax[thisThread], idx);
|
||||
}
|
||||
}
|
||||
|
||||
for (int t = 0; t < threadUsed; t++)
|
||||
{
|
||||
if (!threadActivated[t])
|
||||
continue;
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (long p = tUsedMin[t]; p < tUsedMax[t]; p++)
|
||||
densityGrid[p] += threadedDensity[t][p];
|
||||
}
|
||||
|
||||
for (int t = 0; t < threadUsed; t++)
|
||||
{
|
||||
delete[] threadedDensity[t];
|
||||
}
|
||||
}
|
||||
|
||||
void CICFilter::getDensityField(CICType*& field, uint32_t& res)
|
||||
|
@ -238,3 +198,4 @@ void CICFilter::getDensityField(CICType*& field, uint32_t& res)
|
|||
field = densityGrid;
|
||||
res = totalSize;
|
||||
}
|
||||
|
||||
|
|
8
external/cosmotool/src/cic.hpp
vendored
8
external/cosmotool/src/cic.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/cic.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/cic.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -36,10 +36,10 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#ifndef __CICFILTER_HPP
|
||||
#define __CICFILTER_HPP
|
||||
|
||||
#include "CosmoTool/config.hpp"
|
||||
#include "config.hpp"
|
||||
#include <inttypes.h>
|
||||
|
||||
using namespace CosmoTool;
|
||||
namespace CosmoTool {
|
||||
|
||||
typedef float CICType;
|
||||
|
||||
|
@ -67,4 +67,6 @@ typedef float CICType;
|
|||
uint32_t szGrid;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
9
external/cosmotool/src/config.hpp
vendored
9
external/cosmotool/src/config.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/config.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/config.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -39,6 +39,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
namespace CosmoTool
|
||||
|
@ -83,13 +84,13 @@ namespace CosmoTool
|
|||
* Base exception class for all exceptions handled by
|
||||
* this library.
|
||||
*/
|
||||
class Exception : public std::exception
|
||||
class Exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
Exception(const std::string& mess)
|
||||
: msg(mess), msgok(true) {}
|
||||
: std::runtime_error(mess), msg(mess), msgok(true) {}
|
||||
Exception()
|
||||
: msgok(false) {}
|
||||
: std::runtime_error("No message"), msgok(false) {}
|
||||
|
||||
virtual ~Exception() throw () {}
|
||||
|
||||
|
|
134
external/cosmotool/src/cosmopower.cpp
vendored
134
external/cosmotool/src/cosmopower.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/cosmopower.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/cosmopower.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -41,6 +41,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#include <fstream>
|
||||
#include <gsl/gsl_integration.h>
|
||||
#include "cosmopower.hpp"
|
||||
#include "tf_fit.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
@ -69,9 +70,17 @@ CosmoPower::CosmoPower()
|
|||
|
||||
Theta_27 = 2.728/2.7;
|
||||
|
||||
ehu_params = 0;
|
||||
|
||||
updateCosmology();
|
||||
}
|
||||
|
||||
CosmoPower::~CosmoPower()
|
||||
{
|
||||
if (ehu_params)
|
||||
delete ehu_params;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is \hat{tophat}
|
||||
*/
|
||||
|
@ -90,7 +99,8 @@ static double powC(double q, double alpha_c)
|
|||
|
||||
static double T_tilde_0(double q, double alpha_c, double beta_c)
|
||||
{
|
||||
double a = log(M_E + 1.8 * beta_c * q);
|
||||
static const double c_E = M_E;
|
||||
double a = log(c_E + 1.8 * beta_c * q);
|
||||
return a / ( a + powC(q, alpha_c) * q * q);
|
||||
}
|
||||
|
||||
|
@ -121,37 +131,81 @@ double CosmoPower::powerEfstathiou(double k)
|
|||
return normPower * pow(k,n) * pow(1+pow(f,nu),(-2/nu));
|
||||
}
|
||||
|
||||
void CosmoPower::updateHuWigglesOriginal()
|
||||
{
|
||||
if (ehu_params == 0)
|
||||
ehu_params = new TF_Transfer();
|
||||
|
||||
ehu_params->TFset_parameters( (OMEGA_C+OMEGA_B)*h*h,
|
||||
OMEGA_B/(OMEGA_C+OMEGA_B), Theta_27*2.7);
|
||||
}
|
||||
|
||||
void CosmoPower::updateHuWigglesConsts()
|
||||
{
|
||||
double f_b = OMEGA_B / OMEGA_0;
|
||||
double f_c = OMEGA_C / OMEGA_0;
|
||||
|
||||
double k_silk = 1.6 * pow(OMEGA_B * h * h, 0.52) * pow(OmegaEff, 0.73) * (1 + pow(10.4 * OmegaEff, -0.95));
|
||||
double z_eq = 2.50e4 * OmegaEff * pow(Theta_27, -4);
|
||||
//double s = 44.5 * log(9.83 / OmegaEff) / (sqrt(1 + 10 * pow(OMEGA_B * h * h, 0.75)));
|
||||
double k_eq = 7.46e-2 * OmegaEff * pow(Theta_27, -2);
|
||||
|
||||
double b1_zd = 0.313 * pow(OmegaEff, -0.419) * (1 + 0.607 * pow(OmegaEff, 0.674));
|
||||
double b2_zd = 0.238 * pow(OmegaEff, 0.223);
|
||||
double z_d = 1291 * pow(OmegaEff, 0.251) / (1 + 0.659 * pow(OmegaEff, 0.828)) * (1 + b1_zd * pow(OMEGA_B*h*h, b2_zd));
|
||||
|
||||
double R_d = 31.5 * OMEGA_B * h * h * pow(Theta_27, -4) * 1e3 / z_d;
|
||||
double Req = 31.5 * OMEGA_B * h * h * pow(Theta_27, -4) * 1e3 / z_eq;
|
||||
|
||||
double s = 2./(3.*k_eq) * sqrt(6/Req) * log((sqrt(1 + R_d) + sqrt(R_d + Req))/(1 + sqrt(Req)));
|
||||
|
||||
double a1 = pow(46.9 * OmegaEff, 0.670) * (1 + pow(32.1 * OmegaEff, -0.532));
|
||||
double a2 = pow(12.0 * OmegaEff, 0.424) * (1 + pow(45.0 * OmegaEff, -0.582));
|
||||
double alpha_c = pow(a1, -f_b) * pow(a2, -pow(f_b, 3));
|
||||
|
||||
double b1_betac = 0.944 * 1/(1 + pow(458 * OmegaEff, -0.708));
|
||||
double b2_betac = pow(0.395 * OmegaEff, -0.0266);
|
||||
double beta_c = 1/ ( 1 + b1_betac * (pow(f_c, b2_betac) - 1) );
|
||||
|
||||
double alpha_b = 2.07 * k_eq * s * pow(1 + R_d, -0.75) * powG((1 + z_eq)/(1 + z_d));
|
||||
double beta_b = 0.5 + f_b + (3 - 2 * f_b) * sqrt(pow(17.2 * OmegaEff, 2) + 1);
|
||||
double beta_node = 8.41 * pow(OmegaEff, 0.435);
|
||||
|
||||
ehu.k_silk = k_silk;
|
||||
ehu.s = s;
|
||||
ehu.k_eq = k_eq;
|
||||
ehu.alpha_c = alpha_c;
|
||||
ehu.beta_c = beta_c;
|
||||
|
||||
ehu.alpha_b = alpha_b;
|
||||
ehu.beta_b = beta_b;
|
||||
ehu.beta_node = beta_node;
|
||||
}
|
||||
|
||||
double CosmoPower::powerHuWiggles(double k)
|
||||
{
|
||||
// EISENSTEIN ET HU (1998)
|
||||
// FULL POWER SPECTRUM WITH BARYONS AND WIGGLES
|
||||
|
||||
double k_silk = 1.6 * pow(OMEGA_B * h * h, 0.52) * pow(OmegaEff, 0.73) * (1 + pow(10.4 * OmegaEff, -0.95));
|
||||
double z_eq = 2.50e4 * OmegaEff * pow(Theta_27, -4);
|
||||
double s = 44.5 * log(9.83 / OmegaEff) / (sqrt(1 + 10 * pow(OMEGA_B * h * h, 0.75)));
|
||||
double f = 1 / (1 + pow(k * s / 5.4, 4));
|
||||
double k_eq = 7.46e-2 * OmegaEff * pow(Theta_27, -2);
|
||||
double a1 = pow(46.9 * OmegaEff, 0.670) * (1 + pow(32.1 * OmegaEff, -0.532));
|
||||
double a2 = pow(12.0 * OmegaEff, 0.424) * (1 + pow(45.0 * OmegaEff, -0.582));
|
||||
double alpha_c = pow(a1, -OMEGA_B/ OMEGA_0) * pow(a2, -pow(OMEGA_B / OMEGA_0, 3));
|
||||
double k_silk = ehu.k_silk;
|
||||
double s = ehu.s;
|
||||
double k_eq = ehu.k_eq;
|
||||
double alpha_c = ehu.alpha_c;
|
||||
double beta_c = ehu.beta_c;
|
||||
double alpha_b = ehu.alpha_b;
|
||||
double beta_b = ehu.beta_b;
|
||||
double xx = k * s;
|
||||
|
||||
double s_tilde = s * pow(1 + pow(ehu.beta_node / (xx), 3), -1./3);
|
||||
|
||||
double f = 1 / (1 + pow(xx / 5.4, 4));
|
||||
double q = k / (13.41 * k_eq);
|
||||
double b1_betac = 0.944 * 1/(1 + pow(458 * OmegaEff, -0.708));
|
||||
double b2_betac = pow(0.395 * OmegaEff, -0.0266);
|
||||
double beta_c = 1/ ( 1 + b1_betac * (pow(OMEGA_C / OMEGA_0, b2_betac) - 1) );
|
||||
double T_c = f * T_tilde_0(q, 1, beta_c) + (1 - f) * T_tilde_0(q, alpha_c, beta_c);
|
||||
|
||||
double b1_zd = 0.313 * pow(OmegaEff, -0.419) * (1 + 0.607 * pow(OmegaEff, 0.674));
|
||||
double b2_zd = 0.238 * pow(OmegaEff, 0.223);
|
||||
double z_d = 1291 * pow(OmegaEff, 0.251) / (1 + 0.659 * pow(OmegaEff, 0.828)) * (1 + b1_zd * pow(OmegaEff, b2_zd));
|
||||
double R_d = 31.5 * OMEGA_B * h * h * pow(Theta_27, -4) * 1e3 / z_d;
|
||||
|
||||
double alpha_b = 2.07 * k_eq * s * pow(1 + R_d, -0.75) * powG((1 + z_eq)/(1 + z_d));
|
||||
double beta_b = 0.5 + OMEGA_B / OMEGA_0 + (3 - 2 * OMEGA_B / OMEGA_0) * sqrt(pow(17.2 * OmegaEff, 2) + 1);
|
||||
double beta_node = 8.41 * pow(OmegaEff, 0.435);
|
||||
double s_tilde = s * pow(1 + pow(beta_node / (k * s), 3), -1./3);
|
||||
|
||||
double T_b = (T_tilde_0(q, 1, 1) / (1 + pow(k * s / 5.2, 2)) + alpha_b / (1 + pow(beta_b / (k * s), 3)) * exp(-pow(k/k_silk, 1.4))) * j_0(k * s_tilde);
|
||||
double T_b = (
|
||||
T_tilde_0(q, 1, 1) / (1 + pow(xx / 5.2, 2)) +
|
||||
alpha_b / (1 + pow(beta_b / xx, 3)) * exp(-pow(k/k_silk, 1.4))
|
||||
) * j_0(k * s_tilde);
|
||||
|
||||
double T_k = OMEGA_B/OMEGA_0 * T_b + OMEGA_C/OMEGA_0 * T_c;
|
||||
|
||||
|
@ -212,7 +266,7 @@ double CosmoPower::powerBDM(double k)
|
|||
|
||||
double CosmoPower::powerTest(double k)
|
||||
{
|
||||
return 1/(1+k*k);
|
||||
return normPower;//1/(1+k*k);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -233,12 +287,18 @@ double CosmoPower::integrandNormalize(double x)
|
|||
return power(k)*k*k*f*f/(x*x);
|
||||
}
|
||||
|
||||
void CosmoPower::normalize()
|
||||
void CosmoPower::normalize(double k_min, double k_max)
|
||||
{
|
||||
double normVal = 0;
|
||||
double abserr;
|
||||
gsl_integration_workspace *w = gsl_integration_workspace_alloc(NUM_ITERATION);
|
||||
gsl_function f;
|
||||
double x_min = 0, x_max = 1;
|
||||
|
||||
if (k_max > 0)
|
||||
x_min = 1/(1+k_max);
|
||||
if (k_min > 0)
|
||||
x_max = 1/(1+k_min);
|
||||
|
||||
f.function = gslPowSpecNorm;
|
||||
f.params = this;
|
||||
|
@ -248,12 +308,12 @@ void CosmoPower::normalize()
|
|||
ofstream ff("PP_k.txt");
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
double k = pow(10.0, 4.0*i/100.-2);
|
||||
double k = pow(10.0, 8.0*i/100.-4);
|
||||
ff << k << " " << power(k) << endl;
|
||||
}
|
||||
|
||||
// gsl_integration_qagiu(&f, 0, 0, TOLERANCE, NUM_ITERATION, w, &normVal, &abserr);
|
||||
gsl_integration_qag(&f, 0, 1, 0, TOLERANCE, NUM_ITERATION, GSL_INTEG_GAUSS61, w, &normVal, &abserr);
|
||||
gsl_integration_qag(&f, x_min, x_max, 0, TOLERANCE, NUM_ITERATION, GSL_INTEG_GAUSS61, w, &normVal, &abserr);
|
||||
gsl_integration_workspace_free(w);
|
||||
|
||||
normVal /= (2*M_PI*M_PI);
|
||||
|
@ -301,6 +361,16 @@ double CosmoPower::power(double k)
|
|||
return (this->*eval)(k);
|
||||
}
|
||||
|
||||
double CosmoPower::powerHuWigglesOriginal(double k)
|
||||
{
|
||||
float tfb, tfc;
|
||||
|
||||
ehu_params->TFfit_onek(k, &tfb, &tfc);
|
||||
|
||||
double T_k = OMEGA_B/OMEGA_0 * tfb + OMEGA_C/OMEGA_0 * tfc;
|
||||
|
||||
return normPower * pow(k,n) * T_k * T_k;
|
||||
}
|
||||
|
||||
void CosmoPower::setFunction(CosmoFunction f)
|
||||
{
|
||||
|
@ -310,8 +380,13 @@ void CosmoPower::setFunction(CosmoFunction f)
|
|||
eval = &CosmoPower::powerEfstathiou;
|
||||
break;
|
||||
case HU_WIGGLES:
|
||||
updateHuWigglesConsts();
|
||||
eval = &CosmoPower::powerHuWiggles;
|
||||
break;
|
||||
case HU_WIGGLES_ORIGINAL:
|
||||
updateHuWigglesOriginal();
|
||||
eval = &CosmoPower::powerHuWigglesOriginal;
|
||||
break;
|
||||
case HU_BARYON:
|
||||
eval = &CosmoPower::powerHuBaryons;
|
||||
break;
|
||||
|
@ -337,5 +412,6 @@ void CosmoPower::setFunction(CosmoFunction f)
|
|||
|
||||
void CosmoPower::setNormalization(double A_K)
|
||||
{
|
||||
normPower = A_K/power(0.002);
|
||||
normPower = A_K;///power(0.002);
|
||||
}
|
||||
|
||||
|
|
46
external/cosmotool/src/cosmopower.hpp
vendored
46
external/cosmotool/src/cosmopower.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/cosmopower.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/cosmopower.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -38,6 +38,8 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
|
||||
namespace CosmoTool {
|
||||
|
||||
struct TF_Transfer;
|
||||
|
||||
class CosmoPower
|
||||
{
|
||||
public:
|
||||
|
@ -63,28 +65,42 @@ namespace CosmoTool {
|
|||
double OmegaEff;
|
||||
double Gamma0;
|
||||
double normPower;
|
||||
|
||||
struct EHuParams {
|
||||
double k_silk;
|
||||
double s;
|
||||
double k_eq;
|
||||
double alpha_b, beta_b;
|
||||
double alpha_c, beta_c;
|
||||
double beta_node;
|
||||
};
|
||||
|
||||
EHuParams ehu;
|
||||
TF_Transfer *ehu_params;
|
||||
|
||||
enum CosmoFunction
|
||||
{
|
||||
POWER_EFSTATHIOU,
|
||||
HU_WIGGLES,
|
||||
HU_BARYON,
|
||||
OLD_POWERSPECTRUM,
|
||||
POWER_BARDEEN,
|
||||
POWER_SUGIYAMA,
|
||||
POWER_BDM,
|
||||
POWER_TEST
|
||||
};
|
||||
enum CosmoFunction {
|
||||
POWER_EFSTATHIOU,
|
||||
HU_WIGGLES,
|
||||
HU_BARYON,
|
||||
OLD_POWERSPECTRUM,
|
||||
POWER_BARDEEN,
|
||||
POWER_SUGIYAMA,
|
||||
POWER_BDM,
|
||||
POWER_TEST,
|
||||
HU_WIGGLES_ORIGINAL
|
||||
};
|
||||
|
||||
CosmoPower();
|
||||
~CosmoPower();
|
||||
|
||||
void setFunction(CosmoFunction f);
|
||||
|
||||
void updateCosmology();
|
||||
void updatePhysicalCosmology();
|
||||
void normalize();
|
||||
void normalize(double k_min = -1, double k_max = -1);
|
||||
void setNormalization(double A_K);
|
||||
|
||||
void updateHuWigglesConsts();
|
||||
void updateHuWigglesOriginal();
|
||||
|
||||
double eval_theta_theta(double k);
|
||||
double power(double k);
|
||||
|
@ -101,7 +117,7 @@ namespace CosmoTool {
|
|||
double powerSugiyama(double k);
|
||||
double powerBDM(double k);
|
||||
double powerTest(double k);
|
||||
|
||||
double powerHuWigglesOriginal(double k);
|
||||
};
|
||||
|
||||
};
|
||||
|
|
2
external/cosmotool/src/dinterpolate.hpp
vendored
2
external/cosmotool/src/dinterpolate.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/dinterpolate.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/dinterpolate.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/eskow.hpp
vendored
2
external/cosmotool/src/eskow.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/eskow.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/eskow.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/field.hpp
vendored
2
external/cosmotool/src/field.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/field.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/field.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/fixArray.hpp
vendored
2
external/cosmotool/src/fixArray.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fixArray.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fixArray.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
52
external/cosmotool/src/fortran.cpp
vendored
52
external/cosmotool/src/fortran.cpp
vendored
|
@ -43,7 +43,6 @@ using namespace std;
|
|||
using namespace CosmoTool;
|
||||
|
||||
UnformattedRead::UnformattedRead(const string& fname)
|
||||
throw(NoSuchFileException)
|
||||
{
|
||||
f = new ifstream(fname.c_str());
|
||||
if (!*f)
|
||||
|
@ -52,10 +51,10 @@ UnformattedRead::UnformattedRead(const string& fname)
|
|||
swapOrdering = false;
|
||||
cSize = Check_32bits;
|
||||
checkPointRef = checkPointAccum = 0;
|
||||
recordBuffer = 0;
|
||||
}
|
||||
|
||||
UnformattedRead::UnformattedRead(const char *fname)
|
||||
throw(NoSuchFileException)
|
||||
{
|
||||
f = new ifstream(fname);
|
||||
if (!*f)
|
||||
|
@ -63,11 +62,14 @@ UnformattedRead::UnformattedRead(const char *fname)
|
|||
swapOrdering = false;
|
||||
cSize = Check_32bits;
|
||||
checkPointRef = checkPointAccum = 0;
|
||||
recordBuffer = 0;
|
||||
}
|
||||
|
||||
|
||||
UnformattedRead::~UnformattedRead()
|
||||
{
|
||||
if (recordBuffer != 0)
|
||||
delete[] recordBuffer;
|
||||
delete f;
|
||||
}
|
||||
|
||||
|
@ -97,7 +99,6 @@ void UnformattedRead::setCheckpointSize(CheckpointSize cs)
|
|||
}
|
||||
|
||||
void UnformattedRead::skip(int64_t off)
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
if (checkPointAccum == 0 && checkPointRef == 0)
|
||||
{
|
||||
|
@ -115,8 +116,7 @@ void UnformattedRead::skip(int64_t off)
|
|||
checkPointAccum += off;
|
||||
}
|
||||
|
||||
void UnformattedRead::beginCheckpoint()
|
||||
throw (InvalidUnformattedAccess,EndOfFileException)
|
||||
void UnformattedRead::beginCheckpoint(bool bufferRecord)
|
||||
{
|
||||
if (checkPointAccum != 0)
|
||||
throw InvalidUnformattedAccess();
|
||||
|
@ -129,15 +129,26 @@ void UnformattedRead::beginCheckpoint()
|
|||
|
||||
if (f->eof())
|
||||
throw EndOfFileException();
|
||||
|
||||
if (bufferRecord) {
|
||||
std::cout << "Use fast I/O mode" << std::endl;
|
||||
recordBuffer = new uint8_t[checkPointRef];
|
||||
f->read(reinterpret_cast<char *>(recordBuffer), checkPointRef);
|
||||
}
|
||||
}
|
||||
|
||||
void UnformattedRead::endCheckpoint(bool autodrop)
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
if (recordBuffer != 0) {
|
||||
delete[] recordBuffer;
|
||||
recordBuffer = 0;
|
||||
}
|
||||
|
||||
if (checkPointRef != checkPointAccum)
|
||||
{
|
||||
if (!autodrop || checkPointAccum > checkPointRef)
|
||||
if (!autodrop || checkPointAccum > checkPointRef) {
|
||||
throw InvalidUnformattedAccess();
|
||||
}
|
||||
f->seekg(checkPointRef-checkPointAccum, ios::cur);
|
||||
}
|
||||
|
||||
|
@ -145,21 +156,25 @@ void UnformattedRead::endCheckpoint(bool autodrop)
|
|||
|
||||
checkPointRef = (cSize == Check_32bits) ? 4 : 8;
|
||||
checkPointAccum = 0;
|
||||
checkPointRef = (cSize == Check_32bits) ? readInt32() : readInt64();
|
||||
checkPointRef = (cSize == Check_32bits) ? readUint32() : readInt64();
|
||||
|
||||
if (oldCheckPoint != checkPointRef)
|
||||
if (oldCheckPoint != checkPointRef) {
|
||||
throw InvalidUnformattedAccess();
|
||||
}
|
||||
|
||||
checkPointAccum = checkPointRef = 0;
|
||||
}
|
||||
|
||||
void UnformattedRead::readOrderedBuffer(void *buffer, int size)
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
if ((checkPointAccum+(uint64_t)size) > checkPointRef)
|
||||
throw InvalidUnformattedAccess();
|
||||
|
||||
f->read((char *)buffer, size);
|
||||
if (recordBuffer != 0) {
|
||||
memcpy(buffer, &recordBuffer[checkPointAccum], size);
|
||||
} else {
|
||||
f->read((char *)buffer, size);
|
||||
}
|
||||
|
||||
if (swapOrdering)
|
||||
{
|
||||
|
@ -171,7 +186,6 @@ void UnformattedRead::readOrderedBuffer(void *buffer, int size)
|
|||
}
|
||||
|
||||
double UnformattedRead::readReal64()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -185,7 +199,6 @@ double UnformattedRead::readReal64()
|
|||
}
|
||||
|
||||
float UnformattedRead::readReal32()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -199,7 +212,6 @@ float UnformattedRead::readReal32()
|
|||
}
|
||||
|
||||
uint32_t UnformattedRead::readUint32()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -213,7 +225,6 @@ uint32_t UnformattedRead::readUint32()
|
|||
}
|
||||
|
||||
int32_t UnformattedRead::readInt32()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -227,7 +238,6 @@ int32_t UnformattedRead::readInt32()
|
|||
}
|
||||
|
||||
int64_t UnformattedRead::readInt64()
|
||||
throw (InvalidUnformattedAccess)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -243,7 +253,6 @@ int64_t UnformattedRead::readInt64()
|
|||
//// UnformattedWrite
|
||||
|
||||
UnformattedWrite::UnformattedWrite(const string& fname)
|
||||
throw(NoSuchFileException)
|
||||
{
|
||||
f = new ofstream(fname.c_str());
|
||||
if (!*f)
|
||||
|
@ -255,7 +264,6 @@ UnformattedWrite::UnformattedWrite(const string& fname)
|
|||
}
|
||||
|
||||
UnformattedWrite::UnformattedWrite(const char *fname)
|
||||
throw(NoSuchFileException)
|
||||
{
|
||||
f = new ofstream(fname);
|
||||
if (!*f)
|
||||
|
@ -285,7 +293,6 @@ void UnformattedWrite::setCheckpointSize(CheckpointSize cs)
|
|||
}
|
||||
|
||||
void UnformattedWrite::beginCheckpoint()
|
||||
throw (InvalidUnformattedAccess,FilesystemFullException)
|
||||
{
|
||||
if (checkPointAccum != 0)
|
||||
throw InvalidUnformattedAccess();
|
||||
|
@ -303,7 +310,6 @@ void UnformattedWrite::beginCheckpoint()
|
|||
}
|
||||
|
||||
void UnformattedWrite::endCheckpoint()
|
||||
throw (InvalidUnformattedAccess,FilesystemFullException)
|
||||
{
|
||||
if (checkPointAccum == 0)
|
||||
throw InvalidUnformattedAccess();
|
||||
|
@ -335,7 +341,6 @@ void UnformattedWrite::endCheckpoint()
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeOrderedBuffer(void *buffer, int size)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
f->write((char *)buffer, size);
|
||||
|
||||
|
@ -352,7 +357,6 @@ void UnformattedWrite::writeOrderedBuffer(void *buffer, int size)
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeReal64(double d)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -366,7 +370,6 @@ void UnformattedWrite::writeReal64(double d)
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeReal32(float f)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -380,7 +383,6 @@ void UnformattedWrite::writeReal32(float f)
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeInt32(int32_t i)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -393,7 +395,6 @@ void UnformattedWrite::writeInt32(int32_t i)
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeInt64(int64_t i)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
@ -406,7 +407,6 @@ void UnformattedWrite::writeInt64(int64_t i)
|
|||
}
|
||||
|
||||
void UnformattedWrite::writeInt8(int8_t i)
|
||||
throw (FilesystemFullException)
|
||||
{
|
||||
union { char b; int8_t i; } a;
|
||||
|
||||
|
|
67
external/cosmotool/src/fortran.hpp
vendored
67
external/cosmotool/src/fortran.hpp
vendored
|
@ -46,6 +46,9 @@ namespace CosmoTool
|
|||
{
|
||||
class InvalidUnformattedAccess : public Exception
|
||||
{
|
||||
public:
|
||||
InvalidUnformattedAccess()
|
||||
: Exception("Invalid unformatted fortran file format") {}
|
||||
};
|
||||
|
||||
class FortranTypes
|
||||
|
@ -64,10 +67,8 @@ namespace CosmoTool
|
|||
{
|
||||
public:
|
||||
|
||||
UnformattedRead(const std::string& fname)
|
||||
throw (NoSuchFileException);
|
||||
UnformattedRead(const char *fname)
|
||||
throw (NoSuchFileException);
|
||||
UnformattedRead(const std::string& fname);
|
||||
UnformattedRead(const char *fname);
|
||||
~UnformattedRead();
|
||||
|
||||
// Todo implement primitive description
|
||||
|
@ -76,36 +77,28 @@ namespace CosmoTool
|
|||
|
||||
uint64_t getBlockSize() const { return checkPointRef; }
|
||||
|
||||
void beginCheckpoint()
|
||||
throw (InvalidUnformattedAccess,EndOfFileException);
|
||||
void endCheckpoint(bool autodrop = false)
|
||||
throw (InvalidUnformattedAccess);
|
||||
void beginCheckpoint(bool bufferRecord = false);
|
||||
void endCheckpoint(bool autodrop = false);
|
||||
|
||||
double readReal64()
|
||||
throw (InvalidUnformattedAccess);
|
||||
float readReal32()
|
||||
throw (InvalidUnformattedAccess);
|
||||
uint32_t readUint32()
|
||||
throw (InvalidUnformattedAccess);
|
||||
int32_t readInt32()
|
||||
throw (InvalidUnformattedAccess);
|
||||
int64_t readInt64()
|
||||
throw (InvalidUnformattedAccess);
|
||||
double readReal64();
|
||||
float readReal32();
|
||||
uint32_t readUint32();
|
||||
int32_t readInt32();
|
||||
int64_t readInt64();
|
||||
|
||||
void skip(int64_t off)
|
||||
throw (InvalidUnformattedAccess);
|
||||
void skip(int64_t off);
|
||||
|
||||
int64_t position() const;
|
||||
void seek(int64_t pos);
|
||||
|
||||
void readOrderedBuffer(void *buffer, int size)
|
||||
throw (InvalidUnformattedAccess);
|
||||
void readOrderedBuffer(void *buffer, int size);
|
||||
protected:
|
||||
bool swapOrdering;
|
||||
CheckpointSize cSize;
|
||||
uint64_t checkPointRef;
|
||||
uint64_t checkPointAccum;
|
||||
std::ifstream *f;
|
||||
uint8_t *recordBuffer;
|
||||
|
||||
};
|
||||
|
||||
|
@ -113,34 +106,24 @@ namespace CosmoTool
|
|||
{
|
||||
public:
|
||||
|
||||
UnformattedWrite(const std::string& fname)
|
||||
throw (NoSuchFileException);
|
||||
UnformattedWrite(const char *fname)
|
||||
throw (NoSuchFileException);
|
||||
UnformattedWrite(const std::string& fname);
|
||||
UnformattedWrite(const char *fname);
|
||||
~UnformattedWrite();
|
||||
|
||||
// Todo implement primitive description
|
||||
void setOrdering(Ordering o);
|
||||
void setCheckpointSize(CheckpointSize cs);
|
||||
|
||||
void beginCheckpoint()
|
||||
throw (FilesystemFullException,InvalidUnformattedAccess);
|
||||
void endCheckpoint()
|
||||
throw (FilesystemFullException,InvalidUnformattedAccess);
|
||||
void beginCheckpoint();
|
||||
void endCheckpoint();
|
||||
|
||||
void writeReal64(double d)
|
||||
throw (FilesystemFullException);
|
||||
void writeReal32(float f)
|
||||
throw (FilesystemFullException);
|
||||
void writeInt32(int32_t i)
|
||||
throw (FilesystemFullException);
|
||||
void writeInt64(int64_t i)
|
||||
throw (FilesystemFullException);
|
||||
void writeInt8(int8_t c)
|
||||
throw (FilesystemFullException);
|
||||
void writeReal64(double d);
|
||||
void writeReal32(float f);
|
||||
void writeInt32(int32_t i);
|
||||
void writeInt64(int64_t i);
|
||||
void writeInt8(int8_t c);
|
||||
|
||||
void writeOrderedBuffer(void *buffer, int size)
|
||||
throw(FilesystemFullException);
|
||||
void writeOrderedBuffer(void *buffer, int size);
|
||||
protected:
|
||||
bool swapOrdering;
|
||||
CheckpointSize cSize;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/base_types.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/base_types.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -55,6 +55,7 @@ namespace CosmoTool
|
|||
protected:
|
||||
SpectrumFunction() {}
|
||||
public:
|
||||
typedef T type;
|
||||
typedef Eigen::Array<T, 1, Eigen::Dynamic> VecType;
|
||||
typedef Eigen::Map<VecType, Eigen::Aligned> MapType;
|
||||
typedef Eigen::Map<VecType const, Eigen::Aligned> ConstMapType;
|
||||
|
@ -88,6 +89,7 @@ namespace CosmoTool
|
|||
FourierMap() {}
|
||||
|
||||
public:
|
||||
typedef T type;
|
||||
typedef Eigen::Array<T, 1, Eigen::Dynamic> VecType;
|
||||
typedef Eigen::Map<VecType, Eigen::Aligned> MapType;
|
||||
typedef Eigen::Map<VecType const, Eigen::Aligned> ConstMapType;
|
||||
|
@ -168,6 +170,7 @@ namespace CosmoTool
|
|||
{
|
||||
protected:
|
||||
FourierTransform() {}
|
||||
FourierTransform(const FourierTransform<T>& a) { abort(); }
|
||||
public:
|
||||
virtual ~FourierTransform() { }
|
||||
|
||||
|
@ -189,6 +192,7 @@ namespace CosmoTool
|
|||
class MapUtilityFunction
|
||||
{
|
||||
public:
|
||||
typedef T type;
|
||||
typedef SpectrumFunction<T> Spectrum;
|
||||
typedef boost::shared_ptr<Spectrum> Spectrum_ptr;
|
||||
typedef FourierMap<std::complex<T> > FMap;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/euclidian_maps.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/euclidian_maps.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -36,10 +36,16 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#ifndef __DETAILS_EUCLIDIAN_MAPS
|
||||
#define __DETAILS_EUCLIDIAN_MAPS
|
||||
|
||||
#include <cmath>
|
||||
#include <boost/multi_array.hpp>
|
||||
|
||||
namespace CosmoTool
|
||||
{
|
||||
|
||||
namespace details {
|
||||
static void no_free_euclidian_map(void *) {}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class EuclidianFourierMapBase: public FourierMap<T>
|
||||
{
|
||||
|
@ -57,9 +63,22 @@ namespace CosmoTool
|
|||
m_dims = indims;
|
||||
m_size = 1;
|
||||
for (int i = 0; i < m_dims.size(); i++)
|
||||
m_size *= m_dims[i];
|
||||
m_size *= m_dims[i];
|
||||
}
|
||||
|
||||
template<typename ArrayType>
|
||||
EuclidianFourierMapBase(ArrayType& indata)
|
||||
{
|
||||
m_data = boost::shared_ptr<T>(
|
||||
indata.origin(),
|
||||
std::ptr_fun(details::no_free_euclidian_map));
|
||||
m_dims = DimArray(indata.num_dimensions());
|
||||
m_size = indata.num_elements();
|
||||
for (int i = 0; i < m_dims.size(); i++)
|
||||
m_dims[i] = indata.shape()[i];
|
||||
}
|
||||
|
||||
|
||||
virtual ~EuclidianFourierMapBase()
|
||||
{
|
||||
}
|
||||
|
@ -70,6 +89,14 @@ namespace CosmoTool
|
|||
virtual T *data() { return m_data.get(); }
|
||||
virtual long size() const { return m_size; }
|
||||
|
||||
boost::multi_array_ref<T, 1>& array() {
|
||||
return boost::multi_array_ref<T, 1>(m_data.get(), boost::extents[size]);
|
||||
}
|
||||
|
||||
boost::const_multi_array_ref<T, 1>& array() const {
|
||||
return boost::const_multi_array_ref<T, 1>(m_data.get(), boost::extents[size]);
|
||||
}
|
||||
|
||||
virtual FourierMap<T> *copy() const
|
||||
{
|
||||
FourierMap<T> *m = this->mimick();
|
||||
|
@ -89,6 +116,12 @@ namespace CosmoTool
|
|||
: EuclidianFourierMapBase<T>(indata, indims)
|
||||
{}
|
||||
|
||||
template<typename ArrayType>
|
||||
EuclidianFourierMapReal(ArrayType& indata)
|
||||
: EuclidianFourierMapBase<T>(indata)
|
||||
{}
|
||||
|
||||
|
||||
virtual FourierMap<T> *mimick() const
|
||||
{
|
||||
return new EuclidianFourierMapReal<T>(
|
||||
|
@ -124,16 +157,32 @@ namespace CosmoTool
|
|||
int dim0,
|
||||
const DimArray& indims,
|
||||
const std::vector<double>& dk)
|
||||
: EuclidianFourierMapBase<std::complex<T> >(indata, indims), delta_k(dk), m_dim0(dim0), even0((dim0 % 2)==0)
|
||||
: EuclidianFourierMapBase<std::complex<T> >(indata, indims),
|
||||
delta_k(dk), m_dim0(dim0), even0((dim0 % 2)==0)
|
||||
{
|
||||
assert(dk.size() == indims.size());
|
||||
plane_size = 1;
|
||||
alleven = true;
|
||||
for (int q = 1; q < indims.size(); q++)
|
||||
{
|
||||
plane_size *= indims[q];
|
||||
alleven = alleven && ((indims[q]%2)==0);
|
||||
}
|
||||
for (int q = 1; q < indims.size(); q++) {
|
||||
plane_size *= indims[q];
|
||||
alleven = alleven && ((indims[q]%2)==0);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ArrayType>
|
||||
EuclidianFourierMapComplex(ArrayType& indata,
|
||||
int dim0,
|
||||
const std::vector<double>& dk)
|
||||
: EuclidianFourierMapBase<std::complex<T> >(indata),
|
||||
delta_k(dk), m_dim0(dim0), even0((dim0 % 2)==0)
|
||||
{
|
||||
assert(dk.size() == indata.num_dimensions());
|
||||
plane_size = 1;
|
||||
alleven = true;
|
||||
for (int q = 1; q < this->m_dims.size(); q++) {
|
||||
plane_size *= this->m_dims[q];
|
||||
alleven = alleven && ((this->m_dims[q]%2)==0);
|
||||
}
|
||||
}
|
||||
|
||||
virtual FourierMap<std::complex<T> > *mimick() const
|
||||
|
@ -161,18 +210,17 @@ namespace CosmoTool
|
|||
assert(kvec.size() == dims.size());
|
||||
|
||||
kvec[0] = ik[0] * delta_k[0];
|
||||
for (int q = 1; q < ik.size(); q++)
|
||||
{
|
||||
int dk = ik[q];
|
||||
if (dk > dims[q]/2)
|
||||
dk = dk - dims[q];
|
||||
for (int q = 1; q < ik.size(); q++) {
|
||||
int dk = ik[q];
|
||||
if (dk > dims[q]/2)
|
||||
dk = dk - dims[q];
|
||||
|
||||
kvec[q] = dk*delta_k[q];
|
||||
}
|
||||
kvec[q] = dk*delta_k[q];
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Array2>
|
||||
void get_Kvec(long p, Array2& kvec) const
|
||||
void get_Kvec_p(long p, Array2& kvec) const
|
||||
{
|
||||
const DimArray& dims = this->getDims();
|
||||
DimArray d(delta_k.size());
|
||||
|
@ -200,19 +248,18 @@ namespace CosmoTool
|
|||
double k2 = 0;
|
||||
k2 += CosmoTool::square(ik[0]*delta_k[0]);
|
||||
|
||||
for (int q = 1; q < ik.size(); q++)
|
||||
{
|
||||
int dk = ik[q];
|
||||
for (int q = 1; q < ik.size(); q++) {
|
||||
int dk = ik[q];
|
||||
|
||||
if (dk > dims[q]/2)
|
||||
dk = dk - dims[q];
|
||||
|
||||
k2 += CosmoTool::square(delta_k[q]*dk);
|
||||
}
|
||||
if (dk > dims[q]/2)
|
||||
dk = dk - dims[q];
|
||||
|
||||
k2 += CosmoTool::square(delta_k[q]*dk);
|
||||
}
|
||||
return std::sqrt(k2);
|
||||
}
|
||||
|
||||
double get_K(long p) const
|
||||
double get_K_p(long p) const
|
||||
{
|
||||
const DimArray& dims = this->getDims();
|
||||
DimArray d(delta_k.size());
|
||||
|
@ -230,7 +277,8 @@ namespace CosmoTool
|
|||
virtual std::complex<T> dot_product(const FourierMap<std::complex<T> >& other) const
|
||||
throw(std::bad_cast)
|
||||
{
|
||||
const EuclidianFourierMapComplex<T>& m2 = dynamic_cast<const EuclidianFourierMapComplex<T>&>(other);
|
||||
const EuclidianFourierMapComplex<T>& m2 =
|
||||
dynamic_cast<const EuclidianFourierMapComplex<T>&>(other);
|
||||
if (this->size() != m2.size())
|
||||
throw std::bad_cast();
|
||||
|
||||
|
@ -240,24 +288,21 @@ namespace CosmoTool
|
|||
int N0 = dims[0] + (even0 ? 0 : 1);
|
||||
std::complex<T> result = 0;
|
||||
|
||||
for (long q0 = 1; q0 < N0-1; q0++)
|
||||
{
|
||||
for (long p = 0; p < plane_size; p++)
|
||||
{
|
||||
long idx = q0+dims[0]*p;
|
||||
assert(idx < this->size());
|
||||
result += 2*(conj(d1[idx]) * d2[idx]).real();
|
||||
}
|
||||
}
|
||||
if (even0)
|
||||
{
|
||||
for (long p = 0; p < plane_size; p++)
|
||||
{
|
||||
long q0 = N0*p, q1 = (p+1)*N0-1;
|
||||
result += conj(d1[q0]) * d2[q0];
|
||||
result += conj(d1[q1]) * d2[q1];
|
||||
}
|
||||
}
|
||||
for (long q0 = 1; q0 < N0-1; q0++) {
|
||||
for (long p = 0; p < plane_size; p++) {
|
||||
long idx = q0+dims[0]*p;
|
||||
assert(idx < this->size());
|
||||
result += T(2)*(std::conj(d1[idx]) * d2[idx]).real();
|
||||
}
|
||||
}
|
||||
if (even0) {
|
||||
for (long p = 0; p < plane_size; p++)
|
||||
{
|
||||
long q0 = N0*p, q1 = (p+1)*N0-1;
|
||||
result += T(2)*std::conj(d1[q0]) * d2[q0];
|
||||
result += T(2)*std::conj(d1[q1]) * d2[q1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/euclidian_spectrum_1d.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/euclidian_spectrum_1d.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -115,7 +115,7 @@ namespace CosmoTool
|
|||
|
||||
for (long p = 1; p < rand_map.size(); p++)
|
||||
{
|
||||
double A_k = std::sqrt(0.5*V*f(rand_map.get_K(p)));
|
||||
double A_k = std::sqrt(0.5*V*f(rand_map.get_K_p(p)));
|
||||
d[p] = std::complex<T>(gsl_ran_gaussian(rng, A_k),
|
||||
gsl_ran_gaussian(rng, A_k));
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ namespace CosmoTool
|
|||
plane_size *= dims[q];
|
||||
}
|
||||
|
||||
for (long p = 1; p < plane_size/2; p++)
|
||||
for (long p = 1; p < plane_size/2+1; p++)
|
||||
{
|
||||
long q = (p+1)*dims[0]-1;
|
||||
long q2 = (plane_size-p+1)*dims[0]-1;
|
||||
|
@ -147,6 +147,13 @@ namespace CosmoTool
|
|||
d[q] = conj(d[q2]);
|
||||
}
|
||||
|
||||
for (long p = 1; p < plane_size/2+1; p++)
|
||||
{
|
||||
long q = (p)*dims[0];
|
||||
long q2 = (plane_size-p)*dims[0];
|
||||
d[q] = conj(d[q2]);
|
||||
}
|
||||
|
||||
if (alleven)
|
||||
{
|
||||
long q = 0;
|
||||
|
@ -164,7 +171,7 @@ namespace CosmoTool
|
|||
std::complex<T> *d = m.data();
|
||||
|
||||
for (long p = 0; p < m_c.size(); p++)
|
||||
d[p] *= f(m_c.get_K(p));
|
||||
d[p] *= f(m_c.get_K_p(p));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -174,7 +181,7 @@ namespace CosmoTool
|
|||
std::complex<T> *d = m.data();
|
||||
|
||||
for (long p = 0; p < m_c.size(); p++)
|
||||
d[p] *= std::sqrt(f(m_c.get_K(p)));
|
||||
d[p] *= std::sqrt(f(m_c.get_K_p(p)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -185,7 +192,7 @@ namespace CosmoTool
|
|||
|
||||
for (long p = 0; p < m_c.size(); p++)
|
||||
{
|
||||
T A = f(m_c.get_K(p));
|
||||
T A = f(m_c.get_K_p(p));
|
||||
if (A==0)
|
||||
d[p] = 0;
|
||||
else
|
||||
|
@ -201,7 +208,7 @@ namespace CosmoTool
|
|||
|
||||
for (long p = 0; p < m_c.size(); p++)
|
||||
{
|
||||
T A = std::sqrt(f(m_c.get_K(p)));
|
||||
T A = std::sqrt(f(m_c.get_K_p(p)));
|
||||
if (A == 0)
|
||||
d[p] = 0;
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/euclidian_spectrum_1d_bin.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/euclidian_spectrum_1d_bin.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/euclidian_transform.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/euclidian_transform.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -55,11 +55,25 @@ namespace CosmoTool
|
|||
std::vector<double> m_L;
|
||||
public:
|
||||
EuclidianFourierTransform(const DimArray& dims, const std::vector<double>& L)
|
||||
{
|
||||
realMap = 0;
|
||||
create_plan(dims, L);
|
||||
}
|
||||
|
||||
void create_plan(const DimArray& dims, const std::vector<double>& L)
|
||||
{
|
||||
assert(L.size() == dims.size());
|
||||
std::vector<double> dk(L.size());
|
||||
std::vector<int> swapped_dims(dims.size());
|
||||
|
||||
|
||||
if (realMap != 0)
|
||||
{
|
||||
delete realMap;
|
||||
delete fourierMap;
|
||||
calls::destroy_plan(m_synthesis);
|
||||
calls::destroy_plan(m_analysis);
|
||||
}
|
||||
|
||||
m_dims = dims;
|
||||
m_dims_hc = dims;
|
||||
m_dims_hc[0] = dims[0]/2+1;
|
||||
|
@ -69,28 +83,34 @@ namespace CosmoTool
|
|||
Nc = 1;
|
||||
volume = 1;
|
||||
for (int i = 0; i < dims.size(); i++)
|
||||
{
|
||||
N *= dims[i];
|
||||
{
|
||||
N *= dims[i];
|
||||
Nc *= m_dims_hc[i];
|
||||
volume *= L[i];
|
||||
dk[i] = 2*M_PI/L[i];
|
||||
volume *= L[i];
|
||||
dk[i] = 2*M_PI/L[i];
|
||||
swapped_dims[dims.size()-1-i] = dims[i];
|
||||
}
|
||||
}
|
||||
|
||||
realMap = new EuclidianFourierMapReal<T>(
|
||||
boost::shared_ptr<T>(calls::alloc_real(N),
|
||||
std::ptr_fun(calls::free)),
|
||||
m_dims);
|
||||
boost::shared_ptr<T>(calls::alloc_real(N),
|
||||
std::ptr_fun(calls::free)),
|
||||
m_dims);
|
||||
fourierMap = new EuclidianFourierMapComplex<T>(
|
||||
boost::shared_ptr<std::complex<T> >((std::complex<T>*)calls::alloc_complex(Nc),
|
||||
std::ptr_fun(calls::free)),
|
||||
dims[0], m_dims_hc, dk);
|
||||
m_analysis = calls::plan_dft_r2c(dims.size(), &swapped_dims[0],
|
||||
realMap->data(), (typename calls::complex_type *)fourierMap->data(),
|
||||
FFTW_DESTROY_INPUT|FFTW_MEASURE);
|
||||
m_synthesis = calls::plan_dft_c2r(dims.size(), &swapped_dims[0],
|
||||
(typename calls::complex_type *)fourierMap->data(), realMap->data(),
|
||||
FFTW_DESTROY_INPUT|FFTW_MEASURE);
|
||||
boost::shared_ptr<std::complex<T> >(
|
||||
(std::complex<T>*)calls::alloc_complex(Nc),
|
||||
std::ptr_fun(calls::free)),
|
||||
dims[0], m_dims_hc, dk);
|
||||
{
|
||||
m_analysis = calls::plan_dft_r2c(
|
||||
dims.size(), &swapped_dims[0],
|
||||
realMap->data(),
|
||||
(typename calls::complex_type *)fourierMap->data(),
|
||||
FFTW_DESTROY_INPUT|FFTW_MEASURE);
|
||||
m_synthesis = calls::plan_dft_c2r(
|
||||
dims.size(), &swapped_dims[0],
|
||||
(typename calls::complex_type *)fourierMap->data(), realMap->data(),
|
||||
FFTW_DESTROY_INPUT|FFTW_MEASURE);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~EuclidianFourierTransform()
|
||||
|
@ -106,12 +126,22 @@ namespace CosmoTool
|
|||
calls::execute(m_synthesis);
|
||||
realMap->scale(1/volume);
|
||||
}
|
||||
|
||||
void synthesis_unnormed()
|
||||
{
|
||||
calls::execute(m_synthesis);
|
||||
}
|
||||
|
||||
void analysis()
|
||||
{
|
||||
calls::execute(m_analysis);
|
||||
fourierMap->scale(volume/N);
|
||||
}
|
||||
|
||||
void analysis_unnormed()
|
||||
{
|
||||
calls::execute(m_analysis);
|
||||
}
|
||||
|
||||
void synthesis_conjugate()
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/healpix_alms.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/healpix_alms.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/healpix_map.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/healpix_map.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/healpix_spectrum.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/healpix_spectrum.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -100,8 +100,8 @@ namespace CosmoTool
|
|||
for (LType m = 1; m <= std::min(l,alms.Mmax()); m++)
|
||||
{
|
||||
std::complex<T>& c = new_data[alms.index(l,m)];
|
||||
c.real() = gsl_ran_gaussian(rng, Al);
|
||||
c.imag() = gsl_ran_gaussian(rng, Al);
|
||||
c.real(gsl_ran_gaussian(rng, Al));
|
||||
c.imag(gsl_ran_gaussian(rng, Al));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/healpix_transform.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/healpix_transform.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -36,13 +36,15 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#ifndef __COSMOTOOL_FOURIER_HEALPIX_DETAILS_TRANSFORM_HPP
|
||||
#define __COSMOTOOL_FOURIER_HEALPIX_DETAILS_TRANSFORM_HPP
|
||||
|
||||
#include <valarray>
|
||||
|
||||
namespace CosmoTool
|
||||
{
|
||||
|
||||
template<typename T> struct HealpixJobHelper__ {};
|
||||
|
||||
template<> struct HealpixJobHelper__<double>
|
||||
{ enum {val=1}; };
|
||||
{ enum {val=SHARP_DP}; };
|
||||
|
||||
template<> struct HealpixJobHelper__<float>
|
||||
{ enum {val=0}; };
|
||||
|
@ -65,6 +67,13 @@ namespace CosmoTool
|
|||
sharp_make_triangular_alm_info (Lmax, Mmax, 1, &ainfo);
|
||||
}
|
||||
|
||||
HealpixFourierTransform(long nSide, long Lmax, long Mmax, int iterate, const std::valarray<double>& weights )
|
||||
: realMap(nSide), fourierMap(Lmax, Mmax), ainfo(0), ginfo(0), m_iterate(iterate)
|
||||
{
|
||||
sharp_make_weighted_healpix_geom_info (nSide, 1, &weights[0], &ginfo);
|
||||
sharp_make_triangular_alm_info (Lmax, Mmax, 1, &ainfo);
|
||||
}
|
||||
|
||||
virtual ~HealpixFourierTransform()
|
||||
{
|
||||
sharp_destroy_geom_info(ginfo);
|
||||
|
@ -88,8 +97,8 @@ namespace CosmoTool
|
|||
{
|
||||
void *aptr=reinterpret_cast<void *>(fourierMap.data()), *mptr=reinterpret_cast<void *>(realMap.data());
|
||||
|
||||
sharp_execute (SHARP_MAP2ALM, 0, 0, &aptr, &mptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0,0);
|
||||
sharp_execute (SHARP_MAP2ALM, 0, &aptr, &mptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0);
|
||||
for (int i = 0; i < m_iterate; i++)
|
||||
{
|
||||
HealpixFourierMap<T> tmp_map(realMap.Nside());
|
||||
|
@ -97,11 +106,11 @@ namespace CosmoTool
|
|||
typename HealpixFourierMap<T>::MapType m0 = tmp_map.eigen();
|
||||
typename HealpixFourierMap<T>::MapType m1 = realMap.eigen();
|
||||
|
||||
sharp_execute (SHARP_ALM2MAP, 0, 0, &aptr, &tmp_ptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0,0);
|
||||
sharp_execute (SHARP_ALM2MAP, 0, &aptr, &tmp_ptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0);
|
||||
m0 = m1 - m0;
|
||||
sharp_execute (SHARP_MAP2ALM, 0, 1, &aptr, &tmp_ptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0,0);
|
||||
sharp_execute (SHARP_MAP2ALM, 0, &aptr, &tmp_ptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val | SHARP_ADD,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,8 +118,8 @@ namespace CosmoTool
|
|||
{
|
||||
void *aptr=reinterpret_cast<void *>(fourierMap.data()), *mptr=reinterpret_cast<void *>(realMap.data());
|
||||
|
||||
sharp_execute (SHARP_ALM2MAP, 0, 0, &aptr, &mptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0,0);
|
||||
sharp_execute (SHARP_ALM2MAP, 0, &aptr, &mptr, ginfo, ainfo, 1,
|
||||
HealpixJobHelper__<T>::val,0,0);
|
||||
}
|
||||
|
||||
virtual void analysis_conjugate()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/details/healpix_utility.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/details/healpix_utility.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace CosmoTool
|
|||
HealpixSpectrum<T> *new_spectrum = new HealpixSpectrum<T>(in_spec.Lmax());
|
||||
T *out_d = new_spectrum->data();
|
||||
|
||||
std::copy(data, data + min(size,new_spectrum->size()), out_d);
|
||||
std::copy(data, data + std::min(size,new_spectrum->size()), out_d);
|
||||
|
||||
return Spectrum_ptr(new_spectrum);
|
||||
}
|
||||
|
|
2
external/cosmotool/src/fourier/euclidian.hpp
vendored
2
external/cosmotool/src/fourier/euclidian.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/euclidian.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/euclidian.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/fft/fftw_calls.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/fft/fftw_calls.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -37,6 +37,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#define __FFTW_UNIFIED_CALLS_HPP
|
||||
|
||||
#include <fftw3.h>
|
||||
#include <complex>
|
||||
|
||||
namespace CosmoTool
|
||||
{
|
||||
|
@ -68,6 +69,10 @@ public: \
|
|||
static void free(void *p) { fftw_free(p); } \
|
||||
\
|
||||
static void execute(plan_type p) { prefix ## _execute(p); } \
|
||||
static void execute_r2c(plan_type p, real_type *in, complex_type *out) { prefix ## _execute_dft_r2c(p, in, out); } \
|
||||
static void execute_c2r(plan_type p, complex_type *in, real_type *out) { prefix ## _execute_dft_c2r(p, in, out); } \
|
||||
static void execute_r2c(plan_type p, real_type *in, std::complex<real_type> *out) { prefix ## _execute_dft_r2c(p, in, (complex_type*)out); } \
|
||||
static void execute_c2r(plan_type p, std::complex<real_type> *in, real_type *out) { prefix ## _execute_dft_c2r(p, (complex_type*) in, out); } \
|
||||
static plan_type plan_dft_r2c_2d(int Nx, int Ny, \
|
||||
real_type *in, complex_type *out, \
|
||||
unsigned flags) \
|
||||
|
@ -88,6 +93,13 @@ public: \
|
|||
{ \
|
||||
return prefix ## _plan_dft_r2c_3d(Nx, Ny, Nz, in, out, flags); \
|
||||
} \
|
||||
static plan_type plan_dft_c2r_3d(int Nx, int Ny, int Nz, \
|
||||
complex_type *in, real_type *out, \
|
||||
unsigned flags) \
|
||||
{ \
|
||||
return prefix ## _plan_dft_c2r_3d(Nx, Ny, Nz, in, out, flags); \
|
||||
} \
|
||||
\
|
||||
static plan_type plan_dft_r2c(int rank, const int *n, real_type *in, \
|
||||
complex_type *out, unsigned flags) \
|
||||
{ \
|
||||
|
@ -104,7 +116,7 @@ public: \
|
|||
|
||||
FFTW_CALLS_BASE(double, fftw);
|
||||
FFTW_CALLS_BASE(float, fftwf);
|
||||
|
||||
#undef FFTW_CALLS_BASE
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
2
external/cosmotool/src/fourier/healpix.hpp
vendored
2
external/cosmotool/src/fourier/healpix.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/fourier/healpix.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/fourier/healpix.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/growthFactor.cpp
vendored
2
external/cosmotool/src/growthFactor.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/growthFactor.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/growthFactor.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/growthFactor.hpp
vendored
2
external/cosmotool/src/growthFactor.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/growthFactor.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/growthFactor.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
43
external/cosmotool/src/h5_readFlash.cpp
vendored
43
external/cosmotool/src/h5_readFlash.cpp
vendored
|
@ -1,11 +1,45 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/h5_readFlash.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
This software is a computer program whose purpose is to provide a toolbox for cosmological
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
+*/
|
||||
/*+
|
||||
!!
|
||||
|
||||
This file has been developped by P. M. Sutter
|
||||
|
||||
!!
|
||||
|
||||
+*/
|
||||
*/
|
||||
/* This file contains the functions that read the data from the HDF5 file
|
||||
* The functions accept the PARAMESH data through arguments.
|
||||
*/
|
||||
|
@ -178,7 +212,6 @@ void h5_read_runtime_parameters
|
|||
*numPart = *numPart * *numPart * *numPart;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,7 +226,7 @@ void h5_read_flash3_particles (H5File* file,
|
|||
float *vel1,
|
||||
float *vel2,
|
||||
float *vel3,
|
||||
long *id)
|
||||
int64_t *id)
|
||||
{
|
||||
|
||||
herr_t status;
|
||||
|
@ -219,7 +252,6 @@ void h5_read_flash3_particles (H5File* file,
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/* first determine how many particle properties are
|
||||
present in the input data file, and determine which of these
|
||||
are the properties we are interested in */
|
||||
|
@ -349,7 +381,7 @@ void h5_read_flash3_particles (H5File* file,
|
|||
|
||||
if (id) {
|
||||
for(p=0; p < (pcount); p++) {
|
||||
id[p+poffset] = (long) *(partBuffer+iptag-1+p*numProps);
|
||||
id[p+poffset] = (int64_t) *(partBuffer+iptag-1+p*numProps);
|
||||
} }
|
||||
|
||||
if (pos1 && pos2 && pos3) {
|
||||
|
@ -390,7 +422,6 @@ void h5_read_flash3_particles (H5File* file,
|
|||
//status = H5Tclose(datatype);
|
||||
//status = H5Sclose(dataspace);
|
||||
//status = H5Dclose(dataset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
47
external/cosmotool/src/h5_readFlash.hpp
vendored
47
external/cosmotool/src/h5_readFlash.hpp
vendored
|
@ -1,4 +1,38 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/h5_readFlash.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
This software is a computer program whose purpose is to provide a toolbox for cosmological
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
+*/
|
||||
/*+
|
||||
|
||||
!!! NOTE !!!
|
||||
|
||||
|
@ -6,18 +40,19 @@ This file has been developped by P. M. Sutter.
|
|||
|
||||
!!!!
|
||||
|
||||
+*/
|
||||
*/
|
||||
/* This file contains the functions that read the data from the HDF5 file
|
||||
* The functions accept the PARAMESH data through arguments.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
//#include <stddef.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "hdf5_flash.h"
|
||||
#include "H5Cpp.h"
|
||||
#include "hdf5_flash.h"
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace H5;
|
||||
|
||||
|
@ -39,7 +74,7 @@ void h5_read_flash3_particles (H5File* file,
|
|||
float *vel1,
|
||||
float *vel2,
|
||||
float *vel3,
|
||||
long *id);
|
||||
int64_t *id);
|
||||
|
||||
void h5_read_flash3_header_info(H5File* file,
|
||||
double* time, /* simulation time */
|
||||
|
|
33
external/cosmotool/src/hdf5_flash.h
vendored
33
external/cosmotool/src/hdf5_flash.h
vendored
|
@ -1,9 +1,36 @@
|
|||
/*+
|
||||
!!
|
||||
This is CosmoTool (./src/hdf5_flash.h) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
This particular file has been developped by P. M. Sutter
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
!!
|
||||
This software is a computer program whose purpose is to provide a toolbox for cosmological
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
+*/
|
||||
/* general header file for the HDF 5 IO in FLASH */
|
||||
|
||||
|
|
7
external/cosmotool/src/interpolate.cpp
vendored
7
external/cosmotool/src/interpolate.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/interpolate.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/interpolate.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -66,7 +66,6 @@ Interpolate::~Interpolate()
|
|||
}
|
||||
|
||||
double Interpolate::compute(double x)
|
||||
throw (InvalidRangeException)
|
||||
{
|
||||
double y;
|
||||
|
||||
|
@ -85,7 +84,6 @@ double Interpolate::compute(double x)
|
|||
}
|
||||
|
||||
double Interpolate::compute(double x) const
|
||||
throw (InvalidRangeException)
|
||||
{
|
||||
double y;
|
||||
|
||||
|
@ -107,7 +105,6 @@ double Interpolate::compute(double x) const
|
|||
|
||||
|
||||
double Interpolate::derivative(double x)
|
||||
throw (InvalidRangeException)
|
||||
{
|
||||
double y, dy, x0 = x;
|
||||
|
||||
|
@ -199,7 +196,6 @@ Interpolate CosmoTool::buildFromVector(const InterpolatePairs& v)
|
|||
}
|
||||
|
||||
Interpolate CosmoTool::buildInterpolateFromFile(const char *fname)
|
||||
throw (NoSuchFileException)
|
||||
{
|
||||
vector<MyPair> allData;
|
||||
ifstream f(fname);
|
||||
|
@ -239,7 +235,6 @@ Interpolate CosmoTool::buildInterpolateFromFile(const char *fname)
|
|||
|
||||
Interpolate CosmoTool::buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx,
|
||||
bool logy)
|
||||
throw (NoSuchFileException,InvalidRangeException)
|
||||
{
|
||||
vector<MyPair> allData;
|
||||
ifstream f(fname);
|
||||
|
|
17
external/cosmotool/src/interpolate.hpp
vendored
17
external/cosmotool/src/interpolate.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/interpolate.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/interpolate.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -54,12 +54,9 @@ namespace CosmoTool
|
|||
bool logx = false, bool logy = false);
|
||||
~Interpolate();
|
||||
|
||||
double compute(double x)
|
||||
throw (InvalidRangeException);
|
||||
double compute(double x) const
|
||||
throw (InvalidRangeException);
|
||||
double derivative(double x)
|
||||
throw (InvalidRangeException);
|
||||
double compute(double x);
|
||||
double compute(double x) const;
|
||||
double derivative(double x);
|
||||
|
||||
const Interpolate& operator=(const Interpolate& a);
|
||||
|
||||
|
@ -77,10 +74,8 @@ namespace CosmoTool
|
|||
|
||||
typedef std::vector< std::pair<double,double> > InterpolatePairs;
|
||||
|
||||
Interpolate buildInterpolateFromFile(const char *fname)
|
||||
throw (NoSuchFileException);
|
||||
Interpolate buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx = false, bool logy = false)
|
||||
throw (NoSuchFileException,InvalidRangeException);
|
||||
Interpolate buildInterpolateFromFile(const char *fname);
|
||||
Interpolate buildInterpolateFromColumns(const char *fname, uint32_t col1, uint32_t col2, bool logx = false, bool logy = false);
|
||||
Interpolate buildFromVector(const InterpolatePairs& v);
|
||||
|
||||
|
||||
|
|
8
external/cosmotool/src/interpolate3d.hpp
vendored
8
external/cosmotool/src/interpolate3d.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/interpolate3d.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/interpolate3d.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -135,6 +135,12 @@ namespace CosmoTool
|
|||
int Nx, Ny, Nz;
|
||||
};
|
||||
|
||||
|
||||
template<typename IType, typename ArrayType>
|
||||
void singleInterpolation(IType *input_array, ArrayType *x, ArrayType *y, ArrayType *z, ArrayType *scalers)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
2
external/cosmotool/src/kdtree_leaf.hpp
vendored
2
external/cosmotool/src/kdtree_leaf.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/kdtree_leaf.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/kdtree_leaf.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
14
external/cosmotool/src/kdtree_splitters.hpp
vendored
14
external/cosmotool/src/kdtree_splitters.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/kdtree_splitters.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/kdtree_splitters.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -48,17 +48,17 @@ namespace CosmoTool
|
|||
typedef typename KDDef<N,CType>::CoordType ctype;
|
||||
|
||||
|
||||
void check_splitting(KDCell<N,ValType,CType> **cells, uint32_t Ncells, int axis, uint32_t split_index, ctype midCoord)
|
||||
void check_splitting(KDCell<N,ValType,CType> **cells, NodeIntType Ncells, int axis, NodeIntType split_index, ctype midCoord)
|
||||
{
|
||||
ctype delta = std::numeric_limits<ctype>::max();
|
||||
assert(split_index < Ncells);
|
||||
assert(axis < N);
|
||||
for (uint32_t i = 0; i < split_index; i++)
|
||||
for (NodeIntType i = 0; i < split_index; i++)
|
||||
{
|
||||
assert(cells[i]->coord[axis] <= midCoord);
|
||||
delta = min(midCoord-cells[i]->coord[axis], delta);
|
||||
}
|
||||
for (uint32_t i = split_index+1; i < Ncells; i++)
|
||||
for (NodeIntType i = split_index+1; i < Ncells; i++)
|
||||
{
|
||||
assert(cells[i]->coord[axis] > midCoord);
|
||||
delta = min(cells[i]->coord[axis]-midCoord, delta);
|
||||
|
@ -67,7 +67,7 @@ namespace CosmoTool
|
|||
assert (std::abs(cells[split_index]->coord[axis]-midCoord) <= delta);
|
||||
}
|
||||
|
||||
void operator()(KDCell<N,ValType,CType> **cells, uint32_t Ncells, uint32_t& split_index, int axis, coords minBound, coords maxBound)
|
||||
void operator()(KDCell<N,ValType,CType> **cells, NodeIntType Ncells, NodeIntType& split_index, int axis, coords minBound, coords maxBound)
|
||||
{
|
||||
if (Ncells == 1)
|
||||
{
|
||||
|
@ -76,9 +76,9 @@ namespace CosmoTool
|
|||
}
|
||||
|
||||
ctype midCoord = 0.5*(maxBound[axis]+minBound[axis]);
|
||||
uint32_t below = 0, above = Ncells-1;
|
||||
NodeIntType below = 0, above = Ncells-1;
|
||||
ctype delta_min = std::numeric_limits<ctype>::max();
|
||||
uint32_t idx_min = std::numeric_limits<uint32_t>::max();
|
||||
NodeIntType idx_min = std::numeric_limits<NodeIntType>::max();
|
||||
|
||||
while (below < above)
|
||||
{
|
||||
|
|
4
external/cosmotool/src/loadFlash.cpp
vendored
4
external/cosmotool/src/loadFlash.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/loadFlash.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/loadFlash.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -106,7 +106,7 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags)
|
|||
} }
|
||||
|
||||
if (loadflags & NEED_GADGET_ID) {
|
||||
data->Id = new long[data->NumPart];
|
||||
data->Id = new int64_t[data->NumPart];
|
||||
if (data->Id == 0) {
|
||||
delete data;
|
||||
return 0;
|
||||
|
|
2
external/cosmotool/src/loadFlash.hpp
vendored
2
external/cosmotool/src/loadFlash.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/loadFlash.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/loadFlash.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/loadFlash_dummy.cpp
vendored
2
external/cosmotool/src/loadFlash_dummy.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/loadFlash_dummy.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/loadFlash_dummy.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
23
external/cosmotool/src/loadGadget.cpp
vendored
23
external/cosmotool/src/loadGadget.cpp
vendored
|
@ -146,14 +146,14 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
if (GadgetFormat == 2) {
|
||||
int64_t startBlock = 0;
|
||||
char block[5];
|
||||
int32_t blocksize;
|
||||
uint32_t blocksize;
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
f->beginCheckpoint();
|
||||
f->readOrderedBuffer(block, 4);
|
||||
block[4] = 0;
|
||||
blocksize = f->readInt32();
|
||||
blocksize = f->readUint32();
|
||||
f->endCheckpoint();
|
||||
blockTable[block].position = f->position();
|
||||
blockTable[block].size = blocksize;
|
||||
|
@ -172,9 +172,9 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
|
||||
ssize_t NumPart = 0, NumPartTotal = 0;
|
||||
#define ENSURE2(name,out_sz) { \
|
||||
int64_t sz; \
|
||||
if (GadgetFormat == 2) { \
|
||||
BlockMap::iterator iter = blockTable.find(name); \
|
||||
int64_t sz; \
|
||||
if (iter == blockTable.end()) { \
|
||||
std::cerr << "GADGET2: Cannot find block named '" << name << "'" << endl; \
|
||||
if (data) delete data; \
|
||||
|
@ -184,7 +184,14 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
f->seek(iter->second.position); \
|
||||
sz = iter->second.size; \
|
||||
out_sz = sz;\
|
||||
} else if (GadgetFormat==1) { \
|
||||
int64_t oldpos = f->position(); \
|
||||
f->beginCheckpoint(); \
|
||||
out_sz = f->getBlockSize(); \
|
||||
f->endCheckpoint(true); \
|
||||
f->seek(oldpos); \
|
||||
} \
|
||||
\
|
||||
}
|
||||
#define ENSURE(name) ENSURE2(name,sz);
|
||||
|
||||
|
@ -241,7 +248,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
try
|
||||
{
|
||||
ENSURE("POS ");
|
||||
f->beginCheckpoint();
|
||||
f->beginCheckpoint(true); // Use more memory but faster I/O
|
||||
if (f->getBlockSize() != NumPart*float_size*3) {
|
||||
// Check that single would work
|
||||
if (f->getBlockSize() == NumPart*sizeof(float)*3) {
|
||||
|
@ -292,7 +299,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
try
|
||||
{
|
||||
ENSURE("VEL ");
|
||||
f->beginCheckpoint();
|
||||
f->beginCheckpoint(true);
|
||||
for(int k = 0, p = 0; k < 6; k++) {
|
||||
for(int n = 0; n < h.npart[k]; n++) {
|
||||
// THIS IS GADGET 1
|
||||
|
@ -336,8 +343,8 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
throw InvalidUnformattedAccess();
|
||||
}
|
||||
|
||||
f->beginCheckpoint();
|
||||
data->Id = new long[data->NumPart];
|
||||
f->beginCheckpoint(true);
|
||||
data->Id = new int64_t[data->NumPart];
|
||||
if (data->Id == 0)
|
||||
{
|
||||
delete f;
|
||||
|
@ -395,7 +402,7 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||
} else {
|
||||
for(int n = 0; n < h.npart[k]; n++)
|
||||
{
|
||||
if ((n%1000000)==0) cout << n << endl;
|
||||
// if ((n%1000000)==0) cout << n << endl;
|
||||
data->Mass[l++] = h.mass[k];
|
||||
}
|
||||
}
|
||||
|
|
20
external/cosmotool/src/loadRamses.cpp
vendored
20
external/cosmotool/src/loadRamses.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/loadRamses.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/loadRamses.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -34,7 +34,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
+*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include "/usr/include/regex.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
@ -252,7 +252,7 @@ int readInfoFile(const char *basename, int outputId, InfoData& info)
|
|||
const char *pattern = "^([A-Za-z_]+)[ ]*=[ ]*([0-9\\.E+\\-]+)";
|
||||
|
||||
err = regcomp (&unit_l_rx, pattern, REG_EXTENDED);
|
||||
cout << unit_l_rx.re_nsub << endl;
|
||||
// cout << unit_l_rx.re_nsub << endl;
|
||||
if (err)
|
||||
{
|
||||
char errString[255];
|
||||
|
@ -309,7 +309,7 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
|
||||
double hubble = info.aexp*info.aexp/info.unit_t / (1e5/CM_IN_MPC);
|
||||
double L0 = info.boxSize*info.unitLength*hubble/100/CM_IN_MPC/info.aexp;
|
||||
double unit_vel = L0*hubble/info.aexp;
|
||||
double unit_vel = L0*100/info.aexp;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -417,9 +417,12 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
data->Vel[1] = new float[nPar];
|
||||
data->Vel[2] = new float[nPar];
|
||||
}
|
||||
if (flags & NEED_MASS) {
|
||||
data->Mass = new float[nPar];
|
||||
}
|
||||
if (flags & NEED_GADGET_ID)
|
||||
{
|
||||
data->Id = new long[nPar];
|
||||
data->Id = new int64_t[nPar];
|
||||
}
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
|
@ -455,9 +458,10 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
|
||||
float minMass = INFINITY;
|
||||
infile.beginCheckpoint();
|
||||
for (uint32_t i = nPar; i > 0; i--)
|
||||
{
|
||||
for (uint32_t i = 0; i < nPar; i++) {
|
||||
float dummyF = dp ? infile.readReal64() : infile.readReal32();
|
||||
if (flags & NEED_MASS)
|
||||
data->Mass[i] = dummyF;
|
||||
if (dummyF < minMass) minMass = dummyF;
|
||||
}
|
||||
infile.endCheckpoint();
|
||||
|
@ -477,7 +481,7 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
|
|||
}
|
||||
catch (const NoSuchFileException& e)
|
||||
{
|
||||
cerr << "No such file " << fname << endl;
|
||||
// cerr << "No such file " << fname << endl;
|
||||
delete data;
|
||||
return 0;
|
||||
}
|
||||
|
|
2
external/cosmotool/src/loadRamses.hpp
vendored
2
external/cosmotool/src/loadRamses.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/loadRamses.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/loadRamses.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/loadSimu.hpp
vendored
2
external/cosmotool/src/loadSimu.hpp
vendored
|
@ -78,7 +78,7 @@ namespace CosmoTool
|
|||
|
||||
ssize_t NumPart;
|
||||
ssize_t TotalNumPart;
|
||||
long *Id;
|
||||
int64_t *Id;
|
||||
float *Pos[3];
|
||||
float *Vel[3];
|
||||
float *Mass;
|
||||
|
|
4
external/cosmotool/src/load_data.cpp
vendored
4
external/cosmotool/src/load_data.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/load_data.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/load_data.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -41,7 +41,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
using namespace CosmoTool;
|
||||
|
||||
//#define LARGE_CONTROL
|
||||
#define LITTLE_ENDIAN
|
||||
//#define LITTLE_ENDIAN
|
||||
|
||||
#define NEW(t,n) ((t *)malloc(sizeof(t)*n))
|
||||
#define SKIP(f) fread(&dummy,sizeof(dummy),1,f);
|
||||
|
|
2
external/cosmotool/src/mach.hpp
vendored
2
external/cosmotool/src/mach.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/mach.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/mach.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/miniargs.cpp
vendored
2
external/cosmotool/src/miniargs.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/miniargs.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/miniargs.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/miniargs.hpp
vendored
2
external/cosmotool/src/miniargs.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/miniargs.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/miniargs.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
44
external/cosmotool/src/mykdtree.hpp
vendored
44
external/cosmotool/src/mykdtree.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/mykdtree.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/mykdtree.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -40,8 +40,14 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#include "config.hpp"
|
||||
#include "bqueue.hpp"
|
||||
|
||||
#ifndef __KD_TREE_ACTIVE_CELLS
|
||||
#define __KD_TREE_ACTIVE_CELLS 1
|
||||
#endif
|
||||
|
||||
namespace CosmoTool {
|
||||
|
||||
typedef uint64_t NodeIntType;
|
||||
|
||||
template<int N, typename CType = ComputePrecision>
|
||||
struct KDDef
|
||||
{
|
||||
|
@ -52,7 +58,9 @@ namespace CosmoTool {
|
|||
template<int N, typename ValType, typename CType = ComputePrecision>
|
||||
struct KDCell
|
||||
{
|
||||
#if __KD_TREE_ACTIVE_CELLS == 1
|
||||
bool active;
|
||||
#endif
|
||||
ValType val;
|
||||
typename KDDef<N,CType>::KDCoordinates coord;
|
||||
};
|
||||
|
@ -78,7 +86,7 @@ namespace CosmoTool {
|
|||
KDTreeNode<N,ValType,CType> *children[2];
|
||||
typename KDDef<N,CType>::KDCoordinates minBound, maxBound;
|
||||
#ifdef __KD_TREE_NUMNODES
|
||||
uint32_t numNodes;
|
||||
NodeIntType numNodes;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -116,7 +124,7 @@ namespace CosmoTool {
|
|||
template<int N, typename ValType, typename CType = ComputePrecision>
|
||||
struct KD_default_cell_splitter
|
||||
{
|
||||
void operator()(KDCell<N,ValType,CType> **cells, uint32_t Ncells, uint32_t& split_index, int axis, typename KDDef<N,CType>::KDCoordinates minBound, typename KDDef<N,CType>::KDCoordinates maxBound);
|
||||
void operator()(KDCell<N,ValType,CType> **cells, NodeIntType Ncells, NodeIntType& split_index, int axis, typename KDDef<N,CType>::KDCoordinates minBound, typename KDDef<N,CType>::KDCoordinates maxBound);
|
||||
};
|
||||
|
||||
template<int N, typename ValType, typename CType = ComputePrecision, typename CellSplitter = KD_default_cell_splitter<N,ValType,CType> >
|
||||
|
@ -130,7 +138,7 @@ namespace CosmoTool {
|
|||
|
||||
CellSplitter splitter;
|
||||
|
||||
KDTree(Cell *cells, uint32_t Ncells);
|
||||
KDTree(Cell *cells, NodeIntType Ncells);
|
||||
~KDTree();
|
||||
|
||||
void setPeriodic(bool on, CoordType replicate)
|
||||
|
@ -147,13 +155,11 @@ namespace CosmoTool {
|
|||
|
||||
uint32_t getIntersection(const coords& x, CoordType r,
|
||||
Cell **cells,
|
||||
uint32_t numCells)
|
||||
throw (NotEnoughCells);
|
||||
uint32_t numCells);
|
||||
uint32_t getIntersection(const coords& x, CoordType r,
|
||||
Cell **cells,
|
||||
CoordType *distances,
|
||||
uint32_t numCells)
|
||||
throw (NotEnoughCells);
|
||||
uint32_t numCells);
|
||||
uint32_t countCells(const coords& x, CoordType r);
|
||||
|
||||
Cell *getNearestNeighbour(const coords& x);
|
||||
|
@ -169,14 +175,14 @@ namespace CosmoTool {
|
|||
void optimize();
|
||||
|
||||
Node *getAllNodes() { return nodes; }
|
||||
uint32_t getNumNodes() const { return lastNode; }
|
||||
NodeIntType getNumNodes() const { return lastNode; }
|
||||
|
||||
uint32_t countActives() const;
|
||||
NodeIntType countActives() const;
|
||||
|
||||
#ifdef __KD_TREE_NUMNODES
|
||||
uint32_t getNumberInNode(const Node *n) const { return n->numNodes; }
|
||||
NodeIntType getNumberInNode(const Node *n) const { return n->numNodes; }
|
||||
#else
|
||||
uint32_t getNumberInNode(const Node *n) const {
|
||||
NodeIntType getNumberInNode(const Node *n) const {
|
||||
if (n == 0)
|
||||
return 0;
|
||||
return 1+getNumberInNode(n->children[0])+getNumberInNode(n->children[1]);
|
||||
|
@ -184,15 +190,14 @@ namespace CosmoTool {
|
|||
#endif
|
||||
|
||||
#ifdef __KD_TREE_SAVE_ON_DISK
|
||||
KDTree(std::istream& i, Cell *cells, uint32_t Ncells)
|
||||
throw (InvalidOnDiskKDTree);
|
||||
KDTree(std::istream& i, Cell *cells, NodeIntType Ncells);
|
||||
|
||||
void saveTree(std::ostream& o) const;
|
||||
#endif
|
||||
protected:
|
||||
Node *nodes;
|
||||
uint32_t numNodes;
|
||||
uint32_t lastNode;
|
||||
NodeIntType numNodes;
|
||||
NodeIntType lastNode;
|
||||
|
||||
Node *root;
|
||||
Cell **sortingHelper;
|
||||
|
@ -202,7 +207,7 @@ namespace CosmoTool {
|
|||
coords replicate;
|
||||
|
||||
Node *buildTree(Cell **cell0,
|
||||
uint32_t NumCells,
|
||||
NodeIntType NumCells,
|
||||
uint32_t depth,
|
||||
coords minBound,
|
||||
coords maxBound);
|
||||
|
@ -210,8 +215,7 @@ namespace CosmoTool {
|
|||
template<bool justCount>
|
||||
void recursiveIntersectionCells(RecursionInfoCells<N,ValType, CType>& info,
|
||||
Node *node,
|
||||
int level)
|
||||
throw (NotEnoughCells);
|
||||
int level);
|
||||
|
||||
CoordType computeDistance(const Cell *cell, const coords& x) const;
|
||||
void recursiveNearest(Node *node,
|
||||
|
@ -225,7 +229,7 @@ namespace CosmoTool {
|
|||
};
|
||||
|
||||
template<int N, typename T, typename CType>
|
||||
uint32_t gatherActiveCells(KDCell<N,T,CType> **cells, uint32_t numCells);
|
||||
NodeIntType gatherActiveCells(KDCell<N,T,CType> **cells, NodeIntType numCells);
|
||||
|
||||
};
|
||||
|
||||
|
|
68
external/cosmotool/src/mykdtree.tcc
vendored
68
external/cosmotool/src/mykdtree.tcc
vendored
|
@ -1,5 +1,6 @@
|
|||
#include "replicateGenerator.hpp"
|
||||
#include <cstring>
|
||||
#include "omptl/omptl_algorithm"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
@ -30,7 +31,7 @@ namespace CosmoTool {
|
|||
}
|
||||
|
||||
template<int N, typename ValType, typename CType, typename CellSplitter>
|
||||
KDTree<N,ValType,CType,CellSplitter>::KDTree(Cell *cells, uint32_t Ncells)
|
||||
KDTree<N,ValType,CType,CellSplitter>::KDTree(Cell *cells, NodeIntType Ncells)
|
||||
{
|
||||
periodic = false;
|
||||
|
||||
|
@ -39,7 +40,7 @@ namespace CosmoTool {
|
|||
nodes = new Node[numNodes];
|
||||
|
||||
sortingHelper = new Cell *[Ncells];
|
||||
for (uint32_t i = 0; i < Ncells; i++)
|
||||
for (NodeIntType i = 0; i < Ncells; i++)
|
||||
sortingHelper[i] = &cells[i];
|
||||
|
||||
optimize();
|
||||
|
@ -51,7 +52,7 @@ namespace CosmoTool {
|
|||
coords absoluteMin, absoluteMax;
|
||||
|
||||
std::cout << "Optimizing the tree..." << std::endl;
|
||||
uint32_t activeCells = gatherActiveCells(sortingHelper, numNodes);
|
||||
NodeIntType activeCells = gatherActiveCells(sortingHelper, numNodes);
|
||||
std::cout << " number of active cells = " << activeCells << std::endl;
|
||||
|
||||
lastNode = 0;
|
||||
|
@ -61,7 +62,7 @@ namespace CosmoTool {
|
|||
absoluteMax[i] = -std::numeric_limits<typeof (absoluteMax[0])>::max();
|
||||
}
|
||||
// Find min and max corner
|
||||
for (uint32_t i = 0; i < activeCells; i++)
|
||||
for (NodeIntType i = 0; i < activeCells; i++)
|
||||
{
|
||||
KDCell<N,ValType,CType> *cell = sortingHelper[i];
|
||||
|
||||
|
@ -82,7 +83,6 @@ namespace CosmoTool {
|
|||
uint32_t KDTree<N,ValType,CType,CellSplitter>::getIntersection(const coords& x, CoordType r,
|
||||
KDTree<N,ValType,CType,CellSplitter>::Cell **cells,
|
||||
uint32_t numCells)
|
||||
throw (NotEnoughCells)
|
||||
{
|
||||
RecursionInfoCells<N,ValType,CType> info;
|
||||
|
||||
|
@ -116,7 +116,6 @@ namespace CosmoTool {
|
|||
Cell **cells,
|
||||
CoordType *distances,
|
||||
uint32_t numCells)
|
||||
throw (NotEnoughCells)
|
||||
{
|
||||
RecursionInfoCells<N,ValType> info;
|
||||
|
||||
|
@ -179,12 +178,13 @@ namespace CosmoTool {
|
|||
void KDTree<N,ValType,CType,CellSplitter>::recursiveIntersectionCells(RecursionInfoCells<N,ValType,CType>& info,
|
||||
Node *node,
|
||||
int level)
|
||||
throw (NotEnoughCells)
|
||||
{
|
||||
int axis = level % N;
|
||||
CoordType d2 = 0;
|
||||
|
||||
#if __KD_TREE_ACTIVE_CELLS == 1
|
||||
if (node->value->active)
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -223,12 +223,13 @@ namespace CosmoTool {
|
|||
}
|
||||
|
||||
template<int N, typename ValType, typename CType>
|
||||
uint32_t gatherActiveCells(KDCell<N,ValType,CType> **cells,
|
||||
uint32_t Ncells)
|
||||
NodeIntType gatherActiveCells(KDCell<N,ValType,CType> **cells,
|
||||
NodeIntType Ncells)
|
||||
{
|
||||
uint32_t swapId = Ncells-1;
|
||||
uint32_t i = 0;
|
||||
NodeIntType swapId = Ncells-1;
|
||||
NodeIntType i = 0;
|
||||
|
||||
#if __KD_TREE_ACTIVE_CELLS == 1
|
||||
while (!cells[swapId]->active && swapId > 0)
|
||||
swapId--;
|
||||
|
||||
|
@ -244,21 +245,25 @@ namespace CosmoTool {
|
|||
}
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
return swapId+1;
|
||||
}
|
||||
|
||||
template<int N, typename ValType, typename CType>
|
||||
void KD_default_cell_splitter<N,ValType,CType>::operator()(KDCell<N,ValType,CType> **cells, uint32_t Ncells, uint32_t& split_index, int axis, typename KDDef<N,CType>::KDCoordinates minBound, typename KDDef<N,CType>::KDCoordinates maxBound)
|
||||
void KD_default_cell_splitter<N,ValType,CType>::operator()(KDCell<N,ValType,CType> **cells, NodeIntType Ncells,
|
||||
NodeIntType& split_index, int axis,
|
||||
typename KDDef<N,CType>::KDCoordinates minBound,
|
||||
typename KDDef<N,CType>::KDCoordinates maxBound)
|
||||
{
|
||||
CellCompare<N,ValType,CType> compare(axis);
|
||||
std::sort(cells, cells+Ncells, compare);
|
||||
omptl::sort(cells,cells+Ncells,compare); // std::sort(cells, cells+Ncells, compare);
|
||||
split_index = Ncells/2;
|
||||
}
|
||||
|
||||
|
||||
template<int N, typename ValType, typename CType, typename CellSplitter>
|
||||
KDTreeNode<N,ValType,CType> *KDTree<N,ValType,CType,CellSplitter>::buildTree(Cell **cell0,
|
||||
uint32_t Ncells,
|
||||
NodeIntType Ncells,
|
||||
uint32_t depth,
|
||||
coords minBound,
|
||||
coords maxBound)
|
||||
|
@ -266,10 +271,16 @@ namespace CosmoTool {
|
|||
if (Ncells == 0)
|
||||
return 0;
|
||||
|
||||
Node *node;
|
||||
int axis = depth % N;
|
||||
Node *node = &nodes[lastNode++];
|
||||
uint32_t mid;
|
||||
NodeIntType mid;
|
||||
coords tmpBound;
|
||||
NodeIntType nodeId;
|
||||
|
||||
#pragma omp atomic capture
|
||||
nodeId = (this->lastNode)++;
|
||||
|
||||
node = &nodes[nodeId];
|
||||
|
||||
// Isolate the environment
|
||||
splitter(cell0, Ncells, mid, axis, minBound, maxBound);
|
||||
|
@ -282,12 +293,20 @@ namespace CosmoTool {
|
|||
tmpBound[axis] = node->value->coord[axis];
|
||||
|
||||
depth++;
|
||||
node->children[0] = buildTree(cell0, mid, depth, minBound, tmpBound);
|
||||
#pragma omp task private(tmpBound)
|
||||
{
|
||||
node->children[0] = buildTree(cell0, mid, depth, minBound, tmpBound);
|
||||
}
|
||||
|
||||
memcpy(tmpBound, minBound, sizeof(coords));
|
||||
tmpBound[axis] = node->value->coord[axis];
|
||||
node->children[1] = buildTree(cell0+mid+1, Ncells-mid-1, depth,
|
||||
#pragma omp task private(tmpBound)
|
||||
{
|
||||
node->children[1] = buildTree(cell0+mid+1, Ncells-mid-1, depth,
|
||||
tmpBound, maxBound);
|
||||
}
|
||||
|
||||
#pragma omp taskwait
|
||||
|
||||
#ifdef __KD_TREE_NUMNODES
|
||||
node->numNodes = (node->children[0] != 0) ? node->children[0]->numNodes : 0;
|
||||
|
@ -299,12 +318,14 @@ namespace CosmoTool {
|
|||
}
|
||||
|
||||
template<int N, typename ValType, typename CType, typename CellSplitter>
|
||||
uint32_t KDTree<N,ValType,CType,CellSplitter>::countActives() const
|
||||
NodeIntType KDTree<N,ValType,CType,CellSplitter>::countActives() const
|
||||
{
|
||||
uint32_t numActive = 0;
|
||||
for (uint32_t i = 0; i < lastNode; i++)
|
||||
NodeIntType numActive = 0;
|
||||
for (NodeIntType i = 0; i < lastNode; i++)
|
||||
{
|
||||
#if __KD_TREE_ACTIVE_CELLS == 1
|
||||
if (nodes[i].value->active)
|
||||
#endif
|
||||
numActive++;
|
||||
}
|
||||
return numActive;
|
||||
|
@ -586,8 +607,7 @@ namespace CosmoTool {
|
|||
}
|
||||
|
||||
template<int N, typename ValType, typename CType, typename CellSplitter>
|
||||
KDTree<N,ValType,CType,CellSplitter>::KDTree(std::istream& in, Cell *cells, uint32_t Ncells)
|
||||
throw (InvalidOnDiskKDTree)
|
||||
KDTree<N,ValType,CType,CellSplitter>::KDTree(std::istream& in, Cell *cells, NodeIntType Ncells)
|
||||
{
|
||||
KDTreeHeader h;
|
||||
|
||||
|
@ -665,7 +685,7 @@ namespace CosmoTool {
|
|||
root = &nodes[h.rootId];
|
||||
|
||||
sortingHelper = new Cell *[Ncells];
|
||||
for (uint32_t i = 0; i < Ncells; i++)
|
||||
for (NodeIntType i = 0; i < Ncells; i++)
|
||||
sortingHelper[i] = &cells[i];
|
||||
}
|
||||
#endif
|
||||
|
|
2
external/cosmotool/src/newton.hpp
vendored
2
external/cosmotool/src/newton.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/newton.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/newton.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
210
external/cosmotool/src/octTree.cpp
vendored
210
external/cosmotool/src/octTree.cpp
vendored
|
@ -1,210 +0,0 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/octTree.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
This software is a computer program whose purpose is to provide a toolbox for cosmological
|
||||
data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited
|
||||
liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
+*/
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include "config.hpp"
|
||||
#include "octTree.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace CosmoTool;
|
||||
|
||||
//#define VERBOSE
|
||||
|
||||
static uint32_t mypow(uint32_t i, uint32_t p)
|
||||
{
|
||||
if (p == 0)
|
||||
return 1;
|
||||
else if (p == 1)
|
||||
return i;
|
||||
|
||||
uint32_t k = p/2;
|
||||
uint32_t j = mypow(i, k);
|
||||
if (2*k==p)
|
||||
return j*j;
|
||||
else
|
||||
return j*j*i;
|
||||
}
|
||||
|
||||
OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
|
||||
uint32_t maxMeanTreeDepth, uint32_t maxAbsoluteDepth,
|
||||
uint32_t threshold)
|
||||
{
|
||||
cout << "MeanTree=" << maxMeanTreeDepth << endl;
|
||||
numCells = mypow(8, maxMeanTreeDepth);
|
||||
assert(numCells < invalidOctCell);
|
||||
//#ifdef VERBOSE
|
||||
cerr << "Allocating " << numCells << " octtree cells" << endl;
|
||||
//#endif
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
xMin[j] = particles[0][j];
|
||||
|
||||
for (octPtr i = 1; i < numParticles; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
if (particles[i][j] < xMin[j])
|
||||
xMin[j] = particles[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
lenNorm = 0;
|
||||
for (octPtr i = 0; i < numParticles; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
float delta = particles[i][j]-xMin[j];
|
||||
if (delta > lenNorm)
|
||||
lenNorm = delta;
|
||||
}
|
||||
}
|
||||
cout << xMin[0] << " " << xMin[1] << " " << xMin[2] << " lNorm=" << lenNorm << endl;
|
||||
|
||||
cells = new OctCell[numCells];
|
||||
Lbox = (float)(octCoordTypeNorm+1);
|
||||
|
||||
cells[0].numberLeaves = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
cells[0].children[i] = emptyOctCell;
|
||||
|
||||
lastNode = 1;
|
||||
this->particles = particles;
|
||||
this->numParticles = numParticles;
|
||||
buildTree(maxAbsoluteDepth);
|
||||
//#ifdef VERBOSE
|
||||
cerr << "Used " << lastNode << " cells" << endl;
|
||||
//#endif
|
||||
}
|
||||
|
||||
OctTree::~OctTree()
|
||||
{
|
||||
delete cells;
|
||||
}
|
||||
|
||||
void OctTree::buildTree(uint32_t maxAbsoluteDepth)
|
||||
{
|
||||
for (octPtr i = 0; i < numParticles; i++)
|
||||
{
|
||||
OctCoords rootCenter = { octCoordCenter, octCoordCenter, octCoordCenter };
|
||||
insertParticle(0, // root node
|
||||
rootCenter,
|
||||
octCoordCenter,
|
||||
i,
|
||||
maxAbsoluteDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OctTree::insertParticle(octPtr node,
|
||||
const OctCoords& icoord,
|
||||
octCoordType halfNodeLength,
|
||||
octPtr particleId,
|
||||
uint32_t maxAbsoluteDepth)
|
||||
{
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Entering " << node << " (" << icoord[0] << "," << icoord[1] << "," << icoord[2] << ")" << endl;
|
||||
#endif
|
||||
int octPos = 0;
|
||||
int ipos[3] = { 0,0,0};
|
||||
octPtr newNode;
|
||||
OctCoords newCoord;
|
||||
|
||||
cells[node].numberLeaves++;
|
||||
if (maxAbsoluteDepth == 0)
|
||||
{
|
||||
// All children must be invalid.
|
||||
for (int i = 0 ; i < 8; i++)
|
||||
cells[node].children[i] = invalidOctCell;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
float treePos = (particles[particleId][j]-xMin[j])*Lbox/lenNorm;
|
||||
if ((octPtr)(treePos) > icoord[j])
|
||||
{
|
||||
octPos |= (1 << j);
|
||||
ipos[j] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (cells[node].children[octPos] == emptyOctCell)
|
||||
{
|
||||
// Put the particle there.
|
||||
cells[node].children[octPos] = particleId | octParticleMarker;
|
||||
return;
|
||||
}
|
||||
|
||||
// If it is a node, explores it.
|
||||
if (!(cells[node].children[octPos] & octParticleMarker))
|
||||
{
|
||||
assert(halfNodeLength >= 2);
|
||||
// Compute coordinates
|
||||
for (int j = 0; j < 3; j++)
|
||||
newCoord[j] = icoord[j]+(2*ipos[j]-1)*halfNodeLength/2;
|
||||
insertParticle(cells[node].children[octPos], newCoord, halfNodeLength/2,
|
||||
particleId, maxAbsoluteDepth-1);
|
||||
return;
|
||||
}
|
||||
|
||||
// We have a particle there.
|
||||
// Make a new node and insert the old particle into this node.
|
||||
// Insert the new particle into the node also
|
||||
// Finally put the node in place
|
||||
|
||||
newNode = lastNode++;
|
||||
assert(lastNode != numCells);
|
||||
|
||||
for (int j = 0; j < 8; j++)
|
||||
cells[newNode].children[j] = emptyOctCell;
|
||||
cells[newNode].numberLeaves = 0;
|
||||
|
||||
// Compute coordinates
|
||||
for (int j = 0; j < 3; j++)
|
||||
newCoord[j] = icoord[j]+(2*ipos[j]-1)*halfNodeLength/2;
|
||||
|
||||
octPtr oldPartId = cells[node].children[octPos] & octParticleMask;
|
||||
|
||||
insertParticle(newNode, newCoord, halfNodeLength/2,
|
||||
oldPartId, maxAbsoluteDepth-1);
|
||||
insertParticle(newNode, newCoord, halfNodeLength/2,
|
||||
particleId, maxAbsoluteDepth-1);
|
||||
cells[node].children[octPos] = newNode;
|
||||
}
|
||||
|
77
external/cosmotool/src/octTree.hpp
vendored
77
external/cosmotool/src/octTree.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/octTree.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/octTree.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -55,12 +55,20 @@ namespace CosmoTool
|
|||
|
||||
typedef octCoordType OctCoords[3];
|
||||
|
||||
template<class T = void>
|
||||
struct OctCell
|
||||
{
|
||||
octPtr numberLeaves;
|
||||
octPtr children[8];
|
||||
T data;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct OctTree_defaultUpdater {
|
||||
void operator()(T& d) { }
|
||||
};
|
||||
|
||||
template<typename T_dataUpdater = OctTree_defaultUpdater<void>, class T = void>
|
||||
class OctTree
|
||||
{
|
||||
public:
|
||||
|
@ -103,9 +111,10 @@ namespace CosmoTool
|
|||
|
||||
|
||||
protected:
|
||||
T_dataUpdater updater;
|
||||
const FCoordinates *particles;
|
||||
octPtr numParticles;
|
||||
OctCell *cells;
|
||||
OctCell<T> *cells;
|
||||
float Lbox;
|
||||
octPtr lastNode;
|
||||
octPtr numCells;
|
||||
|
@ -128,47 +137,47 @@ namespace CosmoTool
|
|||
FCoordinates center, realCenter;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
center[j] = icoord[j]/(2.*octCoordCenter);
|
||||
realCenter[j] = xMin[j] + center[j]*lenNorm;
|
||||
}
|
||||
{
|
||||
center[j] = icoord[j]/(2.*octCoordCenter);
|
||||
realCenter[j] = xMin[j] + center[j]*lenNorm;
|
||||
}
|
||||
|
||||
f(realCenter, cells[node].numberLeaves, lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
||||
false);
|
||||
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
||||
false);
|
||||
|
||||
if (!condition(realCenter, cells[node].numberLeaves,
|
||||
lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||
cells[node].children[0] == invalidOctCell))
|
||||
return;
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
octPtr newNode = cells[node].children[i];
|
||||
int ipos[3] = { (i&1), (i&2)>>1, (i&4)>>2 };
|
||||
|
||||
if (newNode == emptyOctCell || newNode == invalidOctCell)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
newCoord[j] = icoord[j]+(2*ipos[j]-1)*halfNodeLength/2;
|
||||
|
||||
if (newNode & octParticleMarker)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
center[j] = newCoord[j]/(2.*octCoordCenter);
|
||||
realCenter[j] = xMin[j] + lenNorm*center[j];
|
||||
}
|
||||
{
|
||||
octPtr newNode = cells[node].children[i];
|
||||
int ipos[3] = { (i&1), (i&2)>>1, (i&4)>>2 };
|
||||
|
||||
if (newNode == emptyOctCell || newNode == invalidOctCell)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
newCoord[j] = icoord[j]+(2*ipos[j]-1)*halfNodeLength/2;
|
||||
|
||||
if (newNode & octParticleMarker)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
center[j] = newCoord[j]/(2.*octCoordCenter);
|
||||
realCenter[j] = xMin[j] + lenNorm*center[j];
|
||||
}
|
||||
|
||||
f(realCenter,
|
||||
1, lenNorm*halfNodeLength/(2.*octCoordCenter),
|
||||
false, true);
|
||||
continue;
|
||||
}
|
||||
f(realCenter,
|
||||
1, lenNorm*halfNodeLength/(2.*octCoordCenter),
|
||||
false, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
walkTreeElements(f, condition, cells[node].children[i], newCoord, halfNodeLength/2);
|
||||
}
|
||||
walkTreeElements(f, condition, cells[node].children[i], newCoord, halfNodeLength/2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -177,4 +186,6 @@ namespace CosmoTool
|
|||
};
|
||||
|
||||
|
||||
#include "octTree.tcc"
|
||||
|
||||
#endif
|
||||
|
|
2
external/cosmotool/src/pool.hpp
vendored
2
external/cosmotool/src/pool.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/pool.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/pool.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/powerSpectrum.cpp
vendored
2
external/cosmotool/src/powerSpectrum.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/powerSpectrum.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/powerSpectrum.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/powerSpectrum.hpp
vendored
2
external/cosmotool/src/powerSpectrum.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/powerSpectrum.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/powerSpectrum.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/replicateGenerator.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/replicateGenerator.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
2
external/cosmotool/src/sparseGrid.hpp
vendored
2
external/cosmotool/src/sparseGrid.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/sparseGrid.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/sparseGrid.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
|
56
external/cosmotool/src/sphSmooth.hpp
vendored
56
external/cosmotool/src/sphSmooth.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/sphSmooth.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/sphSmooth.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -35,7 +35,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
|
||||
#ifndef __COSMOTOOL_SPH_SMOOTH_HPP
|
||||
#define __COSMOTOOL_SPH_SMOOTH_HPP
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "config.hpp"
|
||||
#include "mykdtree.hpp"
|
||||
|
||||
|
@ -60,37 +60,54 @@ namespace CosmoTool
|
|||
typedef void (*runParticleValue)(ValType& t);
|
||||
|
||||
public:
|
||||
typedef SPHCell *P_SPHCell;
|
||||
struct SPHState
|
||||
{
|
||||
boost::shared_ptr<P_SPHCell[]> ngb;
|
||||
boost::shared_ptr<CoordType[]> distances;
|
||||
typename SPHTree::coords currentCenter;
|
||||
int currentNgb;
|
||||
ComputePrecision smoothRadius;
|
||||
};
|
||||
|
||||
|
||||
SPHSmooth(SPHTree *tree, uint32_t Nsph);
|
||||
virtual ~SPHSmooth();
|
||||
|
||||
void fetchNeighbours(const typename SPHTree::coords& c);
|
||||
void fetchNeighbours(const typename SPHTree::coords& c, SPHState *state = 0);
|
||||
|
||||
void fetchNeighbours(const typename SPHTree::coords& c, uint32_t newNsph);
|
||||
void fetchNeighboursOnVolume(const typename SPHTree::coords& c, ComputePrecision radius);
|
||||
const typename SPHTree::coords& getCurrentCenter() const
|
||||
{
|
||||
return currentCenter;
|
||||
return internal.currentCenter;
|
||||
}
|
||||
|
||||
template<typename FuncT>
|
||||
ComputePrecision computeSmoothedValue(const typename SPHTree::coords& c,
|
||||
computeParticleValue fun);
|
||||
FuncT fun, SPHState *state = 0);
|
||||
|
||||
template<typename FuncT>
|
||||
ComputePrecision computeInterpolatedValue(const typename SPHTree::coords& c,
|
||||
computeParticleValue fun);
|
||||
FuncT fun, SPHState *state = 0);
|
||||
|
||||
ComputePrecision getMaxDistance(const typename SPHTree::coords& c,
|
||||
SPHNode *node) const;
|
||||
|
||||
ComputePrecision getSmoothingLen() const
|
||||
{
|
||||
return smoothRadius;
|
||||
return internal.smoothRadius;
|
||||
}
|
||||
|
||||
// TO USE WITH EXTREME CARE !
|
||||
void setSmoothingLen(ComputePrecision len)
|
||||
{
|
||||
smoothRadius = len;
|
||||
internal.smoothRadius = len;
|
||||
}
|
||||
// END
|
||||
|
||||
void runForEachNeighbour(runParticleValue fun);
|
||||
template<typename FuncT>
|
||||
void runForEachNeighbour(FuncT fun, SPHState *state = 0);
|
||||
void addGridSite(const typename SPHTree::coords& c);
|
||||
|
||||
bool hasNeighbours() const;
|
||||
|
@ -100,34 +117,31 @@ namespace CosmoTool
|
|||
SPHTree *getTree() { return tree; }
|
||||
|
||||
void changeNgb(uint32_t newMax) {
|
||||
delete[] ngb;
|
||||
delete[] distances;
|
||||
ngb = new SPHCell *[newMax];
|
||||
distances = new CoordType[newMax];
|
||||
internal.ngb = boost::shared_ptr<SPHCell *>(new SPHCell *[newMax]);
|
||||
internal.distances = boost::shared_ptr<CoordType>(new CoordType[newMax]);
|
||||
maxNgb = newMax;
|
||||
}
|
||||
|
||||
uint32_t getCurrent() const { return currentNgb; }
|
||||
uint32_t getCurrent() const { return internal.currentNgb; }
|
||||
|
||||
uint32_t getNgb() const { return maxNgb; }
|
||||
|
||||
protected:
|
||||
SPHCell **ngb;
|
||||
CoordType *distances;
|
||||
SPHState internal;
|
||||
uint32_t Nsph;
|
||||
uint32_t deltaNsph;
|
||||
uint32_t maxNgb;
|
||||
uint32_t currentNgb;
|
||||
SPHTree *tree;
|
||||
ComputePrecision smoothRadius;
|
||||
typename SPHTree::coords currentCenter;
|
||||
|
||||
template<typename FuncT>
|
||||
ComputePrecision computeWValue(const typename SPHTree::coords & c,
|
||||
SPHCell& cell,
|
||||
CoordType d,
|
||||
computeParticleValue fun);
|
||||
FuncT fun, SPHState *state);
|
||||
|
||||
template<typename FuncT>
|
||||
void runUnrollNode(SPHNode *node,
|
||||
runParticleValue fun);
|
||||
FuncT fun);
|
||||
};
|
||||
|
||||
template<class ValType1, class ValType2, int Ndims>
|
||||
|
|
125
external/cosmotool/src/sphSmooth.tcc
vendored
125
external/cosmotool/src/sphSmooth.tcc
vendored
|
@ -1,4 +1,5 @@
|
|||
#include <cmath>
|
||||
#include "algo.hpp"
|
||||
|
||||
namespace CosmoTool {
|
||||
|
||||
|
@ -7,29 +8,28 @@ SPHSmooth<ValType,Ndims>::SPHSmooth(SPHTree *tree, uint32_t Nsph)
|
|||
{
|
||||
this->Nsph = Nsph;
|
||||
this->tree = tree;
|
||||
this->currentNgb = 0;
|
||||
internal.currentNgb = 0;
|
||||
|
||||
this->maxNgb = Nsph;
|
||||
ngb = new SPHCell *[maxNgb];
|
||||
distances = new CoordType[maxNgb];
|
||||
internal.ngb = boost::shared_ptr<SPHCell *[]>(new SPHCell *[maxNgb]);
|
||||
internal.distances = boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
SPHSmooth<ValType,Ndims>::~SPHSmooth()
|
||||
{
|
||||
delete[] ngb;
|
||||
delete[] distances;
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
template<typename FuncT>
|
||||
ComputePrecision SPHSmooth<ValType,Ndims>::computeWValue(const typename SPHTree::coords& c,
|
||||
SPHCell& cell,
|
||||
CoordType d,
|
||||
computeParticleValue fun)
|
||||
FuncT fun, SPHState *state)
|
||||
{
|
||||
CoordType weight;
|
||||
|
||||
d /= smoothRadius;
|
||||
d /= state->smoothRadius;
|
||||
weight = getKernel(d);
|
||||
|
||||
if (cell.val.weight != 0)
|
||||
|
@ -47,86 +47,92 @@ SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c, uin
|
|||
|
||||
if (requested > maxNgb)
|
||||
{
|
||||
delete[] ngb;
|
||||
delete[] distances;
|
||||
|
||||
maxNgb = requested;
|
||||
ngb = new SPHCell *[maxNgb];
|
||||
distances = new CoordType[maxNgb];
|
||||
internal.ngb = boost::shared_ptr<P_SPHCell[]>(new P_SPHCell[maxNgb]);
|
||||
internal.distances = boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
|
||||
}
|
||||
|
||||
memcpy(currentCenter, c, sizeof(c));
|
||||
tree->getNearestNeighbours(c, requested, ngb, distances);
|
||||
memcpy(internal.currentCenter, c, sizeof(c));
|
||||
tree->getNearestNeighbours(c, requested, (SPHCell **)internal.ngb.get(), (CoordType*)internal.distances.get());
|
||||
|
||||
currentNgb = 0;
|
||||
for (uint32_t i = 0; i < requested && ngb[i] != 0; i++,currentNgb++)
|
||||
internal.currentNgb = 0;
|
||||
for (uint32_t i = 0; i < requested && (internal.ngb)[i] != 0; i++,internal.currentNgb++)
|
||||
{
|
||||
distances[i] = sqrt(distances[i]);
|
||||
d2 = distances[i];
|
||||
internal.distances[i] = sqrt(internal.distances[i]);
|
||||
d2 = internal.distances[i];
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
}
|
||||
|
||||
smoothRadius = max_dist / 2;
|
||||
internal.smoothRadius = max_dist / 2;
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
void
|
||||
SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c)
|
||||
void SPHSmooth<ValType,Ndims>::fetchNeighbours(const typename SPHTree::coords& c, SPHState *state)
|
||||
{
|
||||
ComputePrecision d2, max_dist = 0;
|
||||
uint32_t requested = Nsph;
|
||||
|
||||
memcpy(currentCenter, c, sizeof(c));
|
||||
tree->getNearestNeighbours(c, requested, ngb, distances);
|
||||
if (state != 0) {
|
||||
state->distances = boost::shared_ptr<CoordType[]>(new CoordType[Nsph]);
|
||||
state->ngb = boost::shared_ptr<SPHCell *[]>(new SPHCell *[Nsph]);
|
||||
} else
|
||||
state = &internal;
|
||||
|
||||
memcpy(state->currentCenter, c, sizeof(c));
|
||||
|
||||
tree->getNearestNeighbours(c, requested, state->ngb.get(), state->distances.get());
|
||||
|
||||
currentNgb = 0;
|
||||
for (uint32_t i = 0; i < requested && ngb[i] != 0; i++,currentNgb++)
|
||||
state->currentNgb = 0;
|
||||
for (uint32_t i = 0; i < requested && state->ngb[i] != 0; i++,state->currentNgb++)
|
||||
{
|
||||
distances[i] = sqrt(distances[i]);
|
||||
d2 = distances[i];
|
||||
d2 = internal.distances[i] = sqrt(internal.distances[i]);
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
max_dist = d2;
|
||||
}
|
||||
|
||||
smoothRadius = max_dist / 2;
|
||||
}
|
||||
state->smoothRadius = max_dist / 2;
|
||||
}
|
||||
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
void
|
||||
SPHSmooth<ValType,Ndims>::fetchNeighboursOnVolume(const typename SPHTree::coords& c,
|
||||
ComputePrecision radius)
|
||||
ComputePrecision radius)
|
||||
{
|
||||
uint32_t numPart;
|
||||
ComputePrecision d2, max_dist = 0;
|
||||
|
||||
memcpy(currentCenter, c, sizeof(c));
|
||||
memcpy(internal.currentCenter, c, sizeof(c));
|
||||
|
||||
currentNgb = tree->getIntersection(c, radius, ngb, distances,
|
||||
internal.currentNgb = tree->getIntersection(c, radius, internal.ngb, internal.distances,
|
||||
maxNgb);
|
||||
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
for (uint32_t i = 0; i < internal.currentNgb; i++)
|
||||
{
|
||||
distances[i] = sqrt(distances[i]);
|
||||
d2 = distances[i];
|
||||
d2 = internal.distances[i] = sqrt(internal.distances[i]);
|
||||
if (d2 > max_dist)
|
||||
max_dist = d2;
|
||||
max_dist = d2;
|
||||
}
|
||||
smoothRadius = max_dist / 2;
|
||||
internal.smoothRadius = max_dist / 2;
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
template<typename FuncT>
|
||||
ComputePrecision
|
||||
SPHSmooth<ValType,Ndims>::computeSmoothedValue(const typename SPHTree::coords& c,
|
||||
computeParticleValue fun)
|
||||
FuncT fun, SPHState *state)
|
||||
{
|
||||
if (state == 0)
|
||||
state = &internal;
|
||||
|
||||
ComputePrecision outputValue = 0;
|
||||
ComputePrecision max_dist = 0;
|
||||
ComputePrecision r3 = smoothRadius * smoothRadius * smoothRadius;
|
||||
ComputePrecision r3 = cube(state->smoothRadius);
|
||||
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
for (uint32_t i = 0; i < state->currentNgb; i++)
|
||||
{
|
||||
outputValue += computeWValue(c, *ngb[i], distances[i], fun);
|
||||
outputValue += computeWValue(c, *state->ngb[i], state->distances[i], fun, state);
|
||||
}
|
||||
|
||||
return outputValue / r3;
|
||||
|
@ -140,28 +146,36 @@ ComputePrecision interpolateOne(const ValType& t)
|
|||
|
||||
// WARNING ! Cell's weight must be 1 !!!
|
||||
template<typename ValType, int Ndims>
|
||||
template<typename FuncT>
|
||||
ComputePrecision SPHSmooth<ValType,Ndims>::computeInterpolatedValue(const typename SPHTree::coords& c,
|
||||
computeParticleValue fun)
|
||||
FuncT fun, SPHState *state)
|
||||
{
|
||||
if (state == 0)
|
||||
state = &internal;
|
||||
|
||||
ComputePrecision outputValue = 0;
|
||||
ComputePrecision max_dist = 0;
|
||||
ComputePrecision weight = 0;
|
||||
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
for (uint32_t i = 0; i < state->currentNgb; i++)
|
||||
{
|
||||
outputValue += computeWValue(c, *ngb[i], distances[i], fun);
|
||||
weight += computeWValue(c, *ngb[i], distances[i], interpolateOne);
|
||||
outputValue += computeWValue(c, *state->ngb[i], state->distances[i], fun);
|
||||
weight += computeWValue(c, *state->ngb[i], state->distances[i], interpolateOne);
|
||||
}
|
||||
|
||||
return (outputValue == 0) ? 0 : (outputValue / weight);
|
||||
}
|
||||
|
||||
template<typename ValType, int Ndims>
|
||||
void SPHSmooth<ValType,Ndims>::runForEachNeighbour(runParticleValue fun)
|
||||
template<typename FuncT>
|
||||
void SPHSmooth<ValType,Ndims>::runForEachNeighbour(FuncT fun, SPHState *state)
|
||||
{
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
if (state == 0)
|
||||
state = &internal;
|
||||
|
||||
for (uint32_t i = 0; i < state->currentNgb; i++)
|
||||
{
|
||||
fun(ngb[i]);
|
||||
fun(state->ngb[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,14 +186,13 @@ void SPHSmooth<ValType,Ndims>::addGridSite(const typename SPHTree::coords& c)
|
|||
ComputePrecision outputValue = 0;
|
||||
ComputePrecision max_dist = 0;
|
||||
|
||||
ComputePrecision r3 = smoothRadius * smoothRadius * smoothRadius;
|
||||
ComputePrecision r3 = cube(internal.smoothRadius);
|
||||
|
||||
for (uint32_t i = 0; i < currentNgb; i++)
|
||||
for (uint32_t i = 0; i < internal.currentNgb; i++)
|
||||
{
|
||||
ComputePrecision d = distances[i];
|
||||
SPHCell& cell = *ngb[i];
|
||||
cell.val.weight += getKernel(d/smoothRadius) / r3;
|
||||
|
||||
ComputePrecision d = internal.distances[i];
|
||||
SPHCell& cell = *(internal.ngb[i]);
|
||||
cell.val.weight += getKernel(d/internal.smoothRadius) / r3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +215,7 @@ SPHSmooth<ValType,Ndims>::getKernel(ComputePrecision x) const
|
|||
template<typename ValType, int Ndims>
|
||||
bool SPHSmooth<ValType,Ndims>::hasNeighbours() const
|
||||
{
|
||||
return (currentNgb != 0);
|
||||
return (internal.currentNgb != 0);
|
||||
}
|
||||
|
||||
template<class ValType1, class ValType2, int Ndims>
|
||||
|
|
4
external/cosmotool/src/yorick.hpp
vendored
4
external/cosmotool/src/yorick.hpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/yorick.hpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/yorick.hpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -218,7 +218,7 @@ namespace CosmoTool
|
|||
|
||||
template<typename T>
|
||||
void saveArray(const std::string& fname,
|
||||
T *array, uint32_t *dimList, uint32_t rank);
|
||||
const T *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
template<typename T>
|
||||
void loadArray(const std::string& fname,
|
||||
|
|
12
external/cosmotool/src/yorick_nc3.cpp
vendored
12
external/cosmotool/src/yorick_nc3.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/yorick_nc3.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/yorick_nc3.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -37,7 +37,7 @@ knowledge of the CeCILL license and that you accept its terms.
|
|||
#include "config.hpp"
|
||||
#ifdef NETCDFCPP4
|
||||
#include <netcdf>
|
||||
using namespace netCDF
|
||||
using namespace netCDF;
|
||||
#else
|
||||
#include <netcdfcpp.h>
|
||||
#endif
|
||||
|
@ -235,7 +235,7 @@ namespace CosmoTool {
|
|||
|
||||
template<typename T>
|
||||
void saveArray(const std::string& fname,
|
||||
T *array, uint32_t *dimList, uint32_t rank)
|
||||
const T *array, uint32_t *dimList, uint32_t rank)
|
||||
{
|
||||
NcFile f(fname.c_str(), NcFile::Replace, 0, 0, NcFile::Netcdf4);
|
||||
|
||||
|
@ -300,10 +300,10 @@ namespace CosmoTool {
|
|||
double*& array, uint32_t *&dimList, uint32_t& rank);
|
||||
|
||||
template void saveArray<int>(const std::string& fname,
|
||||
int *array, uint32_t *dimList, uint32_t rank);
|
||||
const int *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<float>(const std::string& fname,
|
||||
float *array, uint32_t *dimList, uint32_t rank);
|
||||
const float *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<double>(const std::string& fname,
|
||||
double *array, uint32_t *dimList, uint32_t rank);
|
||||
const double *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
}
|
||||
|
|
18
external/cosmotool/src/yorick_nc4.cpp
vendored
18
external/cosmotool/src/yorick_nc4.cpp
vendored
|
@ -1,5 +1,5 @@
|
|||
/*+
|
||||
This is CosmoTool (./src/yorick_nc4.cpp) -- Copyright (C) Guilhem Lavaux (2007-2013)
|
||||
This is CosmoTool (./src/yorick_nc4.cpp) -- Copyright (C) Guilhem Lavaux (2007-2014)
|
||||
|
||||
guilhem.lavaux@gmail.com
|
||||
|
||||
|
@ -131,9 +131,9 @@ public:
|
|||
{
|
||||
if (curPos[i] == dimList[i].getSize())
|
||||
{
|
||||
curPos[i-1]++;
|
||||
curPos[i] = 0;
|
||||
}
|
||||
curPos[i-1]++;
|
||||
curPos[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -174,7 +174,7 @@ namespace CosmoTool {
|
|||
vector<NcDim> ldimList;
|
||||
|
||||
for (uint32_t i = 0; i < rank; i++)
|
||||
ldimList.push_back(dimArray[rank-1-i]);
|
||||
ldimList.push_back(dimArray[i]);
|
||||
|
||||
OutputGenCDF<T> *impl = new OutputGenCDF<T>(f, v, ldimList, rank);
|
||||
return ProgressiveOutput<T>(impl);
|
||||
|
@ -203,7 +203,7 @@ namespace CosmoTool {
|
|||
|
||||
template<typename T>
|
||||
void saveArray(const std::string& fname,
|
||||
T *array, uint32_t *dimList, uint32_t rank)
|
||||
const T *array, uint32_t *dimList, uint32_t rank)
|
||||
{
|
||||
NcFile f(fname.c_str(), NcFile::replace);
|
||||
|
||||
|
@ -263,10 +263,10 @@ namespace CosmoTool {
|
|||
double*& array, uint32_t *&dimList, uint32_t& rank);
|
||||
|
||||
template void saveArray<int>(const std::string& fname,
|
||||
int *array, uint32_t *dimList, uint32_t rank);
|
||||
const int *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<float>(const std::string& fname,
|
||||
float *array, uint32_t *dimList, uint32_t rank);
|
||||
const float *array, uint32_t *dimList, uint32_t rank);
|
||||
template void saveArray<double>(const std::string& fname,
|
||||
double *array, uint32_t *dimList, uint32_t rank);
|
||||
const double *array, uint32_t *dimList, uint32_t rank);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue