mdp_field< T > Class Template Reference

most generic field object More...

#include <mdp_field.h>

List of all members.

Public Member Functions

 mdp_field ()
 declare empty field (zero size)
 mdp_field (mdp_lattice &a, int n=1)
 declares a field on lattice a and allocates a vector of n T at each site
 mdp_field (const mdp_field &field)
bool allocated ()
 checks if a field is allocated of has zero-size
void allocate_field (mdp_lattice &a, int n=0)
 Allows dynamical allocation of a field that is not allocated.
void fill_header ()
void deallocate_memory ()
void reset_field ()
 do not use, may cause memory leaks
void deallocate_field ()
 dynamically deallocate field
virtual ~mdp_field ()
T & operator() (mdp_site x, int i=0)
 returns component i of the vector of objects T stored at site x
T & operator() (int idx, int i=0)
T * operator[] (mdp_site x)
 retruns the address of the vector of objects T stored at site x
T & operator[] (mdp_int i)
T * address (mdp_site x, int i=0) const
void shift (int i, int mu)
void operator= (const mdp_field &a)
void operator= (const T a)
void operator+= (const mdp_field &a)
void operator-= (const mdp_field &a)
template<class T2 >
void operator*= (const T2 a)
template<class T2 >
void operator/= (const T2 a)
mdp_latticelattice () const
 returns by reference the lattice this field is defined on
mdp_int field_size ()
 returns the total memory in bytes occupied by the field
mdp_int file_size ()
 returns the total space in bytes required to store the field
int where_global (mdp_int i)
 only used by mdp_field::load() and mdp_field::save()
void switch_endianess_4bytes ()
void switch_endianess_8bytes ()
mdp_int global_size ()
 lattice size in units of sizeof(T)
mdp_int physical_size ()
mdp_int size_per_site ()
mdp_int physical_local_start (int i=2)
mdp_int physical_local_stop (int i=2)
T * physical_address (mdp_int i=0)
void update (int np=2, int d=-1, int size=1)
bool load (string filename, int processIO=0, mdp_int max_buffer_size=1024, bool load_header=true, mdp_int skip_bytes=0, bool(*user_read)(FILE *, void *, mdp_int, mdp_int, mdp_int, const mdp_lattice &)=0, bool try_switch_endianess=true)
 Best way to load a field.
bool save (string filename, int processIO=0, mdp_int max_buffer_size=1024, bool load_header=true, mdp_int skip_bytes=0, bool(*user_write)(FILE *, void *, mdp_int, mdp_int, mdp_int, const mdp_lattice &)=0)
 Best way to save a field.
bool save_vtk (string filename, int t=-1, int component=-1, int processIO=0, bool ASCII=false)
 Best way to save a field.

Public Attributes

mdp_field_file_header header
 the field file header, contains data only if field was read from file

Protected Attributes

mdp_latticeptr
T * m
mdp_int Tsize
mdp_int size
int field_components

Detailed Description

template<class T>
class mdp_field< T >

most generic field object

Example:

///    int box[]={10,10,10};
///    mdp_lattice lattice(3,box);
///    mdp_field<float> psi(lattice,10);
///    mdp_site x(lattice);
///    forallsites(x)
///      for(int i=0; i<10; i++)
///         psi(x,i)=0.0;
///    psi.update(); // synchronization
///    psi.save("myfield");
///    psi.load("myfield");
/// 

Constructor & Destructor Documentation

template<class T>
mdp_field< T >::mdp_field (  )  [inline]

declare empty field (zero size)

template<class T>
mdp_field< T >::mdp_field ( mdp_lattice a,
int  n = 1 
) [inline]

declares a field on lattice a and allocates a vector of n T at each site

template<class T>
mdp_field< T >::mdp_field ( const mdp_field< T > &  field  )  [inline]
template<class T>
virtual mdp_field< T >::~mdp_field (  )  [inline, virtual]

Member Function Documentation

template<class T>
T* mdp_field< T >::address ( mdp_site  x,
int  i = 0 
) const [inline]
template<class T>
void mdp_field< T >::allocate_field ( mdp_lattice a,
int  n = 0 
) [inline]

Allows dynamical allocation of a field that is not allocated.

template<class T>
bool mdp_field< T >::allocated (  )  [inline]

checks if a field is allocated of has zero-size

template<class T>
void mdp_field< T >::deallocate_field (  )  [inline]

dynamically deallocate field

template<class T>
void mdp_field< T >::deallocate_memory (  )  [inline]
template<class T>
mdp_int mdp_field< T >::field_size (  )  [inline]

returns the total memory in bytes occupied by the field

