1#ifndef PRDC_FIELD_HEADER_TPP
2#define PRDC_FIELD_HEADER_TPP
11#include <prdc/crystal/UnitCell.h>
12#include <prdc/crystal/unitCellHeader.h>
14#include <pscf/mesh/Mesh.h>
15#include <pscf/math/IntVec.h>
16#include <pscf/math/arithmetic.h>
18#include <util/misc/Log.h>
19#include <util/format/Int.h>
20#include <util/format/Dbl.h>
21#include <util/math/Constants.h>
35 std::string& groupName,
60 if (label ==
"group_name") {
78 std::string
const & groupName,
82 out <<
"format " <<
Int(ver1,3) <<
" " <<
Int(ver2,3) << std::endl;
83 out <<
"dim" << std::endl
84 <<
" " << D << std::endl;
91 if (groupName !=
"") {
92 out <<
"group_name" << std::endl
93 <<
" " << groupName << std::endl;
99 out <<
"N_monomer" << std::endl
100 <<
" " << nMonomer << std::endl;
119 if (label !=
"mesh" && label !=
"ngrid") {
120 std::string msg =
"\n";
121 msg +=
"Error reading field file:\n";
122 msg +=
"Expected mesh or ngrid, but found [";
128 in >> meshDimensionsIn;
130 if (meshDimensionsIn != meshDimensions) {
132 <<
"Inconsistent mesh dimensions:\n"
133 <<
"meshDimensions (expected) = " << meshDimensions <<
"\n"
134 <<
"meshDimensions (from file) = " << meshDimensionsIn <<
"\n";
135 UTIL_THROW(
"Unexpected mesh dimensions in field file header");
143 out <<
"mesh " << std::endl
144 <<
" " << meshDimensions << std::endl;
An IntVec<D, T> is a D-component vector of elements of integer type T.
Base template for UnitCell<D> classes, D=1, 2 or 3.
Wrapper for an int, for formatted ostream output.
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.
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
void readUnitCellHeader(std::istream &in, UnitCell< D > &cell)
Read UnitCell<D> from a field file header (fortran PSCF format).
void writeFieldHeader(std::ostream &out, int ver1, int ver2, UnitCell< D > const &cell, std::string const &groupName, int nMonomer)
Write common part of field header (fortran PSCF format).
void writeUnitCellHeader(std::ostream &out, UnitCell< D > const &cell)
Write UnitCell<D> to a field file header (fortran PSCF format).
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).
void writeMeshDimensions(std::ostream &out, IntVec< D > const &meshDimensions)
Write mesh dimensions to a field file header.
void readMeshDimensions(std::istream &in, IntVec< D > const &meshDimensions)
Read mesh dimensions from a field file header.
Periodic fields and crystallography.
PSCF package top-level namespace.