CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::data::Field3D Class Reference

The class Field3D. More...

#include "Headers/Field3D.h"

Inheritance diagram for cbl::data::Field3D:

Public Member Functions

Constructors/destructors
 Field3D ()=default
 default constructor
 
 Field3D (const double deltaR, const double minX, const double maxX, const double minY, const double maxY, const double minZ, const double maxZ)
 constructor More...
 
 Field3D (const int nx, const int ny, const int nz, const double minX, const double maxX, const double minY, const double maxY, const double minZ, const double maxZ)
 constructor More...
 
virtual ~Field3D ()=default
 default destructor
 
Member functions to set the private/protected members
void set_parameters (const double deltaR, const double minX, const double maxX, const double minY, const double maxY, const double minZ, const double maxZ)
 set the parameters More...
 
void set_parameters (const int nx, const int ny, const int nz, const double minX, const double maxX, const double minY, const double maxY, const double minZ, const double maxZ)
 set the parameters More...
 
Member functions to get the private/protected members
int nx () const
 get the private member m_nX More...
 
int ny () const
 get the private member m_nY More...
 
int nz () const
 get the private member m_nZ More...
 
int nzFourier () const
 get the private member m_nZF More...
 
int nCells () const
 get the private member m_nCells More...
 
int nCellsFourier () const
 get the private member m_nCells_Fourier More...
 
double MinX () const
 get the private member m_MinX More...
 
double MinY () const
 get the private member m_MinY More...
 
double MinZ () const
 get the private member m_MinZ More...
 
double MaxX () const
 get the private member m_MaxX More...
 
double MaxY () const
 get the private member m_MaxY More...
 
double MaxZ () const
 get the private member m_MaxZ More...
 
double deltaX () const
 get the private member m_deltaX More...
 
double deltaY () const
 get the private member m_deltaY More...
 
double deltaZ () const
 get the private member m_deltaZ More...
 
double Volume () const
 get the private member m_Volume More...
 
double XX (const int i) const
 get the value of the X coordinates at the i-th cell More...
 
double YY (const int i) const
 get the value of the Y coordinates at the i-th cell More...
 
double ZZ (const int i) const
 get the value of the Z coordinates at the i-th cell More...
 
double kX (const int i) const
 get the value of the X coordinates at the i-th cell, Fourier space More...
 
double kY (const int i) const
 get the value of the Y coordinates at the i-th cell, Fourier space More...
 
double kZ (const int i) const
 get the value of the Z coordinates at the i-th cell, Fourier space More...
 
virtual double ScalarField (const int i, const int j, const int k) const
 get the value of the scalar field More...
 
virtual double ScalarField (const std::vector< double > pos) const
 get the value of the scalar field More...
 
virtual std::vector< double > ScalarField () const
 get the value of the scalar field More...
 
virtual std::vector< double > VectorField (const int i, const int j, const int k) const
 get the value of the vector field More...
 
virtual std::vector< double > VectorField (const std::vector< double > pos) const
 get the value of the vector field More...
 
virtual double ScalarField_FourierSpace_real (const int i, const int j, const int k) const
 get the value of the scalar field, Fourier space, real part More...
 
virtual double ScalarField_FourierSpace_complex (const int i, const int j, const int k) const
 get the value of the scalar field, Fourier space, complex part More...
 
virtual std::vector< double > ScalarField_FourierSpace_real () const
 get the value of the scalar field, Fourier space, real part More...
 
virtual std::vector< double > ScalarField_FourierSpace_complex () const
 get the value of the scalar field, Fourier space, complex part More...
 
virtual std::vector< double > VectorField_FourierSpace_real (const int i, const int j, const int k) const
 get the value of the vector field, Fourier space, real part More...
 
virtual std::vector< double > VectorField_FourierSpace_complex (const int i, const int j, const int k) const
 get the value of the vector field, Fourier space, complex part More...
 
Member functions to compute data properties
virtual void FourierTransformField ()
 perform the Fourier transform on the field
 
virtual void FourierAntiTransformField ()
 perform the anti-Fourier transform on the field
 
