#include <lattice.h>
A container class to hold all the arrays on the lattice and access them.
T | The type of the contained values. |
Public Types | |
using | iterator = typename std::vector< T >::iterator |
Iterator of lattice. More... | |
using | const_iterator = typename std::vector< T >::const_iterator |
Const interator of lattice. More... | |
Public Member Functions | |
RectangularLattice (const std::array< double, 3 > &l, const std::array< int, 3 > &n, const std::array< double, 3 > &orig, bool per, const LatticeUpdate upd) | |
Rectangular lattice constructor. More... | |
RectangularLattice (RectangularLattice< T > const &rl) | |
Copy-constructor. More... | |
void | reset () |
Sets all values on lattice to zeros. More... | |
bool | out_of_bounds (int ix, int iy, int iz) const |
Checks if 3D index is out of lattice bounds. More... | |
ThreeVector | cell_center (int ix, int iy, int iz) const |
Find the coordinates of a given cell. More... | |
ThreeVector | cell_center (int index) const |
Find the coordinate of cell center given the 1d index of the cell. More... | |
const std::array< double, 3 > & | lattice_sizes () const |
const std::array< int, 3 > & | n_cells () const |
const std::array< double, 3 > & | cell_sizes () const |
const std::array< double, 3 > & | origin () const |
bool | periodic () const |
LatticeUpdate | when_update () const |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
T & | operator[] (std::size_t i) |
const T & | operator[] (std::size_t i) const |
std::size_t | size () const |
void | assign_value (int lattice_index, T value) |
Overwrite with a template value T at a given node. More... | |
int | index1d (int ix, int iy, int iz) |
Return the index of a given cell. More... | |
int | index_left (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -x direction ("left"). More... | |
int | index_right (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +x direction ("right"). More... | |
int | index_down (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -y direction ("down"). More... | |
int | index_up (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +y direction ("up"). More... | |
int | index_backward (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -z direction ("backward"). More... | |
int | index_forward (int ix, int iy, int iz) |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +z direction ("forward"). More... | |
void | compute_gradient_lattice (RectangularLattice< ThreeVector > &grad_lat) const |
Compute a gradient on a lattice of doubles via the finite difference method. More... | |
void | compute_four_gradient_lattice (RectangularLattice< FourVector > &old_lat, double time_step, RectangularLattice< std::array< FourVector, 4 >> &grad_lat) const |
Compute a fourgradient on a lattice of FourVectors jmu via the finite difference method. More... | |
T & | node (int ix, int iy, int iz) |
Take the value of a cell given its 3-D indices. More... | |
bool | value_at (const ThreeVector &r, T &value) |
Interpolates lattice quantity to coordinate r. More... | |
template<typename F > | |
void | iterate_sublattice (const std::array< int, 3 > &lower_bounds, const std::array< int, 3 > &upper_bounds, F &&func) |
A sub-lattice iterator, which iterates in a 3D-structured manner and calls a function on every cell. More... | |
template<typename F > | |
void | iterate_in_cube (const ThreeVector &point, const double r_cut, F &&func) |
Iterates only nodes whose cell centers lie not further than r_cut in x, y, z directions from the given point, that is iterates within a cube of side length 2*r_cut, and applies a function to each node. More... | |
template<typename F > | |
void | integrate_volume (F &integral, F(*integrand)(ThreeVector, T &, ThreeVector), const double rcut, const ThreeVector &point) |
Calculate a volume integral with given integrand. More... | |
template<typename F > | |
void | iterate_in_rectangle (const ThreeVector &point, const std::array< double, 3 > &rectangle, F &&func) |
Iterates only nodes whose cell centers lie not further than d_x in x-, d_y in y-, and d_z in z-direction from the given point, that is iterates within a rectangle of side lengths (2*dx, 2*dy, 2*dz), and applies a function to each node. More... | |
template<typename F > | |
void | iterate_nearest_neighbors (const ThreeVector &point, F &&func) |
Iterates only over nodes corresponding to the center cell (the cell containing the given point) and its nearest neighbors in the -x, +x, -y, +y, -z, +z directions, and applies a function to each node. More... | |
template<typename L > | |
bool | identical_to_lattice (const L *lat) const |
Checks if lattices of possibly different types have identical structure. More... | |
Protected Attributes | |
std::vector< T > | lattice_ |
The lattice itself, array containing physical quantities. More... | |
const std::array< double, 3 > | lattice_sizes_ |
Lattice sizes in x, y, z directions. More... | |
const std::array< int, 3 > | n_cells_ |
Number of cells in x,y,z directions. More... | |
const std::array< double, 3 > | cell_sizes_ |
Cell sizes in x, y, z directions. More... | |
const double | cell_volume_ |
Volume of a cell. More... | |
const std::array< double, 3 > | origin_ |
Coordinates of the left down nearer corner. More... | |
const bool | periodic_ |
Whether the lattice is periodic. More... | |
const LatticeUpdate | when_update_ |
When the lattice should be recalculated. More... | |
Private Member Functions | |
int | positive_modulo (int i, int n) const |
Returns division modulo, which is always between 0 and n-1 in is not suitable, because it returns results from -(n-1) to n-1. More... | |
using smash::RectangularLattice< T >::iterator = typename std::vector<T>::iterator |
using smash::RectangularLattice< T >::const_iterator = typename std::vector<T>::const_iterator |
|
inline |
Rectangular lattice constructor.
[in] | l | 3-dimensional array (lx,ly,lz) indicates the size of the lattice in x, y, z directions respectively [fm]. |
[in] | n | 3-dimensional array (nx,ny,nz) indicates the number of cells of the lattice in x, y, z directions respectively. Each cell in the lattice is labeled by three integers i, j, k where \(i\in[0, nx-1]\), \(j\in[0, ny-1]\), \(k\in[0, nz-1]\). The sizes of each cell are given by lx/nx, ly/ny, lz/nz in x,y,z directions respectively. |
[in] | orig | A 3-dimensional array indicating the coordinates of the origin [fm]. |
[in] | per | Boolean indicating whether a periodic boundary condition is applied. |
[in] | upd | Enum indicating how frequently the lattice is updated. |
Definition at line 66 of file lattice.h.
|
inline |
|
inline |
|
inline |
Checks if 3D index is out of lattice bounds.
[in] | ix | The index of the cell in x direction. |
[in] | iy | The index of the cell in y direction. |
[in] | iz | The index of the cell in z direction. |
|
inline |
|
inline |
Find the coordinate of cell center given the 1d index of the cell.
[in] | index | 1-dimensional index of the given cell. It can be related to a 3-dimensional one by index = ix + nx (iy + iz * ny). |
Definition at line 145 of file lattice.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the index of a given cell.
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -x direction ("left").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
Definition at line 221 of file lattice.h.
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +x direction ("right").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -y direction ("down").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +y direction ("up").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the -z direction ("backward").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Given the indices of a cell in the x, y, and z directions, return index of the nearest cell in the +z direction ("forward").
[in] | ix | index of a cell in the x-direction |
[in] | iy | index of a cell in the y-direction |
[in] | iz | index of a cell in the z-direction |
|
inline |
Compute a gradient on a lattice of doubles via the finite difference method.
return a lattice of ThreeVectors which are gradients of the values on the original lattice
Definition at line 320 of file lattice.h.
|
inline |
Compute a fourgradient on a lattice of FourVectors jmu via the finite difference method.
[in] | old_lat | the lattice of FourVectors jmu at a previous time step |
[in] | time_step | the used time step, needed for the time derivative |
[out] | grad_lat | a lattice of 4-arrays of 4-vectors with the following structure: [djmu_dt, djmu_dx, djmu_dy, djmu_dz] |
Definition at line 418 of file lattice.h.
|
inline |
Take the value of a cell given its 3-D indices.
[in] | ix | The index of the cell in x direction. |
[in] | iy | The index of the cell in y direction. |
[in] | iz | The index of the cell in z direction. |
Definition at line 524 of file lattice.h.
|
inline |
Interpolates lattice quantity to coordinate r.
Result is stored in the value variable. Returns true if coordinate r is on the lattice, false if out of the lattice. In the latter case, the value is set to the default value (usually 0).
[in] | r | Position where the physical quantity would be evaluated. |
[out] | value | Physical quantity evaluated at the nearest cell to the given position. |
Definition at line 547 of file lattice.h.
|
inline |
A sub-lattice iterator, which iterates in a 3D-structured manner and calls a function on every cell.
F | Type of the function. Arguments are the current node and the 3 integer indices of the cell. |
[in] | lower_bounds | Starting numbers for iterating ix, iy, iz. |
[in] | upper_bounds | Ending numbers for iterating ix, iy, iz. |
[in] | func | Function acting on the cells (such as taking value). |
Definition at line 571 of file lattice.h.
|
inline |
Iterates only nodes whose cell centers lie not further than r_cut in x, y, z directions from the given point, that is iterates within a cube of side length 2*r_cut, and applies a function to each node.
Useful for adding quantities from one particle to the lattice.
F | Type of the function. Arguments are the current node and the 3 integer indices of the cell. |
[in] | point | Position, usually the position of particle [fm]. |
[in] | r_cut | Maximum distance from the cell center to the given position. [fm] |
[in] | func | Function acting on the cells (such as taking value). |
Definition at line 617 of file lattice.h.
|
inline |
Calculate a volume integral with given integrand.
F | return type of the integrand |
[out] | integral | variable to store rsult in. Input should be 0. |
[in] | integrand | Function to be integrated |
[in] | rcut | size of the integration volume. In total the intgration volume will be a cube with edge length 2*rcut |
[in] | point | center of the integration volume |
Definition at line 658 of file lattice.h.
|
inline |
Iterates only nodes whose cell centers lie not further than d_x in x-, d_y in y-, and d_z in z-direction from the given point, that is iterates within a rectangle of side lengths (2*dx, 2*dy, 2*dz), and applies a function to each node.
Useful for adding quantities from one particle to the lattice.
F | Type of the function. Arguments are the current node and the 3 integer indices of the cell. |
[in] | point | Position, usually the position of particle [fm]. |
[in] | rectangle | Maximum distances in the x-, y-, and z-directions from the cell center to the given position. [fm] |
[in] | func | Function acting on the cells (such as taking value). |
Definition at line 683 of file lattice.h.
|
inline |
Iterates only over nodes corresponding to the center cell (the cell containing the given point) and its nearest neighbors in the -x, +x, -y, +y, -z, +z directions, and applies a function to each node.
Useful for adding quantities from one particle to the lattice.
F | Type of the function. Arguments are the current node and the 3 integer indices of the cell. |
[in] | point | Position, usually the position of particle [fm]. |
[in] | func | Function acting on the cells (such as taking value). |
Definition at line 727 of file lattice.h.
|
inline |
Checks if lattices of possibly different types have identical structure.
L | Type of the other lattice. |
[in] | lat | The other lattice being compared with the current one |
Definition at line 770 of file lattice.h.
|
inlineprivate |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |