PSCF v1.2
fieldIoUtil.h
1#ifndef PRDC_FIELD_IO_UTIL_H
2#define PRDC_FIELD_IO_UTIL_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <pscf/math/IntVec.h> // Template with a default parameter
12
13// Forward class declarations
14namespace Util {
15 template <typename T> class DArray;
16}
17namespace Pscf {
18 template <int D> class Mesh;
19 namespace Prdc {
20 template <int D> class UnitCell;
21 template <int D> class Basis;
22 }
23}
24
25namespace Pscf {
26namespace Prdc {
27
28 using namespace Util;
29 using namespace Pscf;
30
31 // Utilities for checking field and array dimensions
32
54 template <int D, class FT>
55 void checkAllocateField(FT& field, IntVec<D> const& dimensions);
56
80 template <int D, class FT>
82 int nMonomer,
83 IntVec<D> const& dimensions);
84
101 template <int D, class FT>
102 void inspectFields(DArray<FT> const & fields,
103 int & nMonomer,
104 IntVec<D> & dimensions);
105
127 template <int D, class AT>
129 int nMonomer,
130 int capacity);
131
144 template <class AT>
145 void inspectArrays(DArray<AT> const & arrays,
146 int & nMonomer,
147 int & capacity);
148
149
150 // Templates for RGrid data IO
151
163 template <int D>
164 void readMeshDimensions(std::istream& in,
165 IntVec<D> const& meshDimensions);
166
175 template <int D>
176 void writeMeshDimensions(std::ostream &out,
177 IntVec<D> const& meshDimensions);
178
195 template <int D, class AT>
196 void readRGridData(std::istream& in,
197 DArray<AT>& fields,
198 int nMonomer,
199 IntVec<D> const& dimensions);
200
216 template <int D, class AT>
217 void readRGridData(std::istream& in,
218 AT& field,
219 IntVec<D> const& dimensions);
220
237 template <int D, class AT>
238 void writeRGridData(std::ostream& out,
239 DArray<AT> const& fields,
240 int nMonomer,
241 IntVec<D> const& dimensions);
242
258 template <int D, class AT>
259 void writeRGridData(std::ostream& out,
260 AT const& field,
261 IntVec<D> const& dimensions);
262
263 // Templates for KGrid data IO
264
281 template <int D, class AT>
282 void readKGridData(std::istream& in,
283 DArray<AT>& fields,
284 int nMonomer,
285 IntVec<D> const& dftDimensions);
286
302 template <int D, class AT>
303 void readKGridData(std::istream& in,
304 AT& field,
305 IntVec<D> const& dftDimensions);
306
323 template <int D, class AT>
324 void writeKGridData(std::ostream& out,
325 DArray<AT> const& fields,
326 int nMonomer,
327 IntVec<D> const& dftDimensions);
328
344 template <int D, class AT>
345 void writeKGridData(std::ostream& in,
346 AT const& field,
347 IntVec<D> const& dftDimensions);
348
349 // Templates for Io of symmetrized basis format
350
359 int readNBasis(std::istream& in);
360
369 void writeNBasis(std::ostream& out, int nBasis);
370
395 template <int D>
396 void readBasisData(std::istream& in,
397 DArray< DArray<double> >& fields,
398 UnitCell<D> const& unitCell,
399 Mesh<D> const& mesh,
400 Basis<D> const& basis,
401 int nStarIn);
402
419 template <int D>
420 void writeBasisData(std::ostream &out,
421 DArray<DArray<double> > const & fields,
422 Basis<D> const & basis);
423
434 template <int D, class AT>
435 void convertBasisToKGrid(DArray<double> const & components,
436 AT& dft,
437 Basis<D> const& basis,
438 IntVec<D> const& dftDimensions);
439
457 template <int D, class AT>
458 void convertKGridToBasis(AT const & in,
459 DArray<double> & out,
460 Basis<D> const& basis,
461 IntVec<D> const& dftDimensions,
462 bool checkSymmetry = true,
463 double epsilon = 1.0e-8);
464
483 template <int D, class AT>
484 bool hasSymmetry(AT const& in,
485 Basis<D> const& basis,
486 IntVec<D> const& dftDimensions,
487 double epsilon = 1.0e-8,
488 bool verbose = true);
489
490 // Field manipulation utilities
491
511 template <int D, class AT>
512 void replicateUnitCell(std::ostream& out,
513 DArray<AT > const & fields,
514 IntVec<D> const & meshDimensions,
515 UnitCell<D> const & unitCell,
516 IntVec<D> const & replicas);
517
550 template <int D, class AT>
551 void expandRGridDimension(std::ostream &out,
552 DArray< AT > const & fields,
553 IntVec<D> const & meshDimensions,
554 UnitCell<D> const & unitCell,
555 int d,
556 DArray<int> newGridDimensions);
557
558} // namespace Prdc
559} // namespace Pscf
560#include "fieldIoUtil.tpp"
561#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Description of a regular grid of points in a periodic domain.
Symmetry-adapted Fourier basis for pseudo-spectral scft.
Definition fieldIoUtil.h:21
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition rpg/System.h:34
Dynamically allocatable contiguous array template.
void replicateUnitCell(std::ostream &out, DArray< AT > const &fields, IntVec< D > const &meshDimensions, UnitCell< D > const &unitCell, IntVec< D > const &replicas)
Write r-grid fields in a replicated unit cell to std::ostream.
void writeKGridData(std::ostream &out, DArray< AT > const &fields, int nMonomer, IntVec< D > const &dftDimensions)
Write data for array of k-grid fields, with no header section.
void writeNBasis(std::ostream &out, int nBasis)
Write the number of basis functions to a basis field file header.
bool hasSymmetry(AT const &in, Basis< D > const &basis, IntVec< D > const &dftDimensions, double epsilon=1.0e-8, bool verbose=true)
Check if a k-grid field has the declared space group symmetry.
void inspectArrays(DArray< AT > const &arrays, int &nMonomer, int &capacity)
Inspect dimensions of a DArray of 1D arrays, each of type AT.
void inspectFields(DArray< FT > const &fields, int &nMonomer, IntVec< D > &dimensions)
Inspect dimensions of a DArray of fields, each of type FT.
void checkAllocateArrays(DArray< AT > &arrays, int nMonomer, int capacity)
Check allocation of a DArray of 1D arrays, allocate if necessary.
void readKGridData(std::istream &in, DArray< AT > &fields, int nMonomer, IntVec< D > const &dftDimensions)
Read data for array of k-grid fields, with no header section.
void convertBasisToKGrid(DArray< double > const &components, AT &dft, Basis< D > const &basis, IntVec< D > const &dftDimensions)
Convert a real field from symmetrized basis to Fourier grid.
void writeMeshDimensions(std::ostream &out, IntVec< D > const &meshDimensions)
Write mesh dimensions to a field file header.
void expandRGridDimension(std::ostream &out, DArray< AT > const &fields, IntVec< D > const &meshDimensions, UnitCell< D > const &unitCell, int d, DArray< int > newGridDimensions)
Expand the dimensionality of space from D to d.
void writeRGridData(std::ostream &out, DArray< AT > const &fields, int nMonomer, IntVec< D > const &dimensions)
Write data for array of r-grid fields, with no header section.
void convertKGridToBasis(AT const &in, DArray< double > &out, Basis< D > const &basis, IntVec< D > const &dftDimensions, bool checkSymmetry=true, double epsilon=1.0e-8)
Convert a real field from Fourier grid to symmetrized basis.
int readNBasis(std::istream &in)
Read the number of basis functions from a basis field file header.
void readRGridData(std::istream &in, DArray< AT > &fields, int nMonomer, IntVec< D > const &dimensions)
Read data for array of r-grid fields, with no header section.
void readMeshDimensions(std::istream &in, IntVec< D > const &meshDimensions)
Read mesh dimensions from a field file header.
void writeBasisData(std::ostream &out, DArray< DArray< double > > const &fields, Basis< D > const &basis)
Write array of fields in basis format, without a header.
void readBasisData(std::istream &in, DArray< DArray< double > > &fields, UnitCell< D > const &unitCell, Mesh< D > const &mesh, Basis< D > const &basis, int nStarIn)
Read a set of fields in basis format.
void checkAllocateFields(DArray< FT > &fields, int nMonomer, IntVec< D > const &dimensions)
Check allocation of an array of fields, allocate if necessary.
void checkAllocateField(FT &field, IntVec< D > const &dimensions)
Check allocation of a single field, allocate if necessary.
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.