template<class T>
mdp_int mdp_field< T >::file_size (  )  [inline]

returns the total space in bytes required to store the field

template<class T>
void mdp_field< T >::fill_header (  )  [inline]
template<class T>
mdp_int mdp_field< T >::global_size (  )  [inline]

lattice size in units of sizeof(T)

template<class T>
mdp_lattice& mdp_field< T >::lattice (  )  const [inline]

returns by reference the lattice this field is defined on

template<class T >
bool mdp_field< T >::load ( string  filename,
int  processIO = 0,
mdp_int  max_buffer_size = 1024,
bool  load_header = true,
mdp_int  skip_bytes = 0,
bool(*)(FILE *, void *, mdp_int, mdp_int, mdp_int, const mdp_lattice &)  user_read = 0,
bool  try_switch_endianess = true 
) [inline]

Best way to load a field.

template<class T>
T& mdp_field< T >::operator() ( int  idx,
int  i = 0 
) [inline]
template<class T>
T& mdp_field< T >::operator() ( mdp_site  x,
int  i = 0 
) [inline]

returns component i of the vector of objects T stored at site x

Reimplemented in mdp_nmatrix_field, mdp_nvector_field, and mdp_vector_field.

template<class T>
template<class T2 >
void mdp_field< T >::operator*= ( const T2  a  )  [inline]
template<class T>
void mdp_field< T >::operator+= ( const mdp_field< T > &  a  )  [inline]
template<class T>
void mdp_field< T >::operator-= ( const mdp_field< T > &  a  )  [inline]
template<class T>
template<class T2 >
void mdp_field< T >::operator/= ( const T2  a  )  [inline]
template<class T>
void mdp_field< T >::operator= ( const T  a  )  [inline]
template<class T>
void mdp_field< T >::operator= ( const mdp_field< T > &  a  )  [inline]
template<class T>
T& mdp_field< T >::operator[] ( mdp_int  i  )  [inline]
template<class T>
T* mdp_field< T >::operator[] ( mdp_site  x  )  [inline]

retruns the address of the vector of objects T stored at site x

template<class T>
T* mdp_field< T >::physical_address ( mdp_int  i = 0  )  [inline]
template<class T>
mdp_int mdp_field< T >::physical_local_start ( int  i = 2  )  [inline]
template<class T>
mdp_int mdp_field< T >::physical_local_stop ( int  i = 2  )  [inline]
template<class T>
mdp_int mdp_field< T >::physical_size (  )  [inline]
template<class T>
void mdp_field< T >::reset_field (  )  [inline]

do not use, may cause memory leaks

template<class T >
bool mdp_field< T >::save ( string  filename,
int  processIO = 0,
mdp_int  max_buffer_size = 1024,
bool  load_header = true,
mdp_int  skip_bytes = 0,
bool(*)(FILE *, void *, mdp_int, mdp_int, mdp_int, const mdp_lattice &)  user_write = 0 
) [inline]

Best way to save a field.

template<class T >
bool mdp_field< T >::save_vtk ( string  filename,
int  t = -1,
int  component = -1,
int  processIO = 0,
bool  ASCII = false 
) [inline]

Best way to save a field.

template<class T>
void mdp_field< T >::shift ( int  i,
int  mu 
) [inline]

shifts the entire fields in direction mu of i steps (i can be positive or negative) note that if i=1, field(x-mu) is assigned to field(x) function requires communication

template<class T>
mdp_int mdp_field< T >::size_per_site (  )  [inline]
template<class T>
void mdp_field< T >::switch_endianess_4bytes (  )  [inline]
template<class T>
void mdp_field< T >::switch_endianess_8bytes (  )  [inline]
template<class T >
void mdp_field< T >::update ( int  np = 2,
int  d = -1,
int  ncomp = 1 
) [inline]

the most important communication function in MDP. it must be called after each field variables are modified. it restores the syncronization between parallel processes.

The only communication function for a field object To be invoked every time field variables are assigned and Need to be sinchronized between the parallel processes

template<class T>
int mdp_field< T >::where_global ( mdp_int  i  )  [inline]

Member Data Documentation

template<class T>
int mdp_field< T >::field_components [protected]
template<class T>
mdp_field_file_header mdp_field< T >::header

the field file header, contains data only if field was read from file

template<class T>
T* mdp_field< T >::m [protected]
template<class T>
mdp_lattice* mdp_field< T >::ptr [protected]
template<class T>
mdp_int mdp_field< T >::size [protected]
template<class T>
mdp_int mdp_field< T >::Tsize [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines

Generated on Wed Dec 23 14:03:15 2009 for fermiqcd by  doxygen 1.6.1