Merge branch 'master' of bitbucket.org:glavaux/cosmotool

This commit is contained in:
Guilhem Lavaux 2022-01-27 13:36:25 +01:00
commit 0b77b010e4
11 changed files with 243 additions and 226 deletions

View File

@ -70,8 +70,8 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A toolbox for impatient cosmologists")
SET(CPACK_PACKAGE_VENDOR "Guilhem Lavaux")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE_CeCILL_V2")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "2")
SET(CPACK_PACKAGE_VERSION_PATCH "3${EXTRA_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "0${EXTRA_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_STRIP_FILES "lib/libCosmoTool.so")
SET(CPACK_SOURCE_IGNORE_FILES

View File

@ -1,6 +1,6 @@
package:
name: cosmotool
version: "1.2.3"
version: "1.3.0"
source:
git_rev: a86c9a8

View File

@ -116,8 +116,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cosmotool/config.py.in ${CMAKE_CURREN
INSTALL(TARGETS
${ct_TARGETS}
COMPONENT python
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/cosmotool
)
INSTALL(DIRECTORY cosmotool ${CMAKE_CURRENT_BINARY_DIR}/cosmotool DESTINATION ${PYTHON_SITE_PACKAGES}
INSTALL(DIRECTORY cosmotool ${CMAKE_CURRENT_BINARY_DIR}/cosmotool
COMPONENT python DESTINATION ${PYTHON_SITE_PACKAGES}
FILES_MATCHING PATTERN "*.py")
add_custom_target(
python-install
DEPENDS ${ct_TARGETS}
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=python -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")

View File

@ -247,6 +247,9 @@ class PySimulationAdaptor(PySimulationBase):
def __init__(self,sim):
self.simu = sim
def getNumParticles(self):
return self.simu.numParticles
def getBoxsize(self):
return self.simu.BoxSize

View File

@ -533,12 +533,13 @@ cdef void INTERNAL_project_cic_with_mass_periodic(DTYPE_t[:,:,:] g,
def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, ndim=1] mass, int Ngrid,
double Lbox, bool periodic = False, centered=True):
double Lbox, bool periodic = False, centered=True, output=None):
"""
project_cic(x array (N,3), mass (may be None), Ngrid, Lbox, periodict, centered=True)
project_cic(x array (N,3), mass (may be None), Ngrid, Lbox, periodict, centered=True, output=None)
This function does a Cloud-In-Cell projection of a 3d unstructured dataset. First argument is a Nx3 array of coordinates.
Second argument is an optinal mass. Ngrid is the size output grid and Lbox is the physical size of the grid.
if output is not None, it must be a numpy array with dimension NgridxNgridxNgrid. The result will be accumulated in that array.
"""
cdef npx.ndarray[DTYPE_t, ndim=3] g
cdef double shifter
@ -558,7 +559,13 @@ def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, nd
if mass is not None and mass.shape[0] != x.shape[0]:
raise ValueError("Mass array and coordinate array must have the same number of elements")
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
if output is None:
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
else:
if type(output) != np.ndarray:
raise ValueError("Invalid array type")
g = output
cdef DTYPE_t[:,:,:] d_g = g
cdef DTYPE_t[:,:] d_x = x

View File

@ -108,7 +108,7 @@ int main(int argc, char **argv)
H5::H5File in_f(fname1, 0);
H5::H5File out_f(outFile, H5F_ACC_TRUNC);
array_type v1_data;
uint32_t N1_points, N2_points;
uint64_t N1_points, N2_points;
array3_type bins(boost::extents[Nres][Nres][Nres]);
@ -124,12 +124,12 @@ int main(int argc, char **argv)
MyCell *allCells_1 = new MyCell[N1_points];
#pragma omp parallel for schedule(static)
for (long i = 0; i < Nres*Nres*Nres; i++)
for (uint32_t i = 0; i < Nres*Nres*Nres; i++)
bins.data()[i] = 0;
cout << "Shuffling data in cells..." << endl;
#pragma omp parallel for schedule(static)
for (int i = 0 ; i < N1_points; i++)
for (uint64_t i = 0 ; i < N1_points; i++)
{
for (int j = 0; j < 3; j++)
allCells_1[i].coord[j] = v1_data[i][j];

View File

@ -229,7 +229,7 @@ class BuildCMakeExt(build_ext):
CosmoTool_extension = CMakeExtension(name="cosmotool")
setup(name='cosmotool',
version='1.2.3',
version='1.3.0',
packages=["cosmotool"],
package_dir={'cosmotool': 'python/cosmotool'},
install_requires=['numpy','cffi','numexpr','pyfftw','h5py'],

View File

@ -99,8 +99,8 @@ namespace CosmoTool {
typename KDDef<N,CType>::CoordType r, r2;
KDCell<N, ValType,CType> **cells;
typename KDDef<N,CType>::CoordType *distances;
uint32_t currentRank;
uint32_t numCells;
uint64_t currentRank;
uint64_t numCells;
};
@ -114,7 +114,7 @@ namespace CosmoTool {
RecursionMultipleInfo(const typename KDDef<N,CType>::KDCoordinates& rx,
KDCell<N,ValType,CType> **cells,
uint32_t numCells)
uint64_t numCells)
: queue(cells, numCells, INFINITY),traversed(0)
{
std::copy(rx, rx+N, x);
@ -153,20 +153,20 @@ namespace CosmoTool {
std::copy(replicate, replicate+N, this->replicate);
}
uint32_t getIntersection(const coords& x, CoordType r,
uint64_t getIntersection(const coords& x, CoordType r,
Cell **cells,
uint32_t numCells);
uint32_t getIntersection(const coords& x, CoordType r,
uint64_t numCells);
uint64_t getIntersection(const coords& x, CoordType r,
Cell **cells,
CoordType *distances,
uint32_t numCells);
uint32_t countCells(const coords& x, CoordType r);
uint64_t numCells);
uint64_t countCells(const coords& x, CoordType r);
Cell *getNearestNeighbour(const coords& x);
void getNearestNeighbours(const coords& x, uint32_t NumCells,
void getNearestNeighbours(const coords& x, uint64_t NumCells,
Cell **cells);
void getNearestNeighbours(const coords& x, uint32_t NumCells,
void getNearestNeighbours(const coords& x, uint64_t NumCells,
Cell **cells,
CoordType *distances);

View File

@ -80,9 +80,9 @@ namespace CosmoTool {
}
template<int N, typename ValType, typename CType, typename CellSplitter>
uint32_t KDTree<N,ValType,CType,CellSplitter>::getIntersection(const coords& x, CoordType r,
uint64_t KDTree<N,ValType,CType,CellSplitter>::getIntersection(const coords& x, CoordType r,
KDTree<N,ValType,CType,CellSplitter>::Cell **cells,
uint32_t numCells)
uint64_t numCells)
{
RecursionInfoCells<N,ValType,CType> info;
@ -112,10 +112,10 @@ namespace CosmoTool {
}
template<int N, typename ValType, typename CType, typename CellSplitter>
uint32_t KDTree<N,ValType,CType,CellSplitter>::getIntersection(const coords& x, CoordType r,
uint64_t KDTree<N,ValType,CType,CellSplitter>::getIntersection(const coords& x, CoordType r,
Cell **cells,
CoordType *distances,
uint32_t numCells)
uint64_t numCells)
{
RecursionInfoCells<N,ValType> info;
@ -144,7 +144,7 @@ namespace CosmoTool {
}
template<int N, typename ValType, typename CType, typename CellSplitter>
uint32_t KDTree<N,ValType,CType,CellSplitter>::countCells(const coords& x, CoordType r)
uint64_t KDTree<N,ValType,CType,CellSplitter>::countCells(const coords& x, CoordType r)
{
RecursionInfoCells<N,ValType> info;
@ -501,7 +501,7 @@ namespace CosmoTool {
}
template<int N, typename ValType, typename CType, typename CellSplitter>
void KDTree<N,ValType,CType,CellSplitter>::getNearestNeighbours(const coords& x, uint32_t N2,
void KDTree<N,ValType,CType,CellSplitter>::getNearestNeighbours(const coords& x, uint64_t N2,
Cell **cells)
{
RecursionMultipleInfo<N,ValType> info(x, cells, N2);
@ -527,7 +527,7 @@ namespace CosmoTool {
}
template<int N, typename ValType, typename CType, typename CellSplitter>
void KDTree<N,ValType,CType,CellSplitter>::getNearestNeighbours(const coords& x, uint32_t N2,
void KDTree<N,ValType,CType,CellSplitter>::getNearestNeighbours(const coords& x, uint64_t N2,
Cell **cells,
CoordType *distances)
{

View File

@ -222,8 +222,7 @@ namespace CosmoTool
template<typename T>
void loadArray(const std::string& fname,
T*& array, uint32_t *& dimList, uint32_t& rank)
throw (NoSuchFileException);
T*& array, uint32_t *& dimList, uint32_t& rank);
ProgressiveDoubleOutput saveDoubleArrayProgressive(const char *fname, uint32_t *dimList, uint32_t rank);
};

View File

@ -224,7 +224,6 @@ namespace CosmoTool {
template<typename T>
void loadArray(const std::string& fname,
T*&array, uint32_t *&dimList, uint32_t& rank)
throw (NoSuchFileException)
{
NcFile f(fname.c_str(), NcFile::read);