PSCF v1.3
Pscf::Rpg::WFieldContainer< D > Class Template Reference

A container of fields stored in both basis and r-grid format. More...

#include <WFieldContainer.h>

Inheritance diagram for Pscf::Rpg::WFieldContainer< D >:
Pscf::Prdc::WFieldsReal< D, Prdc::Cuda::RField< D >, Rpg::FieldIo< D > >

Public Types

typedef WFieldsReal< D, RField< D >, FieldIo< D > > Base
 Alias for base class template instantiation.

Public Member Functions

void setRGrid (DeviceArray< cudaReal > &fields)
 Set new w fields, in unfolded real-space (r-grid) format.
void setFieldIo (FieldIo< D > const &fieldIo)
 Create association with FIT (store pointer).
void setNMonomer (int nMonomer)
 Set stored value of nMonomer.
void allocateRGrid (IntVec< D > const &dimensions)
 Allocate or re-allocate memory for fields in rgrid format.
void allocateBasis (int nBasis)
 Allocate or re-allocate memory for fields in basis format.
void allocate (int nMonomer, int nBasis, IntVec< D > const &dimensions)
 Allocate memory for all fields.
void setBasis (DArray< DArray< double > > const &fields)
 Set field component values, in symmetrized Fourier format.
void setRGrid (DArray< RField< D > > const &fields, bool isSymmetric=false)
 Set fields values in real-space (r-grid) format.
void readBasis (std::istream &in)
 Read fields from an input stream in symmetrized basis format.
void readBasis (std::string filename)
 Read fields from a named file, in symmetrized basis format.
void readRGrid (std::istream &in, bool isSymmetric=false)
 Reads fields from an input stream in real-space (r-grid) format.
void readRGrid (std::string filename, bool isSymmetric=false)
 Reads fields from a named file in real-space (r-grid) format.
void symmetrize ()
 Symmetrize r-grid fields, compute corresponding basis components.
void clear ()
 Clear data stored in this object without deallocating.
void writeBasis (std::ostream &out) const
 Write fields to an input stream in symmetrized basis format.
void writeBasis (std::string filename) const
 Write fields to a named file, in symmetrized basis format.
void writeRGrid (std::ostream &out) const
 Writes fields to an input stream in real-space (r-grid) format.
void writeRGrid (std::string filename) const
 Writes fields to a named file in real-space (r-grid) format.
DArray< DArray< double > > const & basis () const
 Get array of all fields in basis format.
DArray< double > const & basis (int monomerId) const
 Get the field for one monomer type in basis format.
DArray< RField< D > > const & rgrid () const
 Get array of all fields in r-space grid format.
RField< D > const & rgrid (int monomerId) const
 Get the field for one monomer type in r-space grid format.
bool isAllocatedRGrid () const
 Has memory been allocated for fields in r-grid format?
bool isAllocatedBasis () const
 Has memory been allocated for fields in basis format?
bool hasData () const
 Has field data been set in either format?
bool isSymmetric () const
 Are fields symmetric under all elements of the space group?
Public Member Functions inherited from Pscf::Prdc::WFieldsReal< D, Prdc::Cuda::RField< D >, Rpg::FieldIo< D > >
 WFieldsReal ()
 Constructor.
 ~WFieldsReal ()
 Destructor.
void setFieldIo (Rpg::FieldIo< D > const &fieldIo)
 Create association with FIT (store pointer).
void setReadUnitCell (UnitCell< D > &cell)
 Set unit cell used when reading field files.
void setWriteUnitCell (UnitCell< D > const &cell)
 Set unit cell used when writing field files.
void setNMonomer (int nMonomer)
 Set stored value of nMonomer.
void allocateRGrid (IntVec< D > const &dimensions)
 Allocate or re-allocate memory for fields in rgrid format.
void allocateBasis (int nBasis)
 Allocate or re-allocate memory for fields in basis format.
void allocate (int nMonomer, int nBasis, IntVec< D > const &dimensions)
 Allocate memory for all fields.
void setBasis (DArray< DArray< double > > const &fields)
 Set field component values, in symmetrized Fourier format.
void setRGrid (DArray< Prdc::Cuda::RField< D > > const &fields, bool isSymmetric=false)
 Set fields values in real-space (r-grid) format.
void readBasis (std::istream &in)
 Read fields from an input stream in symmetrized basis format.
void readRGrid (std::istream &in, bool isSymmetric=false)
 Reads fields from an input stream in real-space (r-grid) format.
void symmetrize ()
 Symmetrize r-grid fields, compute corresponding basis components.
void clear ()
 Clear data stored in this object without deallocating.
Signal< void > & signal ()
 Get a signal that notifies observers of field modification.
void writeBasis (std::ostream &out) const
 Write fields to an input stream in symmetrized basis format.
void writeRGrid (std::ostream &out) const
 Writes fields to an input stream in real-space (r-grid) format.
