PSCF v1.2
|
File input/output operations and format conversions for fields. More...
#include <FieldIoReal.h>
Public Member Functions | |
Construction, Initialization and Destruction | |
FieldIoReal () | |
Constructor. | |
virtual | ~FieldIoReal () |
Destructor. | |
void | associate (Mesh< D > const &mesh, FFTT const &fft, typename UnitCell< D >::LatticeSystem const &lattice, bool const &hasGroup, std::string const &groupName, SpaceGroup< D > const &group, Basis< D > &basis) |
Create association with other objects in parent Domain. | |
void | setFileMaster (FileMaster const &fileMaster) |
Create an association with a FileMaster. | |
Field File IO - Symmetry Adapted Basis Format | |
void | readFieldsBasis (std::istream &in, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read concentration or chemical potential fields from file. | |
void | readFieldsBasis (std::string filename, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read concentration or chemical potential components from file. | |
void | readFieldBasis (std::istream &in, DArray< double > &field, UnitCell< D > &unitCell) const |
Read single concentration or chemical potential field from file. | |
void | readFieldBasis (std::string filename, DArray< double > &field, UnitCell< D > &unitCell) const |
Read single concentration or chemical potential field from file. | |
void | writeFieldBasis (std::string filename, DArray< double > const &field, UnitCell< D > const &unitCell) const |
Write single concentration or chemical potential field to file. | |
void | writeFieldsBasis (std::ostream &out, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write concentration or chemical potential field components to file. | |
void | writeFieldsBasis (std::string filename, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write concentration or chemical potential field components to file. | |
void | writeFieldBasis (std::ostream &out, DArray< double > const &field, UnitCell< D > const &unitCell) const |
Write a single field in basis format to an output stream. | |
Field File IO - Real Space Grid Format | |
virtual void | readFieldsRGrid (std::istream &in, DArray< RFRT > &fields, UnitCell< D > &unitCell) const |
Read array of RField objects (r-grid fields) from an istream. | |
void | readFieldsRGrid (std::string filename, DArray< RFRT > &fields, UnitCell< D > &unitCell) const |
Read array of RField objects (fields on r-space grid) from file. | |
virtual void | readFieldsRGridData (std::istream &in, DArray< RFRT > &fields, int nMonomer) const |
Read data for array of r-grid fields, with no header section. | |
virtual void | readFieldRGrid (std::istream &in, RFRT &field, UnitCell< D > &unitCell) const |
Read single RField (field on an r-space grid) from an istream. | |
void | readFieldRGrid (std::string filename, RFRT &field, UnitCell< D > &unitCell) const |
Read single RField (field on an r-space grid) from named file. | |
virtual void | writeFieldsRGrid (std::ostream &out, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true, bool writeMeshSize=true) const |
Write array of RField objects (fields on r-space grid) to ostream. | |
void | writeFieldsRGrid (std::string filename, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RField objects (fields on an r-space grid) to file. | |
virtual void | writeFieldRGrid (std::ostream &out, RFRT const &field, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true) const |
Write a single RField (field on an r-space grid) to ostream. | |
void | writeFieldRGrid (std::string filename, RFRT const &field, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write a single RField (fields on an r-space grid) to a file. | |
Field File IO - Fourier Space (K-Space) Grid Format | |
virtual void | readFieldsKGrid (std::istream &in, DArray< RFKT > &fields, UnitCell< D > &unitCell) const |
Read array of RFieldDft objects (k-space fields) from istream. | |
void | readFieldsKGrid (std::string filename, DArray< RFKT > &fields, UnitCell< D > &unitCell) const |
Read array of RFieldDft objects (k-space fields) from file. | |
virtual void | writeFieldsKGrid (std::ostream &out, DArray< RFKT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RFieldDft objects (k-space fields) to file. | |
void | writeFieldsKGrid (std::string filename, DArray< RFKT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RFieldDft objects (k-space fields) to a file. | |
Field Format Conversion | |
virtual void | convertBasisToKGrid (DArray< double > const &components, RFKT &dft) const |
Convert a field from symmetrized basis to Fourier grid (k-grid). | |
void | convertBasisToKGrid (DArray< DArray< double > > const &in, DArray< RFKT > &out) const |
Convert fields from symmetrized basis to Fourier grid (k-grid). | |
virtual void | convertKGridToBasis (RFKT const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert a field from Fourier (k-grid) to symmetrized basis form. | |
void | convertKGridToBasis (DArray< RFKT > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert multiple fields from Fourier (k-grid) to symmetrized basis. | |
void | convertBasisToRGrid (DArray< double > const &in, RFRT &out) const |
Convert a field from symmetrized basis to spatial grid (r-grid). | |
void | convertBasisToRGrid (DArray< DArray< double > > const &in, DArray< RFRT > &out) const |
Convert fields from symmetrized basis to spatial grid (r-grid). | |
void | convertRGridToBasis (RFRT const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert a field from spatial grid (r-grid) to symmetrized basis. | |
void | convertRGridToBasis (DArray< RFRT > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert fields from spatial grid (r-grid) to symmetrized basis. | |
void | convertKGridToRGrid (DArray< RFKT > const &in, DArray< RFRT > &out) const |
Convert fields from k-grid (DFT) to real space (r-grid) format. | |
void | convertKGridToRGrid (RFKT const &in, RFRT &out) const |
Convert a field from k-grid (DFT) to real space (r-grid) format. | |
void | convertRGridToKGrid (DArray< RFRT > const &in, DArray< RFKT > &out) const |
Convert fields from spatial grid (r-grid) to k-grid format. | |
void | convertRGridToKGrid (RFRT const &in, RFKT &out) const |
Convert a field from spatial grid (r-grid) to k-grid format. | |
Test Space Group Symmetry | |
virtual bool | hasSymmetry (RFKT const &in, double epsilon=1.0e-8, bool verbose=true) const |
Check if a k-grid field has the declared space group symmetry. | |
bool | hasSymmetry (RFRT const &in, double epsilon=1.0e-8, bool verbose=true) const |
Check if an r-grid field has the declared space group symmetry. | |
Field Scaling Utilities | |
virtual void | scaleFieldBasis (DArray< double > &field, double factor) const |
Multiply a single field in basis format by a real scalar. | |
void | scaleFieldsBasis (DArray< DArray< double > > &fields, double factor) const |
Scale an array of fields in basis format by a real scalar. | |
virtual void | scaleFieldRGrid (RFRT &field, double factor) const |
Multiply a single field in r-grid format by a real scalar. | |
void | scaleFieldsRGrid (DArray< RFRT > &fields, double factor) const |
Scale an array of r-grid fields by a real scalar. | |
Grid Manipulation Utilities | |
virtual void | replicateUnitCell (std::ostream &out, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const |
Write r-grid fields in a replicated unit cell to std::ostream. | |
void | replicateUnitCell (std::string filename, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const |
Write r-grid fields in a replicated unit cell to named file. | |
virtual void | expandRGridDimension (std::ostream &out, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const |
Expand dimension of an array of r-grid fields, write to ostream. | |
void | expandRGridDimension (std::string filename, DArray< RFRT > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > newGridDimensions) const |
Expand dimensions of array of r-grid fields, write to file. | |
Field File IO Utilities | |
void | readFieldHeader (std::istream &in, int &nMonomer, UnitCell< D > &unitCell, bool &isSymmetric) const |
Reader header of field file (fortran pscf format) | |
void | writeFieldHeader (std::ostream &out, int nMonomer, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write header for field file (fortran pscf format) | |
Protected Member Functions | |
Mesh< D > const & | mesh () const |
Get spatial discretization mesh by const reference. | |
FFTT const & | fft () const |
Get FFT object by const reference. | |
UnitCell< D >::LatticeSystem const & | lattice () const |
Get the lattice type enum value by const reference. | |
bool | hasGroup () const |
Has a space group been declared externally ? | |
std::string const & | groupName () const |
Get associated group name string by const reference. | |
SpaceGroup< D > const & | group () const |
Get associated SpaceGroup<D> by const reference. | |
Basis< D > const & | basis () const |
Get the associated Basis by const reference. | |
FileMaster const & | fileMaster () const |
Get associated FileMaster by const reference. | |
File input/output operations and format conversions for fields.
This class provides functions to read and write arrays that contain fields in any of three representations (symmetry-adapted basis, r-space grid, or Fourier k-space grid), and to convert among these representations. The member functions that implement field IO operations define the file formats for these field representations.
Template parameters:
D - dimension of space, i.e., 1, 2, or 3 RFRT - real field r-grid type, e.g., RField<D> RFKT - real field k-grid type, e.g., RFieldDft<D> FFT - fast Fourier transform type, e.g., FFT<D>
Side effect of reading a field file: The member functions that read fields from a file may all construct a symmetry adapted basis within an associated Basis object as a side effect of reading the field header. All of these functions call member function readFieldHeader member function to read the field file header. If a group has been declared in the Domain block of the parameter file for the associated system but the symmetry adapted basis has not been initialized before entry to this function, the readFieldHeader function will construct the basis before returning.
Definition at line 67 of file FieldIoReal.h.
Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::FieldIoReal | ( | ) |
Constructor.
Definition at line 46 of file FieldIoReal.tpp.
|
virtual |
Destructor.
Definition at line 60 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::associate | ( | Mesh< D > const & | mesh, |
FFTT const & | fft, | ||
typename UnitCell< D >::LatticeSystem const & | lattice, | ||
bool const & | hasGroup, | ||
std::string const & | groupName, | ||
SpaceGroup< D > const & | group, | ||
Basis< D > & | basis ) |
Create association with other objects in parent Domain.
mesh | associated spatial discretization Mesh<D> |
fft | associated FFT object for fast transforms |
lattice | lattice system type (enumeration value) |
hasGroup | true if a space group is declared |
groupName | space group name string |
group | associated SpaceGroup object |
basis | associated Basis object |
Definition at line 73 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::setFileMaster | ( | FileMaster const & | fileMaster | ) |
Create an association with a FileMaster.
fileMaster | associated FileMaster (for file paths) |
Definition at line 95 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldsBasis | ( | std::istream & | in, |
DArray< DArray< double > > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read concentration or chemical potential fields from file.
This function reads fields in a symmetry adapted basis from input stream in.
The capacity of DArray fields is equal to nMonomer, and element fields[i] is a DArray containing components of the field associated with monomer type i.
The header of a field file in basis format must declare the group name, and this name must agree with that declared in the parameter file.
in | input stream (i.e., input file) |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 105 of file FieldIoReal.tpp.
Referenced by Pscf::Rpc::System< D >::basisToRGrid(), Pscf::Rpc::BasisFieldState< D >::read(), Pscf::Rpc::System< D >::scaleFieldsBasis(), and Pscf::Rpg::System< D >::scaleFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldsBasis | ( | std::string | filename, |
DArray< DArray< double > > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read concentration or chemical potential components from file.
This function opens an input file with the specified filename, reads components in symmetry-adapted form from that file, and then closes the file. This function calls the overloaded member function readFieldsBasis that takes a std::istream parameter rather than a filename parameter.
filename | name of input file |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 402 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldBasis | ( | std::istream & | in, |
DArray< double > & | field, | ||
UnitCell< D > & | unitCell ) const |
Read single concentration or chemical potential field from file.
This function reads a single field in symmetry adapted basis format from the input stream in. The corresponding readFieldsBasis function is called internally.
in | input stream (i.e., input file) |
field | array to store the field (basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 142 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldBasis | ( | std::string | filename, |
DArray< double > & | field, | ||
UnitCell< D > & | unitCell ) const |
Read single concentration or chemical potential field from file.
This function opens an input file with the specified filename, reads field in symmetry adapted basis format from that file, and and then closes the file. The overloaded readFieldBasis function that takes a std::istream parameter is called internally.
filename | name of input file |
field | array to store the field (basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 418 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldBasis | ( | std::string | filename, |
DArray< double > const & | field, | ||
UnitCell< D > const & | unitCell ) const |
Write single concentration or chemical potential field to file.
This function opens an output file with the specified filename, writes the field in symmetry adapted basis format to that file, and closes the file.
filename | name of output file |
field | field to be written (symmetry adapted basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 448 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldsBasis | ( | std::ostream & | out, |
DArray< DArray< double > > const & | fields, | ||
UnitCell< D > const & | unitCell ) const |
Write concentration or chemical potential field components to file.
This function writes field components in a symmetry adapted basis to an output stream.
out | output stream (i.e., output file) |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 171 of file FieldIoReal.tpp.
References Pscf::Prdc::inspectArrays().
Referenced by Pscf::Rpc::System< D >::rGridToBasis(), Pscf::Rpc::System< D >::scaleFieldsBasis(), Pscf::Rpg::System< D >::scaleFieldsBasis(), and Pscf::Rpc::BasisFieldState< D >::write().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldsBasis | ( | std::string | filename, |
DArray< DArray< double > > const & | fields, | ||
UnitCell< D > const & | unitCell ) const |
Write concentration or chemical potential field components to file.
This function opens an output file with the specified filename, writes components in symmetry-adapted form to that file, and then closes the file.
filename | name of input file |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 433 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldBasis | ( | std::ostream & | out, |
DArray< double > const & | field, | ||
UnitCell< D > const & | unitCell ) const |
Write a single field in basis format to an output stream.
This function writes the field in symmetry adapted basis format.
out | output stream (i.e., output file) |
field | field to be written (symmetry adapted basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 199 of file FieldIoReal.tpp.
References Util::DArray< T >::allocate(), and Util::Array< Data >::capacity().
|
virtual |
Read array of RField objects (r-grid fields) from an istream.
The capacity of array fields is equal to nMonomer, and element fields[i] is the RFRT associated with monomer type i.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | input stream (i.e., input file) |
fields | array of RField fields (r-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 703 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldsRGrid | ( | std::string | filename, |
DArray< RFRT > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read array of RField objects (fields on r-space grid) from file.
The capacity of array fields is equal to nMonomer, and element fields[i] is the RFRT associated with monomer type i.
This function opens an input file with the specified filename, reads fields in RFRT real-space grid format from that file, and then closes the file.
filename | name of input file |
fields | array of RField fields (r-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 460 of file FieldIoReal.tpp.
|
virtual |
Read data for array of r-grid fields, with no header section.
This function reads the data section of the rgrid-field format, with no header.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | input file stream |
fields | array of RField fields (r-space grid) |
nMonomer | number of monomer types |
Definition at line 713 of file FieldIoReal.tpp.
References UTIL_THROW.
|
virtual |
Read single RField (field on an r-space grid) from an istream.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | input stream (i.e., input file) |
field | fields defined on r-space grid |
unitCell | associated crystallographic unit cell |
Definition at line 723 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldRGrid | ( | std::string | filename, |
RFRT & | field, | ||
UnitCell< D > & | unitCell ) const |
Read single RField (field on an r-space grid) from named file.
This function opens an input file with the specified filename, reads a field in RFRT real-space grid format, and closes the file.
filename | name of input file |
field | fields defined on r-space grid |
unitCell | associated crystallographic unit cell |
Definition at line 472 of file FieldIoReal.tpp.
|
virtual |
Write array of RField objects (fields on r-space grid) to ostream.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
out | output stream (i.e., output file) |
fields | array of RField objects (fields on r-space grid) |
unitCell | associated crystallographic unit cell |
writeHeader | flag to write header of file if true |
isSymmetric | Do fields have a space group symmetry ? |
writeMeshSize | Should mesh size be written at end of header? |
Definition at line 733 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldsRGrid | ( | std::string | filename, |
DArray< RFRT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write array of RField objects (fields on an r-space grid) to file.
This function opens an output file with the specified filename, writes fields in RFRT real-space grid format to that file, and then closes the file.
filename | name of output file |
fields | array of RFRT objects (fields on r-space grid) |
unitCell | associated crystallographic unit cell |
isSymmetric | Do fields have a space group symmetry ? |
Definition at line 484 of file FieldIoReal.tpp.
|
virtual |
Write a single RField (field on an r-space grid) to ostream.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
out | output stream |
field | field defined on r-space grid |
unitCell | associated crystallographic unit cell |
writeHeader | should a file header be written? |
isSymmetric | Does the field have a space group symmetry? |
Definition at line 746 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldRGrid | ( | std::string | filename, |
RFRT const & | field, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write a single RField (fields on an r-space grid) to a file.
This function opens an output file with the specified filename, write a field in RFRT real-space grid format to that file, and then closes the file.
filename | name of output file |
field | field defined on r-space grid |
unitCell | associated crystallographic unit cell |
isSymmetric | Does the field have a space group symmetry? |
Definition at line 500 of file FieldIoReal.tpp.
|
virtual |
Read array of RFieldDft objects (k-space fields) from istream.
The capacity of the array is equal to nMonomer, and element fields[i] is the discrete Fourier transform of the field for monomer type i.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | input stream (i.e., input file) |
fields | array of RFieldDft fields (k-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 758 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldsKGrid | ( | std::string | filename, |
DArray< RFKT > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read array of RFieldDft objects (k-space fields) from file.
This function opens a file with name filename, reads discrete Fourier components (Dft) of fields from that file, and closes the file.
The capacity of the array is equal to nMonomer, and element fields[i] is the discrete Fourier transform of the field for monomer type i.
filename | name of input file |
fields | array of RFieldDft fields (k-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 513 of file FieldIoReal.tpp.
|
virtual |
Write array of RFieldDft objects (k-space fields) to file.
The capacity of the array fields is equal to nMonomer. Element fields[i] is the discrete Fourier transform of the field for monomer type i.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
out | output stream (i.e., output file) |
fields | array of RFieldDft fields |
unitCell | associated crystallographic unit cell |
isSymmetric | Does this field have space group symmetry? |
Definition at line 766 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldsKGrid | ( | std::string | filename, |
DArray< RFKT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write array of RFieldDft objects (k-space fields) to a file.
This function opens a file with name filename, writes discrete Fourier transform components (DFT) components of fields to that file, and closes the file.
filename | name of output file. |
fields | array of RFieldDft fields (k-space grid) |
unitCell | associated crystallographic unit cell |
isSymmetric | Does this field have space group symmetry? |
Definition at line 525 of file FieldIoReal.tpp.
|
virtual |
Convert a field from symmetrized basis to Fourier grid (k-grid).
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
components | coefficients of symmetry-adapted basis functions |
dft | discrete Fourier transform of a real field |
Definition at line 774 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertBasisToKGrid | ( | DArray< DArray< double > > const & | in, |
DArray< RFKT > & | out ) const |
Convert fields from symmetrized basis to Fourier grid (k-grid).
The in and out parameters are arrays of fields, in which element number i is the field associated with monomer type i.
in | fields expanded in symmetry-adapted Fourier basis |
out | fields defined as discrete Fourier transforms (k-grid) |
Definition at line 221 of file FieldIoReal.tpp.
|
virtual |
Convert a field from Fourier (k-grid) to symmetrized basis form.
If the checkSymmetry parameter is true, this function checks if the input field satisfies the space group symmetry to within a tolerance given by the epsilon parameter, and prints a warning to Log::file() if it does not.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | discrete Fourier transform (k-grid) of a field |
out | components of field in asymmetry-adapted Fourier basis |
checkSymmetry | flag indicating whether to check symmetry |
epsilon | error tolerance for symmetry test (if any) |
Definition at line 780 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertKGridToBasis | ( | DArray< RFKT > const & | in, |
DArray< DArray< double > > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert multiple fields from Fourier (k-grid) to symmetrized basis.
The in and out parameters are each an array of fields, in which element i is the field associated with monomer type i.
If the checkSymmetry parameter is true, this function checks if the input fields all satisfies the space group symmetry to within a tolerance given by the parameter epsilon, and prints a warning to Log::file() for each field that does not.
in | fields defined as discrete Fourier transforms (k-grid) |
out | components of fields in symmetry adapted basis |
checkSymmetry | flag indicate whether to check symmetry |
epsilon | error tolerance for symmetry test (if any) |
Definition at line 239 of file FieldIoReal.tpp.
References Pscf::Prdc::convertKGridToBasis(), Pscf::Prdc::inspectArrays(), Pscf::Prdc::inspectFields(), and UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertBasisToRGrid | ( | DArray< double > const & | in, |
RFRT & | out ) const |
Convert a field from symmetrized basis to spatial grid (r-grid).
in | field in symmetry adapted basis form |
out | field defined on real-space grid |
Definition at line 275 of file FieldIoReal.tpp.
Referenced by Pscf::Rpc::System< D >::basisToRGrid().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertBasisToRGrid | ( | DArray< DArray< double > > const & | in, |
DArray< RFRT > & | out ) const |
Convert fields from symmetrized basis to spatial grid (r-grid).
in | fields in symmetry adapted basis form |
out | fields defined on real-space grid |
Definition at line 285 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), Pscf::Prdc::checkAllocateField(), and UTIL_ASSERT.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertRGridToBasis | ( | RFRT const & | in, |
DArray< double > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert a field from spatial grid (r-grid) to symmetrized basis.
If the boolean checkSymmetry parameter is true, this function checks whether the the input field has the correct space group symmetry to within an error threshhold given by the epsilon parameter. If this error threshhold is exceeded, a warning is written to Log::file().
in | field defined on real-space grid |
out | field in symmetry adapted basis form |
checkSymmetry | if true, check space group symmetry |
epsilon | error threshhold for symmetry test |
Definition at line 300 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), and Pscf::Prdc::convertKGridToBasis().
Referenced by Pscf::Rpc::System< D >::rGridToBasis().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertRGridToBasis | ( | DArray< RFRT > const & | in, |
DArray< DArray< double > > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert fields from spatial grid (r-grid) to symmetrized basis.
If the boolean checkSymmetry parameter is true, this function checks whether the input fields all have the correct space group symmetry to within an error threshhold given by the epsilon parameter. If this error threshhold is exceeded by an field, a warning is written to Log::file().
in | fields defined on real-space grid |
out | fields in symmetry adapted basis form |
checkSymmetry | if true, check space group symmetry |
epsilon | error threshhold for symmetry test |
Definition at line 312 of file FieldIoReal.tpp.
References Pscf::Prdc::inspectArrays(), Pscf::Prdc::inspectFields(), and UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertKGridToRGrid | ( | DArray< RFKT > const & | in, |
DArray< RFRT > & | out ) const |
Convert fields from k-grid (DFT) to real space (r-grid) format.
This function simply calls the inverse FFT for an array of fields. The inverse FFT provided by the underlying FFTW library overwrites its input, which is why field parameter "in" is passed as a non-const reference.
in | fields in discrete Fourier format (k-grid) |
out | fields defined on real-space grid (r-grid) |
Definition at line 340 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertKGridToRGrid | ( | RFKT const & | in, |
RFRT & | out ) const |
Convert a field from k-grid (DFT) to real space (r-grid) format.
This function simply calls the inverse FFT for a single field. The inverse FFT provided by the underlying FFTW library overwrites its input, which is why argument "in" a non-const reference.
in | field in discrete Fourier format (k-grid) |
out | field defined on real-space grid (r-grid) |
Definition at line 355 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertRGridToKGrid | ( | DArray< RFRT > const & | in, |
DArray< RFKT > & | out ) const |
Convert fields from spatial grid (r-grid) to k-grid format.
in | fields defined on real-space grid (r-grid) |
out | fields in discrete Fourier format (k-grid) |
Definition at line 365 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), and UTIL_ASSERT.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::convertRGridToKGrid | ( | RFRT const & | in, |
RFKT & | out ) const |
Convert a field from spatial grid (r-grid) to k-grid format.
in | field defined on real-space grid (r-grid) |
out | field in discrete Fourier format (k-grid) |
Definition at line 380 of file FieldIoReal.tpp.
|
virtual |
Check if a k-grid field has the declared space group symmetry.
This function checks whether the discrete Fourier transform of a real field satisfies all the symmetries of a space group to within an error threshhold given by parameter epsilon. If the parameter verbose is true and the deviation from symmetry exceeds the error threshhold, errors are written to Log::file().
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
in | field in real space grid (r-grid) format |
epsilon | error threshold used to test for symmetry |
verbose | if true, write error to Log::file() |
Definition at line 791 of file FieldIoReal.tpp.
bool Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::hasSymmetry | ( | RFRT const & | in, |
double | epsilon = 1.0e-8, | ||
bool | verbose = true ) const |
Check if an r-grid field has the declared space group symmetry.
This function checks whether a field defined on the nodes of a regular real-space grid satisfies all the symmetries of a space group to within an error threshhold given by parameter epsilon. If parameter verbose is true and the deviation from symmetry exceeds the error threshhold, errors are written to Log::file().
in | field in real space grid (r-grid) format |
epsilon | error threshold used to test for symmetry |
verbose | if true, write error to Log::file() |
Definition at line 264 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), and Pscf::Prdc::hasSymmetry().
|
virtual |
Multiply a single field in basis format by a real scalar.
This function takes a single real periodic field and multiplies all components in place by a common real factor, thereby modifying the input.
field | field in basis form to be rescaled |
factor | factor by which to multiply every field element |
Reimplemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Definition at line 798 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::scaleFieldsBasis | ( | DArray< DArray< double > > & | fields, |
double | factor ) const |
Scale an array of fields in basis format by a real scalar.
This function takes an array of real periodic fields and multiplies all components in place by a common real scalar, thereby modifying the input.
fields | array of fields in basis form to be rescaled |
factor | factor by which to multiply every field element |
Definition at line 538 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity().
Referenced by Pscf::Rpc::System< D >::scaleFieldsBasis(), and Pscf::Rpg::System< D >::scaleFieldsBasis().
|
virtual |
Multiply a single field in r-grid format by a real scalar.
This function takes a single real periodic field and multiplies all elements in place by a common real factor, thereby modifying the input.
field | RField (r-space) field to be rescaled |
factor | factor by which to multiply every field element |
Definition at line 804 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::scaleFieldsRGrid | ( | DArray< RFRT > & | fields, |
double | factor ) const |
Scale an array of r-grid fields by a real scalar.
This function takes an array of real periodic fields and multiplies all elements in place by a common real scalar, thereby modifying the input.
fields | array of RField (r-space) fields to be rescaled |
factor | factor by which to multiply every field element |
Definition at line 549 of file FieldIoReal.tpp.
Referenced by Pscf::Rpc::System< D >::scaleFieldsRGrid(), and Pscf::Rpg::System< D >::scaleFieldsRGrid().
|
virtual |
Write r-grid fields in a replicated unit cell to std::ostream.
This function takes an input array of periodic fields and outputs them within an expanded unit cell in which the original input unit cell has been replicated a specified number of times in each direction. Results are written to an std::ostream output stream.
Element i of the replicas IntVec<D> parameter contains the number of unit cell replicas along direction i.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
out | output stream (i.e., output file) |
fields | array of RField (r-space) fields to be replicated |
unitCell | original crystallographic unit cell |
replicas | number of unit cell replicas in each direction |
Definition at line 810 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::replicateUnitCell | ( | std::string | filename, |
DArray< RFRT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
IntVec< D > const & | replicas ) const |
Write r-grid fields in a replicated unit cell to named file.
This function opens output file filename, writes fields within a replicated unit cell to the file, and closes the file. See documentation of the overloaded function of the same name with a std::ostream parameter, which is called internally.
filename | output file name |
fields | array of RField fields (r-space grid) needs |
unitCell | original crystallographic unit cell |
replicas | number of unit cell replicas in each direction |
Definition at line 560 of file FieldIoReal.tpp.
|
virtual |
Expand dimension of an array of r-grid fields, write to ostream.
This function is used for template dimension D < 3, and allows a 1D or 2D field to be expanded into a higher dimensional (2D or 3D) field in which field values are independent of the values of coordinates associated with the added dimensions. For example, it can output a lamellar computed with D=1 on a 3D grid (d=3) in a format that can be read by pscf_pc when invoked with D=3.
The default version is unimplemented and throws an Exception. An implementation for this function must be defined in each subclass.
out | output stream (i.e., output file) |
fields | input array of RField fields (r-space grid) |
unitCell | original crystallographic unit cell |
d | expanded dimension (greater than D) |
newGridDimensions | number of grid points in added dimensions |
Definition at line 821 of file FieldIoReal.tpp.
References UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::expandRGridDimension | ( | std::string | filename, |
DArray< RFRT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
int | d, | ||
DArray< int > | newGridDimensions ) const |
Expand dimensions of array of r-grid fields, write to file.
This function opens an output file with the specified filename, writes expanded fields in RField<d> real-space grid format to that file, and then closes the file. The overloaded function of the same name with a std::ostream parameter is called internally.
filename | name of output file |
fields | input array of RFRT objects (r-space grid) |
unitCell | original crystallographic unit cell |
d | expanded dimension (greater than D) |
newGridDimensions | number of grid points in added dimensions |
Definition at line 573 of file FieldIoReal.tpp.
References Pscf::Prdc::expandRGridDimension().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::readFieldHeader | ( | std::istream & | in, |
int & | nMonomer, | ||
UnitCell< D > & | unitCell, | ||
bool & | isSymmetric ) const |
Reader header of field file (fortran pscf format)
This reads the common part of the header for all field file formats. This contains the dimension of space, the lattice system, a list of unit cell parameters, the space group name as an optional parameter, and the number of monomer types. The unit cell data is read into the associated UnitCell<D>, which is thus updated.
The value of "dim" in the header file must match the template parameter D, or an Exception is thrown. If the UnitCell<D> object passed to this function already contains a non-null lattice type, it must match the lattice system in the header file, or an Exception is thrown.
The isSymmetric parameter is set to true on return if a group name is found in the header. Presence of a group name parameter in the header is optional. If the header does contain a group name and a group name was declared in the parameter file (i.e., if hasGroup() is true), then these group names must match or an Exception is thrown.
If a space group was defined in the parameter file but the associated Basis object is not been initialized, this function will initialize the basis by calling Basis<D>::makeBasis via a private pointer, using the unit cell parameters found in the file header. This function thus can modify the associated Basis object as a side effect (even though this function is marked const). Because all member functions that read entire field files call this function to read the file header, the same statement about the Basis also applies to all such read functions.
in | input stream (i.e., input file) |
nMonomer | number of fields in the field file (output) |
unitCell | associated crystallographic unit cell (output) |
isSymmetric | Is there a group name in the header? (output) |
Definition at line 592 of file FieldIoReal.tpp.
References Pscf::Prdc::UnitCellBase< D >::nParameter(), and UTIL_CHECK.
Referenced by Pscf::Rpc::RGridTrajectoryReader< D >::readHeader(), and Pscf::Rpg::RGridTrajectoryReader< D >::readHeader().
void Pscf::Prdc::FieldIoReal< D, RFRT, RFKT, FFTT >::writeFieldHeader | ( | std::ostream & | out, |
int | nMonomer, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write header for field file (fortran pscf format)
out | output stream (i.e., output file) |
nMonomer | number of monomer types or fields |
unitCell | associated crystallographic unit cell |
isSymmetric | Do the fields have a space group symmetry? |
Definition at line 667 of file FieldIoReal.tpp.
Referenced by Pscf::Rpc::ConcentrationWriter< D >::writeHeader(), Pscf::Rpc::TrajectoryWriter< D >::writeHeader(), Pscf::Rpg::ConcentrationWriter< D >::writeHeader(), and Pscf::Rpg::TrajectoryWriter< D >::writeHeader().
|
inlineprotected |
Get spatial discretization mesh by const reference.
Definition at line 943 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get FFT object by const reference.
Definition at line 950 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get the lattice type enum value by const reference.
Definition at line 957 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Has a space group been declared externally ?
Definition at line 964 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get associated group name string by const reference.
Definition at line 971 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get associated SpaceGroup<D> by const reference.
Definition at line 978 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get the associated Basis by const reference.
Definition at line 985 of file FieldIoReal.h.
References UTIL_ASSERT.
|
inlineprotected |
Get associated FileMaster by const reference.
Definition at line 992 of file FieldIoReal.h.
References UTIL_ASSERT.