virtual void GaussianConvolutionField (const double kernel_size)
 perform a smoothing of the field with a gaussian kernel More...
 
virtual void set_ScalarField (const double value, const int i, const int j, const int k, const bool add=0)
 set the value of the scalar field More...
 
virtual void set_VectorField (const std::vector< double > value, const int i, const int j, const int k, const bool add=0)
 set the value of the vectorr field More...
 
virtual void set_ScalarField_FourierSpace_real (const double value, const int i, const int j, const int k, const bool add=0)
 set the value of the scalar field in Fourier space, real part More...
 
virtual void set_ScalarField_FourierSpace_complex (const double value, const int i, const int j, const int k, const bool add=0)
 set the value of the scalar field in Fourier space, complex part More...
 
virtual void set_VectorField_FourierSpace_real (const std::vector< double > value, const int i, const int j, const int k, const bool add=0)
 set the value of the vector field, Fourier space, real part More...
 
virtual void set_VectorField_FourierSpace_complex (const std::vector< double > value, const int i, const int j, const int k, const bool add=0)
 set the value of the vector field, Fourier space, complex part More...
 
virtual void reset ()
 set to 0 the fields
 

Protected Member Functions

long int inds_to_index (const int i, const int j, const int k) const
 contract 3 indeces into one More...
 
long int inds_to_index_Fourier (const int i, const int j, const int k) const
 contract 3 indeces into one, Fourier space More...
 

Protected Attributes

int m_nX
 number of cells along the x-axis
 
int m_nY
 number of cells along the y-axis
 
int m_nZ
 number of cells along the z-axis
 
int m_nZF
 number of cells along the z-axis, Fourier space
 
int m_nCells
 number of cells
 
int m_nCells_Fourier
 number of cells, Fourier space
 
double m_deltaX
 X cell size.
 
double m_deltaY
 Y cell size.
 
double m_deltaZ
 Z cell size.
 
double m_MinX
 lower x bound
 
double m_MinY
 lower y bound
 
double m_MinZ
 lower z bound
 
double m_MaxX
 upper x bound
 
double m_MaxY
 upper y bound
 
double m_MaxZ
 upper z bound
 
double m_Volume
 box volume
 
std::vector< double > m_X
 coordinates of the cells along the x-axis
 
std::vector< double > m_Y
 coordinates of the cells along the y-axis
 
std::vector< double > m_Z
 coordinates of the cells along the z-axis
 
std::vector< double > m_kX
 coordinates of the cells along the kx-axis
 
std::vector< double > m_kY
 coordinates of the cells along the ky-axis
 
std::vector< double > m_kZ
 coordinates of the cells along the kz-axis
 

Detailed Description

The class Field3D.

This class is used to handle objects of type Field3D

Definition at line 51 of file Field3D.h.

Constructor & Destructor Documentation

◆ Field3D() [1/2]

cbl::data::Field3D::Field3D ( const double  deltaR,
const double  minX,
const double  maxX,
const double  minY,
const double  maxY,
const double  minZ,
const double  maxZ 
)

constructor

Parameters
deltaRsize of the cubic cells
minXlower x bound
maxXupper x bound
minYlower y bound
maxYupper y bound
minZlower z bound
maxZupper z bound

Definition at line 45 of file Field3D.cpp.

◆ Field3D() [2/2]

cbl::data::Field3D::Field3D ( const int  nx,
const int  ny,
const int  nz,
const double  minX,
const double  maxX,
const double  minY,
const double  maxY,
const double  minZ,
const double  maxZ 
)

constructor

Parameters
nxnumber of x-axis cells
nynumber of y-axis cells
nznumber of z-axis cells
minXlower x bound
maxXupper x bound
minYlower y bound
maxYupper y bound
minZlower z bound
maxZupper z bound

Definition at line 54 of file Field3D.cpp.

Member Function Documentation

◆ deltaX()

double cbl::data::Field3D::deltaX ( ) const
inline

get the private member m_deltaX

Returns
the X cell size