DArray< DArray< double > > const & basis () const
 Get array of all fields in basis format.
DArray< Prdc::Cuda::RField< D > > const & rgrid () const
 Get array of all fields in r-space grid format.
bool isAllocatedRGrid () const
 Has memory been allocated for fields in r-grid format?
bool isAllocatedBasis () const
 Has memory been allocated for fields in basis format?
bool hasData () const
 Has field data been set in either format?
bool isSymmetric () const
 Are fields symmetric under all elements of the space group?

Protected Member Functions

IntVec< D > const & meshDimensions () const
 Get mesh dimensions in each direction, set on r-grid allocation.
int meshSize () const
 Get mesh size (number of grid points), set on r-grid allocation.
int nBasis () const
 Get number of basis functions, set on basis allocation.
int nMonomer () const
 Get number of monomer types.
FieldIo< D > const & fieldIo () const
 Get associated FIT object (const reference).
Protected Member Functions inherited from Pscf::Prdc::WFieldsReal< D, Prdc::Cuda::RField< D >, Rpg::FieldIo< D > >
IntVec< D > const & meshDimensions () const
 Get mesh dimensions in each direction, set on r-grid allocation.
int meshSize () const
 Get mesh size (number of grid points), set on r-grid allocation.
int nBasis () const
 Get number of basis functions, set on basis allocation.
int nMonomer () const
 Get number of monomer types.
Rpg::FieldIo< D > const & fieldIo () const
 Get associated FIT object (const reference).

Detailed Description

template<int D>
class Pscf::Rpg::WFieldContainer< D >

A container of fields stored in both basis and r-grid format.

Almost all of the implementation of this class is defined by the base class template Prdc::WFieldsReal . See documentation of that template for information.

Definition at line 32 of file rpg/field/WFieldContainer.h.

Member Typedef Documentation

◆ Base

template<int D>
typedef WFieldsReal<D, RField<D>, FieldIo<D> > Pscf::Rpg::WFieldContainer< D >::Base

Alias for base class template instantiation.

Definition at line 39 of file rpg/field/WFieldContainer.h.

Member Function Documentation

◆ setRGrid() [1/2]

template<int D>
void Pscf::Rpg::WFieldContainer< D >::setRGrid ( DeviceArray< cudaReal > & fields)

Set new w fields, in unfolded real-space (r-grid) format.

The array fields is an unfolded array that contains fields for all monomer types, with the field for monomer 0 first, etc.

Parameters
fieldsunfolded array of new w (chemical potential) fields

Definition at line 29 of file rpg/field/WFieldContainer.tpp.

References Util::DArray< Data >::allocate(), isSymmetric(), meshDimensions(), meshSize(), nMonomer(), and Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::setRGrid().

◆ setFieldIo()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::setFieldIo ( FieldIo< D > const & fieldIo)

Create association with FIT (store pointer).

Parameters
fieldIoassociated FIT object

◆ setNMonomer()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::setNMonomer ( int nMonomer)

Set stored value of nMonomer.

May only be called once.

Parameters
nMonomernumber of monomer types.

◆ allocateRGrid()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::allocateRGrid ( IntVec< D > const & dimensions)

Allocate or re-allocate memory for fields in rgrid format.

Parameters
dimensionsdimensions of spatial mesh

◆ allocateBasis()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::allocateBasis ( int nBasis)

Allocate or re-allocate memory for fields in basis format.

Parameters
nBasisnumber of basis functions

◆ allocate()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::allocate ( int nMonomer,
int nBasis,
IntVec< D > const & dimensions )

Allocate memory for all fields.

This function may only be called once.

Parameters
nMonomernumber of monomer types
nBasisnumber of basis functions
dimensionsdimensions of spatial mesh

◆ setBasis()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::setBasis ( DArray< DArray< double > > const & fields)

Set field component values, in symmetrized Fourier format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

The associated basis must be initialized on entry. As needed, r-grid and/or basis fields may be allocated within this function.

Parameters
fieldsarray of new fields in basis format

