Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
Mesh_base< T > Class Template Reference

: class handling basic mesh functions, the most important are creating and destroing the underlying data structure creates a mesh of N1*N2*N3 cells More...

#include <class_mesh.hpp>

Public Member Functions

 Mesh_base (size_t n1, size_t n2, size_t n3)
 
T * real ()
 
const T * real () const
 
void assign (T val)
 
T & operator[] (size_t i)
 
const T & operator[] (size_t i) const
 
T & operator() (size_t i, size_t j, size_t k)
 
const T & operator() (size_t i, size_t j, size_t k) const
 
T & operator() (size_t i, size_t j)
 
const T & operator() (size_t i, size_t j) const
 
template<typename U >
T & operator() (Vec_3D< U > pos)
 
template<typename U >
const T & operator() (Vec_3D< U > pos) const
 
Mesh_baseoperator+= (const T &rhs)
 
Mesh_baseoperator-= (const T &rhs)
 
Mesh_baseoperator*= (const T &rhs)
 
Mesh_baseoperator/= (const T &rhs)
 

Public Attributes

size_t N1
 
size_t N2
 
size_t N3
 
size_t length
 
std::vector< T > data
 

Detailed Description

template<typename T>
class Mesh_base< T >

: class handling basic mesh functions, the most important are creating and destroing the underlying data structure creates a mesh of N1*N2*N3 cells

Definition at line 24 of file class_mesh.hpp.

Constructor & Destructor Documentation

template<typename T>
Mesh_base< T >::Mesh_base ( size_t  n1,
size_t  n2,
size_t  n3 
)
inline

Definition at line 28 of file class_mesh.hpp.

28  :
29  N1(n1), N2(n2), N3(n3), length(n1*n2*n3), data(length) {}
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N1
Definition: class_mesh.hpp:32
size_t N3
Definition: class_mesh.hpp:32
size_t length
Definition: class_mesh.hpp:32
size_t N2
Definition: class_mesh.hpp:32

Member Function Documentation

template<typename T>
void Mesh_base< T >::assign ( val)
inline

Definition at line 38 of file class_mesh.hpp.

Referenced by anonymous_namespace{mod_frozen_potential.cpp}::LinkedList::get_linked_list(), get_rho_from_par(), and TEST_CASE().

