mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
Upgraded CosmoToolbox
This commit is contained in:
parent
5ad0bed91c
commit
aa9fe698b2
4 changed files with 30 additions and 11 deletions
10
external/cosmotool/src/loadGadget.cpp
vendored
10
external/cosmotool/src/loadGadget.cpp
vendored
|
@ -268,10 +268,10 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
|
void CosmoTool::writeGadget(const std::string& fname, SimuData *data, int GadgetFormat)
|
||||||
{
|
{
|
||||||
UnformattedWrite *f;
|
UnformattedWrite *f;
|
||||||
int npart[6];
|
int npart[6], npartTotal[6];
|
||||||
float mass[6];
|
float mass[6];
|
||||||
|
|
||||||
if (data->Pos[0] == 0 || data->Vel[0] == 0 || data->Id == 0)
|
if (data->Pos[0] == 0 || data->Vel[0] == 0 || data->Id == 0)
|
||||||
|
@ -283,12 +283,12 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
npart[i] = 0;
|
npart[i] = npartTotal[i] = 0;
|
||||||
mass[i] = 0;
|
mass[i] = 0;
|
||||||
}
|
}
|
||||||
mass[1] = 1.0;
|
mass[1] = 1.0;
|
||||||
|
|
||||||
npart[1] = data->NumPart;
|
npart[1] = data->NumPart;
|
||||||
|
npartTotal[1] = data->TotalNumPart;
|
||||||
|
|
||||||
f->beginCheckpoint();
|
f->beginCheckpoint();
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
|
@ -302,7 +302,7 @@ void CosmoTool::writeGadget(const char *fname, SimuData *data, int GadgetFormat)
|
||||||
f->writeInt32(0);
|
f->writeInt32(0);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
f->writeInt32(npart[i]);
|
f->writeInt32(npartTotal[i]);
|
||||||
f->writeInt32(0);
|
f->writeInt32(0);
|
||||||
f->writeInt32(1);
|
f->writeInt32(1);
|
||||||
f->writeReal64(data->BoxSize);
|
f->writeReal64(data->BoxSize);
|
||||||
|
|
4
external/cosmotool/src/loadGadget.hpp
vendored
4
external/cosmotool/src/loadGadget.hpp
vendored
|
@ -36,6 +36,8 @@ knowledge of the CeCILL license and that you accept its terms.
|
||||||
#ifndef __COSMO_LOAD_GADGET_HPP
|
#ifndef __COSMO_LOAD_GADGET_HPP
|
||||||
#define __COSMO_LOAD_GADGET_HPP
|
#define __COSMO_LOAD_GADGET_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "load_data.hpp"
|
#include "load_data.hpp"
|
||||||
#include "loadSimu.hpp"
|
#include "loadSimu.hpp"
|
||||||
|
|
||||||
|
@ -45,7 +47,7 @@ namespace CosmoTool {
|
||||||
int GadgetFormat = 1, SimuFilter filter = 0);
|
int GadgetFormat = 1, SimuFilter filter = 0);
|
||||||
|
|
||||||
// Only single snapshot supported
|
// Only single snapshot supported
|
||||||
void writeGadget(const char *fname, SimuData *data, int GadgetFormat = 1);
|
void writeGadget(const std::string& fname, SimuData *data, int GadgetFormat = 1);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
external/cosmotool/src/mykdtree.hpp
vendored
10
external/cosmotool/src/mykdtree.hpp
vendored
|
@ -136,7 +136,13 @@ namespace CosmoTool {
|
||||||
void setPeriodic(bool on, CoordType replicate)
|
void setPeriodic(bool on, CoordType replicate)
|
||||||
{
|
{
|
||||||
periodic = on;
|
periodic = on;
|
||||||
this->replicate = replicate;
|
std::fill(this->replicate, this->replicate+N, replicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPeriodic(bool on, const coords& replicate)
|
||||||
|
{
|
||||||
|
periodic = on;
|
||||||
|
std::copy(replicate, replicate+N, this->replicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getIntersection(const coords& x, CoordType r,
|
uint32_t getIntersection(const coords& x, CoordType r,
|
||||||
|
@ -193,7 +199,7 @@ namespace CosmoTool {
|
||||||
Cell *base_cell;
|
Cell *base_cell;
|
||||||
|
|
||||||
bool periodic;
|
bool periodic;
|
||||||
CoordType replicate;
|
coords replicate;
|
||||||
|
|
||||||
Node *buildTree(Cell **cell0,
|
Node *buildTree(Cell **cell0,
|
||||||
uint32_t NumCells,
|
uint32_t NumCells,
|
||||||
|
|
17
external/cosmotool/src/replicateGenerator.hpp
vendored
17
external/cosmotool/src/replicateGenerator.hpp
vendored
|
@ -46,18 +46,29 @@ namespace CosmoTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Coord Coords[N];
|
typedef Coord Coords[N];
|
||||||
Coord replicate;
|
Coords replicate;
|
||||||
|
|
||||||
ReplicateGenerator(const Coords& x, Coord shift)
|
ReplicateGenerator(const Coords& x, Coord shift)
|
||||||
{
|
{
|
||||||
face = 0;
|
face = 0;
|
||||||
replicate = shift;
|
std::fill(replicate, replicate+N, shift);
|
||||||
numFaces = spower<N,long>(3);
|
numFaces = spower<N,long>(3);
|
||||||
std::copy(x, x+N, x_base);
|
std::copy(x, x+N, x_base);
|
||||||
if (!next())
|
if (!next())
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReplicateGenerator(const Coords& x, Coords& shift)
|
||||||
|
{
|
||||||
|
face = 0;
|
||||||
|
std::copy(shift, shift+N, replicate);
|
||||||
|
numFaces = spower<N,long>(3);
|
||||||
|
std::copy(x, x+N, x_base);
|
||||||
|
if (!next())
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool next()
|
bool next()
|
||||||
{
|
{
|
||||||
if (face == numFaces)
|
if (face == numFaces)
|
||||||
|
@ -72,7 +83,7 @@ namespace CosmoTool
|
||||||
int c_face;
|
int c_face;
|
||||||
c_face = q_face % 3;
|
c_face = q_face % 3;
|
||||||
q_face /= 3;
|
q_face /= 3;
|
||||||
x_shifted[i] = x_base[i] + (c_face-1)*replicate;
|
x_shifted[i] = x_base[i] + (c_face-1)*replicate[i];
|
||||||
no_move = no_move && (c_face == 1);
|
no_move = no_move && (c_face == 1);
|
||||||
}
|
}
|
||||||
if (no_move)
|
if (no_move)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue