|
PSCF v1.5.0
|
A container of w fields stored in both basis and r-grid format. More...
#include <WFields.h>
Public Member Functions | |
Construction, Destruction, and Initialization | |
| WFields () | |
| Constructor. | |
| ~WFields () | |
| Destructor. | |
| void | setFieldIo (FieldIo< D, T > const &fieldIo) |
| Create association with a FieldIo object (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. | |
Field Modifiers | |
| void | setBasis (DArray< DArray< double > > const &fields) |
| Set field component values, in symmetrized Fourier format. | |
| void | setRGrid (DArray< RField< D, T > > const &fields, bool isSymmetric=false) |
| Set fields values in real-space (r-grid) format. | |
| void | setRGrid (BackendArray< RealT, T > &fields) |
| Set new w fields, in unfolded 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. | |
| Signal< void > & | signal () |
| Get a signal that notifies observers of field modification. | |
Field Output | |
| 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. | |
Field Accessors (by const reference) | |
| 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, T > > const & | rgrid () const |
| Get array of all fields in r-space grid format. | |
| RField< D, T > const & | rgrid (int monomerId) const |
| Get the field for one monomer type in r-space grid format. | |
Boolean Queries | |
| 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? | |
A container of w fields stored in both basis and r-grid format.
Template parameters : The template parameters represent:
- D : integer dimensionality of space, D=1,2, or 3 - T : a backend type class (e.g. (CPT or CUT))
Subclasses : Specializations of Rp::WFields are used as base classes for corresponding specializations of Rp::WFields.
Field Representations : A WFields object contains a list of nMonomer chemical potential (w) fields that are each associated with a monomer type. The fields may be stored in two different formats:
A WFields is designed to automatically update one of these representations when the other is modified, as appropriate. An associated FieldIo object is used for these conversions.
The setBasis and readBasis functions allow the user to input new components in basis format, and both internally recompute the values in r-grid format. The setRGrid and setBasis functions allow the user to input the fields in r-grid format, and compute corresponding components in basis format if and only if the user declares that the fields are known to be invariant under all symmetries of the space group. A boolean flag named isSymmetric is used to keep track of whether the current field is symmetric, and thus whether the basis format exists.
Signal : A WFields object owns an instance of class Util::Signal<void> that notifies all observers whenever the fields owned by this object are modified. This signal object may be accessed by reference using the signal() member function. The Util::Signal<void>::addObserver function may used to add "observer" objects and indicate a zero-parameter member function of each observer that will be called whenever the fields are modified.
| Pscf::Rp::WFields< D, T >::WFields | ( | ) |
Constructor.
Definition at line 37 of file WFields.tpp.
Referenced by Pscf::Rp::System< D, T >::System().
| Pscf::Rp::WFields< D, T >::~WFields | ( | ) |
Destructor.
Definition at line 60 of file WFields.tpp.
| void Pscf::Rp::WFields< D, T >::setFieldIo | ( | FieldIo< D, T > const & | fieldIo | ) |
Create association with a FieldIo object (store pointer).
| fieldIo | associated FieldIo object |
Definition at line 69 of file WFields.tpp.
| void Pscf::Rp::WFields< D, T >::setReadUnitCell | ( | UnitCell< D > & | cell | ) |
Set unit cell used when reading field files.
This function creates a stored pointer to a UnitCell<D> that is used by the readBasis and readRGrid functions, which reset the unit cell parameters in this object to those read from the field file header. This function may only be called once.
| cell | unit cell that is modified by readBasis and readRGrid. |
Definition at line 76 of file WFields.tpp.
References UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::setWriteUnitCell | ( | UnitCell< D > const & | cell | ) |
Set unit cell used when writing field files.
This function creates a stored pointer to a UnitCell<D> that is is used by the writeBasis and writeRGrid functions, which each write the unit cell parameters from in this object to a field file header. This function may only be called once.
| cell | unit cell that is used by writeBasis and writeRGrid. |
Definition at line 86 of file WFields.tpp.
References UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::setNMonomer | ( | int | nMonomer | ) |
Set stored value of nMonomer.
May only be called once.
| nMonomer | number of monomer types. |
Definition at line 96 of file WFields.tpp.
References UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::allocateRGrid | ( | IntVec< D > const & | dimensions | ) |
Allocate or re-allocate memory for fields in rgrid format.
| dimensions | dimensions of spatial mesh |
Definition at line 108 of file WFields.tpp.
References UTIL_CHECK.
Referenced by readRGrid(), setBasis(), and setRGrid().
| void Pscf::Rp::WFields< D, T >::allocateBasis | ( | int | nBasis | ) |
Allocate or re-allocate memory for fields in basis format.
| nBasis | number of basis functions |
Definition at line 135 of file WFields.tpp.
Referenced by readRGrid(), and setBasis().
| void Pscf::Rp::WFields< D, T >::allocate | ( | int | nMonomer, |
| int | nBasis, | ||
| IntVec< D > const & | dimensions ) |
Allocate memory for all fields.
This function may only be called once.
| nMonomer | number of monomer types |
| nBasis | number of basis functions |
| dimensions | dimensions of spatial mesh |
Definition at line 155 of file WFields.tpp.
| void Pscf::Rp::WFields< D, T >::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.
| fields | array of new fields in basis format |
Definition at line 171 of file WFields.tpp.
References allocateBasis(), allocateRGrid(), basis(), Pscf::Mesh< D >::dimensions(), Pscf::Basis< D >::isInitialized(), Pscf::Basis< D >::nBasis(), Pscf::Mesh< D >::size(), and UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::setRGrid | ( | DArray< RField< D, T > > 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.
| fields | array of new fields in r-grid format |
| isSymmetric | is this field symmetric under the space group? |
Definition at line 215 of file WFields.tpp.
References allocateRGrid(), Pscf::Mesh< D >::dimensions(), Pscf::VecOp::eqV(), isSymmetric(), Pscf::Mesh< D >::size(), and UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::setRGrid | ( | BackendArray< RealT, T > & | fields | ) |
Set new w fields, in unfolded real-space (r-grid) format.
The input array fields is an unfolded array that contains fields for all monomer types, with the field for monomer 0 first, etc.
| fields | unfolded array of new w fields (input) |
Definition at line 254 of file WFields.tpp.
References Util::DArray< Data >::allocate(), and UTIL_CHECK.
| void Pscf::Rp::WFields< D, T >::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.
| in | input stream from which to read fields |
Definition at line 281 of file WFields.tpp.
References basis(), Pscf::Basis< D >::isInitialized(), Pscf::readNBasis(), signal(), Pscf::Mesh< D >::size(), and UTIL_CHECK.
Referenced by readBasis().
| void Pscf::Rp::WFields< D, T >::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.
| filename | file from which to read fields |
Definition at line 339 of file WFields.tpp.
References readBasis().
| void Pscf::Rp::WFields< D, T >::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.
| in | input stream from which to read fields |
| isSymmetric | is this field symmetric under the space group? |
Definition at line 360 of file WFields.tpp.
References allocateBasis(), allocateRGrid(), basis(), Pscf::Mesh< D >::dimensions(), Pscf::Basis< D >::isInitialized(), isSymmetric(), Pscf::Basis< D >::nBasis(), signal(), and UTIL_CHECK.
Referenced by readRGrid().
| void Pscf::Rp::WFields< D, T >::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.
| filename | file from which to read fields |
| isSymmetric | Is this field symmetric under the space group? |
Definition at line 402 of file WFields.tpp.
References isSymmetric(), and readRGrid().
| void Pscf::Rp::WFields< D, T >::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.
Definition at line 415 of file WFields.tpp.
References signal(), and UTIL_CHECK.
|
inline |
| Signal< void > & Pscf::Rp::WFields< D, T >::signal | ( | ) |
Get a signal that notifies observers of field modification.
Definition at line 494 of file WFields.tpp.
References UTIL_CHECK.
Referenced by readBasis(), readRGrid(), and symmetrize().
| void Pscf::Rp::WFields< D, T >::writeBasis | ( | std::ostream & | out | ) | const |
Write fields to an input stream in symmetrized basis format.
| out | output stream to which to write fields |
Definition at line 432 of file WFields.tpp.
References UTIL_CHECK.
Referenced by writeBasis().
| void Pscf::Rp::WFields< D, T >::writeBasis | ( | std::string | filename | ) | const |
Write fields to a named file, in symmetrized basis format.
| filename | file to which to write fields |
Definition at line 449 of file WFields.tpp.
References writeBasis().
| void Pscf::Rp::WFields< D, T >::writeRGrid | ( | std::ostream & | out | ) | const |
Writes fields to an input stream in real-space (r-grid) format.
| out | output stream to which to write fields |
Definition at line 461 of file WFields.tpp.
References UTIL_CHECK.
Referenced by writeRGrid().
| void Pscf::Rp::WFields< D, T >::writeRGrid | ( | std::string | filename | ) | const |
Writes fields to a named file in real-space (r-grid) format.
| filename | file to which to write fields |
Definition at line 480 of file WFields.tpp.
References writeRGrid().
|
inline |
Get array of all fields in basis format.
The array capacity is equal to the number of monomer types.
Definition at line 530 of file WFields.h.
References UTIL_ASSERT.
Referenced by readBasis(), readRGrid(), and setBasis().
|
inline |
Get the field for one monomer type in basis format.
An Exception is thrown if isSymmetric is false.
| monomerId | integer monomer type index (0,...,nMonomer-1) |
Definition at line 538 of file WFields.h.
References UTIL_ASSERT.
|
inline |
Get array of all fields in r-space grid format.
The array capacity is equal to the number of monomer types.
Definition at line 546 of file WFields.h.
References UTIL_ASSERT.
|
inline |
Get the field for one monomer type in r-space grid format.
| monomerId | integer monomer type index (0,..,nMonomer-1) |
Definition at line 554 of file WFields.h.
References UTIL_ASSERT.
|
inline |
|
inline |
|
inline |
|
inline |
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.
Definition at line 577 of file WFields.h.
Referenced by readRGrid(), readRGrid(), and setRGrid().