12#include <prdc/crystal/SpaceGroup.h>
13#include <prdc/crystal/Basis.h>
14#include <prdc/field/fieldHeader.h>
15#include <util/signal/Signal.h>
16#include <util/misc/FileMaster.h>
27 template <
int D,
class FFT,
class WLT,
class FIT>
36 waveListPtr_(nullptr),
39 fileMasterPtr_(nullptr),
49 waveListPtr_ =
new WLT();
50 fieldIoPtr_ =
new FIT();
56 unitCell_.setSignal(*signalPtr_);
62 template <
int D,
class FFT,
class WLT,
class FIT>
75 template <
int D,
class FFT,
class WLT,
class FIT>
78 fileMasterPtr_ = &fileMaster;
79 fieldIo().setFileMaster(fileMaster);
85 template <
int D,
class FFT,
class WLT,
class FIT>
95 fft().setup(mesh_.dimensions());
99 unitCell_.set(lattice_);
104 waveList().allocate(mesh_, unitCell_);
108 bool hasGroupName =
false;
110 in,
"groupName", groupName_).isActive();
116 readGroup(groupName_, *groupPtr_);
120 isInitialized_ =
true;
128 template <
int D,
class FFT,
class WLT,
class FIT>
143 unitCell_, groupName_, nMonomer);
146 lattice_ = unitCell_.lattice();
153 if (label !=
"mesh" && label !=
"ngrid") {
154 std::string msg =
"\n";
155 msg +=
"Error reading field file:\n";
156 msg +=
"Expected mesh or ngrid, but found [";
165 if (mesh_.size() == 0) {
166 mesh_.setDimensions(nGrid);
167 fft().setup(mesh_.dimensions());
172 waveList().allocate(mesh_, unitCell_);
176 if (groupName_ !=
"") {
177 readGroup(groupName_, *groupPtr_);
182 isInitialized_ =
true;
188 template <
int D,
class FFT,
class WLT,
class FIT>
197 if (!
basis().isInitialized()) {
208 template <
int D,
class FFT,
class WLT,
class FIT>
216 fileMaster().openOutputFile(filename, file);
217 bool isSymmetric =
true;
219 fieldIo().writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
220 basis().outputStars(file);
227 template <
int D,
class FFT,
class WLT,
class FIT>
235 fileMaster().openOutputFile(filename, file);
236 bool isSymmetric =
true;
238 fieldIo().writeFieldHeader(file, nMonomer, unitCell_, isSymmetric);
239 basis().outputWaves(file);
246 template <
int D,
class FFT,
class WLT,
class FIT>
253 fileMaster().openOutputFile(filename, file);
261 template <
int D,
class FFT,
class WLT,
class FIT>
263 {
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.
Crystallographic space group.
Base template for UnitCell<D> classes, D=1, 2 or 3.
bool hasBasis() const
Has a symmetry-adapted Fourier basis been initialized?
SpaceGroup< D > const & group() const
Get the SpaceGroup by const reference.
WaveList< D > & waveList()
void setFileMaster(FileMaster &fileMaster)
Create association with a FileMaster, needed by FieldIo.
FIT & fieldIo()
Get the FieldIo by non-const reference.
Basis< D > & basis()
Get the Basis object by non-const reference.
void writeStars(std::string const &filename) const
Output information about stars and symmetrized basis functions.
virtual void readParameters(std::istream &in)
Read body of parameter block (without opening and closing lines).
FFT & fft()
Get the FFT by non-const reference.
void makeBasis()
Construct basis if not done already.
void writeGroup(std::string const &filename) const
Output all elements of the space group.
void readRGridFieldHeader(std::istream &in, int &nMonomer)
Read initialization data from header of an r-grid field file.
void writeWaves(std::string const &filename) const
Output information about waves.
A FileMaster manages input and output files for a simulation.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
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.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.