1#ifndef PRDC_DOMAIN_TMPL_TPP
2#define PRDC_DOMAIN_TMPL_TPP
11#include "DomainTmpl.h"
12#include <prdc/crystal/SpaceGroup.h>
13#include <prdc/crystal/Basis.h>
14#include <prdc/field/fieldIoUtil.h>
15#include <util/signal/Signal.h>
16#include <util/misc/FileMaster.h>
26 template <
int D,
class FFT,
class WLT,
class FIT>
35 waveListPtr_(nullptr),
38 fileMasterPtr_(nullptr),
48 waveListPtr_ =
new WLT();
49 fieldIoPtr_ =
new FIT();
55 unitCell_.setSignal(*signalPtr_);
61 template <
int D,
class FFT,
class WLT,
class FIT>
74 template <
int D,
class FFT,
class WLT,
class FIT>
77 fileMasterPtr_ = &fileMaster;
78 fieldIo().setFileMaster(fileMaster);
84 template <
int D,
class FFT,
class WLT,
class FIT>
92 read(in,
"mesh", mesh_);
94 fft().setup(mesh_.dimensions());
97 read(in,
"lattice", lattice_);
98 unitCell_.set(lattice_);
103 waveList().allocate(mesh_, unitCell_);
107 bool hasGroupName =
false;
108 hasGroupName = readOptional(in,
"groupName", groupName_).isActive();
114 readGroup(groupName_, *groupPtr_);
118 isInitialized_ =
true;
126 template <
int D,
class FFT,
class WLT,
class FIT>
141 unitCell_, groupName_, nMonomer);
144 lattice_ = unitCell_.lattice();
151 if (label !=
"mesh" && label !=
"ngrid") {
152 std::string msg =
"\n";
153 msg +=
"Error reading field file:\n";
154 msg +=
"Expected mesh or ngrid, but found [";
163 if (mesh_.size() == 0) {
164 mesh_.setDimensions(nGrid);
165 fft().setup(mesh_.dimensions());
170 waveList().allocate(mesh_, unitCell_);
174 if (groupName_ !=
"") {
175 readGroup(groupName_, *groupPtr_);
180 isInitialized_ =
true;
186 template <
int D,
class FFT,
class WLT,
class FIT>
195 if (!
basis().isInitialized()) {
206 template <
int D,
class FFT,
class WLT,
class FIT>
214 fileMaster().openOutputFile(filename, file);
215 bool isSymmetric =
true;
217 fieldIo().writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
218 basis().outputStars(file);
225 template <
int D,
class FFT,
class WLT,
class FIT>
233 fileMaster().openOutputFile(filename, file);
234 bool isSymmetric =
true;
236 fieldIo().writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
237 basis().outputWaves(file);
244 template <
int D,
class FFT,
class WLT,
class FIT>
251 fileMaster().openOutputFile(filename, file);
259 template <
int D,
class FFT,
class WLT,
class FIT>
261 {
return basis().isInitialized(); }
An IntVec<D, T> is a D-component vector of elements of integer type T.
Symmetry-adapted Fourier basis for pseudo-spectral SCFT.
Fourier transform wrapper.
void writeWaves(std::string const &filename) const
Output information about waves.
WLT & waveList()
Get the WaveList by non-const reference.
void readRGridFieldHeader(std::istream &in, int &nMonomer)
Read initialization data from header of an r-grid field file.
bool hasBasis() const
Has a symmetry-adapted Fourier basis been initialized?
virtual void readParameters(std::istream &in)
Read body of parameter block (without opening and closing lines).
Basis< D > & basis()
Get the Basis object by non-const reference.
FIT & fieldIo()
Get the FieldIo by non-const reference.
void setFileMaster(FileMaster &fileMaster)
Create association with a FileMaster, needed by FieldIo.
FFT & fft()
Get the FFT by non-const reference.
SpaceGroup< D > const & group() const
Get the SpaceGroup by const reference.
void writeStars(std::string const &filename) const
Output information about stars and symmetrized basis functions.
bool hasGroup() const
Has a space group been declared?
void writeGroup(std::string const &filename) const
Output all elements of the space group.
void makeBasis()
Construct basis if not done already.
Crystallographic space group.
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.