CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::chainmesh::ChainMesh Class Reference

The class ChainMesh. More...

#include "Headers/ChainMesh.h"

Inheritance diagram for cbl::chainmesh::ChainMesh:

Public Member Functions

 ChainMesh ()=default
 default constructor
 
 ChainMesh (const double cell_size, const long nDim)
 constructor More...
 
 ~ChainMesh ()=default
 default destructor
 
void set_par (const double cell_size, const long nDim)
 function that set parameters for the chain-mesh More...
 
long nCell () const
 get the private member ChainMesh::m_nCell_tot More...
 
long nCell_NonEmpty () const
 get the private member ChainMesh::m_nCell_NonEmpty More...
 
std::vector< long > NonEmpty_Cells () const
 get the private member ChainMesh::m_NonEmpty_Cells More...
 
long pos_to_index (const std::vector< double > center) const
 get the index of the cell given the object coordinates More...
 
long inds_to_index (const std::vector< long > indx) const
 get the unique index of the cell given the n indices More...
 
void index_to_inds (const long index, const std::vector< long > nn, std::vector< long > &indx) const
 get the n indices given the unique index More...
 
void create_chain_mesh (const std::vector< std::vector< double > > data, const double rMax, const double rMin=-1., const long nMAX=300, const long nMIN=10)
 create the chain mesh More...
 
void create_chain_mesh_m2 (const std::vector< std::vector< double > > data)
 create the chain mesh More...
 
void get_searching_region (const double r_max, const double r_min=-1.)
 set the internal variable m_search_region, the list of cell around a generic center More...
 
std::vector< long > close_objects_cell (const int cell_index, long ii=-1) const
 get the indeces of the objects close to a cell More...
 
std::vector< long > close_objects (std::vector< double > center, long ii=-1) const
 get the indeces of the objects close to an object More...
 
void normalize (std::vector< std::vector< double >> points, std::vector< double > values, const double rMAX)
 function to set a normalized (square/cubic) grid from a sample of points, used for the N-dim interpolation More...
 
double interpolate (std::vector< double > xi, const int distNum)
 N-dim interpolation of a set of N coordinates on a normalised grid (see normalize) More...
 
std::vector< double > interpolate (std::vector< std::vector< double >> points, std::vector< double > values, std::vector< std::vector< double >> xi, const int distNum, const double rMAX)
 N-dim interpolation. More...
 
std::vector< long > get_list (const long cell_index) const
 get the index of the object inside a cell More...
 

Protected Attributes

int m_nDim
 the number of dimension
 
std::vector< long > m_cell_to_index
 indexes in the i-th cell
 
double m_cell_size
 the size of the cell in unit of the interested quantity
 
std::vector< long > m_List
 list of internal use
 
std::vector< long > m_Label
 array containing the last particle of the chain-mesh in each cell
 
std::vector< std::vector< long > > m_List_index
 index list of internal use
 
std::vector< std::vector< double > > m_Lim
 Min,Max limits of variable(s) used for the chain-mesh.
 
std::vector< double > m_Delta
 Max-Min of variable(s) used for the chain-mesh.
 
std::vector< long > m_nCell
 number of cell(s) for variable(s)
 
std::vector< long > m_search_region
 the list of cell around a generic center
 
long m_nCell_tot
 the total number of cells
 
long m_nCell_NonEmpty
 the number of non-empty cells
 
std::vector< long > m_NonEmpty_Cells
 the total number of non-empty cells
 
std::vector< long > m_multCell
 multiplicative factor to compute the projected number of cells
 
std::vector< std::vector< double > > m_points
 the vector containing the sample points for the n-dim interpolation
 
std::vector< double > m_values
 the vector containing the values of the n-dim function on the sample points
 
std::vector< std::vector< double > > m_extremals
 the vector containing the extremals of the sample points coordinates
 
std::vector< double > m_delta
 vetors of differences between the extremals of the sample points coordinates
 
double m_rMAX
 the maximum radius for the search of close points in the chain mesh
 
double m_rMIN
 the minimum radius for the search of close points in the chain mesh
 

Detailed Description

The class ChainMesh.

This class is used to handle objects of type ChainMesh

Definition at line 60 of file ChainMesh.h.

Constructor & Destructor Documentation

◆ ChainMesh()

cbl::chainmesh::ChainMesh::ChainMesh ( const double  cell_size,
const long  nDim 
)

constructor

Parameters
cell_sizedouble storing the cell size
nDimthe number of dimensions

Definition at line 64 of file ChainMesh.cpp.

Member Function Documentation

◆ close_objects()

vector< long > cbl::chainmesh::ChainMesh::close_objects ( std::vector< double >  center,
long  ii = -1 
) const

get the indeces of the objects close to an object

Parameters
centercoordinates of an object
iithe minimum index given in output
Returns
vector containing the index of the objects inside the cell

Definition at line 298 of file ChainMesh.cpp.

◆ close_objects_cell()

vector< long > cbl::chainmesh::ChainMesh::close_objects_cell ( const int  cell_index,
long  ii = -1 
) const

get the indeces of the objects close to a cell

