PSCF v1.3
|
File input/output, format conversions and other utilities for fields. More...
#include <FieldIoReal.h>
Public Member Functions | |
Construction, Initialization and Destruction | |
FieldIoReal () | |
Constructor. | |
virtual | ~FieldIoReal () |
Destructor. | |
void | associate (Mesh< D > const &mesh, FFT const &fft, typename UnitCell< D >::LatticeSystem const &lattice, bool const &hasGroup, std::string const &groupName, SpaceGroup< D > const &group, Basis< D > &basis) |
Create associations with other members of the parent Domain. | |
void | setFileMaster (FileMaster const &fileMaster) |
Create an association with a FileMaster. | |
void | setNMonomer (int nMonomer) |
Set the number of monomer types. | |
Field File IO - Symmetry Adapted Basis Format | |
void | readFieldsBasis (std::istream &in, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read an array of fields in basis format from an input stream. | |
void | readFieldsBasis (std::string filename, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read an array of fields in basis format from a named file. | |
void | readFieldBasis (std::istream &in, DArray< double > &field, UnitCell< D > &unitCell) const |
Read a single field in basis format from an input stream. | |
void | readFieldBasis (std::string filename, DArray< double > &field, UnitCell< D > &unitCell) const |
Read a single field in basis format from a named file. | |
void | writeFieldsBasis (std::ostream &out, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write an array of fields in basis format to an output stream. | |
void | writeFieldsBasis (std::string filename, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write an array of fields in basis format to a named 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. | |
void | writeFieldBasis (std::string filename, DArray< double > const &field, UnitCell< D > const &unitCell) const |
Write single field in basis format to a named file. | |
Field File IO - Real Space Grid Format | |
virtual bool | readFieldsRGrid (std::istream &in, DArray< RFT > &fields, UnitCell< D > &unitCell) const =0 |
Read array of r-grid fields from an input stream. | |
bool | readFieldsRGrid (std::string filename, DArray< RFT > &fields, UnitCell< D > &unitCell) const |
Read an array of r-grid fields from a named file. | |
virtual void | readFieldsRGridData (std::istream &in, DArray< RFT > &fields, int nMonomer) const =0 |
Read data for array of r-grid fields, with no header section. | |
virtual bool | readFieldRGrid (std::istream &in, RFT &field, UnitCell< D > &unitCell) const =0 |
Read a single r-grid field from an input stream. | |
bool | readFieldRGrid (std::string filename, RFT &field, UnitCell< D > &unitCell) const |
Read a single r-grid field from a named file. | |
virtual void | writeFieldsRGrid (std::ostream &out, DArray< RFT > const &fields, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true, bool writeMeshSize=true) const =0 |
Write an array of r-grid fields to an output stream. | |
void | writeFieldsRGrid (std::string filename, DArray< RFT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write an array of r-grid fields to a named file. | |
virtual void | writeFieldRGrid (std::ostream &out, RFT const &field, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true) const =0 |
Write a single r-grid field to an an output stream. | |
void | writeFieldRGrid (std::string filename, RFT const &field, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write a single r-grid field to a named file. | |
Field File IO - Fourier Space (K-Space) Grid Format | |
virtual void | readFieldsKGrid (std::istream &in, DArray< KFT > &fields, UnitCell< D > &unitCell) const =0 |
Read an array of k-grid fields from an input stream. | |
void | readFieldsKGrid (std::string filename, DArray< KFT > &fields, UnitCell< D > &unitCell) const |
Read an array of k-grid fields from a named file. | |
virtual void | writeFieldsKGrid (std::ostream &out, DArray< KFT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const =0 |
Write an array of k-grid fields to a output stream. | |
void | writeFieldsKGrid (std::string filename, DArray< KFT > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write an array of k-grid fields to a named file. | |
Field Array Format Conversion | |
virtual void | convertBasisToKGrid (DArray< double > const &components, KFT &dft) const =0 |
Convert a single field from basis to Fourier (k-grid) form. | |
void | convertBasisToKGrid (DArray< DArray< double > > const &in, DArray< KFT > &out) const |
Convert an array of fields from basis to Fourier (k-grid) form. | |
virtual void | convertKGridToBasis (KFT const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const =0 |
Convert a single field from Fourier (k-grid) to basis form. | |
void | convertKGridToBasis (DArray< KFT > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert an array of fields from Fourier (k-grid) to basis form. | |
void | convertBasisToRGrid (DArray< double > const &in, RFT &out) const |
Convert a single field from basis to r-grid format. | |
void | convertBasisToRGrid (DArray< DArray< double > > const &in, DArray< RFT > &out) const |
Convert an array of fields from basis to r-grid format. | |
void | convertRGridToBasis (RFT const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert a single field from r-grid to basis form. | |
void | convertRGridToBasis (DArray< RFT > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert an array of fields from r-grid to basis format. | |
void | convertKGridToRGrid (DArray< KFT > const &in, DArray< RFT > &out) const |
Convert an array of field from k-grid to r-grid format. | |
void | convertKGridToRGrid (KFT const &in, RFT &out) const |
Convert a single field from k-grid to r-grid format. | |
void | convertRGridToKGrid (DArray< RFT > const &in, DArray< KFT > &out) const |
Convert an array of fields from r-grid to k-grid (Fourier) format. | |
void | convertRGridToKGrid (RFT const &in, KFT &out) const |
Convert a field from r-grid to k-grid (Fourier) format. | |
Field File Format Conversion | |
void | convertBasisToRGrid (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from basis format to r-grid format. | |
void | convertRGridToBasis (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from r-grid to basis format. | |
void | convertKGridToRGrid (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from Fourier (k-grid) to r-grid format. | |
void | convertRGridToKGrid (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from r-grid to Fourier (k-grid) format. | |
void | convertKGridToBasis (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from Fourier (k-grid) to basis format. | |
void | convertBasisToKGrid (std::string const &inFileName, std::string const &outFileName) const |
Convert a field file from basis to Fourier (k-grid) format. | |
Test Space Group Symmetry | |
virtual bool | hasSymmetry (KFT const &in, double epsilon=1.0e-8, bool verbose=true) const =0 |
Check if a k-grid field has the declared space group symmetry. | |
bool | hasSymmetry (RFT const &in, double epsilon=1.0e-8, bool verbose=true) const |
Check if an r-grid field has the declared space group symmetry. | |
bool | hasSymmetry (std::string const &inFileName, double epsilon=1.0E-8) const |
Check if an r-grid field file has declared space group symmetry. | |
Test Field Equality | |
void | compareFieldsBasis (DArray< DArray< double > > const &field1, DArray< DArray< double > > const &field2) const |
Compare array of fields in basis form, write a report to Log file. | |
void | compareFieldsBasis (std::string const &filename1, std::string const &filename2) const |
Compare two r-grid field files, write a report to Log file. | |
virtual void | compareFieldsRGrid (DArray< RFT > const &field1, DArray< RFT > const &field2) const =0 |
Compare two fields in r-grid form, write a report to Log file. | |
void | compareFieldsRGrid (std::string const &filename1, std::string const &filename2) const |
Compare two r-grid field files, write a report to Log file. | |
Field Scaling (Multiplication by a Scalar) | |
virtual void | scaleFieldBasis (DArray< double > &field, double factor) const |
Multiply a single field in basis form by a real scalar. | |
void | scaleFieldsBasis (DArray< DArray< double > > &fields, double factor) const |
Multiply an array of fields in basis format by a real scalar. | |
void | scaleFieldsBasis (std::string const &inFileName, std::string const &outFileName, double factor) const |
Multiply all fields in a basis field file by a scalar. | |
virtual void | scaleFieldRGrid (RFT &field, double factor) const =0 |
Multiply a single field in r-grid format by a scalar. | |
void | scaleFieldsRGrid (DArray< RFT > &fields, double factor) const |
Scale an array of r-grid fields by a scalar. | |
void | scaleFieldsRGrid (std::string const &inFileName, const std::string &outFileName, double factor) const |
Multiply all fields in an r-grid field file by a scalar. | |
Computing Estimated W Fields | |
void | estimateWBasis (DMatrix< double > const &chi, DArray< DArray< double > > &fields) const |
Convert c fields to estimated w fields, in basis format. | |
void | estimateWBasis (std::string const &inFileName, std::string const &outFileName, DMatrix< double > const &chi) const |
Convert a file of c fields to estimated w fields, in basis format. | |
Replicate Unit Cell | |
virtual void | replicateUnitCell (std::ostream &out, DArray< RFT > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const =0 |
Write r-grid fields in a replicated unit cell to std::ostream. | |
void | replicateUnitCell (std::string filename, DArray< RFT > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const |
Write r-grid fields in a replicated unit cell to a named file. | |
void | replicateUnitCell (std::string const &inFileName, std::string const &outFileName, IntVec< D > const &replicas) const |
Write replicated fields read from one file to another. | |
Expand Spatial Dimension | |
virtual void | expandRGridDimension (std::ostream &out, DArray< RFT > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const =0 |
Increase D for an array of r-grid fields, write to ostream. | |
void | expandRGridDimension (std::string filename, DArray< RFT > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > newGridDimensions) const |
Increase D for an array of r-grid fields, write to a named file. | |
void | expandRGridDimension (std::string const &inFileName, std::string const &outFileName, int d, DArray< int > newGridDimensions) const |
Increase D for an r-grid field 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). | |
Accessor functions (const references) | |
Mesh< D > const & | mesh () const |
Get spatial discretization mesh 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. |
Protected Member Functions | |
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 an associated group name string by const reference. | |
SpaceGroup< D > const & | group () const |
Get an associated SpaceGroup<D> by const reference. | |
FFT const & | fft () const |
Get FFT object by const reference. | |
void | checkAllocateRGrid () const |
Check if r-grid workspace is allocated, allocate if necessary. | |
void | checkAllocateKGrid () const |
Check if k-grid workspace is allocated, allocate if necessary. | |
void | checkAllocateBasis (std::string const &inFileName) const |
Check if basis workspace is allocated, allocate if necessary. |
File input/output, format conversions and other utilities for fields.
This class template provides functions to read and write real-valued fields in any of three representations (symmetry-adapted basis, real-space r-grid, or Fourier space k-grid form), functions to convert among these three representations, and other utilities for manipulating fields and field files.
Template parameters:
Subclasses: The FieldIoReal template is a base class for two class templates named FieldIo that are defined in namespaces Pscf::Rpc and Pscf::Rpg. The Pscf::Rpc::FieldIo<int D> template is derived from a partial specialization of FieldIoReal with parameters RFT = Cpu::RField<D>, KFT = Cpu::RFieldDft<D>, and FFT = Cpu::FFT<D> that are all defined in the Prdc::Cpu namespace, and that all use standard CPU hardware. The analogous template Rpg::Field<int D> in the Pscf::Rpg namespace is derived from a partial specialization of FieldIoReal in which these three parameters are class templates with the same names (RField, RFieldDft, and FFT) that are defined in the Prdc::Cuda namespace, and that all use a GPU.
Basis construction as side effect of reading field files: Every member function that reads fields from a file may construct a symmetry adapted basis in an associated Basis<D> object as a side effect of reading a field file header. All such functions call the member function readFieldHeader to read the field file header. If a space group was declared in the parameter file, but the symmetry-adapted basis has not been initialized before reading a field file header, then the readFieldHeader function will initialize the associated Basis<D> object using the unit cell parameters found in the field file header.
Pure virtual member functions : This class template defines several pure virtual functions for which different implementations are required for Cpu and Cuda code. Cpu and Cuda implementations of these functions, which are defined in the Rpc::FieldIo<D> and Rpg::FieldIo<D> subclasses, differ because the Cuda versions must explicitly transfer data between Cpu and Gpu memory.
Definition at line 85 of file FieldIoReal.h.
Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::FieldIoReal | ( | ) |
Constructor.
Definition at line 46 of file FieldIoReal.tpp.
|
virtual |
Destructor.
Definition at line 64 of file FieldIoReal.tpp.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::associate | ( | Mesh< D > const & | mesh, |
FFT const & | fft, | ||
typename UnitCell< D >::LatticeSystem const & | lattice, | ||
bool const & | hasGroup, | ||
std::string const & | groupName, | ||
SpaceGroup< D > const & | group, | ||
Basis< D > & | basis ) |
Create associations with other members of the parent Domain.
This function may be called within the constructor of the Domain object, since addresses of other members of the Domain are known at this point.
mesh | associated spatial discretization Mesh<D> |
fft | associated FFT object for fast transforms |
lattice | lattice system type (enumeration value) |
hasGroup | true iff a space group has been declared |
groupName | space group name string |
group | associated SpaceGroup object |
basis | associated Basis object |
Definition at line 74 of file FieldIoReal.tpp.
References basis(), fft(), group(), groupName(), hasGroup(), lattice(), and mesh().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::setFileMaster | ( | FileMaster const & | fileMaster | ) |
Create an association with a FileMaster.
The FileMaster is used to open and close files in all member functions that take file name arguments and that open and close files. This allows prefixes for input and output files (if any) to be automatically prepended to file names.
fileMaster | associated FileMaster (for file paths) |
Definition at line 96 of file FieldIoReal.tpp.
References fileMaster().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::setNMonomer | ( | int | nMonomer | ) |
Set the number of monomer types.
This is used to allocate private arrays of fields used by some functions that read field data into this workspace memory. This function may only be called once, shortly after the value of nMonomer is read from the parameter file.
nMonomer | number of monomer types |
Definition at line 104 of file FieldIoReal.tpp.
References UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsBasis | ( | std::istream & | in, |
DArray< DArray< double > > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read an array of fields in basis format from an input stream.
This function reads fields in a symmetry adapted basis format from input stream in. The header of the field file must declare a group name, and this name must agree with that declared in the parameter file. Upon successful return, element fields[i] of the fields container is a DArray<double> containing the components of the field associated with monomer type i, defined as coefficients of symmetry-adapted basis functions defined by the current basis. If a basis has not been constructed before entry, it will be constructed within this function.
On entry, the fields container must either be allocated with a capacity equal to the number of monomer types in the field file, and a capacity for each field equal to the number of basis functions in the basis, or it may be unallocated. If the fields container is not allocated, it will allocated within this function with these dimensions. The number of monomer types does not need to be equal to the value set by the setNMonomer(int) function.
in | input stream (e.g., input file stream) |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated unit cell object |
Definition at line 119 of file FieldIoReal.tpp.
References basis(), hasGroup(), Pscf::Prdc::inspectArrays(), mesh(), Pscf::Prdc::readBasisData(), Pscf::Prdc::readFieldHeader(), Pscf::Prdc::readNBasis(), and UTIL_CHECK.
Referenced by compareFieldsBasis(), convertBasisToKGrid(), convertBasisToRGrid(), readFieldBasis(), readFieldsBasis(), and scaleFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsBasis | ( | std::string | filename, |
DArray< DArray< double > > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read an array of fields in basis format from a named file.
This function opens an input file with the specified filename, reads an array of fields in symmetry-adapted form from that file, and then closes the file. The overloaded readFieldsBasis member function that takes a std::istream& argument is called internally to read the file.
filename | name of input file |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 247 of file FieldIoReal.tpp.
References fileMaster(), and readFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldBasis | ( | std::istream & | in, |
DArray< double > & | field, | ||
UnitCell< D > & | unitCell ) const |
Read a single field in basis format from an input stream.
This function reads a single field in symmetry adapted basis format from an input stream. Upon successful return, the field array contains the components of a single field, defined as coefficients of symmetry-adapted basis functions. On entry, the field array must either be allocated with a capacity equal to the number of basis functions in the associated basis, or unallocated. If field is unallocated, it will be allocated by this function.
in | input stream (i.e., input file stream) |
field | array to store the field (basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 157 of file FieldIoReal.tpp.
References Util::DArray< Data >::allocate(), basis(), Util::Array< Data >::capacity(), Util::DArray< Data >::isAllocated(), readFieldsBasis(), and UTIL_CHECK.
Referenced by readFieldBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldBasis | ( | std::string | filename, |
DArray< double > & | field, | ||
UnitCell< D > & | unitCell ) const |
Read a single field in basis format from a named file.
This function opens an input file with the specified filename, reads a single field in symmetry adapted basis format from that file, and and then closes the file. The overloaded member function readFieldBasis that takes an std::istream& argument is called internally to read the file.
filename | name of input file |
field | array to store the field (basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 263 of file FieldIoReal.tpp.
References fileMaster(), and readFieldBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsBasis | ( | std::ostream & | out, |
DArray< DArray< double > > const & | fields, | ||
UnitCell< D > const & | unitCell ) const |
Write an array of fields in basis format to an output stream.
This function writes field components in a symmetry adapted basis to an output stream. On entry, the fields array must be allocated, and the capacity of each field must be equal the number of basis functions in the basis.
out | output stream (i.e., output file) |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 190 of file FieldIoReal.tpp.
References basis(), Pscf::Prdc::inspectArrays(), UTIL_CHECK, Pscf::Prdc::writeBasisData(), Pscf::Prdc::writeFieldHeader(), and Pscf::Prdc::writeNBasis().
Referenced by convertKGridToBasis(), convertRGridToBasis(), estimateWBasis(), scaleFieldsBasis(), writeFieldBasis(), and writeFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsBasis | ( | std::string | filename, |
DArray< DArray< double > > const & | fields, | ||
UnitCell< D > const & | unitCell ) const |
Write an array of fields in basis format to a named 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. The overloaded writeFieldsBasis member function that takes a std::ostream& argument is called to write the file.
filename | name of input file |
fields | array of fields (symmetry adapted basis components) |
unitCell | associated crystallographic unit cell |
Definition at line 278 of file FieldIoReal.tpp.
References fileMaster(), and writeFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::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 one field in symmetry adapted basis format. On entry, the field array must be allocated with a capacity equal to the number of basis functions in the basis.
out | output stream (i.e., output file) |
field | field to be written (symmetry adapted basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 218 of file FieldIoReal.tpp.
References Util::DArray< Data >::allocate(), Util::Array< Data >::capacity(), and writeFieldsBasis().
Referenced by writeFieldBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldBasis | ( | std::string | filename, |
DArray< double > const & | field, | ||
UnitCell< D > const & | unitCell ) const |
Write single field in basis format to a named 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. The overloaded writeFieldBasis that takes a std::ostream& argument is called to write the file.
filename | name of output file |
field | field to be written (symmetry adapted basis format) |
unitCell | associated crystallographic unit cell |
Definition at line 293 of file FieldIoReal.tpp.
References fileMaster(), and writeFieldBasis().
|
pure virtual |
Read array of r-grid fields from an input stream.
Upon successful return, element fields[i] of the fields array is the instance of RFT containing the r-grid field associated with monomer type i.
On entry, array fields must either be unallocated or be allocated with capacity equal to the number of monomers in the field file, with mesh dimensions for each field equal to mesh().dimensions(). If it is unallocated, it will be allocated within this function.
in | input stream (i.e., input file) |
fields | array of r-grid fields |
unitCell | associated crystallographic unit cell |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by compareFieldsRGrid(), convertRGridToBasis(), convertRGridToKGrid(), expandRGridDimension(), hasSymmetry(), readFieldsRGrid(), replicateUnitCell(), and scaleFieldsRGrid().
bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsRGrid | ( | std::string | filename, |
DArray< RFT > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read an array of r-grid fields from a named file.
This function opens an input file with the specified filename, reads fields in real-space grid format from that file, and then closes the file. The overloaded readFieldsRGrid member function that takes a std::istream& argument is called to read the file.
filename | name of input file |
fields | array of r-grid fields (instances of RFT) |
unitCell | associated crystallographic unit cell |
Definition at line 308 of file FieldIoReal.tpp.
References fileMaster(), and readFieldsRGrid().
|
pure virtual |
Read data for array of r-grid fields, with no header section.
This function reads the data section of the rgrid-field format, without first reading a header.
On entry, array fields must either be unallocated or be allocated with capacity equal to the number of monomers in the field file, with mesh dimensions for each field equal to mesh().dimensions(). If it is unallocated, it will be allocated within this function.
in | input file stream |
fields | array of r-grid fields (instances of RFT) |
nMonomer | expected number of monomer types (input |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
|
pure virtual |
Read a single r-grid field from an input stream.
On entry, the field must either be unallocated or be allocated with a mesh dimension equal to mesh().dimensions(). If it is unallocated, it will be allocated within this function.
in | input stream (i.e., input file) |
field | single r-grid field (instance of RFT) |
unitCell | associated crystallographic unit cell |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by readFieldRGrid().
bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldRGrid | ( | std::string | filename, |
RFT & | field, | ||
UnitCell< D > & | unitCell ) const |
Read a single r-grid field from a named file.
This function opens an input file with the specified filename, reads a field in real-space grid format from that file, and then closes the file. The overloaded readFieldRGrid member function that takes a std::istream& argument is called to read the file.
filename | name of input file |
field | single field defined on r-space grid |
unitCell | associated crystallographic unit cell |
Definition at line 325 of file FieldIoReal.tpp.
References fileMaster(), and readFieldRGrid().
|
pure virtual |
Write an array of r-grid fields to an output stream.
On entry, the container fields must be allocated, and the mesh dimensions of each field must equal mesh().dimensions(). The writeHeader argument may be set false to completely suppress writing of the file header. The isSymmetric argument is only relevant if writeHeader is true.
out | output stream (i.e., output file) |
fields | array of RField objects (fields on r-space grid) |
unitCell | associated crystallographic unit cell |
writeHeader | iff true, write file header |
isSymmetric | iff true, write space group name |
writeMeshSize | Should mesh size be written at end of header? |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by convertBasisToRGrid(), convertKGridToRGrid(), scaleFieldsRGrid(), and writeFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsRGrid | ( | std::string | filename, |
DArray< RFT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write an array of r-grid fields to a named file.
This function opens a file, writes field file header and data to the file, and closes the file. The overloaded writeFieldsGrid member function that takes a std::ostream& argument is called internally with writeHeader == true to write the data.
filename | name of output file |
fields | array of RFT objects (fields on r-space grid) |
unitCell | associated crystallographic unit cell |
isSymmetric | iff true, write space group name |
Definition at line 342 of file FieldIoReal.tpp.
References fileMaster(), and writeFieldsRGrid().
|
pure virtual |
Write a single r-grid field to an an output stream.
On entry, the field container must be allocated with mesh dimensions equal to mesh().dimensions(). The writeHeader argument may be set false to suppress writing of the file header.
out | output stream |
field | field defined on r-space grid |
unitCell | associated crystallographic unit cell |
writeHeader | should a file header be written? |
isSymmetric | iff true, write space group name |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by writeFieldRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldRGrid | ( | std::string | filename, |
RFT const & | field, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write a single r-grid field to a named file.
This function opens a file, writes the header and data for a single field to the file, and closes that file. The overloaded writeFieldGrid member function that takes a std::ostream& argument is called internally with writeHeader == true to write the file.
filename | name of output file |
field | field defined on r-space grid |
unitCell | associated crystallographic unit cell |
isSymmetric | iff true, write space group name |
Definition at line 361 of file FieldIoReal.tpp.
References fileMaster(), and writeFieldRGrid().
|
pure virtual |
Read an array of k-grid fields from an input stream.
Upon successful return, element fields[i] of the fields array is the instance of KFT containing the DFT of a real field associated with monomer type i.
On entry, array fields must either be unallocated or be allocated with capacity equal to the number of monomers in the field file, with mesh dimensions for each field equal to mesh().dimensions(). If it is unallocated, it will be allocated within this function.
in | input stream (i.e., input file) |
fields | array of KFT fields (k-space grid) |
unitCell | associated crystallographic unit cell |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by convertKGridToBasis(), convertKGridToRGrid(), and readFieldsKGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsKGrid | ( | std::string | filename, |
DArray< KFT > & | fields, | ||
UnitCell< D > & | unitCell ) const |
Read an array of k-grid fields from a named file.
This function opens a file with name filename, reads discrete Fourier components (Dft) of fields from that file, and closes the file. The overloaded readFieldsKGrid member function that takes a std::istream& argument is called to read the file.
filename | name of input file |
fields | array of k-space (KFT) fields |
unitCell | associated crystallographic unit cell |
Definition at line 377 of file FieldIoReal.tpp.
References fileMaster(), and readFieldsKGrid().
|
pure virtual |
Write an array of k-grid fields to a output stream.
On entry, the container fields must be allocated, and the mesh dimensions of each field must equal mesh().dimensions(). Element fields[i] contains the DFT of the field associated with monomer type i.
out | output stream (i.e., output file) |
fields | array of k-grid fields (instances of KFT) |
unitCell | associated crystallographic unit cell |
isSymmetric | iff true, write space group name |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by convertBasisToKGrid(), convertRGridToKGrid(), and writeFieldsKGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsKGrid | ( | std::string | filename, |
DArray< KFT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
bool | isSymmetric = true ) const |
Write an array of k-grid fields to a named 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 Fourier-grid fields (instances of KFT) |
unitCell | associated crystallographic unit cell |
isSymmetric | iff true, write space group name |
Definition at line 392 of file FieldIoReal.tpp.
References fileMaster(), and writeFieldsKGrid().
|
pure virtual |
Convert a single field from basis to Fourier (k-grid) form.
components | components in symmetry-adapted basis format |
dft | discrete Fourier transform of a real field |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToKGrid | ( | DArray< DArray< double > > const & | in, |
DArray< KFT > & | out ) const |
Convert an array of fields from basis to Fourier (k-grid) form.
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 410 of file FieldIoReal.tpp.
References basis(), Pscf::Prdc::convertBasisToKGrid(), Pscf::Prdc::inspectArrays(), Pscf::Prdc::inspectFields(), mesh(), and UTIL_CHECK.
|
pure virtual |
Convert a single field from Fourier (k-grid) to 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.
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) |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToBasis | ( | DArray< KFT > const & | in, |
DArray< DArray< double > > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert an array of fields from Fourier (k-grid) to basis form.
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 433 of file FieldIoReal.tpp.
References Pscf::Prdc::convertKGridToBasis(), Pscf::Prdc::inspectArrays(), Pscf::Prdc::inspectFields(), and UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToRGrid | ( | DArray< double > const & | in, |
RFT & | out ) const |
Convert a single field from basis to r-grid format.
in | field in symmetry-adapted basis form |
out | field defined on real-space grid |
Definition at line 490 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), Pscf::Prdc::convertBasisToKGrid(), fft(), Util::DArray< Data >::isAllocated(), mesh(), and UTIL_CHECK.
Referenced by convertBasisToRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToRGrid | ( | DArray< DArray< double > > const & | in, |
DArray< RFT > & | out ) const |
Convert an array of fields from basis to r-grid format.
in | fields in symmetry adapted basis form |
out | fields defined on real-space grid |
Definition at line 505 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), Pscf::Prdc::checkAllocateField(), Pscf::Prdc::convertBasisToKGrid(), fft(), Util::DArray< Data >::isAllocated(), mesh(), and UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToBasis | ( | RFT const & | in, |
DArray< double > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert a single field from r-grid to basis form.
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 525 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), Pscf::Prdc::convertKGridToBasis(), fft(), and mesh().
Referenced by convertRGridToBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToBasis | ( | DArray< RFT > const & | in, |
DArray< DArray< double > > & | out, | ||
bool | checkSymmetry = true, | ||
double | epsilon = 1.0e-8 ) const |
Convert an array of fields from r-grid to basis format.
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 540 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), Pscf::Prdc::convertKGridToBasis(), fft(), Pscf::Prdc::inspectArrays(), Pscf::Prdc::inspectFields(), mesh(), and UTIL_CHECK.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToRGrid | ( | DArray< KFT > const & | in, |
DArray< RFT > & | out ) const |
Convert an array of field from k-grid to r-grid format.
This function simply calls the inverse FFT for an array of fields.
in | fields in discrete Fourier format (k-grid) |
out | fields defined on real-space grid (r-grid) |
Definition at line 601 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), fft(), and UTIL_ASSERT.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToRGrid | ( | KFT const & | in, |
RFT & | out ) const |
Convert a single field from k-grid to r-grid format.
This function simply calls the inverse FFT for a single field.
in | field in discrete Fourier format (k-grid) |
out | field defined on real-space grid (r-grid) |
Definition at line 616 of file FieldIoReal.tpp.
References fft().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToKGrid | ( | DArray< RFT > const & | in, |
DArray< KFT > & | out ) const |
Convert an array of fields from r-grid to k-grid (Fourier) format.
This function simply calls the forward FFT repeatedly for an array of fields.
in | fields defined on real-space grid (r-grid) |
out | fields in discrete Fourier format (k-grid) |
Definition at line 626 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), fft(), and UTIL_ASSERT.
Referenced by convertRGridToKGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToKGrid | ( | RFT const & | in, |
KFT & | out ) const |
Convert a field from r-grid to k-grid (Fourier) format.
This function simply calls the forward FFT for a single field.
in | field defined on real-space grid (r-grid) |
out | field in discrete Fourier format (k-grid) |
Definition at line 641 of file FieldIoReal.tpp.
References fft().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToRGrid | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from basis format to r-grid format.
This function reads a field file in basis format, converts the fields to r-grid format, and writes the fields in r-grid format to a different file.
This and other field file format conversion functions read field data into private workspace in which memory is allocated for nMonomer fields, where nMonomer is the value set by the setNMonomer(int i) member function. The number of monomer types in the input file must thus be equal to this stored value of nMonomer.
inFileName | name of input file (basis format) |
outFileName | name of output file (r-grid format) |
Definition at line 566 of file FieldIoReal.tpp.
References checkAllocateBasis(), checkAllocateRGrid(), convertBasisToRGrid(), readFieldsBasis(), and writeFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToBasis | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from r-grid to basis format.
The number of monomers in the input file must equal the number set by the setNMonomer(int) member function.
This function checks if the input fields have the declared space group symmetry, and prints a warning if it detects deviations that exceed some small threshhold, but proceeds to attempt the conversion even if such an error is detected. Converting a field that does not have the declared space group symmetry to basis format is a destructive operation that modifies the field in unpredictable ways.
inFileName | name of input file (r-grid format) |
outFileName | name of output file (basis format) |
Definition at line 583 of file FieldIoReal.tpp.
References checkAllocateBasis(), checkAllocateRGrid(), convertRGridToBasis(), readFieldsRGrid(), and writeFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToRGrid | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from Fourier (k-grid) to r-grid format.
The number of monomers in the input file must equal the number set by the setNMonomer(int) member function.
inFileName | name of input file (k-grid format) |
outFileName | name of output file (r-grid format) |
Definition at line 650 of file FieldIoReal.tpp.
References checkAllocateKGrid(), checkAllocateRGrid(), fft(), readFieldsKGrid(), and writeFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertRGridToKGrid | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from r-grid to Fourier (k-grid) format.
The number of monomers in the input file must equal the number set by the setNMonomer(int) member function.
inFileName | name of input file (r-grid format) |
outFileName | name of output file (k-grid format) |
Definition at line 669 of file FieldIoReal.tpp.
References checkAllocateKGrid(), checkAllocateRGrid(), convertRGridToKGrid(), readFieldsRGrid(), and writeFieldsKGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToBasis | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from Fourier (k-grid) to basis format.
The number of monomers in the input file must equal the number set by the setNMonomer(int) member function.
This function checks if the input fields have the declared space group symmetry, and prints a warning if it detects deviations that exceed some small threshhold, but proceeds to attempt the conversion even if such an error is detected. Converting a field that does not have the declared space group symmetry to basis format is a destructive operation that modifies the field in unpredictable ways.
inFileName | name of input file (k-grid format) |
outFileName | name of output file (basis format) |
Definition at line 456 of file FieldIoReal.tpp.
References checkAllocateBasis(), checkAllocateKGrid(), Pscf::Prdc::convertKGridToBasis(), readFieldsKGrid(), and writeFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToKGrid | ( | std::string const & | inFileName, |
std::string const & | outFileName ) const |
Convert a field file from basis to Fourier (k-grid) format.
The number of monomers in the input file must equal the number set by the setNMonomer(int) member function.
inFileName | name of input file (basis format) |
outFileName | name of output file (k-grid format) |
Definition at line 472 of file FieldIoReal.tpp.
References checkAllocateBasis(), checkAllocateKGrid(), Pscf::Prdc::convertBasisToKGrid(), readFieldsBasis(), and writeFieldsKGrid().
|
pure 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 is invariant under all the symmetry operations of a declared space group to within an specfiied 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().
in | field in real space grid (r-grid) format |
epsilon | error threshold used to test for symmetry |
verbose | if true, write any error to Log::file() |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::hasSymmetry | ( | RFT 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 is invariant under all the symmetry operations of a declared space group to within an error threshhold given by function 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 689 of file FieldIoReal.tpp.
References Pscf::Prdc::checkAllocateField(), fft(), Pscf::Prdc::hasSymmetry(), and mesh().
bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::hasSymmetry | ( | std::string const & | inFileName, |
double | epsilon = 1.0E-8 ) const |
Check if an r-grid field file has declared space group symmetry.
inFileName | name of input r-grid field file |
epsilon | error threshold used when testing for symmetry |
Definition at line 703 of file FieldIoReal.tpp.
References checkAllocateRGrid(), Pscf::Prdc::hasSymmetry(), and readFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::compareFieldsBasis | ( | DArray< DArray< double > > const & | field1, |
DArray< DArray< double > > const & | field2 ) const |
Compare array of fields in basis form, write a report to Log file.
Outputs maximum and root-mean-squared differences to the standard Log file.
field1 | first array of fields (basis form) |
field2 | second array of fields (basis form) |
Definition at line 728 of file FieldIoReal.tpp.
References Pscf::FieldComparison< FT >::compare(), Util::Log::file(), Pscf::FieldComparison< FT >::maxDiff(), and Pscf::FieldComparison< FT >::rmsDiff().
Referenced by compareFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::compareFieldsBasis | ( | std::string const & | filename1, |
std::string const & | filename2 ) const |
Compare two r-grid field files, write a report to Log file.
filename1 | name of 1st field file |
filename2 | name of 2nd field file |
Definition at line 744 of file FieldIoReal.tpp.
References compareFieldsBasis(), and readFieldsBasis().
|
pure virtual |
Compare two fields in r-grid form, write a report to Log file.
Outputs maximum and root-mean-squared differences to the standard Log file.
field1 | first array of fields (r-grid form) |
field2 | second array of fields (r-grid form) |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by compareFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::compareFieldsRGrid | ( | std::string const & | filename1, |
std::string const & | filename2 ) const |
Compare two r-grid field files, write a report to Log file.
filename1 | name of 1st field file |
filename2 | name of 2nd field file |
Definition at line 757 of file FieldIoReal.tpp.
References compareFieldsRGrid(), and readFieldsRGrid().
|
virtual |
Multiply a single field in basis form 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 (in/out) |
factor | factor by which to multiply every field element |
Definition at line 775 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), Util::DArray< Data >::isAllocated(), and UTIL_CHECK.
Referenced by scaleFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldsBasis | ( | DArray< DArray< double > > & | fields, |
double | factor ) const |
Multiply 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 790 of file FieldIoReal.tpp.
References scaleFieldBasis(), and UTIL_CHECK.
Referenced by scaleFieldsBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldsBasis | ( | std::string const & | inFileName, |
std::string const & | outFileName, | ||
double | factor ) const |
Multiply all fields in a basis field file by a scalar.
inFileName | name of input field file |
outFileName | name of file for rescaled output fields |
factor | factor by which to multiply every field element |
Definition at line 807 of file FieldIoReal.tpp.
References checkAllocateBasis(), readFieldsBasis(), scaleFieldsBasis(), and writeFieldsBasis().
|
pure virtual |
Multiply a single field in r-grid format by a 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 | field in r-grid (RFT) form to be rescaled |
factor | factor by which to multiply every field element |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
Referenced by scaleFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldsRGrid | ( | DArray< RFT > & | fields, |
double | factor ) const |
Scale an array of r-grid fields by a 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 r-grid (RFT) fields to be rescaled |
factor | factor by which to multiply every field element |
Definition at line 823 of file FieldIoReal.tpp.
References Util::Array< Data >::capacity(), and scaleFieldRGrid().
Referenced by scaleFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldsRGrid | ( | std::string const & | inFileName, |
const std::string & | outFileName, | ||
double | factor ) const |
Multiply all fields in an r-grid field file by a scalar.
Read a set of fields from a file, multiply fields by a constant, and write rescaled fields to a different file.
inFileName | name of input field file |
outFileName | name of file for rescaled output fields |
factor | factor by which to multiply all field elements |
Definition at line 837 of file FieldIoReal.tpp.
References checkAllocateRGrid(), readFieldsRGrid(), scaleFieldsRGrid(), and writeFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::estimateWBasis | ( | DMatrix< double > const & | chi, |
DArray< DArray< double > > & | fields ) const |
Convert c fields to estimated w fields, in basis format.
This function converts an array of c-fields in place to an array of estimated w fields. The approximation starts from the SCFT equation
\[ w_{i}({\bf r}) = \sum_{j=1}^{M} \chi_{ij} \phi_{j}({\bf r}) + \xi({\bf r}) \]
in which \(\xi({\bf r})\) is a pressure like field, and simply sets \( \xi({\bf r}) = 0 \) for all \( {\bf r} \). Here, \( M \) is the number of monomer types (nMonomer), i and j are monomer type indices, \(\chi_{ij}\) is a Flory-Huggins interaction parameter, \( \phi_{j} \) is a non-dimensiona monomer concentration (or volume fraction) field (which is an input to this function), and \( w_{i}\) is a monomer chemical potential field.
chi | matrix of Flory-Huggins chi parameters |
fields | array of field in basis format |
Definition at line 858 of file FieldIoReal.tpp.
References Util::DArray< Data >::allocate(), Util::Matrix< Data >::capacity1(), Util::Matrix< Data >::capacity2(), and UTIL_CHECK.
Referenced by estimateWBasis().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::estimateWBasis | ( | std::string const & | inFileName, |
std::string const & | outFileName, | ||
DMatrix< double > const & | chi ) const |
Convert a file of c fields to estimated w fields, in basis format.
This function reads an array of monomer concentration fields (c-fields) in basis format from a file named inFileName, converts them to estimated w fields, and writes the estimated w fields to a file named outFileName.
inFileName | name of input file of c-fields |
outFileName | name of output file of w-fields |
chi | matrix of Flory-Huggins chi parameters |
Definition at line 895 of file FieldIoReal.tpp.
References basis(), Util::Matrix< Data >::capacity1(), Util::Matrix< Data >::capacity2(), checkAllocateBasis(), estimateWBasis(), fileMaster(), mesh(), Pscf::Prdc::readBasisData(), Pscf::Prdc::readFieldHeader(), Pscf::Prdc::readNBasis(), UTIL_CHECK, and writeFieldsBasis().
|
pure 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.
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 |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::replicateUnitCell | ( | std::string | filename, |
DArray< RFT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
IntVec< D > const & | replicas ) const |
Write r-grid fields in a replicated unit cell to a 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 944 of file FieldIoReal.tpp.
References fileMaster(), and Pscf::Prdc::replicateUnitCell().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::replicateUnitCell | ( | std::string const & | inFileName, |
std::string const & | outFileName, | ||
IntVec< D > const & | replicas ) const |
Write replicated fields read from one file to another.
This function reads a field file in r-grid format, and writes replicated fields to another file.
inFileName | name of input field file |
outFileName | name of output field file |
replicas | the number of replicas in each D direction |
Definition at line 960 of file FieldIoReal.tpp.
References checkAllocateRGrid(), readFieldsRGrid(), and Pscf::Prdc::replicateUnitCell().
|
pure virtual |
Increase D for an array of r-grid fields, write to ostream.
This function is used for spatial dimension D < 3, and allows a 1D or 2D field to be transformed into a field defined in a higher dimension (2D or 3D) space in which field values are indepedendent of the values of coordinates associated with the added dimensions. For example, when invoked with D=1, it can transform a lamellar field computed with D=1 to a lamellar field defined on a 3D grid (d=3), written in a format that can be read by pscf_pc when invoked with D=3.
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 |
Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::expandRGridDimension | ( | std::string | filename, |
DArray< RFT > const & | fields, | ||
UnitCell< D > const & | unitCell, | ||
int | d, | ||
DArray< int > | newGridDimensions ) const |
Increase D for an array of r-grid fields, write to a named 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 an std::ostream parameter is called internally.
filename | name of output file |
fields | input array of RFT 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 976 of file FieldIoReal.tpp.
References Pscf::Prdc::expandRGridDimension(), and fileMaster().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::expandRGridDimension | ( | std::string const & | inFileName, |
std::string const & | outFileName, | ||
int | d, | ||
DArray< int > | newGridDimensions ) const |
Increase D for an r-grid field file.
This function reads an array of fields in D-dimensional space from an r-grid field file and writes expanded fields in d-dimensional space to another file.
inFileName | filename name of input field file |
outFileName | filename name of output field file |
d | intended dimensions (d > D) |
newGridDimensions | number of grid points in added dimensions |
Definition at line 992 of file FieldIoReal.tpp.
References checkAllocateRGrid(), Pscf::Prdc::expandRGridDimension(), and readFieldsRGrid().
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::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 PSCF 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 used to update a UnitCell<D> that is passed as a parameter.
If a space group was declared 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 may thus modify the associated Basis object as a side effect (even though this function is marked const). Because all member functions that read complete field files call this function to read the file header, any member function of FieldIo that reads a field file header may thus cause the Basis to be constructed as a side effect.
On return, parameter nMonomer contains the number of monomer types declared in the field file header. This function does not require the number of monomers declared in the field file header to match the value of nMonomer set by the setNMonomer member function.
On return, isSymmetric is set true iff a group name was found in the header.
Consistency checks (Exceptions thrown on failure):
The value of "dim" in the header file must match the template parameter D. 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.
If the header declares a group name, then a matching group name must have been declared in the parameter file.
in | input stream (i.e., file) |
nMonomer | number of monomer types in the header (output) |
unitCell | associated crystallographic unit cell (output) |
isSymmetric | Is there a group name in the header? (output) |
Definition at line 1018 of file FieldIoReal.tpp.
References basis(), Util::Log::file(), group(), groupName(), hasGroup(), Pscf::Prdc::UnitCellBase< D >::isInitialized(), lattice(), mesh(), Pscf::Prdc::UnitCellBase< D >::nParameter(), Pscf::Prdc::readFieldHeader(), UTIL_CHECK, and UTIL_THROW.
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::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., file) |
nMonomer | number of monomer types or fields |
unitCell | associated crystallographic unit cell |
isSymmetric | Should a space group be declared? |
Definition at line 1104 of file FieldIoReal.tpp.
References groupName(), hasGroup(), UTIL_CHECK, and Pscf::Prdc::writeFieldHeader().
|
inline |
Get spatial discretization mesh by const reference.
Definition at line 1251 of file FieldIoReal.h.
Referenced by associate(), checkAllocateKGrid(), checkAllocateRGrid(), convertBasisToKGrid(), convertBasisToRGrid(), convertBasisToRGrid(), convertRGridToBasis(), convertRGridToBasis(), estimateWBasis(), hasSymmetry(), readFieldHeader(), and readFieldsBasis().
|
inline |
Get the associated Basis by const reference.
Definition at line 1260 of file FieldIoReal.h.
Referenced by associate(), checkAllocateBasis(), convertBasisToKGrid(), estimateWBasis(), readFieldBasis(), readFieldHeader(), readFieldsBasis(), and writeFieldsBasis().
|
inline |
Get associated FileMaster by const reference.
Definition at line 1269 of file FieldIoReal.h.
Referenced by checkAllocateBasis(), estimateWBasis(), expandRGridDimension(), readFieldBasis(), readFieldRGrid(), readFieldsBasis(), readFieldsKGrid(), readFieldsRGrid(), replicateUnitCell(), setFileMaster(), writeFieldBasis(), writeFieldRGrid(), writeFieldsBasis(), writeFieldsKGrid(), and writeFieldsRGrid().
|
inlineprotected |
Get the lattice type enum value by const reference.
Definition at line 1282 of file FieldIoReal.h.
Referenced by associate(), and readFieldHeader().
|
inlineprotected |
Has a space group been declared externally ?
Definition at line 1291 of file FieldIoReal.h.
Referenced by associate(), checkAllocateBasis(), readFieldHeader(), readFieldsBasis(), and writeFieldHeader().
|
inlineprotected |
Get an associated group name string by const reference.
Definition at line 1300 of file FieldIoReal.h.
Referenced by associate(), readFieldHeader(), and writeFieldHeader().
|
inlineprotected |
Get an associated SpaceGroup<D> by const reference.
Definition at line 1309 of file FieldIoReal.h.
Referenced by associate(), and readFieldHeader().
|
inlineprotected |
Get FFT object by const reference.
Definition at line 1318 of file FieldIoReal.h.
Referenced by associate(), convertBasisToRGrid(), convertBasisToRGrid(), convertKGridToRGrid(), convertKGridToRGrid(), convertKGridToRGrid(), convertRGridToBasis(), convertRGridToBasis(), convertRGridToKGrid(), convertRGridToKGrid(), and hasSymmetry().
|
protected |
Check if r-grid workspace is allocated, allocate if necessary.
Definition at line 1128 of file FieldIoReal.tpp.
References mesh(), and UTIL_CHECK.
Referenced by convertBasisToRGrid(), convertKGridToRGrid(), convertRGridToBasis(), convertRGridToKGrid(), expandRGridDimension(), hasSymmetry(), replicateUnitCell(), and scaleFieldsRGrid().
|
protected |
Check if k-grid workspace is allocated, allocate if necessary.
Definition at line 1146 of file FieldIoReal.tpp.
References mesh(), and UTIL_CHECK.
Referenced by convertBasisToKGrid(), convertKGridToBasis(), convertKGridToRGrid(), and convertRGridToKGrid().
|
protected |
Check if basis workspace is allocated, allocate if necessary.
If the basis is not initialized, this function peeks at the header of the field file to initialize it, and thus obtain the number of basis functions.
inFileName | name of field file |
Definition at line 1165 of file FieldIoReal.tpp.
References Util::DArray< Data >::allocate(), basis(), fileMaster(), hasGroup(), Pscf::Prdc::readFieldHeader(), and UTIL_CHECK.
Referenced by convertBasisToKGrid(), convertBasisToRGrid(), convertKGridToBasis(), convertRGridToBasis(), estimateWBasis(), and scaleFieldsBasis().