|
PSCF v1.5.0
|
File input/output, format conversions and other utilities for fields. More...
#include <FieldIo.h>
Public Member Functions | |
Construction, Destruction and Initialization | |
| FieldIo () | |
| Constructor. | |
| virtual | ~FieldIo ()=default |
| Destructor. | |
| void | associate (Mesh< D > const &mesh, FFT< D, T > 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< RField< D, T > > &fields, UnitCell< D > &unitCell) const |
| Read array of r-grid fields from an input stream. | |
| bool | readFieldsRGrid (std::string filename, DArray< RField< D, T > > &fields, UnitCell< D > &unitCell) const |
| Read an array of r-grid fields from a named file. | |
| virtual void | readFieldsRGridData (std::istream &in, DArray< RField< D, T > > &fields, int nMonomer) const |
| Read data for array of r-grid fields, with no header section. | |
| virtual bool | readFieldRGrid (std::istream &in, RField< D, T > &field, UnitCell< D > &unitCell) const |
| Read a single r-grid field from an input stream. | |
| bool | readFieldRGrid (std::string filename, RField< D, T > &field, UnitCell< D > &unitCell) const |
| Read a single r-grid field from a named file. | |
| virtual void | writeFieldsRGrid (std::ostream &out, DArray< RField< D, T > > const &fields, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true, bool writeMeshSize=true) const |
| Write an array of r-grid fields to an output stream. | |
| void | writeFieldsRGrid (std::string filename, DArray< RField< D, T > > 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, RField< D, T > const &field, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true) const |
| Write a single r-grid field to an an output stream. | |
| void | writeFieldRGrid (std::string filename, RField< D, T > 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 bool | readFieldsKGrid (std::istream &in, DArray< RFieldDft< D, T > > &fields, UnitCell< D > &unitCell) const |
| Read an array of k-grid fields from an input stream. | |
| bool | readFieldsKGrid (std::string filename, DArray< RFieldDft< D, T > > &fields, UnitCell< D > &unitCell) const |
| Read an array of k-grid fields from a named file. | |
| virtual void | writeFieldsKGrid (std::ostream &out, DArray< RFieldDft< D, T > > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
| Write an array of k-grid fields to a output stream. | |
| void | writeFieldsKGrid (std::string filename, DArray< RFieldDft< D, T > > 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, RFieldDft< D, T > &dft) const |
| Convert a single field from basis to Fourier (k-grid) form. | |
| void | convertBasisToKGrid (DArray< DArray< double > > const &in, DArray< RFieldDft< D, T > > &out) const |
| Convert an array of fields from basis to Fourier (k-grid) form. | |
| virtual void | convertKGridToBasis (RFieldDft< D, T > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
| Convert a single field from Fourier (k-grid) to basis form. | |
| void | convertKGridToBasis (DArray< RFieldDft< D, T > > 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, RField< D, T > &out) const |
| Convert a single field from basis to r-grid format. | |
| void | convertBasisToRGrid (DArray< DArray< double > > const &in, DArray< RField< D, T > > &out) const |
| Convert an array of fields from basis to r-grid format. | |
| void | convertRGridToBasis (RField< D, T > 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< RField< D, T > > 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< RFieldDft< D, T > > const &in, DArray< RField< D, T > > &out) const |
| Convert an array of field from k-grid to r-grid format. | |
| void | convertKGridToRGrid (RFieldDft< D, T > const &in, RField< D, T > &out) const |
| Convert a single field from k-grid to r-grid format. | |
| void | convertRGridToKGrid (DArray< RField< D, T > > const &in, DArray< RFieldDft< D, T > > &out) const |
| Convert an array of fields from r-grid to k-grid (Fourier) format. | |
| void | convertRGridToKGrid (RField< D, T > const &in, RFieldDft< D, T > &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 (RFieldDft< D, T > 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 (RField< D, T > 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< RField< D, T > > const &field1, DArray< RField< D, T > > const &field2) const |
| 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. | |
| void | scaleFieldRGrid (RField< D, T > &field, double factor) const |
| Multiply a single field in r-grid format by a scalar. | |
| void | scaleFieldsRGrid (DArray< RField< D, T > > &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. | |
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< RField< D, T > > 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< RField< D, T > > 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< RField< D, T > > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const |
| Increase D for an array of r-grid fields, write to ostream. | |
| void | expandRGridDimension (std::string filename, DArray< RField< D, T > > 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). | |
Accessors for associated objects (const references) | |
| Mesh< D > const & | mesh () const |
| Get the associated spatial discretization mesh by const reference. | |
| Basis< D > const & | basis () const |
| Get the associated Basis by const reference. | |
| FileMaster const & | fileMaster () const |
| Get the associated FileMaster by const reference. | |
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. Functions that provide these services are all declared const., and can thus be accessed via a const reference to a FieldIo object.
Template parameters:
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 is declared in the parameter file, but the symmetry-adapted basis has not yet been initialized, then the readFieldHeader function will initialize the associated Basis<D> object using the unit cell parameters found in the field file header.
Definition at line 66 of file rp/field/FieldIo.h.
| Pscf::Rp::FieldIo< D, T >::FieldIo | ( | ) |
Constructor.
Definition at line 56 of file FieldIo.tpp.
Referenced by Pscf::Rp::Domain< D, T >::Domain().
|
virtualdefault |
Destructor.
References associate(), basis(), compareFieldsBasis(), compareFieldsRGrid(), convertBasisToKGrid(), convertBasisToRGrid(), convertKGridToBasis(), convertKGridToRGrid(), convertRGridToBasis(), convertRGridToKGrid(), estimateWBasis(), expandRGridDimension(), fileMaster(), hasSymmetry(), mesh(), readFieldBasis(), readFieldHeader(), readFieldRGrid(), readFieldsBasis(), readFieldsKGrid(), readFieldsRGrid(), readFieldsRGridData(), replicateUnitCell(), scaleFieldBasis(), scaleFieldRGrid(), scaleFieldsBasis(), scaleFieldsRGrid(), setFileMaster(), setNMonomer(), writeFieldBasis(), writeFieldHeader(), writeFieldRGrid(), writeFieldsBasis(), writeFieldsKGrid(), and writeFieldsRGrid().
| void Pscf::Rp::FieldIo< D, T >::associate | ( | Mesh< D > const & | mesh, |
| FFT< D, T > 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 78 of file FieldIo.tpp.
References basis(), and mesh().
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 100 of file FieldIo.tpp.
References fileMaster().
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 107 of file FieldIo.tpp.
References UTIL_CHECK.
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 122 of file FieldIo.tpp.
References UTIL_CHECK.
Referenced by convertBasisToKGrid(), convertBasisToRGrid(), readFieldBasis(), scaleFieldsBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 160 of file FieldIo.tpp.
| void Pscf::Rp::FieldIo< D, T >::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 176 of file FieldIo.tpp.
References Util::DArray< Data >::allocate(), basis(), Util::Array< Data >::capacity(), Util::Array< Data >::isAllocated(), readFieldsBasis(), and UTIL_CHECK.
Referenced by readFieldBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 209 of file FieldIo.tpp.
References fileMaster(), and readFieldBasis().
| void Pscf::Rp::FieldIo< D, T >::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 224 of file FieldIo.tpp.
References Pscf::inspectArrays().
Referenced by convertKGridToBasis(), scaleFieldsBasis(), Pscf::Rp::BasisFieldState< D, T >::write(), writeFieldBasis(), writeFieldsBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 252 of file FieldIo.tpp.
References fileMaster(), and writeFieldsBasis().
| void Pscf::Rp::FieldIo< D, T >::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 267 of file FieldIo.tpp.
References Util::DArray< Data >::allocate(), Util::Array< Data >::capacity(), and writeFieldsBasis().
Referenced by writeFieldBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 287 of file FieldIo.tpp.
References fileMaster(), and writeFieldBasis().
|
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 RField 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 |
Definition at line 304 of file FieldIo.tpp.
Referenced by compareFieldsRGrid(), convertRGridToBasis(), convertRGridToKGrid(), expandRGridDimension(), readFieldsRGrid(), replicateUnitCell(), scaleFieldsRGrid(), Pscf::Rp::EinsteinCrystalPerturbation< D, T >::setup(), and ~FieldIo().
| bool Pscf::Rp::FieldIo< D, T >::readFieldsRGrid | ( | std::string | filename, |
| DArray< RField< D, T > > & | 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 (RField objects) |
| unitCell | associated crystallographic unit cell |
Definition at line 335 of file FieldIo.tpp.
References fileMaster(), and readFieldsRGrid().
|
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 (RField objects) |
| nMonomer | expected number of monomer types (input |
Definition at line 352 of file FieldIo.tpp.
References Pscf::associateArrays(), Pscf::checkAllocateFields(), Pscf::copyArrays(), mesh(), and Pscf::readRGridData().
Referenced by Pscf::Rp::RGridTrajectoryReader< D, T >::readFrame(), and ~FieldIo().
|
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 (RField object) |
| unitCell | associated crystallographic unit cell |
Definition at line 376 of file FieldIo.tpp.
References Pscf::checkAllocateField(), mesh(), readFieldHeader(), Pscf::readMeshDimensions(), Pscf::readRGridData(), and UTIL_CHECK.
Referenced by ~FieldIo().
| bool Pscf::Rp::FieldIo< D, T >::readFieldRGrid | ( | std::string | filename, |
| RField< D, T > & | 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 409 of file FieldIo.tpp.
|
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? |
Definition at line 426 of file FieldIo.tpp.
References Pscf::inspectFields(), mesh(), UTIL_CHECK, writeFieldHeader(), and Pscf::writeMeshDimensions().
Referenced by convertBasisToRGrid(), scaleFieldsRGrid(), writeFieldsRGrid(), Pscf::Rp::TrajectoryWriter< D, T >::writeFrame(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::writeFieldsRGrid | ( | std::string | filename, |
| DArray< RField< D, T > > 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 r-grid fields |
| unitCell | associated crystallographic unit cell |
| isSymmetric | iff true, write space group name |
Definition at line 464 of file FieldIo.tpp.
References fileMaster(), and writeFieldsRGrid().
|
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 |
Definition at line 483 of file FieldIo.tpp.
References mesh(), UTIL_CHECK, writeFieldHeader(), and Pscf::writeMeshDimensions().
Referenced by writeFieldRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::writeFieldRGrid | ( | std::string | filename, |
| RField< D, T > 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 515 of file FieldIo.tpp.
References fileMaster(), and writeFieldRGrid().
|
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 RFieldDft 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 k-space fields (RFieldDft) |
| unitCell | associated crystallographic unit cell |
Definition at line 534 of file FieldIo.tpp.
Referenced by convertKGridToBasis(), convertKGridToRGrid(), and ~FieldIo().
| bool Pscf::Rp::FieldIo< D, T >::readFieldsKGrid | ( | std::string | filename, |
| DArray< RFieldDft< D, T > > & | 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 (RFieldDft) fields |
| unitCell | associated crystallographic unit cell |
Definition at line 567 of file FieldIo.tpp.
|
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 (RFieldDft) |
| unitCell | associated crystallographic unit cell |
| isSymmetric | iff true, write space group name |
Definition at line 584 of file FieldIo.tpp.
References Pscf::copyArrays(), Pscf::inspectFields(), mesh(), UTIL_CHECK, writeFieldHeader(), and Pscf::writeMeshDimensions().
Referenced by convertBasisToKGrid(), convertRGridToKGrid(), writeFieldsKGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::writeFieldsKGrid | ( | std::string | filename, |
| DArray< RFieldDft< D, T > > 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 k-grid fields (FieldDft) |
| unitCell | associated crystallographic unit cell |
| isSymmetric | iff true, write space group name |
Definition at line 615 of file FieldIo.tpp.
References fileMaster(), and writeFieldsKGrid().
|
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 |
Definition at line 633 of file FieldIo.tpp.
Referenced by convertBasisToKGrid(), convertBasisToRGrid(), convertBasisToRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertBasisToKGrid | ( | DArray< DArray< double > > const & | in, |
| DArray< RFieldDft< D, T > > & | 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 660 of file FieldIo.tpp.
|
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) |
Definition at line 699 of file FieldIo.tpp.
References basis(), Util::Array< Data >::capacity(), Pscf::convertKGridToBasis(), Util::Array< Data >::isAllocated(), mesh(), and UTIL_CHECK.
Referenced by convertKGridToBasis(), convertKGridToBasis(), convertRGridToBasis(), convertRGridToBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertKGridToBasis | ( | DArray< RFieldDft< D, T > > 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 726 of file FieldIo.tpp.
References convertKGridToBasis(), Pscf::inspectArrays(), Pscf::inspectFields(), and UTIL_CHECK.
| void Pscf::Rp::FieldIo< D, T >::convertBasisToRGrid | ( | DArray< double > const & | in, |
| RField< D, T > & | 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 767 of file FieldIo.tpp.
References Pscf::checkAllocateField(), convertBasisToKGrid(), Util::Array< Data >::isAllocated(), mesh(), and UTIL_CHECK.
Referenced by convertBasisToRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertBasisToRGrid | ( | DArray< DArray< double > > const & | in, |
| DArray< RField< D, T > > & | 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 782 of file FieldIo.tpp.
References Pscf::checkAllocateField(), convertBasisToKGrid(), mesh(), and UTIL_CHECK.
| void Pscf::Rp::FieldIo< D, T >::convertRGridToBasis | ( | RField< D, T > 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 819 of file FieldIo.tpp.
References Pscf::checkAllocateField(), convertKGridToBasis(), and mesh().
Referenced by convertRGridToBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertRGridToBasis | ( | DArray< RField< D, T > > 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 834 of file FieldIo.tpp.
References Pscf::checkAllocateField(), convertKGridToBasis(), Pscf::inspectArrays(), Pscf::inspectFields(), mesh(), and UTIL_CHECK.
| void Pscf::Rp::FieldIo< D, T >::convertKGridToRGrid | ( | DArray< RFieldDft< D, T > > const & | in, |
| DArray< RField< D, T > > & | 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 878 of file FieldIo.tpp.
References UTIL_ASSERT.
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertKGridToRGrid | ( | RFieldDft< D, T > const & | in, |
| RField< D, T > & | 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 893 of file FieldIo.tpp.
| void Pscf::Rp::FieldIo< D, T >::convertRGridToKGrid | ( | DArray< RField< D, T > > const & | in, |
| DArray< RFieldDft< D, T > > & | 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 905 of file FieldIo.tpp.
References UTIL_ASSERT.
Referenced by convertRGridToKGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::convertRGridToKGrid | ( | RField< D, T > const & | in, |
| RFieldDft< D, T > & | 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 920 of file FieldIo.tpp.
| void Pscf::Rp::FieldIo< D, T >::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 802 of file FieldIo.tpp.
References convertBasisToRGrid(), readFieldsBasis(), and writeFieldsRGrid().
| void Pscf::Rp::FieldIo< D, T >::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 860 of file FieldIo.tpp.
References convertRGridToBasis(), and readFieldsRGrid().
| void Pscf::Rp::FieldIo< D, T >::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. The output file header gives the space group only if the input file header does and a space group has been declared.
| inFileName | name of input file (k-grid format) |
| outFileName | name of output file (r-grid format) |
Definition at line 929 of file FieldIo.tpp.
References readFieldsKGrid().
| void Pscf::Rp::FieldIo< D, T >::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. The output file header gives the space group only if the input file header does and a space group has been declared.
| inFileName | name of input file (r-grid format) |
| outFileName | name of output file (k-grid format) |
Definition at line 952 of file FieldIo.tpp.
References convertRGridToKGrid(), readFieldsRGrid(), and writeFieldsKGrid().
| void Pscf::Rp::FieldIo< D, T >::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 749 of file FieldIo.tpp.
References convertKGridToBasis(), readFieldsKGrid(), and writeFieldsBasis().
| void Pscf::Rp::FieldIo< D, T >::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 683 of file FieldIo.tpp.
References convertBasisToKGrid(), readFieldsBasis(), and writeFieldsKGrid().
|
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() |
Definition at line 974 of file FieldIo.tpp.
References mesh(), and UTIL_CHECK.
Referenced by ~FieldIo().
| bool Pscf::Rp::FieldIo< D, T >::hasSymmetry | ( | RField< D, T > 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 1002 of file FieldIo.tpp.
| bool Pscf::Rp::FieldIo< D, T >::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 1016 of file FieldIo.tpp.
| void Pscf::Rp::FieldIo< D, T >::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 1041 of file FieldIo.tpp.
References Pscf::FieldComparison< FT >::compare(), Util::Log::file(), Pscf::FieldComparison< FT >::maxDiff(), and Pscf::FieldComparison< FT >::rmsDiff().
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1057 of file FieldIo.tpp.
|
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) |
Definition at line 1073 of file FieldIo.tpp.
References Util::Log::file().
Referenced by compareFieldsRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1089 of file FieldIo.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 1107 of file FieldIo.tpp.
References Util::Array< Data >::capacity(), Util::Array< Data >::isAllocated(), and UTIL_CHECK.
Referenced by scaleFieldsBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1122 of file FieldIo.tpp.
References scaleFieldBasis(), and UTIL_CHECK.
Referenced by scaleFieldsBasis(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1139 of file FieldIo.tpp.
References readFieldsBasis(), scaleFieldsBasis(), and writeFieldsBasis().
| void Pscf::Rp::FieldIo< D, T >::scaleFieldRGrid | ( | RField< D, T > & | field, |
| double | factor ) const |
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 form to be rescaled |
| factor | factor by which to multiply every field element |
Definition at line 1155 of file FieldIo.tpp.
References UTIL_CHECK.
Referenced by scaleFieldsRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::scaleFieldsRGrid | ( | DArray< RField< D, T > > & | 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 fields to be rescaled |
| factor | factor by which to multiply every field element |
Definition at line 1167 of file FieldIo.tpp.
References scaleFieldRGrid().
Referenced by scaleFieldsRGrid(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1181 of file FieldIo.tpp.
References readFieldsRGrid(), scaleFieldsRGrid(), and writeFieldsRGrid().
| void Pscf::Rp::FieldIo< D, T >::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 1203 of file FieldIo.tpp.
References Util::DArray< Data >::allocate(), Util::Matrix< Data >::capacity1(), Util::Matrix< Data >::capacity2(), and UTIL_CHECK.
Referenced by ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1240 of file FieldIo.tpp.
References basis(), Util::Matrix< Data >::capacity1(), Util::Matrix< Data >::capacity2(), and UTIL_CHECK.
|
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 |
Definition at line 1289 of file FieldIo.tpp.
References Pscf::copyArrays(), Pscf::dissociateArrays(), Pscf::inspectFields(), mesh(), Pscf::replicateUnitCell(), and UTIL_CHECK.
Referenced by replicateUnitCell(), replicateUnitCell(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::replicateUnitCell | ( | std::string | filename, |
| DArray< RField< D, T > > 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 1344 of file FieldIo.tpp.
References fileMaster(), and replicateUnitCell().
| void Pscf::Rp::FieldIo< D, T >::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 1360 of file FieldIo.tpp.
References readFieldsRGrid(), and replicateUnitCell().
|
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 write lamellar field that was computed with D=1 to a lamellar field defined on a 3D grid (d=3), in the format used for a 3D field..
| 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 1317 of file FieldIo.tpp.
References Pscf::copyArrays(), Pscf::dissociateArrays(), Pscf::expandRGridDimension(), Pscf::inspectFields(), mesh(), and UTIL_CHECK.
Referenced by expandRGridDimension(), expandRGridDimension(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::expandRGridDimension | ( | std::string | filename, |
| DArray< RField< D, T > > 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 r-grid fields |
| unitCell | original crystallographic unit cell |
| d | expanded dimension (greater than D) |
| newGridDimensions | number of grid points in added dimensions |
Definition at line 1376 of file FieldIo.tpp.
References expandRGridDimension(), and fileMaster().
| void Pscf::Rp::FieldIo< D, T >::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 1392 of file FieldIo.tpp.
References expandRGridDimension(), and readFieldsRGrid().
| void Pscf::Rp::FieldIo< D, T >::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 1418 of file FieldIo.tpp.
References basis(), Util::Log::file(), Pscf::UnitCellBase< D >::isInitialized(), mesh(), Pscf::UnitCellBase< D >::nParameter(), Pscf::readFieldHeader(), UTIL_CHECK, and UTIL_THROW.
Referenced by readFieldRGrid(), Pscf::Rp::RGridTrajectoryReader< D, T >::readHeader(), and ~FieldIo().
| void Pscf::Rp::FieldIo< D, T >::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 1504 of file FieldIo.tpp.
References UTIL_CHECK, and Pscf::writeFieldHeader().
Referenced by writeFieldRGrid(), writeFieldsKGrid(), writeFieldsRGrid(), Pscf::Rp::TrajectoryWriter< D, T >::writeHeader(), and ~FieldIo().
|
inline |
Get the associated spatial discretization mesh by const reference.
Definition at line 1405 of file rp/field/FieldIo.h.
References UTIL_ASSERT.
Referenced by associate(), convertBasisToRGrid(), convertBasisToRGrid(), convertKGridToBasis(), convertRGridToBasis(), convertRGridToBasis(), expandRGridDimension(), hasSymmetry(), readFieldHeader(), readFieldRGrid(), readFieldsRGridData(), replicateUnitCell(), writeFieldRGrid(), writeFieldsKGrid(), writeFieldsRGrid(), and ~FieldIo().
|
inline |
Get the associated Basis by const reference.
Definition at line 1415 of file rp/field/FieldIo.h.
References UTIL_ASSERT.
Referenced by associate(), convertKGridToBasis(), estimateWBasis(), readFieldBasis(), readFieldHeader(), and ~FieldIo().
|
inline |
Get the associated FileMaster by const reference.
Definition at line 1425 of file rp/field/FieldIo.h.
References UTIL_ASSERT.
Referenced by expandRGridDimension(), readFieldBasis(), readFieldsRGrid(), replicateUnitCell(), setFileMaster(), writeFieldBasis(), writeFieldRGrid(), writeFieldsBasis(), writeFieldsKGrid(), writeFieldsRGrid(), and ~FieldIo().