1#ifndef RP_RGRID_TRAJECTORY_READER_TPP
2#define RP_RGRID_TRAJECTORY_READER_TPP
11#include "RGridTrajectoryReader.h"
13#include <rp/system/System.h>
14#include <rp/solvers/Mixture.h>
15#include <rp/field/Domain.h>
16#include <rp/field/FieldIo.h>
17#include <rp/field/WFields.h>
18#include <rp/field/CFields.h>
20#include <pscf/crystal/UnitCell.h>
21#include <util/misc/ioUtil.h>
22#include <util/misc/FileMaster.h>
27 template <
int D,
class T>
class FieldIo;
34 template <
int D,
class T>
44 template <
int D,
class T>
45 void RGridTrajectoryReader<D,T>::allocate()
47 const int nMonomer = system().mixture().nMonomer();
49 meshDimensions_ = system().domain().mesh().dimensions();
51 wField_.allocate(nMonomer);
52 for (
int i = 0; i < nMonomer; ++i) {
53 wField_[i].allocate(meshDimensions_);
62 template <
int D,
class T>
65 system().fileMaster().open(filename, inputfile_);
72 template <
int D,
class T>
83 system().setUnitCell(tmpUnitCell);
90 template <
int D,
class T>
95 UTIL_THROW(
"Memory not allocated in RGridTrajectoryReader");
99 std::stringstream line;
114 step = std::stoi(value);
125 line >> fileMeshDimensions;
127 UTIL_CHECK(fileMeshDimensions == meshDimensions_);
130 int nMonomer =
system().mixture().nMonomer();
135 system().w().setRGrid(wField_);
143 template <
int D,
class T>
145 { inputfile_.close(); }
An IntVec<D, T> is a D-component vector of elements of integer type T.
File input/output, format conversions and other utilities for fields.
void readFieldHeader(std::istream &in, int &nMonomer, UnitCell< D > &unitCell, bool &isSymmetric) const
Reader header of field file (fortran PSCF format).
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.
bool readFrame() override
Read a single frame from the trajectory file.
RGridTrajectoryReader(System< D, T > &system)
Constructor.
void readHeader() override
Read header of trajectory file (if any).
void close() override
Close the trajectory file.
void open(std::string filename) override
Open trajectory file and read header, if any.
Base class template for classes that represent a complete system.
TrajectoryReader(System< D, T > &system)
Constructor.
System< D, T > & system()
Return reference to parent system.
Base template for UnitCell<D> classes, D=1, 2 or 3.
static std::ostream & file()
Get log ostream by reference.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void checkString(std::istream &in, const std::string &expected)
Extract string from stream, and compare to expected value.
bool getNextLine(std::istream &in, std::string &line)
Read the next non-empty line into a string, strip trailing whitespace.
bool hasSymmetry(AT const &in, Basis< D > const &basis, IntVec< D > const &dftDimensions, double epsilon=1.0e-8, bool verbose=true)
Check if a k-grid field has the declared space group symmetry.
Code for programs that simulate real-valued periodic fields.
PSCF package top-level namespace.