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 | |
Field () | |
Field constructor. | |
void | free () |
Destroys field data. | |
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. | |
void | check_alloc () |
Allocate Field if it is not already allocated. | |
void | set_boundary_condition (Direction dir, hila::bc bc) |
Set the boundary condition in a given Direction (periodic or antiperiodic) | |
hila::bc | get_boundary_condition (Direction dir) const |
Get the boundary condition of the Field. | |
template<typename A > | |
void | copy_boundary_condition (const Field< A > &rhs) |
Copy the boundary condition from another field. | |
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. | |
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. | |
dir_mask_t | start_gather (Direction d, Parity p=ALL) const |
Field< T > & | shift (const CoordinateVector &v, Field< T > &r, Parity par) const |
Create a periodically shifted copy of the field. | |
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. | |
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_subvolume (const CoordinateVector &cmin, const CoordinateVector &cmax, bool broadcast=false) const |
get a subvolume of the field elements to all nodes | |
std::vector< T > | get_slice (const CoordinateVector &c, bool broadcast=false) const |
and get a slice (subvolume) | |
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< T > | reflect (const CoordinateVector &dirs) const |
void | write (std::ofstream &outputfile, bool binary=true, int precision=8) const |
Write the field to a file stream. | |
void | write (const std::string &filename, bool binary=true, int precision=8) const |
Write the Field to a named file replacing the file. | |
void | read (std::ifstream &inputfile) |
Read the Field from a stream. | |
void | write_subvolume (std::ofstream &outputfile, const CoordinateVector &cmin, const CoordinateVector &cmax, int precision=6) const |
T | sum (Parity par=Parity::all, bool allreduce=true) const |
Sum reduction of Field. | |
T | product (Parity par=Parity::all, bool allreduce=true) const |
Product reduction of Field. | |
T | gpu_minmax (bool min_or_max, Parity par, CoordinateVector &loc) const |
Declare gpu_reduce here, defined only for GPU targets. | |
T | minmax (bool is_min, Parity par, CoordinateVector &loc) const |
Function to perform min or max operations. | |
Standard arithmetic operations | |
Not all are always callable, e.g. division may not be implemented by all field types since division is not defined for all | |
Field< T > & | operator= (const Field< T > &rhs) |
Assignment operator. | |
Field< T > & | operator= (Field< T > &&rhs) |
Move Assignment. | |
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. | |
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 , 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. | |
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 |
Unary + operator, acts as Identity. | |
Field< T > | operator- () const |
Unary - operator, acts as negation to all field elements. | |
template<typename S > | |
bool | operator== (const Field< S > &rhs) const |
Field comparison operator. | |
double | squarenorm () const |
Squarenorm. | |
double | norm () |
Norm. | |
Field< T > | conj () const |
Returns field with all elements conjugated depending how conjugate is defined for type. | |
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. | |
template<typename R = T, typename A = decltype(::real(std::declval<R>()))> | |
Field< A > | real () const |
Returns real part of Field. | |
template<typename R = T, typename A = decltype(::imag(std::declval<R>()))> | |
Field< A > | imag () const |
Returns imaginary part of Field. | |
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. | |
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 the following:
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 |
|
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 |
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 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 |
|
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 |
|
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 |