PSCF v1.1
pspc/field/WFieldContainer.h
1#ifndef PSPC_W_FIELD_CONTAINER_H
2#define PSPC_W_FIELD_CONTAINER_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
12#include <util/param/ParamComposite.h> // base class
13
14#include <pscf/math/IntVec.h> // function parameter
15#include <pscf/crystal/UnitCell.h> // function parameter
16#include <pspc/field/RField.h> // member template parameter
17#include <util/containers/DArray.h> // member template
18
19namespace Pscf {
20namespace Pspc {
21
22 template <int D> class FieldIo;
23
24 using namespace Util;
25
57 template <int D>
59 {
60
61 public:
62
67
72
76 void setFieldIo(FieldIo<D> const & fieldIo);
77
85 void setNMonomer(int nMonomer);
86
92 void allocateRGrid(IntVec<D> const & dimensions);
93
97 void deallocateRGrid();
98
104 void allocateBasis(int nBasis);
105
109 void deallocateBasis();
110
120 void allocate(int nMonomer, int nBasis, IntVec<D> const & dimensions);
121
131 void setBasis(DArray< DArray<double> > const & fields);
132
148 void setRGrid(DArray< RField<D> > const & fields,
149 bool isSymmetric = false);
150
165 void readBasis(std::istream& in, UnitCell<D>& unitCell);
166
181 void readBasis(std::string filename, UnitCell<D>& unitCell);
182
202 void readRGrid(std::istream& in, UnitCell<D>& unitCell,
203 bool isSymmetric = false);
204
224 void readRGrid(std::string filename, UnitCell<D>& unitCell,
225 bool isSymmetric = false);
226
232 DArray< DArray<double> > const & basis() const;
233
241 DArray<double> const & basis(int monomerId) const;
242
248 DArray< RField<D> > const & rgrid() const;
249
255 RField<D> const & rgrid(int monomerId) const;
256
260 bool isAllocatedRGrid() const;
261
265 bool isAllocatedBasis() const;
266
272 bool hasData() const;
273
282 bool isSymmetric() const;
283
284 private:
285
286 /*
287 * Array of fields in symmetry-adapted basis format
288 *
289 * Element basis_[i] is an array that contains the components
290 * of the field associated with monomer i, in a symmetry-adapted
291 * Fourier expansion.
292 */
293 DArray< DArray<double> > basis_;
294
295 /*
296 * Array of fields in real-space grid (r-grid) format
297 *
298 * Element basis_[i] is an RField<D> that contains values of the
299 * field associated with monomer i on the nodes of a regular mesh.
300 */
301 DArray< RField<D> > rgrid_;
302
303 /*
304 * Pointer to associated FieldIo object
305 */
306 FieldIo<D> const * fieldIoPtr_;
307
308 /*
309 * Integer vector of grid dimensions.
310 *
311 * Element i is the number of grid points along direction i
312 */
313 IntVec<D> meshDimensions_;
314
315 /*
316 * Total number grid points (product of mesh dimensions)
317 */
318 int meshSize_;
319
320 /*
321 * Number of basis functions in symmetry-adapted basis
322 */
323 int nBasis_;
324
325 /*
326 * Number of monomer types (number of fields)
327 */
328 int nMonomer_;
329
330 /*
331 * Has memory been allocated for fields in r-grid format?
332 */
333 bool isAllocatedRGrid_;
334
335 /*
336 * Has memory been allocated for fields in basis format?
337 */
338 bool isAllocatedBasis_;
339
340 /*
341 * Has field data been initialized ?
342 */
343 bool hasData_;
344
345 /*
346 * Are the fields symmetric under space group operations?
347 *
348 * Set true when fields are set using the symmetry adapted basis
349 * format via function setBasis. False by otherwise.
350 */
351 bool isSymmetric_;
352
353 };
354
355 // Inline member functions
356
357 // Get array of all fields in basis format (const)
358 template <int D>
359 inline
361 { return basis_; }
362
363 // Get one field in basis format (const)
364 template <int D>
365 inline
367 { return basis_[id]; }
368
369 // Get all fields in r-grid format (const)
370 template <int D>
371 inline
372 DArray< RField<D> > const &
374 { return rgrid_; }
375
376 // Get one field in r-grid format (const)
377 template <int D>
378 inline
380 { return rgrid_[id]; }
381
382 // Has memory been allocated for fields in r-grid format?
383 template <int D>
385 { return isAllocatedRGrid_; }
386
387 // Has memory been allocated for fields in basis format?
388 template <int D>
390 { return isAllocatedBasis_; }
391
392 // Has field data been initialized ?
393 template <int D>
394 inline bool WFieldContainer<D>::hasData() const
395 { return hasData_; }
396
397 // Are the fields symmetric under space group operations?
398 template <int D>
400 { return isSymmetric_; }
401
402 #ifndef PSPC_W_FIELD_CONTAINER_TPP
403 // Suppress implicit instantiation
404 extern template class WFieldContainer<1>;
405 extern template class WFieldContainer<2>;
406 extern template class WFieldContainer<3>;
407 #endif
408
409} // namespace Pspc
410} // namespace Pscf
411#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition: IntVec.h:27
File input/output operations and format conversions for fields.
Field of real double precision values on an FFT mesh.
Definition: RField.h:29
A list of fields stored in both basis and r-grid format.
void deallocateRGrid()
De-allocate fields in rgrid format.
void readRGrid(std::istream &in, UnitCell< D > &unitCell, bool isSymmetric=false)
Reads fields from an input stream in real-space (r-grid) format.
void deallocateBasis()
De-allocate fields in basis format.
void setFieldIo(FieldIo< D > const &fieldIo)
Create association with FieldIo (store pointer).
void setBasis(DArray< DArray< double > > const &fields)
Set field component values, in symmetrized Fourier format.
DArray< RField< D > > const & rgrid() const
Get array of all fields in r-space grid format.
bool isSymmetric() const
Are fields symmetric under all elements of the space group?
bool hasData() const
Has field data been set in either format?
bool isAllocatedBasis() const
Has memory been allocated for fields in basis format?
void allocate(int nMonomer, int nBasis, IntVec< D > const &dimensions)
Allocate memory for all fields.
DArray< DArray< double > > const & basis() const
Get array of all fields in basis format.
void allocateBasis(int nBasis)
Allocate or re-allocate memory for fields in basis format.
void setNMonomer(int nMonomer)
Set stored value of nMonomer.
bool isAllocatedRGrid() const
Has memory been allocated for fields in r-grid format?
void setRGrid(DArray< RField< D > > const &fields, bool isSymmetric=false)
Set fields values in real-space (r-grid) format.
void allocateRGrid(IntVec< D > const &dimensions)
Allocate or re-allocate memory for fields in rgrid format.
void readBasis(std::istream &in, UnitCell< D > &unitCell)
Read field component values from input stream, in symmetrized Fourier format.
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition: UnitCell.h:44
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
An object that can read multiple parameters from file.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1