Definition at line 319 of file Field3D.h.

◆ deltaY()

double cbl::data::Field3D::deltaY ( ) const
inline

get the private member m_deltaY

Returns
the Y cell size

Definition at line 325 of file Field3D.h.

◆ deltaZ()

double cbl::data::Field3D::deltaZ ( ) const
inline

get the private member m_deltaZ

Returns
the Z cell size

Definition at line 331 of file Field3D.h.

◆ GaussianConvolutionField()

virtual void cbl::data::Field3D::GaussianConvolutionField ( const double  kernel_size)
inlinevirtual

perform a smoothing of the field with a gaussian kernel

Parameters
kernel_sizesize of the gaussian kernel

Reimplemented in cbl::data::ScalarField3D.

Definition at line 537 of file Field3D.h.

◆ inds_to_index()

long int cbl::data::Field3D::inds_to_index ( const int  i,
const int  j,
const int  k 
) const
inlineprotected

contract 3 indeces into one

Parameters
iindex of the i-th x-axis cell
jindex of the j-th y-axis cell
kindex of the k-th z-axis cell
Returns
k+nZ*(j+nY*i)

Definition at line 130 of file Field3D.h.

◆ inds_to_index_Fourier()

long int cbl::data::Field3D::inds_to_index_Fourier ( const int  i,
const int  j,
const int  k 
) const
inlineprotected

contract 3 indeces into one, Fourier space

Parameters
iindex of the i-th x-axis cell
jindex of the j-th y-axis cell
kindex of the k-th z-axis cell
Returns
k+nZF*(j+nY*i)

Definition at line 141 of file Field3D.h.

◆ kX()

double cbl::data::Field3D::kX ( const int  i) const
inline

get the value of the X coordinates at the i-th cell, Fourier space

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the x-axis

Definition at line 374 of file Field3D.h.

◆ kY()

double cbl::data::Field3D::kY ( const int  i) const
inline

get the value of the Y coordinates at the i-th cell, Fourier space

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the y-axis

Definition at line 384 of file Field3D.h.

◆ kZ()

double cbl::data::Field3D::kZ ( const int  i) const
inline

get the value of the Z coordinates at the i-th cell, Fourier space

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the z-axis

Definition at line 394 of file Field3D.h.

◆ MaxX()

double cbl::data::Field3D::MaxX ( ) const
inline

get the private member m_MaxX

Returns
the upper x bound

Definition at line 301 of file Field3D.h.

◆ MaxY()

double cbl::data::Field3D::MaxY ( ) const
inline

get the private member m_MaxY

Returns
the upper y bound

Definition at line 307 of file Field3D.h.

◆ MaxZ()

double cbl::data::Field3D::MaxZ ( ) const
inline

get the private member m_MaxZ

Returns
the upper z bound

Definition at line 313 of file Field3D.h.

◆ MinX()

double cbl::data::Field3D::MinX ( ) const
inline

get the private member m_MinX

Returns
the lower x bound

Definition at line 283 of file Field3D.h.

◆ MinY()

double cbl::data::Field3D::MinY ( ) const
inline

get the private member m_MinY

Returns
the lower y bound

Definition at line 289 of file Field3D.h.

◆ MinZ()

double cbl::data::Field3D::MinZ ( ) const
inline

get the private member m_MinZ

Returns
the lower z bound

Definition at line 295 of file Field3D.h.

◆ nCells()

int cbl::data::Field3D::nCells ( ) const
inline

get the private member m_nCells

Returns
the number of cells

Definition at line 271 of file Field3D.h.

◆ nCellsFourier()

int cbl::data::Field3D::nCellsFourier ( ) const
inline

get the private member m_nCells_Fourier

Returns
the number of cells, Fourier space

Definition at line 277 of file Field3D.h.

◆ nx()

int cbl::data::Field3D::nx ( ) const
inline

get the private member m_nX

Returns
the number of cells along the x-axis

Definition at line 247 of file Field3D.h.

◆ ny()

int cbl::data::Field3D::ny ( ) const
inline

