PSCF v1.2
|
File input/output operations and format conversions for fields. More...
#include <FieldIo.h>
Public Member Functions | |
FieldIo () | |
Default constructor. | |
~FieldIo () | |
Destructor. | |
void | readFieldsRGrid (std::istream &in, DArray< RField< D > > &fields, UnitCell< D > &unitCell) const override |
Read array of RField objects (r-grid fields) from a stream. | |
void | readFieldsRGridData (std::istream &in, DArray< RField< D > > &fields, int nMonomer) const override |
Read data for an array of r-grid fields, with no header section. | |
void | readFieldRGrid (std::istream &in, RField< D > &field, UnitCell< D > &unitCell) const override |
Read a single RField (field on an r-space grid) from a stream. | |
void | writeFieldsRGrid (std::ostream &out, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true, bool writeMeshSize=true) const override |
Write array of RField objects (fields on r-space grid) to a stream. | |
void | writeFieldRGrid (std::ostream &out, RField< D > const &field, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true) const override |
Write a single RField (field on an r-space grid) to a stream. | |
void | readFieldsKGrid (std::istream &in, DArray< RFieldDft< D > > &fields, UnitCell< D > &unitCell) const override |
Read array of RFieldDft objects (k-space fields) from a stream. | |
void | writeFieldsKGrid (std::ostream &out, DArray< RFieldDft< D > > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const override |
Write array of RFieldDft objects (k-space fields) to file. | |
void | convertBasisToKGrid (DArray< double > const &components, RFieldDft< D > &dft) const override |
Convert a field from symmetrized basis to Fourier grid (k-grid). | |
void | convertKGridToBasis (RFieldDft< D > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const override |
Convert a field from Fourier (k-grid) to symmetrized basis form. | |
bool | hasSymmetry (RFieldDft< D > const &in, double epsilon=1.0e-8, bool verbose=true) const override |
Check if a k-grid field has the declared space group symmetry. | |
void | scaleFieldBasis (DArray< double > &field, double factor) const override |
Rescale a single field in basis format by a scalar factor. | |
void | scaleFieldRGrid (RField< D > &field, double factor) const override |
Rescale a single r-grid field by a scalar factor. | |
void | expandRGridDimension (std::ostream &out, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const override |
Expand spatial dimension of an array of r-grid fields. | |
void | replicateUnitCell (std::ostream &out, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const override |
Write r-grid fields in a replicated unit cell to std::ostream. | |
![]() | |
FieldIoReal () | |
Constructor. | |
virtual | ~FieldIoReal () |
Destructor. | |
void | associate (Mesh< D > const &mesh, FFT< D > const &fft, typename UnitCell< D >::LatticeSystem const &lattice, bool const &hasGroup, std::string const &groupName, SpaceGroup< D > const &group, Basis< D > &basis) |
Create association with other objects in parent Domain. | |
void | setFileMaster (FileMaster const &fileMaster) |
Create an association with a FileMaster. | |
void | readFieldsBasis (std::istream &in, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read concentration or chemical potential fields from file. | |
void | readFieldsBasis (std::string filename, DArray< DArray< double > > &fields, UnitCell< D > &unitCell) const |
Read concentration or chemical potential components from file. | |
void | readFieldBasis (std::istream &in, DArray< double > &field, UnitCell< D > &unitCell) const |
Read single concentration or chemical potential field from file. | |
void | readFieldBasis (std::string filename, DArray< double > &field, UnitCell< D > &unitCell) const |
Read single concentration or chemical potential field from file. | |
void | writeFieldBasis (std::string filename, DArray< double > const &field, UnitCell< D > const &unitCell) const |
Write single concentration or chemical potential field to file. | |
void | 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 | writeFieldsBasis (std::ostream &out, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write concentration or chemical potential field components to file. | |
void | writeFieldsBasis (std::string filename, DArray< DArray< double > > const &fields, UnitCell< D > const &unitCell) const |
Write concentration or chemical potential field components to file. | |
virtual void | readFieldsRGrid (std::istream &in, DArray< RField< D > > &fields, UnitCell< D > &unitCell) const |
Read array of RField objects (r-grid fields) from an istream. | |
void | readFieldsRGrid (std::string filename, DArray< RField< D > > &fields, UnitCell< D > &unitCell) const |
Read array of RField objects (fields on r-space grid) from file. | |
virtual void | readFieldsRGridData (std::istream &in, DArray< RField< D > > &fields, int nMonomer) const |
Read data for array of r-grid fields, with no header section. | |
virtual void | readFieldRGrid (std::istream &in, RField< D > &field, UnitCell< D > &unitCell) const |
Read single RField (field on an r-space grid) from an istream. | |
void | readFieldRGrid (std::string filename, RField< D > &field, UnitCell< D > &unitCell) const |
Read single RField (field on an r-space grid) from named file. | |
virtual void | writeFieldsRGrid (std::ostream &out, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true, bool writeMeshSize=true) const |
Write array of RField objects (fields on r-space grid) to ostream. | |
void | writeFieldsRGrid (std::string filename, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RField objects (fields on an r-space grid) to file. | |
virtual void | writeFieldRGrid (std::ostream &out, RField< D > const &field, UnitCell< D > const &unitCell, bool writeHeader=true, bool isSymmetric=true) const |
Write a single RField (field on an r-space grid) to ostream. | |
void | writeFieldRGrid (std::string filename, RField< D > const &field, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write a single RField (fields on an r-space grid) to a file. | |
virtual void | readFieldsKGrid (std::istream &in, DArray< RFieldDft< D > > &fields, UnitCell< D > &unitCell) const |
Read array of RFieldDft objects (k-space fields) from istream. | |
void | readFieldsKGrid (std::string filename, DArray< RFieldDft< D > > &fields, UnitCell< D > &unitCell) const |
Read array of RFieldDft objects (k-space fields) from file. | |
virtual void | writeFieldsKGrid (std::ostream &out, DArray< RFieldDft< D > > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RFieldDft objects (k-space fields) to file. | |
void | writeFieldsKGrid (std::string filename, DArray< RFieldDft< D > > const &fields, UnitCell< D > const &unitCell, bool isSymmetric=true) const |
Write array of RFieldDft objects (k-space fields) to a file. | |
virtual void | convertBasisToKGrid (DArray< double > const &components, RFieldDft< D > &dft) const |
Convert a field from symmetrized basis to Fourier grid (k-grid). | |
void | convertBasisToKGrid (DArray< DArray< double > > const &in, DArray< RFieldDft< D > > &out) const |
Convert fields from symmetrized basis to Fourier grid (k-grid). | |
virtual void | convertKGridToBasis (RFieldDft< D > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert a field from Fourier (k-grid) to symmetrized basis form. | |
void | convertKGridToBasis (DArray< RFieldDft< D > > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert multiple fields from Fourier (k-grid) to symmetrized basis. | |
void | convertBasisToRGrid (DArray< double > const &in, RField< D > &out) const |
Convert a field from symmetrized basis to spatial grid (r-grid). | |
void | convertBasisToRGrid (DArray< DArray< double > > const &in, DArray< RField< D > > &out) const |
Convert fields from symmetrized basis to spatial grid (r-grid). | |
void | convertRGridToBasis (RField< D > const &in, DArray< double > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert a field from spatial grid (r-grid) to symmetrized basis. | |
void | convertRGridToBasis (DArray< RField< D > > const &in, DArray< DArray< double > > &out, bool checkSymmetry=true, double epsilon=1.0e-8) const |
Convert fields from spatial grid (r-grid) to symmetrized basis. | |
void | convertKGridToRGrid (DArray< RFieldDft< D > > const &in, DArray< RField< D > > &out) const |
Convert fields from k-grid (DFT) to real space (r-grid) format. | |
void | convertKGridToRGrid (RFieldDft< D > const &in, RField< D > &out) const |
Convert a field from k-grid (DFT) to real space (r-grid) format. | |
void | convertRGridToKGrid (DArray< RField< D > > const &in, DArray< RFieldDft< D > > &out) const |
Convert fields from spatial grid (r-grid) to k-grid format. | |
void | convertRGridToKGrid (RField< D > const &in, RFieldDft< D > &out) const |
Convert a field from spatial grid (r-grid) to k-grid format. | |
virtual bool | hasSymmetry (RFieldDft< D > 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 > const &in, double epsilon=1.0e-8, bool verbose=true) const |
Check if an r-grid field has the declared space group symmetry. | |
void | scaleFieldsBasis (DArray< DArray< double > > &fields, double factor) const |
Scale an array of fields in basis format by a real scalar. | |
virtual void | scaleFieldRGrid (RField< D > &field, double factor) const |
Multiply a single field in r-grid format by a real scalar. | |
void | scaleFieldsRGrid (DArray< RField< D > > &fields, double factor) const |
Scale an array of r-grid fields by a real scalar. | |
virtual void | replicateUnitCell (std::ostream &out, DArray< RField< D > > 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 > > const &fields, UnitCell< D > const &unitCell, IntVec< D > const &replicas) const |
Write r-grid fields in a replicated unit cell to named file. | |
virtual void | expandRGridDimension (std::ostream &out, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > const &newGridDimensions) const |
Expand dimension of an array of r-grid fields, write to ostream. | |
void | expandRGridDimension (std::string filename, DArray< RField< D > > const &fields, UnitCell< D > const &unitCell, int d, DArray< int > newGridDimensions) const |
Expand dimensions of array of r-grid fields, write to file. | |
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) | |
Additional Inherited Members | |
![]() | |
Mesh< D > const & | mesh () const |
Get spatial discretization mesh by const reference. | |
FFT< D > const & | fft () const |
Get FFT object by const reference. | |
UnitCell< D >::LatticeSystem const & | lattice () const |
Get the lattice type enum value by const reference. | |
bool | hasGroup () const |
Has a space group been declared externally ? | |
std::string const & | groupName () const |
Get associated group name string by const reference. | |
SpaceGroup< D > const & | group () const |
Get associated SpaceGroup<D> by const reference. | |
Basis< D > const & | basis () const |
Get the associated Basis by const reference. | |
FileMaster const & | fileMaster () const |
Get associated FileMaster by const reference. | |
File input/output operations and format conversions for fields.
Please refer to the documentation of the base class Prdc::FieldIoReal for more complete API documentation for this class template, for reasons discussed below.
Class template Rpc::FieldIo<int D> is derived from a partial specialization of template Prdc::FieldIoReal<D, RFRT, RFKT, FFFT> that is implemented using classes RFRT=RField<D>, RFKT=RFieldDft<D>, and FFFT=FFT<D> that are all defined in the Prdc::Cpu subspace, and that use only conventional use CPU hardware. Rpc::FieldIo is thus a specialization of the FieldIoReal template for CPU hardware. An analogous class template named named Rpg::FieldIo that is designed to use a GPU is defined in the Pscf::Rpg namespace
The pubiic interface of Rpc::FieldIo is identical to that of the base class template Prdc::FieldIoReal. All member functions defined in this Rpc::FieldIo are reimplemented virtual functions that are declared and documented in Prdc::FieldIoReal, but that have trivial do-nothing implementations in the base class. These are all functions for which different implementations are required for the CPU and GPU variants, and which are thus also reimplemented in Rpg::FieldIo.
Definition at line 22 of file rpc/field/WFieldContainer.h.
Pscf::Rpc::FieldIo< D >::FieldIo | ( | ) |
Default constructor.
Definition at line 36 of file rpc/field/FieldIo.tpp.
Pscf::Rpc::FieldIo< D >::~FieldIo | ( | ) |
Destructor.
Definition at line 44 of file rpc/field/FieldIo.tpp.
|
override |
Read array of RField objects (r-grid fields) from a stream.
See documentation of analogous function in Prdc::FieldIoReal.
in | input file stream |
fields | array of RField fields (r-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 51 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::checkAllocateFields(), Pscf::Prdc::readFieldHeader(), Pscf::Prdc::readMeshDimensions(), and Pscf::Prdc::readRGridData().
Referenced by Pscf::Rpc::System< D >::rGridToBasis(), Pscf::Rpc::System< D >::rGridToKGrid(), Pscf::Rpc::System< D >::scaleFieldsRGrid(), and Pscf::Rpc::EinsteinCrystalPerturbation< D >::setup().
|
override |
Read data for an array of r-grid fields, with no header section.
See documentation of analogous function in Prdc::FieldIoReal.
in | input file stream |
fields | array of RField fields (r-space grid) |
nMonomer | number of monomer types |
Definition at line 74 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::checkAllocateFields(), and Pscf::Prdc::readRGridData().
Referenced by Pscf::Rpc::RGridTrajectoryReader< D >::readFrame().
|
override |
Read a single RField (field on an r-space grid) from a stream.
See documentation of analogous function in Prdc::FieldIoReal.
in | input file stream |
field | fields defined on r-space grid |
unitCell | associated crystallographic unit cell |
Definition at line 89 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::checkAllocateField(), Pscf::Prdc::readFieldHeader(), Pscf::Prdc::readMeshDimensions(), Pscf::Prdc::readRGridData(), and UTIL_CHECK.
|
override |
Write array of RField objects (fields on r-space grid) to a stream.
See documentation of analogous function in Prdc::FieldIoReal.
out | output stream (i.e., output file) |
fields | array of RField objects (fields on r-space grid) |
unitCell | associated crystallographic unit cell |
writeHeader | flag to write file header if true |
isSymmetric | Do fields have a space group symmetry ? |
writeMeshSize | Should mesh size be written in header? |
Definition at line 113 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::inspectFields(), Pscf::Prdc::writeFieldHeader(), Pscf::Prdc::writeMeshDimensions(), and Pscf::Prdc::writeRGridData().
Referenced by Pscf::Rpc::System< D >::basisToRGrid(), Pscf::Rpc::System< D >::kGridToRGrid(), Pscf::Rpc::System< D >::scaleFieldsRGrid(), Pscf::Rpc::ConcentrationWriter< D >::writeFrame(), and Pscf::Rpc::TrajectoryWriter< D >::writeFrame().
|
override |
Write a single RField (field on an r-space grid) to a stream.
See documentation of analogous function in Prdc::FieldIoReal.
out | output stream |
field | field defined on r-space grid |
unitCell | associated crystallographic unit cell |
writeHeader | Should a file header be written? |
isSymmetric | Does the field have a space group symmetry? |
Definition at line 144 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::Cpu::RField< D >::meshDimensions(), Pscf::Prdc::writeFieldHeader(), Pscf::Prdc::writeMeshDimensions(), and Pscf::Prdc::writeRGridData().
|
override |
Read array of RFieldDft objects (k-space fields) from a stream.
See documentation of analogous function in Prdc::FieldIoReal.
in | input stream (i.e., input file) |
fields | array of RFieldDft fields (k-space grid) |
unitCell | associated crystallographic unit cell |
Definition at line 169 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::checkAllocateFields(), Pscf::Prdc::readFieldHeader(), Pscf::Prdc::readKGridData(), and Pscf::Prdc::readMeshDimensions().
Referenced by Pscf::Rpc::System< D >::kGridToRGrid().
|
override |
Write array of RFieldDft objects (k-space fields) to file.
See documentation of analogous function in Prdc::FieldIoReal.
out | output stream (i.e., output file) |
fields | array of RFieldDft fields |
unitCell | associated crystallographic unit cell |
isSymmetric | Does this field have space group symmetry? |
Definition at line 193 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::inspectFields(), Pscf::Prdc::writeFieldHeader(), Pscf::Prdc::writeKGridData(), and Pscf::Prdc::writeMeshDimensions().
Referenced by Pscf::Rpc::System< D >::rGridToKGrid().
|
override |
Convert a field from symmetrized basis to Fourier grid (k-grid).
See documentation of analogous function in Prdc::FieldIoReal.
components | coefficients of in symmetry-adapted basis |
dft | discrete Fourier transform of a real field |
Definition at line 219 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::convertBasisToKGrid(), and Pscf::Prdc::Cpu::RFieldDft< D >::dftDimensions().
|
override |
Convert a field from Fourier (k-grid) to symmetrized basis form.
See documentation of analogous function in Prdc::FieldIoReal.
in | discrete Fourier transform (k-grid) of a field |
out | components of field in asymmetry-adapted Fourier basis |
checkSymmetry | flag indicating whether to check symmetry |
epsilon | error tolerance for symmetry test (if any) |
Definition at line 232 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::convertKGridToBasis(), and Pscf::Prdc::Cpu::RFieldDft< D >::dftDimensions().
|
override |
Check if a k-grid field has the declared space group symmetry.
See documentation of analogous function in Prdc::FieldIoReal.
in | field in real space grid (r-grid) format |
epsilon | error threshold used to test for symmetry |
verbose | if true, write error to Log::file() |
Definition at line 248 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::Cpu::RFieldDft< D >::dftDimensions(), and Pscf::Prdc::hasSymmetry().
|
overridevirtual |
Rescale a single field in basis format by a scalar factor.
See documentation of analogous function in Prdc::FieldIoReal. Multiplication is done in-place, and so modifies the input.
field | field in basis format (in-out) |
factor | real scalar by which to multiply all components |
Reimplemented from Pscf::Prdc::FieldIoReal< D, RField< D >, RFieldDft< D >, FFT< D > >.
Definition at line 263 of file rpc/field/FieldIo.tpp.
References Util::Array< Data >::capacity().
|
override |
Rescale a single r-grid field by a scalar factor.
See documentation of analogous function in Prdc::FieldIoReal. Multiplication is done in-place, and so modifies the input.
field | real space (r-grid) field (in-out) |
factor | real scalar by which to multiply all elements |
Definition at line 277 of file rpc/field/FieldIo.tpp.
References Util::Array< Data >::capacity().
|
override |
Expand spatial dimension of an array of r-grid fields.
See documentation of analogous function in Prdc::FieldIoReal.
out | output file stream |
fields | input array of D-dimensional r-grid fields |
unitCell | original D-dimensional unit cell |
d | expanded spatial dimension (d > D) |
newGridDimensions | number of grid points in added dimensions |
Definition at line 313 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::expandRGridDimension().
|
override |
Write r-grid fields in a replicated unit cell to std::ostream.
See documentation of analogous function in Prdc::FieldIoReal.
out | output file stream |
fields | array of RField (r-space) fields to be replicated |
unitCell | original crystallographic unit cell |
replicas | number of unit cell replicas in each direction |
Definition at line 291 of file rpc/field/FieldIo.tpp.
References Pscf::Prdc::inspectFields(), and Pscf::Prdc::replicateUnitCell().