42 const std::vector<std::vector<Complex>>& values_per_spin,
45 , title_(std::move(title))
46 , values_per_spin_(values_per_spin)
51 const std::vector<std::vector<Complex>>&,
55 void write(std::ofstream& output_file)
const {
58 if (
static_cast<int>(values_per_spin_.size()) != number_of_spin_components) {
59 throw std::runtime_error(
60 title_ +
": the field has " + std::to_string(values_per_spin_.size()) +
61 " spin channel(s), the record " + std::to_string(number_of_spin_components));
63 for (
const auto& values : values_per_spin_) {
64 if (
static_cast<int>(values.size()) != number_of_g_vectors) {
65 throw std::runtime_error(title_ +
": the field has " +
66 std::to_string(values.size()) +
67 " G-vector components, the charge-density G-set " +
68 std::to_string(number_of_g_vectors));
73 header.
write(output_file);
78 std::vector<Complex> scaled_values;
79 scaled_values.reserve(
static_cast<size_t>(number_of_g_vectors) * number_of_spin_components);
80 for (
const auto& values : values_per_spin_) {
81 for (
const Complex& value : values) {
82 scaled_values.push_back(value * scale_);
86 output_file, number_of_g_vectors, scaled_values.data(), scaled_values.size());
92 const std::vector<std::vector<Complex>>& values_per_spin_;
One per-spin field on the charge-density G-set, in RHO's layout; see the file comment.
BerkeleyGWFieldFile(const MeanFieldRecord &&, std::string, const std::vector< std::vector< Complex > > &, Real)=delete
See the file writers' own deleted rvalue constructors: this holds references.
void write(std::ofstream &output_file) const
Writes header, G-set and field to an open stream; throws if the field is not on the G-set.
BerkeleyGWFieldFile(const MeanFieldRecord &record, std::string title, const std::vector< std::vector< Complex > > &values_per_spin, Real scale)
Writes the records BerkeleyGW's files share; see the file comment.
void write_charge_density_gvectors(std::ofstream &output_file) const
[nrecord=1][ng][gvec(3,ng)] – the charge-density G-set, in the record's order.
void write_complex_block(std::ofstream &output_file, int32_t count, const Complex *values, size_t number_of_values) const
[nrecord=1][count][values] – one data block of count complex values per spin.
std::complex< double > Complex
int number_of_spin_components
int number_of_g_vectors() const