39  {
40  #pragma omp parallel for
41  for (size_t i = 0; i < length; i++) this->data[i]=val;
42  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t length
Definition: class_mesh.hpp:32
template<typename T>
T& Mesh_base< T >::operator() ( size_t  i,
size_t  j,
size_t  k 
)
inline

Definition at line 48 of file class_mesh.hpp.

48 { return data[i*N2*N3+j*N3+k]; }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N3
Definition: class_mesh.hpp:32
size_t N2
Definition: class_mesh.hpp:32
template<typename T>
const T& Mesh_base< T >::operator() ( size_t  i,
size_t  j,
size_t  k 
) const
inline

Definition at line 49 of file class_mesh.hpp.

49 { return data[i*N2*N3+j*N3+k]; }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N3
Definition: class_mesh.hpp:32
size_t N2
Definition: class_mesh.hpp:32
template<typename T>
T& Mesh_base< T >::operator() ( size_t  i,
size_t  j 
)
inline

Definition at line 51 of file class_mesh.hpp.

51 { return data[i*N3+j]; }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N3
Definition: class_mesh.hpp:32
template<typename T>
const T& Mesh_base< T >::operator() ( size_t  i,
size_t  j 
) const
inline

Definition at line 52 of file class_mesh.hpp.

52 { return data[i*N3+j]; }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N3
Definition: class_mesh.hpp:32
template<typename T>
template<typename U >
T& Mesh_base< T >::operator() ( Vec_3D< U >  pos)
inline

Definition at line 54 of file class_mesh.hpp.

55  {
56  get_per(pos, N1, N2, N3);
57  return data[size_t(pos[0])*N2*N3+size_t(pos[1])*N3+size_t(pos[2])];
58  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N1
Definition: class_mesh.hpp:32
size_t N3
Definition: class_mesh.hpp:32
void get_per(Vec_3D< T > &position, size_t per)
Definition: core_mesh.cpp:66
size_t N2
Definition: class_mesh.hpp:32
template<typename T>
template<typename U >
const T& Mesh_base< T >::operator() ( Vec_3D< U >  pos) const
inline

Definition at line 60 of file class_mesh.hpp.

61  {
62  get_per(pos, N1, N2, N3);
63  return data[size_t(pos[0])*N2*N3+size_t(pos[1])*N3+size_t(pos[2])];
64  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t N1
Definition: class_mesh.hpp:32
size_t N3
Definition: class_mesh.hpp:32
void get_per(Vec_3D< T > &position, size_t per)
Definition: core_mesh.cpp:66
size_t N2
Definition: class_mesh.hpp:32
template<typename T>
Mesh_base& Mesh_base< T >::operator*= ( const T &  rhs)
inline

Definition at line 75 of file class_mesh.hpp.

76  {
77  #pragma omp parallel for
78  for (size_t i = 0; i < length; i++) this->data[i]*=rhs;
79  return *this;
80  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t length
Definition: class_mesh.hpp:32
template<typename T>
Mesh_base& Mesh_base< T >::operator+= ( const T &  rhs)
inline

Definition at line 66 of file class_mesh.hpp.

67  {
68  #pragma omp parallel for
69  for (size_t i = 0; i < length; i++) this->data[i]+=rhs;
70  return *this;
71  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t length
Definition: class_mesh.hpp:32
template<typename T>
Mesh_base& Mesh_base< T >::operator-= ( const T &  rhs)
inline

Definition at line 73 of file class_mesh.hpp.

73 { return *this+=-rhs; }
template<typename T>
Mesh_base& Mesh_base< T >::operator/= ( const T &  rhs)
inline

Definition at line 82 of file class_mesh.hpp.

83  {
84  #pragma omp parallel for
85  for (size_t i = 0; i < length; i++) this->data[i]/=rhs;
86  return *this;
87  }
std::vector< T > data
Definition: class_mesh.hpp:33
size_t length
Definition: class_mesh.hpp:32
template<typename T>
T& Mesh_base< T >::operator[] ( size_t  i)
inline

Definition at line 45 of file class_mesh.hpp.

45 { return data[i]; }
std::vector< T > data
Definition: class_mesh.hpp:33
template<typename T>
const T& Mesh_base< T >::operator[] ( size_t  i) const
inline

Definition at line 46 of file class_mesh.hpp.

46 { return data[i]; }
std::vector< T > data
Definition: class_mesh.hpp:33
template<typename T>
T* Mesh_base< T >::real ( )
inline

Definition at line 36 of file class_mesh.hpp.

Referenced by fftw_execute_dft_c2r(), fftw_execute_dft_r2c(), anonymous_namespace{chameleon.cpp}::ChiSolver< T >::set_linear_recursively(), and TEST_CASE().

36 { return data.data();} // acces data through pointer
std::vector< T > data
Definition: class_mesh.hpp:33
template<typename T>
const T* Mesh_base< T >::real ( ) const
inline

Definition at line 37 of file class_mesh.hpp.

37 { return data.data();} // acces data through const pointer
std::vector< T > data
Definition: class_mesh.hpp:33

Member Data Documentation

template<typename T>
size_t Mesh_base< T >::N1

Definition at line 32 of file class_mesh.hpp.

Referenced by gen_gauss_white_noise(), and TEST_CASE().

template<typename T>
size_t Mesh_base< T >::N2

Definition at line 32 of file class_mesh.hpp.

Referenced by Mesh::operator()(), and TEST_CASE().

template<typename T>
size_t Mesh_base< T >::N3

Definition at line 32 of file class_mesh.hpp.

Referenced by Mesh::operator()(), and TEST_CASE().


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