get the private member m_nY

Returns
the number of cells along the y-axis

Definition at line 253 of file Field3D.h.

◆ nz()

int cbl::data::Field3D::nz ( ) const
inline

get the private member m_nZ

Returns
the number of cells along the Z-axis

Definition at line 259 of file Field3D.h.

◆ nzFourier()

int cbl::data::Field3D::nzFourier ( ) const
inline

get the private member m_nZF

Returns
the number of cells along the z-axis, Fourier space

Definition at line 265 of file Field3D.h.

◆ ScalarField() [1/3]

virtual std::vector<double> cbl::data::Field3D::ScalarField ( ) const
inlinevirtual

get the value of the scalar field

Returns
the values of the scalar field

Reimplemented in cbl::data::ScalarField3D.

Definition at line 424 of file Field3D.h.

◆ ScalarField() [2/3]

virtual double cbl::data::Field3D::ScalarField ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the scalar field

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
the value of the vector field

Reimplemented in cbl::data::ScalarField3D.

Definition at line 405 of file Field3D.h.

◆ ScalarField() [3/3]

virtual double cbl::data::Field3D::ScalarField ( const std::vector< double >  pos) const
inlinevirtual

get the value of the scalar field

Parameters
posvector containing the point coordinates
Returns
the value of the vector field

Reimplemented in cbl::data::ScalarField3D.

Definition at line 416 of file Field3D.h.

◆ ScalarField_FourierSpace_complex() [1/2]

virtual std::vector<double> cbl::data::Field3D::ScalarField_FourierSpace_complex ( ) const
inlinevirtual

get the value of the scalar field, Fourier space, complex part

Returns
the value of the vector field

Definition at line 486 of file Field3D.h.

◆ ScalarField_FourierSpace_complex() [2/2]

virtual double cbl::data::Field3D::ScalarField_FourierSpace_complex ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the scalar field, Fourier space, complex part

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
the value of the scalar field, Fourier space, complex part

Reimplemented in cbl::data::ScalarField3D.

Definition at line 470 of file Field3D.h.

◆ ScalarField_FourierSpace_real() [1/2]

virtual std::vector<double> cbl::data::Field3D::ScalarField_FourierSpace_real ( ) const
inlinevirtual

get the value of the scalar field, Fourier space, real part

Returns
the values of the scalar field

Definition at line 478 of file Field3D.h.

◆ ScalarField_FourierSpace_real() [2/2]

virtual double cbl::data::Field3D::ScalarField_FourierSpace_real ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the scalar field, Fourier space, real part

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
the values of the scalar field, Fourier space, real part

Reimplemented in cbl::data::ScalarField3D.

Definition at line 458 of file Field3D.h.

◆ set_parameters() [1/2]

void cbl::data::Field3D::set_parameters ( const double  deltaR,
const double  minX,
const double  maxX,
const double  minY,
const double  maxY,
const double  minZ,
const double  maxZ 
)

set the parameters

Parameters
deltaRsize of the cubic cells
minXlower x bound
maxXupper x bound
minYlower y bound
maxYupper y bound
minZlower z bound
maxZupper z bound

Definition at line 63 of file Field3D.cpp.

◆ set_parameters() [2/2]

void cbl::data::Field3D::set_parameters ( const int  nx,
const int  ny,
const int  nz,
const double  minX,
const double  maxX,
const double  minY,
const double  maxY,
const double  minZ,
const double  maxZ 
)

set the parameters

Parameters
nxnumber of x-axis cells
nynumber of y-axis cells
nznumber of z-axis cells
minXlower x bound
maxXupper x bound
minYlower y bound
maxYupper y bound
minZlower z bound
maxZupper z bound

Definition at line 123 of file Field3D.cpp.

◆ set_ScalarField()

