PSCF v1.5.0
Pscf::Rp::FieldIo< D, T > Class Template Reference

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.

Detailed Description

template<int D, class T>
class Pscf::Rp::FieldIo< D, T >

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:

  • D : integer dimension of space, i.e., 1, 2, or 3
  • T : backend identifier class (CPT or CUT)

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.

Constructor & Destructor Documentation

◆ FieldIo()

template<int D, class T>
Pscf::Rp::FieldIo< D, T >::FieldIo ( )

Constructor.

Definition at line 56 of file FieldIo.tpp.

Referenced by Pscf::Rp::Domain< D, T >::Domain().

◆ ~FieldIo()

Member Function Documentation

◆ associate()

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

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 78 of file FieldIo.tpp.

References basis(), and mesh().

Referenced by ~FieldIo().

◆ setFileMaster()

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

Parameters
fileMasterassociated FileMaster (for file paths)

Definition at line 100 of file FieldIo.tpp.

References fileMaster().

Referenced by ~FieldIo().

◆ setNMonomer()

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

Parameters
nMonomernumber of monomer types

Definition at line 107 of file FieldIo.tpp.

References UTIL_CHECK.

Referenced by ~FieldIo().

◆ readFieldsBasis() [1/2]

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

Parameters
ininput stream (e.g., input file stream)
fieldsarray of fields (symmetry adapted basis components)
unitCellassociated unit cell object

Definition at line 122 of file FieldIo.tpp.

References UTIL_CHECK.

Referenced by convertBasisToKGrid(), convertBasisToRGrid(), readFieldBasis(), scaleFieldsBasis(), and ~FieldIo().

◆ readFieldsBasis() [2/2]

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

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

Definition at line 160 of file FieldIo.tpp.

◆ readFieldBasis() [1/2]

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

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

◆ readFieldBasis() [2/2]

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

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

Definition at line 209 of file FieldIo.tpp.

References fileMaster(), and readFieldBasis().

◆ writeFieldsBasis() [1/2]

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

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

◆ writeFieldsBasis() [2/2]

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

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

Definition at line 252 of file FieldIo.tpp.

References fileMaster(), and writeFieldsBasis().

◆ writeFieldBasis() [1/2]

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

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

◆ writeFieldBasis() [2/2]

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

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

Definition at line 287 of file FieldIo.tpp.

References fileMaster(), and writeFieldBasis().

◆ readFieldsRGrid() [1/2]

template<int D, class T>
bool Pscf::Rp::FieldIo< D, T >::readFieldsRGrid ( std::istream & in,
DArray< RField< D, T > > & fields,
UnitCell< D > & unitCell ) const
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.

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

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

◆ readFieldsRGrid() [2/2]

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

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

Definition at line 335 of file FieldIo.tpp.

References fileMaster(), and readFieldsRGrid().

◆ readFieldsRGridData()

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::readFieldsRGridData ( std::istream & in,
DArray< RField< D, T > > & fields,
int nMonomer ) const
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 (RField objects)
nMonomerexpected 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().

◆ readFieldRGrid() [1/2]

template<int D, class T>
bool Pscf::Rp::FieldIo< D, T >::readFieldRGrid ( std::istream & in,
RField< D, T > & field,
UnitCell< D > & unitCell ) const
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 (RField object)
unitCellassociated crystallographic unit cell
Returns
true iff header has a space group (isSymmetric flag)

Definition at line 376 of file FieldIo.tpp.

References Pscf::checkAllocateField(), mesh(), readFieldHeader(), Pscf::readMeshDimensions(), Pscf::readRGridData(), and UTIL_CHECK.

Referenced by ~FieldIo().

◆ readFieldRGrid() [2/2]

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

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 409 of file FieldIo.tpp.

◆ writeFieldsRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::writeFieldsRGrid ( std::ostream & out,
DArray< RField< D, T > > const & fields,
UnitCell< D > const & unitCell,
bool writeHeader = true,
bool isSymmetric = true,
bool writeMeshSize = true ) const
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?

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

◆ writeFieldsRGrid() [2/2]

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

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

Definition at line 464 of file FieldIo.tpp.

References fileMaster(), and writeFieldsRGrid().

◆ writeFieldRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::writeFieldRGrid ( std::ostream & out,
RField< D, T > const & field,
UnitCell< D > const & unitCell,
bool writeHeader = true,
bool isSymmetric = true ) const
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

Definition at line 483 of file FieldIo.tpp.

References mesh(), UTIL_CHECK, writeFieldHeader(), and Pscf::writeMeshDimensions().

Referenced by writeFieldRGrid(), and ~FieldIo().

◆ writeFieldRGrid() [2/2]

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

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

Definition at line 515 of file FieldIo.tpp.

References fileMaster(), and writeFieldRGrid().

◆ readFieldsKGrid() [1/2]

template<int D, class T>
bool Pscf::Rp::FieldIo< D, T >::readFieldsKGrid ( std::istream & in,
DArray< RFieldDft< D, T > > & fields,
UnitCell< D > & unitCell ) const
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.

Parameters
ininput stream (i.e., input file)
fieldsarray of k-space fields (RFieldDft)
unitCellassociated crystallographic unit cell
Returns
true iff header has a space group (isSymmetric flag)

Definition at line 534 of file FieldIo.tpp.

Referenced by convertKGridToBasis(), convertKGridToRGrid(), and ~FieldIo().

◆ readFieldsKGrid() [2/2]

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

Parameters
filenamename of input file
fieldsarray of k-space (RFieldDft) fields
unitCellassociated crystallographic unit cell
Returns
true iff header has a space group (isSymmetric flag)

Definition at line 567 of file FieldIo.tpp.

◆ writeFieldsKGrid() [1/2]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::writeFieldsKGrid ( std::ostream & out,
DArray< RFieldDft< D, T > > const & fields,
UnitCell< D > const & unitCell,
bool isSymmetric = true ) const
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 (RFieldDft)
unitCellassociated crystallographic unit cell
isSymmetriciff 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().

◆ writeFieldsKGrid() [2/2]

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

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

Definition at line 615 of file FieldIo.tpp.

References fileMaster(), and writeFieldsKGrid().

◆ convertBasisToKGrid() [1/3]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::convertBasisToKGrid ( DArray< double > const & components,
RFieldDft< D, T > & dft ) const
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

Definition at line 633 of file FieldIo.tpp.

Referenced by convertBasisToKGrid(), convertBasisToRGrid(), convertBasisToRGrid(), and ~FieldIo().

◆ convertBasisToKGrid() [2/3]

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

Parameters
infields expanded in symmetry-adapted Fourier basis
outfields defined as discrete Fourier transforms (k-grid)

Definition at line 660 of file FieldIo.tpp.

◆ convertKGridToBasis() [1/3]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::convertKGridToBasis ( RFieldDft< D, T > const & in,
DArray< double > & out,
bool checkSymmetry = true,
double epsilon = 1.0e-8 ) const
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)

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

◆ convertKGridToBasis() [2/3]

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

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 726 of file FieldIo.tpp.

References convertKGridToBasis(), Pscf::inspectArrays(), Pscf::inspectFields(), and UTIL_CHECK.

◆ convertBasisToRGrid() [1/3]

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

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

◆ convertBasisToRGrid() [2/3]

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

Parameters
infields in symmetry adapted basis form
outfields defined on real-space grid

Definition at line 782 of file FieldIo.tpp.

References Pscf::checkAllocateField(), convertBasisToKGrid(), mesh(), and UTIL_CHECK.

◆ convertRGridToBasis() [1/3]

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

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 819 of file FieldIo.tpp.

References Pscf::checkAllocateField(), convertKGridToBasis(), and mesh().

Referenced by convertRGridToBasis(), and ~FieldIo().

◆ convertRGridToBasis() [2/3]

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

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 834 of file FieldIo.tpp.

References Pscf::checkAllocateField(), convertKGridToBasis(), Pscf::inspectArrays(), Pscf::inspectFields(), mesh(), and UTIL_CHECK.

◆ convertKGridToRGrid() [1/3]

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

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

Definition at line 878 of file FieldIo.tpp.

References UTIL_ASSERT.

Referenced by ~FieldIo().

◆ convertKGridToRGrid() [2/3]

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

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

Definition at line 893 of file FieldIo.tpp.

◆ convertRGridToKGrid() [1/3]

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

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

Definition at line 905 of file FieldIo.tpp.

References UTIL_ASSERT.

Referenced by convertRGridToKGrid(), and ~FieldIo().

◆ convertRGridToKGrid() [2/3]

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

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

Definition at line 920 of file FieldIo.tpp.

◆ convertBasisToRGrid() [3/3]

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

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

Definition at line 802 of file FieldIo.tpp.

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

◆ convertRGridToBasis() [3/3]

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

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

Definition at line 860 of file FieldIo.tpp.

References convertRGridToBasis(), and readFieldsRGrid().

◆ convertKGridToRGrid() [3/3]

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

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

Definition at line 929 of file FieldIo.tpp.

References readFieldsKGrid().

◆ convertRGridToKGrid() [3/3]

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

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

Definition at line 952 of file FieldIo.tpp.

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

◆ convertKGridToBasis() [3/3]

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

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

Definition at line 749 of file FieldIo.tpp.

References convertKGridToBasis(), readFieldsKGrid(), and writeFieldsBasis().

