1#ifndef PRDC_DOMAIN_REAL_TPP
2#define PRDC_DOMAIN_REAL_TPP
11#include "DomainReal.h"
12#include <prdc/field/fieldIoUtil.h>
13#include <util/signal/Signal.h>
14#include <util/misc/FileMaster.h>
24 template <
int D,
class FFT,
class WLT,
class FIT>
36 fileMasterPtr_(nullptr),
41 fieldIo_.associate(mesh_, fft_, lattice_,
42 hasGroup_, groupName_, group_, basis_);
46 unitCell_.setSignal(*signalPtr_);
52 template <
int D,
class FFT,
class WLT,
class FIT>
61 template <
int D,
class FFT,
class WLT,
class FIT>
64 fileMasterPtr_ = &fileMaster;
65 fieldIo_.setFileMaster(fileMaster);
71 template <
int D,
class FFT,
class WLT,
class FIT>
79 read(in,
"mesh", mesh_);
81 fft_.setup(mesh_.dimensions());
84 read(in,
"lattice", lattice_);
85 unitCell_.set(lattice_);
90 waveList_.allocate(mesh_, unitCell_);
94 bool hasGroupName =
false;
95 hasGroupName = readOptional(in,
"groupName", groupName_).isActive();
101 readGroup(groupName_, group_);
105 isInitialized_ =
true;
113 template <
int D,
class FFT,
class WLT,
class FIT>
128 unitCell_, groupName_, nMonomer);
131 lattice_ = unitCell_.lattice();
138 if (label !=
"mesh" && label !=
"ngrid") {
139 std::string msg =
"\n";
140 msg +=
"Error reading field file:\n";
141 msg +=
"Expected mesh or ngrid, but found [";
150 if (mesh_.size() == 0) {
151 mesh_.setDimensions(nGrid);
152 fft_.setup(mesh_.dimensions());
156 if (!waveList_.isAllocated()) {
157 waveList_.allocate(mesh_, unitCell_);
161 if (groupName_ !=
"") {
162 readGroup(groupName_, group_);
164 basis_.makeBasis(mesh_, unitCell_, group_);
167 isInitialized_ =
true;
173 template <
int D,
class FFT,
class WLT,
class FIT>
182 if (!basis_.isInitialized()) {
183 basis_.makeBasis(mesh_, unitCell_, group_);
193 template <
int D,
class FFT,
class WLT,
class FIT>
201 fileMaster().openOutputFile(filename, file);
202 bool isSymmetric =
true;
204 fieldIo_.writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
205 basis_.outputStars(file);
212 template <
int D,
class FFT,
class WLT,
class FIT>
220 fileMaster().openOutputFile(filename, file);
221 bool isSymmetric =
true;
223 fieldIo_.writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
224 basis_.outputWaves(file);
231 template <
int D,
class FFT,
class WLT,
class FIT>
238 fileMaster().openOutputFile(filename, file);
An IntVec<D, T> is a D-component vector of elements of integer type T.
void writeGroup(std::string const &filename) const
Output all elements of the space group.
virtual void readParameters(std::istream &in)
Read body of parameter block (without opening and closing lines).
void readRGridFieldHeader(std::istream &in, int &nMonomer)
Read initialization data from header of an r-grid field file.
void setFileMaster(FileMaster &fileMaster)
Create association with a FileMaster, needed by FieldIo.
void writeStars(std::string const &filename) const
Output information about stars and symmetrized basis functions.
void makeBasis()
Construct basis if not done already.
bool hasGroup() const
Has a space group been declared?
void writeWaves(std::string const &filename) const
Output information about waves.
Base template for UnitCell<D> classes, D=1, 2 or 3.
A FileMaster manages input and output files for a simulation.
void setClassName(const char *className)
Set class name string.
Notifier (or subject) in the Observer design pattern.
#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 readFieldHeader(std::istream &in, int &ver1, int &ver2, UnitCell< D > &cell, std::string &groupName, int &nMonomer)
Read common part of field header (fortran PSCF format).
Periodic fields and crystallography.
PSCF package top-level namespace.