Parameters
cell_indexthe cell index
iithe minimum index given in output
Returns
vector containing the index of the objects inside the cell

Definition at line 271 of file ChainMesh.cpp.

◆ create_chain_mesh()

void cbl::chainmesh::ChainMesh::create_chain_mesh ( const std::vector< std::vector< double > >  data,
const double  rMax,
const double  rMin = -1.,
const long  nMAX = 300,
const long  nMIN = 10 
)

create the chain mesh

Parameters
datathe vector containing the coordinate of the object
rMaxthe maximum radius, to set the interal variable m_search_region
rMinthe minimum radius, to set the interal variable m_search_region
nMAXmaximum number of cells
nMINminimum number of cells

Definition at line 133 of file ChainMesh.cpp.

◆ create_chain_mesh_m2()

void cbl::chainmesh::ChainMesh::create_chain_mesh_m2 ( const std::vector< std::vector< double > >  data)

create the chain mesh

Parameters
datathe vector containing the coordinate of the object

Definition at line 196 of file ChainMesh.cpp.

◆ get_list()

vector< long > cbl::chainmesh::ChainMesh::get_list ( const long  cell_index) const

get the index of the object inside a cell

Parameters
cell_indexthe cell index
Returns
vector containing the index of the objects inside the cell

Definition at line 526 of file ChainMesh.cpp.

◆ get_searching_region()

void cbl::chainmesh::ChainMesh::get_searching_region ( const double  r_max,
const double  r_min = -1. 
)

set the internal variable m_search_region, the list of cell around a generic center

Parameters
r_maxthe maximum radius
r_minthe minimum radius

Definition at line 226 of file ChainMesh.cpp.

◆ index_to_inds()

void cbl::chainmesh::ChainMesh::index_to_inds ( const long  index,
const std::vector< long >  nn,
std::vector< long > &  indx 
) const

get the n indices given the unique index

Parameters
indexthe unique index
nnthe number of cells along the box axis
indxvector of the indices of the nD space cell

Definition at line 112 of file ChainMesh.cpp.

◆ inds_to_index()

long cbl::chainmesh::ChainMesh::inds_to_index ( const std::vector< long >  indx) const

get the unique index of the cell given the n indices

Parameters
indxvector of the indices of the nD space cell
Returns
the cell unique index

Definition at line 95 of file ChainMesh.cpp.

◆ interpolate() [1/2]

double cbl::chainmesh::ChainMesh::interpolate ( std::vector< double >  xi,
const int  distNum 
)

N-dim interpolation of a set of N coordinates on a normalised grid (see normalize)

Parameters
xithe input coordinates that has to be interpolated
distNumthe number of closest points on which the average will be done
Returns
the interpolated value at the input coordinates

Definition at line 387 of file ChainMesh.cpp.

◆ interpolate() [2/2]

vector< double > cbl::chainmesh::ChainMesh::interpolate ( std::vector< std::vector< double >>  points,
std::vector< double >  values,
std::vector< std::vector< double >>  xi,
const int  distNum,
const double  rMAX 
)

N-dim interpolation.

Parameters
pointssample points
valuessample values
xithe coordinates to be interpolated
distNumthe number of closest points on which the average will be done
rMAXthe maximum radius, to set the interal variable m_search_region
Returns
values interolated at the input coordinates

Definition at line 442 of file ChainMesh.cpp.

◆ nCell()

long cbl::chainmesh::ChainMesh::nCell ( ) const
inline

get the private member ChainMesh::m_nCell_tot

Returns
total number of cells

Definition at line 156 of file ChainMesh.h.

◆ nCell_NonEmpty()

long cbl::chainmesh::ChainMesh::nCell_NonEmpty ( ) const
inline

get the private member ChainMesh::m_nCell_NonEmpty

Returns
number of non-empty cells

Definition at line 162 of file ChainMesh.h.

◆ NonEmpty_Cells()

std::vector<long> cbl::chainmesh::ChainMesh::NonEmpty_Cells ( ) const
inline

get the private member ChainMesh::m_NonEmpty_Cells

Returns
indexes of non-empty cells

Definition at line 168 of file ChainMesh.h.

◆ normalize()

void cbl::chainmesh::ChainMesh::normalize ( std::vector< std::vector< double >>  points,
std::vector< double >  values,
const double  rMAX 
)

function to set a normalized (square/cubic) grid from a sample of points, used for the N-dim interpolation

Parameters
pointssample points
valuesthe data on the sample points
rMAXthe maximum radius, to set the internal variable m_search_region

Definition at line 349 of file ChainMesh.cpp.

◆ pos_to_index()

long cbl::chainmesh::ChainMesh::pos_to_index ( const std::vector< double >  center) const

get the index of the cell given the object coordinates

Parameters
centerthe object coordinates
Returns
the cell index

Definition at line 73 of file ChainMesh.cpp.

◆ set_par()

void cbl::chainmesh::ChainMesh::set_par ( const double  cell_size,
const long  nDim 
)

function that set parameters for the chain-mesh

Parameters
cell_sizedouble storing the cell size
nDimthe number of dimensions

Definition at line 45 of file ChainMesh.cpp.


The documentation for this class was generated from the following files: