PSCF v1.3
Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT > Class Template Referenceabstract

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.

Detailed Description

template<int D, class RFT, class KFT, class FFT>
class Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >

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:

  • D : integer dimension of space, i.e., 1, 2, or 3
  • RFT : r-grid (real space) field type, e.g., RField<D>
  • KFT : k-grid (Fourier space) field type, e.g., RFieldDft<D>
  • FFT : fast Fourier transform type, e.g., FFT<D>

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.

Constructor & Destructor Documentation

◆ FieldIoReal()

template<int D, class RFT, class KFT, class FFT>
Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::FieldIoReal ( )

Constructor.

Definition at line 46 of file FieldIoReal.tpp.

◆ ~FieldIoReal()

template<int D, class RFT, class KFT, class FFT>
Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::~FieldIoReal ( )
virtual

Destructor.

Definition at line 64 of file FieldIoReal.tpp.

Member Function Documentation

◆ associate()

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
meshassociated spatial discretization Mesh<D>
fftassociated FFT object for fast transforms
latticelattice system type (enumeration value)
hasGrouptrue iff a space group has been declared
groupNamespace group name string
groupassociated SpaceGroup object
basisassociated Basis object

Definition at line 74 of file FieldIoReal.tpp.

References basis(), fft(), group(), groupName(), hasGroup(), lattice(), and mesh().

◆ setFileMaster()

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
fileMasterassociated FileMaster (for file paths)

Definition at line 96 of file FieldIoReal.tpp.

References fileMaster().

◆ setNMonomer()

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
nMonomernumber of monomer types

Definition at line 104 of file FieldIoReal.tpp.

References UTIL_CHECK.

◆ readFieldsBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
ininput stream (e.g., input file stream)
fieldsarray of fields (symmetry adapted basis components)
unitCellassociated 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().

◆ readFieldsBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldsarray of fields (symmetry adapted basis components)
unitCellassociated crystallographic unit cell

Definition at line 247 of file FieldIoReal.tpp.

References fileMaster(), and readFieldsBasis().

◆ readFieldBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
ininput stream (i.e., input file stream)
fieldarray to store the field (basis format)
unitCellassociated 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().

◆ readFieldBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldarray to store the field (basis format)
unitCellassociated crystallographic unit cell

Definition at line 263 of file FieldIoReal.tpp.

References fileMaster(), and readFieldBasis().

◆ writeFieldsBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
outoutput stream (i.e., output file)
fieldsarray of fields (symmetry adapted basis components)
unitCellassociated 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().

◆ writeFieldsBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldsarray of fields (symmetry adapted basis components)
unitCellassociated crystallographic unit cell

Definition at line 278 of file FieldIoReal.tpp.

References fileMaster(), and writeFieldsBasis().

◆ writeFieldBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
outoutput stream (i.e., output file)
fieldfield to be written (symmetry adapted basis format)
unitCellassociated 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().

◆ writeFieldBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of output file
fieldfield to be written (symmetry adapted basis format)
unitCellassociated crystallographic unit cell

Definition at line 293 of file FieldIoReal.tpp.

References fileMaster(), and writeFieldBasis().

◆ readFieldsRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsRGrid ( std::istream & in,
DArray< RFT > & fields,
UnitCell< D > & unitCell ) const
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.

Parameters
ininput stream (i.e., input file)
fieldsarray of r-grid fields
unitCellassociated crystallographic unit cell
Returns
true iff header declares a space group

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by compareFieldsRGrid(), convertRGridToBasis(), convertRGridToKGrid(), expandRGridDimension(), hasSymmetry(), readFieldsRGrid(), replicateUnitCell(), and scaleFieldsRGrid().

◆ readFieldsRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldsarray of r-grid fields (instances of RFT)
unitCellassociated crystallographic unit cell
Returns
true iff header declares a space group

Definition at line 308 of file FieldIoReal.tpp.

References fileMaster(), and readFieldsRGrid().

◆ readFieldsRGridData()

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsRGridData ( std::istream & in,
DArray< RFT > & fields,
int nMonomer ) const
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.

Parameters
ininput file stream
fieldsarray of r-grid fields (instances of RFT)
nMonomerexpected number of monomer types (input

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ readFieldRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldRGrid ( std::istream & in,
RFT & field,
UnitCell< D > & unitCell ) const
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.

Parameters
ininput stream (i.e., input file)
fieldsingle r-grid field (instance of RFT)
unitCellassociated crystallographic unit cell
Returns
true iff header has a space group (isSymmetric flag)

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by readFieldRGrid().

◆ readFieldRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldsingle field defined on r-space grid
unitCellassociated crystallographic unit cell
Returns
true iff header has a space group (isSymmetric flag)

Definition at line 325 of file FieldIoReal.tpp.

References fileMaster(), and readFieldRGrid().

◆ writeFieldsRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsRGrid ( std::ostream & out,
DArray< RFT > const & fields,
UnitCell< D > const & unitCell,
bool writeHeader = true,
bool isSymmetric = true,
bool writeMeshSize = true ) const
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.

Parameters
outoutput stream (i.e., output file)
fieldsarray of RField objects (fields on r-space grid)
unitCellassociated crystallographic unit cell
writeHeaderiff true, write file header
isSymmetriciff true, write space group name
writeMeshSizeShould 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().

◆ writeFieldsRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of output file
fieldsarray of RFT objects (fields on r-space grid)
unitCellassociated crystallographic unit cell
isSymmetriciff true, write space group name

Definition at line 342 of file FieldIoReal.tpp.

References fileMaster(), and writeFieldsRGrid().

◆ writeFieldRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldRGrid ( std::ostream & out,
RFT const & field,
UnitCell< D > const & unitCell,
bool writeHeader = true,
bool isSymmetric = true ) const
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.

Parameters
outoutput stream
fieldfield defined on r-space grid
unitCellassociated crystallographic unit cell
writeHeadershould a file header be written?
isSymmetriciff true, write space group name

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by writeFieldRGrid().

◆ writeFieldRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of output file
fieldfield defined on r-space grid
unitCellassociated crystallographic unit cell
isSymmetriciff true, write space group name

Definition at line 361 of file FieldIoReal.tpp.

References fileMaster(), and writeFieldRGrid().

◆ readFieldsKGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::readFieldsKGrid ( std::istream & in,
DArray< KFT > & fields,
UnitCell< D > & unitCell ) const
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.

Parameters
ininput stream (i.e., input file)
fieldsarray of KFT fields (k-space grid)
unitCellassociated crystallographic unit cell

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by convertKGridToBasis(), convertKGridToRGrid(), and readFieldsKGrid().

◆ readFieldsKGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of input file
fieldsarray of k-space (KFT) fields
unitCellassociated crystallographic unit cell

Definition at line 377 of file FieldIoReal.tpp.

References fileMaster(), and readFieldsKGrid().

◆ writeFieldsKGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::writeFieldsKGrid ( std::ostream & out,
DArray< KFT > const & fields,
UnitCell< D > const & unitCell,
bool isSymmetric = true ) const
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.

Parameters
outoutput stream (i.e., output file)
fieldsarray of k-grid fields (instances of KFT)
unitCellassociated crystallographic unit cell
isSymmetriciff true, write space group name

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by convertBasisToKGrid(), convertRGridToKGrid(), and writeFieldsKGrid().

◆ writeFieldsKGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of output file.
fieldsarray of Fourier-grid fields (instances of KFT)
unitCellassociated crystallographic unit cell
isSymmetriciff true, write space group name

Definition at line 392 of file FieldIoReal.tpp.

References fileMaster(), and writeFieldsKGrid().

◆ convertBasisToKGrid() [1/3]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertBasisToKGrid ( DArray< double > const & components,
KFT & dft ) const
pure virtual

Convert a single field from basis to Fourier (k-grid) form.

Parameters
componentscomponents in symmetry-adapted basis format
dftdiscrete Fourier transform of a real field

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ convertBasisToKGrid() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infields expanded in symmetry-adapted Fourier basis
outfields 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.

◆ convertKGridToBasis() [1/3]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::convertKGridToBasis ( KFT const & in,
DArray< double > & out,
bool checkSymmetry = true,
double epsilon = 1.0e-8 ) const
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.

Parameters
indiscrete Fourier transform (k-grid) of a field
outcomponents of field in asymmetry-adapted Fourier basis
checkSymmetryflag indicating whether to check symmetry
epsilonerror tolerance for symmetry test (if any)

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ convertKGridToBasis() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infields defined as discrete Fourier transforms (k-grid)
outcomponents of fields in symmetry adapted basis
checkSymmetryflag indicate whether to check symmetry
epsilonerror 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.

◆ convertBasisToRGrid() [1/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infield in symmetry-adapted basis form
outfield 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().

◆ convertBasisToRGrid() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infields in symmetry adapted basis form
outfields 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.

◆ convertRGridToBasis() [1/3]

template<int D, class RFT, class KFT, class FFT>
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().

Parameters
infield defined on real-space grid
outfield in symmetry adapted basis form
checkSymmetryif true, check space group symmetry
epsilonerror 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().

◆ convertRGridToBasis() [2/3]

template<int D, class RFT, class KFT, class FFT>
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().

Parameters
infields defined on real-space grid
outfields in symmetry adapted basis form
checkSymmetryif true, check space group symmetry
epsilonerror 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.

◆ convertKGridToRGrid() [1/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infields in discrete Fourier format (k-grid)
outfields defined on real-space grid (r-grid)

Definition at line 601 of file FieldIoReal.tpp.

References Util::Array< Data >::capacity(), fft(), and UTIL_ASSERT.

◆ convertKGridToRGrid() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infield in discrete Fourier format (k-grid)
outfield defined on real-space grid (r-grid)

Definition at line 616 of file FieldIoReal.tpp.

References fft().

◆ convertRGridToKGrid() [1/3]

template<int D, class RFT, class KFT, class 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.

Parameters
infields defined on real-space grid (r-grid)
outfields 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().

◆ convertRGridToKGrid() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
infield defined on real-space grid (r-grid)
outfield in discrete Fourier format (k-grid)

Definition at line 641 of file FieldIoReal.tpp.

References fft().

◆ convertBasisToRGrid() [3/3]

template<int D, class RFT, class KFT, class 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.

Parameters
inFileNamename of input file (basis format)
outFileNamename of output file (r-grid format)

Definition at line 566 of file FieldIoReal.tpp.

References checkAllocateBasis(), checkAllocateRGrid(), convertBasisToRGrid(), readFieldsBasis(), and writeFieldsRGrid().

◆ convertRGridToBasis() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file (r-grid format)
outFileNamename of output file (basis format)

Definition at line 583 of file FieldIoReal.tpp.

References checkAllocateBasis(), checkAllocateRGrid(), convertRGridToBasis(), readFieldsRGrid(), and writeFieldsBasis().

◆ convertKGridToRGrid() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file (k-grid format)
outFileNamename of output file (r-grid format)

Definition at line 650 of file FieldIoReal.tpp.

References checkAllocateKGrid(), checkAllocateRGrid(), fft(), readFieldsKGrid(), and writeFieldsRGrid().

◆ convertRGridToKGrid() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file (r-grid format)
outFileNamename of output file (k-grid format)

Definition at line 669 of file FieldIoReal.tpp.

References checkAllocateKGrid(), checkAllocateRGrid(), convertRGridToKGrid(), readFieldsRGrid(), and writeFieldsKGrid().

◆ convertKGridToBasis() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file (k-grid format)
outFileNamename of output file (basis format)

Definition at line 456 of file FieldIoReal.tpp.

References checkAllocateBasis(), checkAllocateKGrid(), Pscf::Prdc::convertKGridToBasis(), readFieldsKGrid(), and writeFieldsBasis().

◆ convertBasisToKGrid() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file (basis format)
outFileNamename of output file (k-grid format)

Definition at line 472 of file FieldIoReal.tpp.

References checkAllocateBasis(), checkAllocateKGrid(), Pscf::Prdc::convertBasisToKGrid(), readFieldsBasis(), and writeFieldsKGrid().

◆ hasSymmetry() [1/3]

template<int D, class RFT, class KFT, class FFT>
virtual bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::hasSymmetry ( KFT const & in,
double epsilon = 1.0e-8,
bool verbose = true ) const
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().

Parameters
infield in real space grid (r-grid) format
epsilonerror threshold used to test for symmetry
verboseif true, write any error to Log::file()
Returns
true if the field is symmetric, false otherwise

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ hasSymmetry() [2/3]

template<int D, class RFT, class KFT, class FFT>
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().

Parameters
infield in real space grid (r-grid) format
epsilonerror threshold used to test for symmetry
verboseif true, write error to Log::file()
Returns
true if the field is symmetric, false otherwise

Definition at line 689 of file FieldIoReal.tpp.

References Pscf::Prdc::checkAllocateField(), fft(), Pscf::Prdc::hasSymmetry(), and mesh().

◆ hasSymmetry() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input r-grid field file
epsilonerror threshold used when testing for symmetry
Returns
true if fields all have symmetry, false otherwise

Definition at line 703 of file FieldIoReal.tpp.

References checkAllocateRGrid(), Pscf::Prdc::hasSymmetry(), and readFieldsRGrid().

◆ compareFieldsBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
field1first array of fields (basis form)
field2second 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().

◆ compareFieldsBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filename1name of 1st field file
filename2name of 2nd field file

Definition at line 744 of file FieldIoReal.tpp.

References compareFieldsBasis(), and readFieldsBasis().

◆ compareFieldsRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::compareFieldsRGrid ( DArray< RFT > const & field1,
DArray< RFT > const & field2 ) const
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.

Parameters
field1first array of fields (r-grid form)
field2second array of fields (r-grid form)

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by compareFieldsRGrid().

◆ compareFieldsRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filename1name of 1st field file
filename2name of 2nd field file

Definition at line 757 of file FieldIoReal.tpp.

References compareFieldsRGrid(), and readFieldsRGrid().

◆ scaleFieldBasis()

template<int D, class RFT, class KFT, class FFT>
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldBasis ( DArray< double > & field,
double factor ) const
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.

Parameters
fieldfield in basis form to be rescaled (in/out)
factorfactor 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().

◆ scaleFieldsBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
fieldsarray of fields in basis form to be rescaled
factorfactor by which to multiply every field element

Definition at line 790 of file FieldIoReal.tpp.

References scaleFieldBasis(), and UTIL_CHECK.

Referenced by scaleFieldsBasis().

◆ scaleFieldsBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input field file
outFileNamename of file for rescaled output fields
factorfactor by which to multiply every field element

Definition at line 807 of file FieldIoReal.tpp.

References checkAllocateBasis(), readFieldsBasis(), scaleFieldsBasis(), and writeFieldsBasis().

◆ scaleFieldRGrid()

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::scaleFieldRGrid ( RFT & field,
double factor ) const
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.

Parameters
fieldfield in r-grid (RFT) form to be rescaled
factorfactor by which to multiply every field element

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

Referenced by scaleFieldsRGrid().

◆ scaleFieldsRGrid() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
fieldsarray of r-grid (RFT) fields to be rescaled
factorfactor 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().

◆ scaleFieldsRGrid() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input field file
outFileNamename of file for rescaled output fields
factorfactor by which to multiply all field elements

Definition at line 837 of file FieldIoReal.tpp.

References checkAllocateRGrid(), readFieldsRGrid(), scaleFieldsRGrid(), and writeFieldsRGrid().

◆ estimateWBasis() [1/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
chimatrix of Flory-Huggins chi parameters
fieldsarray 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().

◆ estimateWBasis() [2/2]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input file of c-fields
outFileNamename of output file of w-fields
chimatrix 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().

◆ replicateUnitCell() [1/3]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::replicateUnitCell ( std::ostream & out,
DArray< RFT > const & fields,
UnitCell< D > const & unitCell,
IntVec< D > const & replicas ) const
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.

Parameters
outoutput stream (i.e., output file)
fieldsarray of RField (r-space) fields to be replicated
unitCelloriginal crystallographic unit cell
replicasnumber of unit cell replicas in each direction

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ replicateUnitCell() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenameoutput file name
fieldsarray of RField fields (r-space grid) needs
unitCelloriginal crystallographic unit cell
replicasnumber of unit cell replicas in each direction

Definition at line 944 of file FieldIoReal.tpp.

References fileMaster(), and Pscf::Prdc::replicateUnitCell().

◆ replicateUnitCell() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamename of input field file
outFileNamename of output field file
replicasthe number of replicas in each D direction

Definition at line 960 of file FieldIoReal.tpp.

References checkAllocateRGrid(), readFieldsRGrid(), and Pscf::Prdc::replicateUnitCell().

◆ expandRGridDimension() [1/3]

template<int D, class RFT, class KFT, class FFT>
virtual void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::expandRGridDimension ( std::ostream & out,
DArray< RFT > const & fields,
UnitCell< D > const & unitCell,
int d,
DArray< int > const & newGridDimensions ) const
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.

Parameters
outoutput stream (i.e., output file)
fieldsinput array of RField fields (r-space grid)
unitCelloriginal crystallographic unit cell
dexpanded dimension (greater than D)
newGridDimensionsnumber of grid points in added dimensions

Implemented in Pscf::Rpc::FieldIo< D >, and Pscf::Rpg::FieldIo< D >.

◆ expandRGridDimension() [2/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
filenamename of output file
fieldsinput array of RFT objects (r-space grid)
unitCelloriginal crystallographic unit cell
dexpanded dimension (greater than D)
newGridDimensionsnumber of grid points in added dimensions

Definition at line 976 of file FieldIoReal.tpp.

References Pscf::Prdc::expandRGridDimension(), and fileMaster().

◆ expandRGridDimension() [3/3]

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
inFileNamefilename name of input field file
outFileNamefilename name of output field file
dintended dimensions (d > D)
newGridDimensionsnumber of grid points in added dimensions

Definition at line 992 of file FieldIoReal.tpp.

References checkAllocateRGrid(), Pscf::Prdc::expandRGridDimension(), and readFieldsRGrid().

◆ readFieldHeader()

template<int D, class RFT, class KFT, class FFT>
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.

Parameters
ininput stream (i.e., file)
nMonomernumber of monomer types in the header (output)
unitCellassociated crystallographic unit cell (output)
isSymmetricIs 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.

◆ writeFieldHeader()

template<int D, class RFT, class KFT, class FFT>
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).

Parameters
outoutput stream (i.e., file)
nMonomernumber of monomer types or fields
unitCellassociated crystallographic unit cell
isSymmetricShould a space group be declared?

Definition at line 1104 of file FieldIoReal.tpp.

References groupName(), hasGroup(), UTIL_CHECK, and Pscf::Prdc::writeFieldHeader().

◆ mesh()

template<int D, class RFT, class KFT, class FFT>
Mesh< D > const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::mesh ( ) const
inline

◆ basis()

template<int D, class RFT, class KFT, class FFT>
Basis< D > const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::basis ( ) const
inline

◆ fileMaster()

◆ lattice()

template<int D, class RFT, class KFT, class FFT>
UnitCell< D >::LatticeSystem const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::lattice ( ) const
inlineprotected

Get the lattice type enum value by const reference.

Definition at line 1282 of file FieldIoReal.h.

Referenced by associate(), and readFieldHeader().

◆ hasGroup()

template<int D, class RFT, class KFT, class FFT>
bool Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::hasGroup ( ) const
inlineprotected

Has a space group been declared externally ?

Definition at line 1291 of file FieldIoReal.h.

Referenced by associate(), checkAllocateBasis(), readFieldHeader(), readFieldsBasis(), and writeFieldHeader().

◆ groupName()

template<int D, class RFT, class KFT, class FFT>
std::string const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::groupName ( ) const
inlineprotected

Get an associated group name string by const reference.

Definition at line 1300 of file FieldIoReal.h.

Referenced by associate(), readFieldHeader(), and writeFieldHeader().

◆ group()

template<int D, class RFT, class KFT, class FFT>
SpaceGroup< D > const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::group ( ) const
inlineprotected

Get an associated SpaceGroup<D> by const reference.

Definition at line 1309 of file FieldIoReal.h.

Referenced by associate(), and readFieldHeader().

◆ fft()

template<int D, class RFT, class KFT, class FFT>
FFT const & Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::fft ( ) const
inlineprotected

◆ checkAllocateRGrid()

template<int D, class RFT, class KFT, class FFT>
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::checkAllocateRGrid ( ) const
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().

◆ checkAllocateKGrid()

template<int D, class RFT, class KFT, class FFT>
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::checkAllocateKGrid ( ) const
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().

◆ checkAllocateBasis()

template<int D, class RFT, class KFT, class FFT>
void Pscf::Prdc::FieldIoReal< D, RFT, KFT, FFT >::checkAllocateBasis ( std::string const & inFileName) const
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.

Parameters
inFileNamename 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().


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