HILA
|
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity access patterns, Field[par] with a loop over the appropriate sites. Since the Field class is one of the more important functionalities of HILA, extensive general instructions on the Field class can be read at HILA Functionality documentation. More...
#include <field.h>
Public Member Functions | |
void | check_alloc () |
Allocate Field if it is not already allocated. | |
Field< T > | conj () const |
Returns field with all elements conjugated depending how conjugate is defined for type. | |
template<typename A > | |
void | copy_boundary_condition (const Field< A > &rhs) |
Copy the boundary condition from another field. | |
template<typename R = T, typename A = decltype(::dagger(std::declval<R>()))> | |
Field< A > | dagger () const |
Returns dagger or Hermitian conjugate of Field depending on how it is defined for Field type T. | |
Field< T > | FFT (const CoordinateVector &dirs, fft_direction fdir=fft_direction::forward) const |
Field method for performing FFT. | |
Field< Complex< hila::arithmetic_type< T > > > | FFT_real_to_complex (fft_direction fdir=fft_direction::forward) const |
Field () | |
Field constructor. | |
void | free () |
Destroys field data. | |
hila::bc | get_boundary_condition (Direction dir) const |
Get the boundary condition of the Field. | |
const T | get_element (const CoordinateVector &coord) const |
Get singular element which will be broadcast to all nodes. | |
std::vector< T > | get_elements (const std::vector< CoordinateVector > &coord_list, bool broadcast=false) const |
Get a list of elements and store them into a vector. | |
std::vector< T > | get_slice (const CoordinateVector &c, bool broadcast=false) const |
Get a slice (subvolume) | |
std::vector< T > | get_subvolume (const CoordinateVector &cmin, const CoordinateVector &cmax, bool broadcast=false) const |
Get a subvolume of the field elements to all nodes. | |
auto | get_value_at (const unsigned i) const |
Get an individual element outside a loop. This is also used as a getter in the vanilla code. | |
T | gpu_minmax (bool min_or_max, Parity par, CoordinateVector &loc) const |
Declare gpu_reduce here, defined only for GPU targets. | |
template<typename R = T, typename A = decltype(::imag(std::declval<R>()))> | |
Field< A > | imag () const |
Returns imaginary part of Field. | |
bool | is_allocated () const |
Returns true if the Field data has been allocated. | |
bool | is_initialized (Parity p) const |
Returns true if the Field has been assigned to. | |
T | minmax (bool is_min, Parity par, CoordinateVector &loc) const |
Function to perform min or max operations. | |
double | norm () |
Norm. | |
template<typename A , typename B , std::enable_if_t<!std::is_same< hila::type_mul< A, B >, A >::value &&!std::is_same< hila::type_mul< A, B >, B >::value, int > = 0> | |
auto | operator* (const Field< A > &lhs, const Field< B > &rhs) -> Field< hila::type_mul< A, B > > |
Multiplication operator. | |
template<typename A , std::enable_if_t< std::is_convertible< hila::type_mul< T, A >, T >::value, int > = 0> | |
Field< T > & | operator*= (const Field< A > &rhs) |
Product assignment operator. | |
Field< T > | operator+ () const |
Summation operator. | |
template<typename A , std::enable_if_t< std::is_convertible< hila::type_plus< T, A >, T >::value, int > = 0> | |
Field< T > & | operator+= (const Field< A > &rhs) |
Addition assignment operator. | |
Field< T > | operator- () const |
Subtraction operator. | |
template<typename A , std::enable_if_t< std::is_convertible< hila::type_minus< T, A >, T >::value, int > = 0> | |
Field< T > & | operator-= (const Field< A > &rhs) |
Subtraction assignment operator. | |
template<typename A , typename B , std::enable_if_t<!std::is_same< hila::type_div< A, B >, A >::value &&!std::is_same< hila::type_div< A, B >, B >::value, int > = 0> | |
auto | operator/ (const Field< A > &l, const Field< B > &r) -> Field< hila::type_div< A, B > > |
Division operator. | |
template<typename A , std::enable_if_t< std::is_convertible< hila::type_div< T, A >, T >::value, int > = 0> | |
Field< T > & | operator/= (const Field< A > &rhs) |
Division assignment operator. | |
Field< T > & | operator= (const Field< T > &rhs) |
Assignment operator. | |
Field< T > & | operator= (Field< T > &&rhs) |
Move Assignment. | |
bool | operator== (const Field< T > &rhs) const |
Field comparison operator. | |
T | product (Parity par=Parity::all, bool allreduce=true) const |
Product reduction of Field. | |
void | read (std::ifstream &inputfile) |
Read the Field from a stream. | |
template<typename R = T, typename A = decltype(::real(std::declval<R>()))> | |
Field< A > | real () const |
Returns real part of Field. | |
Field< T > | reflect (const CoordinateVector &dirs) const |
Reflect the Field around the desired axis. | |
void | set_boundary_condition (Direction dir, hila::bc bc) |
Set the boundary condition in a given Direction (periodic or antiperiodic) | |
template<typename A , std::enable_if_t< std::is_assignable< T &, A >::value, int > = 0> | |
const T | set_element (const CoordinateVector &coord, const A &value) |
Get singular element which will be broadcast to all nodes. | |
template<typename A > | |
void | set_value_at (const A &value, unsigned i) |
Set an individual element outside a loop. This is also used as a getter in the vanilla code. | |
Field< T > & | shift (const CoordinateVector &v, Field< T > &r, Parity par) const |
Create a periodically shifted copy of the field. | |
double | squarenorm () const |
Squarenorm. | |
dir_mask_t | start_gather (Direction d, Parity p=ALL) const |
T | sum (Parity par=Parity::all, bool allreduce=true) const |
Sum reduction of Field. | |
void | write (const std::string &filename, bool binary=true, int precision=8) const |
Write the Field to a named file replacing the file. | |
void | write (std::ofstream &outputfile, bool binary=true, int precision=8) const |
Write the field to a file stream. | |
void | write_subvolume (std::ofstream &outputfile, const CoordinateVector &cmin, const CoordinateVector &cmax, int precision=6) const |
Min functions | |
T | min (Parity par=ALL) const |
Find minimum value from Field. | |
T | min (CoordinateVector &loc) const |
Find minimum value and location from Field. | |
T | min (Parity par, CoordinateVector &loc) const |
Find minimum value and location from Field. | |
Max functions | |
T | max (Parity par=ALL) const |
Find maximum value from Field. | |
T | max (CoordinateVector &loc) const |
Find maximum value and location from Field. | |
T | max (Parity par, CoordinateVector &loc) const |
Find maximum value and location from Field. | |
Public Attributes | |
field_struct *__restrict__ | fs |
Field::fs holds all of the field content in Field::field_struct. | |
Related Symbols | |||
(Note that these are not member symbols.) | |||
Mathematical methods. | |||
| |||
template<typename T , typename R = decltype(exp(std::declval<T>()))> | |||
Field< R > | exp (const Field< T > &arg) | ||
Exponential. | |||
template<typename T , typename R = decltype(log(std::declval<T>()))> | |||
Field< R > | log (const Field< T > &arg) | ||
Logarithm. | |||
template<typename T , typename R = decltype(sin(std::declval<T>()))> | |||
Field< R > | sin (const Field< T > &arg) | ||
Sine. | |||
template<typename T , typename R = decltype(cos(std::declval<T>()))> | |||
Field< R > | cos (const Field< T > &arg) | ||
Cosine. | |||
template<typename T , typename R = decltype(tan(std::declval<T>()))> | |||
Field< R > | tan (const Field< T > &arg) | ||
Tangent. | |||
template<typename T , typename R = decltype(asin(std::declval<T>()))> | |||
Field< R > | asin (const Field< T > &arg) | ||
Arcsine. | |||
template<typename T , typename R = decltype(acos(std::declval<T>()))> | |||
Field< R > | acos (const Field< T > &arg) | ||
Arccosine. | |||
template<typename T , typename R = decltype(atan(std::declval<T>()))> | |||
Field< R > | atan (const Field< T > &arg) | ||
Arctangent. | |||
template<typename T , typename R = decltype(abs(std::declval<T>()))> | |||
Field< R > | abs (const Field< T > &arg) | ||
Absolute value. | |||
template<typename T , typename P , typename R = decltype(pow(std::declval<T>()), std::declval<P>())> | |||
Field< R > | pow (const Field< T > &arg, const P p) | ||
Power. | |||
template<typename T > | |||
double | squarenorm (const Field< T > &arg) | ||
Squared norm \(|f|^2\). | |||
template<typename A , typename B , typename R = decltype(std::declval<A>() - std::declval<B>())> | |||
double | squarenorm_relative (const Field< A > &a, const Field< B > &b) | ||
Squarenorm relative \(|a-b|^2\). | |||
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity access patterns, Field[par] with a loop over the appropriate sites. Since the Field class is one of the more important functionalities of HILA, extensive general instructions on the Field class can be read at HILA Functionality documentation.
The Field class contains member functions used by hilapp, which are marked internal, as well as members that are useful for application developers.
The Field mainly implements the interface to the Field and not the content.
The Field contains a pointer to Field::field_struct, which implements MPI communication of the Field boundaries. Though generally the application developer does not need to worry about the Field::field_struct class, hence it is marked as internal and it's documentation cannot be viewed in the Web documentation.
The Field::field_struct points to a field_storage, which is defined by each backend. It implements storing and accessing the Field data, including buffers for storing haloes returned from MPI communication.
T | Field content type |
Field constructor.
The following ways of constructing a Field object are:
Default constructor:
Assigns Field::fs to nullptr.
Copy constructor:
Copy from already existing field of similar type if conversion exists. For example for float to double.
Assignment from constant constructor:
Assign constant to field if conversion exists.
|
inline |
Field< T > Field< T >::FFT | ( | const CoordinateVector & | dirs, |
fft_direction | fftdir = fft_direction::forward |
||
) | const |
Field method for performing FFT.
By default calling without arguments will execute FFT in all directions.
One can also specify the direction of the FFT with a coordinate vector:
With this in mind f.FFT(e_x+e_y+e_z) = f.FFT()
T |
dirs | Direction to perform FFT in, default is all directions |
fftdir | fft_direction::forward (default) or fft_direction::back |
Field< Complex< hila::arithmetic_type< T > > > Field< T >::FFT_real_to_complex | ( | fft_direction | fftdir = fft_direction::forward | ) | const |
FFT_real_to_complex: Field must be a real-valued field, result is a complex-valued field of the same type Implemented just by doing a FFT with a complex field with im=0; fft_direction::back gives a complex conjugate of the forward transform Result is f(-x) = f(L - x) = f(x)^*
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
auto operator* | ( | const Field< A > & | lhs, |
const Field< B > & | rhs | ||
) | -> Field<hila::type_mul<A, B>> |
Multiplication operator.
Multiplication operator can be called in the following ways as long as types are convertible.
Multiplication with field:
Multiplication with scalar:
A | Type of lhs Field |
B | Type of rhs field |
|
inline |
Product assignment operator.
Product assignment operator can be called in the following ways as long as types are convertible.
Product assignment with field:
Product assignment with scalar:
A | Type of r.h.s element |
rhs | Field to compute product with |
|
inline |
Summation operator.
Summation operator can be called in the following ways as long as types are convertible.
unary operator:
Acts as identity of field
Summation with field:
Summation with scalar:
A | Type of lhs Field |
B | Type of rhs field |
|
inline |
Addition assignment operator.
Addition assignmen operator can be called in the following ways as long as types are convertible.
Addition assignment with field:
Addition assignment with scalar:
A | Type of r.h.s element |
rhs | Field to sum |
|
inline |
Subtraction operator.
Subtraction operator can be called in the following ways as long as types are convertible.
unary operator:
Acts as negation of field
Subtraction with field:
Subtraction with scalar:
A | Type of lhs Field |
B | Type of rhs field |
|
inline |
Subtraction assignment operator.
Subtraction assignment operator can be called in the following ways as long as types are convertible.
Subtraction assignment with field:
Subtraction assignment with scalar:
A | Type of r.h.s element |
rhs | Field to subtract |
auto operator/ | ( | const Field< A > & | l, |
const Field< B > & | r | ||
) | -> Field<hila::type_div<A, B>> |
Division operator.
Division operator can be called in the following ways as long as types are convertible.
Division with field:
Division with scalar:
A | Type of lhs Field |
B | Type of rhs field |
|
inline |
Division assignment operator.
Division assignment operator can be called in the following ways as long as types are convertible.
Division assignment with field:
Division assignment with scalar:
A | Type of r.h.s element |
rhs | Field to divide with |
Assignment operator.
Assignment can be performed in the following ways:
Assignment from field:
Assignment from field is possible if types are the same or convertible
Assignment from scalar:
Assignment from scalar is possible if scalar is convertible to Field type
rhs |
T Field< T >::product | ( | Parity | par = Parity::all , |
bool | allreduce = true |
||
) | const |
Product reduction of Field.
The product in the reduction is defined by the Field type T.
par | Parity |
allreduce | Switch to turn on or off MPI allreduce |
Definition at line 306 of file reduction.h.
Field< T > Field< T >::reflect | ( | const CoordinateVector & | dirs | ) | const |
Reflect the Field around the desired axis.
Field<T>::reflect() reflects the field around the desired axis This is here because it uses similar communications as fft TODO: refactorise so that there is separate "make columns" class!
Can be called in the following ways:
Reflect on all axes:
T |
dirs |
|
inline |
Get singular element which will be broadcast to all nodes.
Set a single element. Assuming that each node calls this with the same value, it is sufficient to set the element locally
Works as long as value
type A and field type T match
A | type |
coord | Coordinate of element to be set |
value | Value to be set |
|
inline |
Field< T > & Field< T >::shift | ( | const CoordinateVector & | v, |
Field< T > & | r, | ||
Parity | par | ||
) | const |
Create a periodically shifted copy of the field.
this is currently OK only for short moves, very inefficient for longer moves
v | |
par | |
r |
Definition at line 162 of file field_comm.h.
|
inline |
dir_mask_t Field< T >::start_gather | ( | Direction | d, |
Parity | p = ALL |
||
) | const |
start_gather(): Communicate the field at Parity par from Direction d. Uses accessors to prevent dependency on the layout. return the Direction mask bits where something is happening
Definition at line 262 of file field_comm.h.
Sum reduction of Field.
The sum in the reduction is defined by the Field type T
par | Parity |
allreduce | Switch to turn on or off MPI allreduce |
Definition at line 296 of file reduction.h.
void Field< T >::write_subvolume | ( | std::ofstream & | outputfile, |
const CoordinateVector & | cmin, | ||
const CoordinateVector & | cmax, | ||
int | precision = 6 |
||
) | const |
Write a "subspace" of the original lattice Each element is written on a single line TODO: more formatting?
Definition at line 215 of file field_io.h.
field_struct* __restrict__ Field< T >::fs |