◆ setRGrid() [2/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::setRGrid ( DArray< RField< D > > const & fields,
bool isSymmetric = false )

Set fields values in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the fields are known to be symmetric and so computes and stores the corresponding basis components. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this function. If the isSymmetric parameter is true, the a basis must be initialized prior to entry.

Parameters
fieldsarray of new fields in r-grid format
isSymmetricis this field symmetric under the space group?

◆ readBasis() [1/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::readBasis ( std::istream & in)

Read fields from an input stream in symmetrized basis format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

As needed, r-grid and/or basis fields can be allocated within this function, if not allocated on entry. An associated basis will be initialized if not initialized on entry.

Parameters
ininput stream from which to read fields

◆ readBasis() [2/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::readBasis ( std::string filename)

Read fields from a named file, in symmetrized basis format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

As needed, r-grid and/or basis fields may be allocated within this function, if not allocated on entry. An associated basis will be initialized if not initialized on entry.

Parameters
filenamefile from which to read fields

◆ readRGrid() [1/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::readRGrid ( std::istream & in,
bool isSymmetric = false )

Reads fields from an input stream in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the fields are known to be symmetric and so computes and stores the corresponding basis components. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this function, if not allocated on entry. An associated basis will be initialized if not initialized on entry.

Parameters
ininput stream from which to read fields
isSymmetricis this field symmetric under the space group?

◆ readRGrid() [2/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::readRGrid ( std::string filename,
bool isSymmetric = false )

Reads fields from a named file in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the fields are known to be symmetric and so computes and stores the corresponding basis components. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this function, if not allocated on entry. An associated basis will be initialized if not initialized on entry.

Parameters
filenamefile from which to read fields
isSymmetricIs this field symmetric under the space group?

◆ symmetrize()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::symmetrize ( )

Symmetrize r-grid fields, compute corresponding basis components.

This function may be used after setting or reading w fields in r-grid format that are known to be symmetric under the space group to remove small deviations from symmetry and generate basis components.

The function symmetrizes the fields by converting from r-grid to basis format and then back again, while also storing the resulting basis components and setting isSymmetric() true.

This function assumes that the current wFieldsRGrid fields are known by the user to be symmetric, and does NOT check this. Applying this function to fields that are not symmetric will silently corrupt the fields.

On entry, hasData() must be true and isSymmetric() must be false. On exit, isSymmetric() is true.

◆ clear()

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::clear ( )

Clear data stored in this object without deallocating.

◆ writeBasis() [1/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::writeBasis ( std::ostream & out) const

Write fields to an input stream in symmetrized basis format.

Parameters
outoutput stream to which to write fields

◆ writeBasis() [2/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::writeBasis ( std::string filename) const

Write fields to a named file, in symmetrized basis format.

Parameters
filenamefile to which to write fields

◆ writeRGrid() [1/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::writeRGrid ( std::ostream & out) const

Writes fields to an input stream in real-space (r-grid) format.

Parameters
outoutput stream to which to write fields

◆ writeRGrid() [2/2]

template<int D>
void Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::writeRGrid ( std::string filename) const

Writes fields to a named file in real-space (r-grid) format.

Parameters
filenamefile to which to write fields

◆ basis() [1/2]

template<int D>
DArray< DArray< double > > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::basis ( ) const

Get array of all fields in basis format.

The array capacity is equal to the number of monomer types.

◆ basis() [2/2]

template<int D>
DArray< double > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::basis ( int monomerId) const

Get the field for one monomer type in basis format.

An Exception is thrown if isSymmetric is false.

Parameters
monomerIdinteger monomer type index (0,...,nMonomer-1)

◆ rgrid() [1/2]

template<int D>
DArray< RField< D > > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::rgrid ( ) const

Get array of all fields in r-space grid format.

The array capacity is equal to the number of monomer types.

◆ rgrid() [2/2]

template<int D>
RField< D > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::rgrid ( int monomerId) const

Get the field for one monomer type in r-space grid format.

Parameters
monomerIdinteger monomer type index (0,..,nMonomer-1)

◆ isAllocatedRGrid()

template<int D>
bool Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::isAllocatedRGrid ( ) const

Has memory been allocated for fields in r-grid format?

◆ isAllocatedBasis()

template<int D>
bool Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::isAllocatedBasis ( ) const

Has memory been allocated for fields in basis format?

◆ hasData()

template<int D>
bool Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::hasData ( ) const

Has field data been set in either format?

This flag is set true in setBasis and setRGrid.

◆ isSymmetric()

template<int D>
bool Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::isSymmetric ( ) const

Are fields symmetric under all elements of the space group?

A valid basis format exists if and only if isSymmetric is true. This flag is set true when the fields are input in basis format by the function setBasis or readBasis, or when they are set in grid format by calling the function setRGrid or readRGrid with function parameter isSymmetric == true.

Referenced by setRGrid().

◆ meshDimensions()

template<int D>
IntVec< D > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::meshDimensions ( ) const
protected

Get mesh dimensions in each direction, set on r-grid allocation.

Referenced by setRGrid().

◆ meshSize()

template<int D>
int Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::meshSize ( ) const
protected

Get mesh size (number of grid points), set on r-grid allocation.

Referenced by setRGrid().

◆ nBasis()

template<int D>
int Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::nBasis ( ) const
protected

Get number of basis functions, set on basis allocation.

◆ nMonomer()

template<int D>
int Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::nMonomer ( ) const
protected

Get number of monomer types.

Referenced by setRGrid().

◆ fieldIo()

template<int D>
FieldIo< D > const & Pscf::Prdc::WFieldsReal< D, RField< D >, FieldIo< D > >::fieldIo ( ) const
protected

Get associated FIT object (const reference).


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