◆ convertBasisToKGrid() [3/3]

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

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

Definition at line 683 of file FieldIo.tpp.

References convertBasisToKGrid(), readFieldsBasis(), and writeFieldsKGrid().

◆ hasSymmetry() [1/3]

template<int D, class T>
bool Pscf::Rp::FieldIo< D, T >::hasSymmetry ( RFieldDft< D, T > const & in,
double epsilon = 1.0e-8,
bool verbose = true ) const
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

Definition at line 974 of file FieldIo.tpp.

References mesh(), and UTIL_CHECK.

Referenced by ~FieldIo().

◆ hasSymmetry() [2/3]

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

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 1002 of file FieldIo.tpp.

◆ hasSymmetry() [3/3]

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

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 1016 of file FieldIo.tpp.

◆ compareFieldsBasis() [1/2]

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

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

◆ compareFieldsBasis() [2/2]

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

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

Definition at line 1057 of file FieldIo.tpp.

◆ compareFieldsRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::compareFieldsRGrid ( DArray< RField< D, T > > const & field1,
DArray< RField< D, T > > const & field2 ) const
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)

Definition at line 1073 of file FieldIo.tpp.

References Util::Log::file().

Referenced by compareFieldsRGrid(), and ~FieldIo().

◆ compareFieldsRGrid() [2/2]

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

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

Definition at line 1089 of file FieldIo.tpp.

References compareFieldsRGrid(), and readFieldsRGrid().

◆ scaleFieldBasis()

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::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 1107 of file FieldIo.tpp.

References Util::Array< Data >::capacity(), Util::Array< Data >::isAllocated(), and UTIL_CHECK.

Referenced by scaleFieldsBasis(), and ~FieldIo().

◆ scaleFieldsBasis() [1/2]

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

Parameters
fieldsarray of fields in basis form to be rescaled
factorfactor 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().

◆ scaleFieldsBasis() [2/2]

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

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

Definition at line 1139 of file FieldIo.tpp.

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

◆ scaleFieldRGrid()

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

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

Definition at line 1155 of file FieldIo.tpp.

References UTIL_CHECK.

Referenced by scaleFieldsRGrid(), and ~FieldIo().

◆ scaleFieldsRGrid() [1/2]

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

Parameters
fieldsarray of r-grid fields to be rescaled
factorfactor by which to multiply every field element

Definition at line 1167 of file FieldIo.tpp.

References scaleFieldRGrid().

Referenced by scaleFieldsRGrid(), and ~FieldIo().

◆ scaleFieldsRGrid() [2/2]

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

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

Definition at line 1181 of file FieldIo.tpp.

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

◆ estimateWBasis() [1/2]

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

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

◆ estimateWBasis() [2/2]

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

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

◆ replicateUnitCell() [1/3]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::replicateUnitCell ( std::ostream & out,
DArray< RField< D, T > > const & fields,
UnitCell< D > const & unitCell,
IntVec< D > const & replicas ) const
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

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

◆ replicateUnitCell() [2/3]

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

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 1344 of file FieldIo.tpp.

References fileMaster(), and replicateUnitCell().

◆ replicateUnitCell() [3/3]

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

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

Definition at line 1360 of file FieldIo.tpp.

References readFieldsRGrid(), and replicateUnitCell().

◆ expandRGridDimension() [1/3]

template<int D, class T>
void Pscf::Rp::FieldIo< D, T >::expandRGridDimension ( std::ostream & out,
DArray< RField< D, T > > const & fields,
UnitCell< D > const & unitCell,
int d,
DArray< int > const & newGridDimensions ) const
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..

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

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

◆ expandRGridDimension() [2/3]

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

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

Definition at line 1376 of file FieldIo.tpp.

References expandRGridDimension(), and fileMaster().

◆ expandRGridDimension() [3/3]

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

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 1392 of file FieldIo.tpp.

References expandRGridDimension(), and readFieldsRGrid().

◆ readFieldHeader()

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

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

◆ writeFieldHeader()

template<int D, class T>
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).

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 1504 of file FieldIo.tpp.

References UTIL_CHECK, and Pscf::writeFieldHeader().

Referenced by writeFieldRGrid(), writeFieldsKGrid(), writeFieldsRGrid(), Pscf::Rp::TrajectoryWriter< D, T >::writeHeader(), and ~FieldIo().

◆ mesh()

template<int D, class T>
Mesh< D > const & Pscf::Rp::FieldIo< D, T >::mesh ( ) const
inline

◆ basis()

template<int D, class T>
Basis< D > const & Pscf::Rp::FieldIo< D, T >::basis ( ) const
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().

◆ fileMaster()

template<int D, class T>
FileMaster const & Pscf::Rp::FieldIo< D, T >::fileMaster ( ) const
inline

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