virtual void cbl::data::Field3D::set_ScalarField ( const double  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the scalar field

Parameters
valuevalue of the scalar field
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::ScalarField3D.

Definition at line 550 of file Field3D.h.

◆ set_ScalarField_FourierSpace_complex()

virtual void cbl::data::Field3D::set_ScalarField_FourierSpace_complex ( const double  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the scalar field in Fourier space, complex part

Parameters
valuevalue of the scalar field in Fourier space, complex part
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::ScalarField3D.

Definition at line 591 of file Field3D.h.

◆ set_ScalarField_FourierSpace_real()

virtual void cbl::data::Field3D::set_ScalarField_FourierSpace_real ( const double  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the scalar field in Fourier space, real part

Parameters
valuevalue of the scalar field in Fourier space, real part
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::ScalarField3D.

Definition at line 577 of file Field3D.h.

◆ set_VectorField()

virtual void cbl::data::Field3D::set_VectorField ( const std::vector< double >  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the vectorr field

Parameters
valuevector containing values of the vector field
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::VectorField3D.

Definition at line 563 of file Field3D.h.

◆ set_VectorField_FourierSpace_complex()

virtual void cbl::data::Field3D::set_VectorField_FourierSpace_complex ( const std::vector< double >  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the vector field, Fourier space, complex part

Parameters
valuevector containing values of the vector field, Fourier space, complex part
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::VectorField3D.

Definition at line 621 of file Field3D.h.

◆ set_VectorField_FourierSpace_real()

virtual void cbl::data::Field3D::set_VectorField_FourierSpace_real ( const std::vector< double >  value,
const int  i,
const int  j,
const int  k,
const bool  add = 0 
)
inlinevirtual

set the value of the vector field, Fourier space, real part

Parameters
valuevector containing values of the vector field, Fourier space, real part
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
add1 → add to the current value; 0 → overwrite the value

Reimplemented in cbl::data::VectorField3D.

Definition at line 606 of file Field3D.h.

◆ VectorField() [1/2]

virtual std::vector<double> cbl::data::Field3D::VectorField ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the vector field

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
vector containing the values of the vector field

Reimplemented in cbl::data::VectorField3D.

Definition at line 436 of file Field3D.h.

◆ VectorField() [2/2]

virtual std::vector<double> cbl::data::Field3D::VectorField ( const std::vector< double >  pos) const
inlinevirtual

get the value of the vector field

Parameters
posvector containing the point coordinates
Returns
vector containing the values of the vector field

Reimplemented in cbl::data::VectorField3D.

Definition at line 446 of file Field3D.h.

◆ VectorField_FourierSpace_complex()

virtual std::vector<double> cbl::data::Field3D::VectorField_FourierSpace_complex ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the vector field, Fourier space, complex part

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
vector containing the value of the vector field, Fourier space, complex part

Reimplemented in cbl::data::VectorField3D.

Definition at line 510 of file Field3D.h.

◆ VectorField_FourierSpace_real()

virtual std::vector<double> cbl::data::Field3D::VectorField_FourierSpace_real ( const int  i,
const int  j,
const int  k 
) const
inlinevirtual

get the value of the vector field, Fourier space, real part

Parameters
ithe i-th cell along the x-axis
jthe j-th cell along the y-axis
kthe k-th cell along the z-axis
Returns
vector containing the value of the vector field, Fourier space, real part

Reimplemented in cbl::data::VectorField3D.

Definition at line 498 of file Field3D.h.

◆ Volume()

double cbl::data::Field3D::Volume ( ) const
inline

get the private member m_Volume

Returns
the box volume

Definition at line 337 of file Field3D.h.

◆ XX()

double cbl::data::Field3D::XX ( const int  i) const
inline

get the value of the X coordinates at the i-th cell

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the x-axis

Definition at line 346 of file Field3D.h.

◆ YY()

double cbl::data::Field3D::YY ( const int  i) const
inline

get the value of the Y coordinates at the i-th cell

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the y-axis

Definition at line 355 of file Field3D.h.

◆ ZZ()

double cbl::data::Field3D::ZZ ( const int  i) const
inline

get the value of the Z coordinates at the i-th cell

Parameters
ithe index of the cell
Returns
the value of the center of the cell along the z-axis

Definition at line 364 of file Field3D.h.


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