PSCF v1.5.0
Pscf::Rp::CFields< D, T > Class Template Reference

A list of c fields stored in both basis and r-grid format. More...

#include <CFields.h>

Public Member Functions

 CFields ()
 Constructor.
 ~CFields ()=default
 Destructor.
Initialization and Memory Management
void setFieldIo (FieldIo< D, T > const &fieldIo)
 Create association with a FieldIo (store pointer).
void setWriteUnitCell (UnitCell< D > const &cell)
 Set unit cell used when writing field files.
void setNMonomer (int nMonomer)
 Set stored value of nMonomer.
void allocateRGrid (IntVec< D > const &dimensions)
 Allocate memory for fields in rgrid format.
void allocateBasis (int nBasis)
 Allocate or re-allocate memory for fields in basis format.
void allocate (int nMonomer, int nBasis, IntVec< D > const &dimensions)
 Allocate memory for both r-grid and basis field formats.
Field Accessors (return by reference)
DArray< DArray< double > > & basis ()
 Get array of all fields in basis format (non-const).
DArray< DArray< double > > const & basis () const
 Get array of all fields in basis format (const).
DArray< double > & basis (int monomerId)
 Get the field for one monomer type in basis format (non-const).
DArray< double > const & basis (int monomerId) const
 Get the field for one monomer type in basis format (const).
DArray< RField< D, T > > & rgrid ()
 Get array of all fields in r-grid format (non-const).
DArray< RField< D, T > > const & rgrid () const
 Get array of all fields in r-grid format (const).
RField< D, T > & rgrid (int monomerId)
 Get field for one monomer type in r-grid format (non-const).
RField< D, T > const & rgrid (int monomerId) const
 Get field for one monomer type in r-grid format (const).
Field Output
void writeBasis (std::ostream &out) const
 Write fields to an input stream in symmetrized basis format.
void writeBasis (std::string filename) const
 Write fields to a named file, in symmetrized basis format.
void writeRGrid (std::ostream &out) const
 Writes fields to an input stream in real-space (r-grid) format.
void writeRGrid (std::string filename) const
 Writes fields to a named file in real-space (r-grid) format.
Boolean Variable Queries
bool isAllocatedRGrid () const
 Has memory been allocated for fields in r-grid format?
bool isAllocatedBasis () const
 Has memory been allocated for fields in basis format?
bool hasData () const
 Does this container have up-to-date fields?
bool isSymmetric () const
 Are the fields invariant under elements of the space group?
Boolean Variable Setters
void setHasData (bool hasData)
 Set the hasData flag.
void setIsSymmetric (bool isSymmetric)
 Set the isSymmetric flag.

Protected Member Functions

FieldIo< D, T > const & fieldIo () const
 Get associated FieldIo object (const reference).

Detailed Description

template<int D, class T>
class Pscf::Rp::CFields< D, T >

A list of c fields stored in both basis and r-grid format.

Template parameters : The template parameters represent:

  • D : integer dimensionality of space (D=1, 2, or 3)
  • T : a backend type class (e.g. (CPT or CUT))

Field Representations : A CFields container has a set of nMonomer fields that are each associated with a monomer type. The fields may be stored in two different formats:

  • A DArray of RField containers holds valus of each field on the nodes of a regular grid. This is accessed by the rgrid() and rgrid(int) member functions.
  • A DArray of DArray<double> containers holds components of each field in a symmetry-adapted Fourier expansion (i.e., in basis format). This is accessed by the basis() and basis(int) member functions.

The CFields container provides public non-const (read/write) access to both field representations, and does not automatically update one of these field representations when the other is modified.

Definition at line 57 of file CFields.h.

Constructor & Destructor Documentation

◆ CFields()

template<int D, class T>
Pscf::Rp::CFields< D, T >::CFields ( )

Constructor.

Definition at line 26 of file CFields.tpp.

Referenced by Pscf::Rp::System< D, T >::System().

◆ ~CFields()

template<int D, class T>
Pscf::Rp::CFields< D, T >::~CFields ( )
default

Member Function Documentation

◆ setFieldIo()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::setFieldIo ( FieldIo< D, T > const & fieldIo)

Create association with a FieldIo (store pointer).

Parameters
fieldIoassociated FieldIo object

Definition at line 43 of file CFields.tpp.

References fieldIo().

Referenced by ~CFields().

◆ setWriteUnitCell()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::setWriteUnitCell ( UnitCell< D > const & cell)

Set unit cell used when writing field files.

This function creates a stored pointer to a UnitCell<D> that is is used by the writeBasis and writeRGrid functions, which each write the unit cell parameters from in this object to a field file header. This function may only be called once.

Parameters
cellunit cell that is used by writeBasis and writeRGrid.

Definition at line 50 of file CFields.tpp.

References UTIL_CHECK.

Referenced by ~CFields().

◆ setNMonomer()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::setNMonomer ( int nMonomer)

Set stored value of nMonomer.

This function may only be called once. The value of nMonomer must be positive.

Parameters
nMonomernumber of monomer types.

Definition at line 60 of file CFields.tpp.

References UTIL_CHECK.

Referenced by allocate(), and ~CFields().

◆ allocateRGrid()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::allocateRGrid ( IntVec< D > const & dimensions)

Allocate memory for fields in rgrid format.

This function may only be called once.

Parameters
dimensionsdimensions of spatial mesh

Definition at line 72 of file CFields.tpp.

References UTIL_CHECK.

Referenced by ~CFields().

◆ allocateBasis()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::allocateBasis ( int nBasis)

Allocate or re-allocate memory for fields in basis format.

This function may only be called once.

Parameters
nBasisnumber of basis functions

Definition at line 89 of file CFields.tpp.

References UTIL_CHECK.

Referenced by ~CFields().

◆ allocate()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::allocate ( int nMonomer,
int nBasis,
IntVec< D > const & dimensions )

Allocate memory for both r-grid and basis field formats.

This function may only be called once.

Parameters
nMonomernumber of monomer types
nBasisnumber of basis functions
dimensionsdimensions of spatial mesh

Definition at line 107 of file CFields.tpp.

References setNMonomer().

Referenced by ~CFields().

◆ basis() [1/4]

template<int D, class T>
DArray< DArray< double > > & Pscf::Rp::CFields< D, T >::basis ( )
inline

Get array of all fields in basis format (non-const).

Definition at line 334 of file CFields.h.

References UTIL_ASSERT.

◆ basis() [2/4]

template<int D, class T>
DArray< DArray< double > > const & Pscf::Rp::CFields< D, T >::basis ( ) const
inline

Get array of all fields in basis format (const).

The array capacity is equal to the number of monomer types.

Definition at line 342 of file CFields.h.

References UTIL_ASSERT.

◆ basis() [3/4]

template<int D, class T>
DArray< double > & Pscf::Rp::CFields< D, T >::basis ( int monomerId)
inline

Get the field for one monomer type in basis format (non-const).

Parameters
monomerIdinteger monomer type index (0, ... ,nMonomer-1)

Definition at line 350 of file CFields.h.

References UTIL_ASSERT.

◆ basis() [4/4]

template<int D, class T>
DArray< double > const & Pscf::Rp::CFields< D, T >::basis ( int monomerId) const
inline

Get the field for one monomer type in basis format (const).

Parameters
monomerIdinteger monomer type index (0, ... ,nMonomer-1)

Definition at line 358 of file CFields.h.

References UTIL_ASSERT.

◆ rgrid() [1/4]

template<int D, class T>
DArray< RField< D, T > > & Pscf::Rp::CFields< D, T >::rgrid ( )
inline

Get array of all fields in r-grid format (non-const).

Definition at line 367 of file CFields.h.

References UTIL_ASSERT.

◆ rgrid() [2/4]

template<int D, class T>
DArray< RField< D, T > > const & Pscf::Rp::CFields< D, T >::rgrid ( ) const
inline

Get array of all fields in r-grid format (const).

Definition at line 375 of file CFields.h.

References UTIL_ASSERT.

◆ rgrid() [3/4]

template<int D, class T>
RField< D, T > & Pscf::Rp::CFields< D, T >::rgrid ( int monomerId)
inline

Get field for one monomer type in r-grid format (non-const).

Parameters
monomerIdinteger monomer type index (0,..,nMonomer-1)

Definition at line 383 of file CFields.h.

References UTIL_ASSERT.

◆ rgrid() [4/4]

template<int D, class T>
RField< D, T > const & Pscf::Rp::CFields< D, T >::rgrid ( int monomerId) const
inline

Get field for one monomer type in r-grid format (const).

Parameters
monomerIdinteger monomer type index (0,..,nMonomer-1)

Definition at line 391 of file CFields.h.

References UTIL_ASSERT.

◆ writeBasis() [1/2]

template<int D, class T>
void Pscf::Rp::CFields< D, T >::writeBasis ( std::ostream & out) const

Write fields to an input stream in symmetrized basis format.

Parameters
outoutput stream to which to write fields

Definition at line 121 of file CFields.tpp.

References UTIL_CHECK.

Referenced by writeBasis().

◆ writeBasis() [2/2]

template<int D, class T>
void Pscf::Rp::CFields< D, T >::writeBasis ( std::string filename) const

Write fields to a named file, in symmetrized basis format.

Parameters
filenamename of file to which to write fields

Definition at line 138 of file CFields.tpp.

References fieldIo(), and writeBasis().

◆ writeRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::CFields< D, T >::writeRGrid ( std::ostream & out) const

Writes fields to an input stream in real-space (r-grid) format.

Parameters
outoutput stream to which to write fields

Definition at line 150 of file CFields.tpp.

References fieldIo(), and UTIL_CHECK.

Referenced by writeRGrid().

◆ writeRGrid() [2/2]

template<int D, class T>
void Pscf::Rp::CFields< D, T >::writeRGrid ( std::string filename) const

Writes fields to a named file in real-space (r-grid) format.

Parameters
filenamename of file to which to write fields

Definition at line 169 of file CFields.tpp.

References fieldIo(), and writeRGrid().

◆ isAllocatedRGrid()

template<int D, class T>
bool Pscf::Rp::CFields< D, T >::isAllocatedRGrid ( ) const
inline

Has memory been allocated for fields in r-grid format?

Definition at line 399 of file CFields.h.

◆ isAllocatedBasis()

template<int D, class T>
bool Pscf::Rp::CFields< D, T >::isAllocatedBasis ( ) const
inline

Has memory been allocated for fields in basis format?

Definition at line 404 of file CFields.h.

◆ hasData()

template<int D, class T>
bool Pscf::Rp::CFields< D, T >::hasData ( ) const
inline

Does this container have up-to-date fields?

Definition at line 409 of file CFields.h.

Referenced by setHasData().

◆ isSymmetric()

template<int D, class T>
bool Pscf::Rp::CFields< D, T >::isSymmetric ( ) const
inline

Are the fields invariant under elements of the space group?

Definition at line 414 of file CFields.h.

Referenced by setIsSymmetric().

◆ setHasData()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::setHasData ( bool hasData)
inline

Set the hasData flag.

This should be set true when fields are set to those computed from the current w fields, and false when any input to that calculation changes.

Definition at line 181 of file CFields.tpp.

References hasData().

◆ setIsSymmetric()

template<int D, class T>
void Pscf::Rp::CFields< D, T >::setIsSymmetric ( bool isSymmetric)
inline

Set the isSymmetric flag.

This should be set true if and only if the fields are known to have been computed from symmetric w fields, and the basis representation exists.

Definition at line 191 of file CFields.tpp.

References isSymmetric(), and UTIL_CHECK.

◆ fieldIo()

template<int D, class T>
FieldIo< D, T > const & Pscf::Rp::CFields< D, T >::fieldIo ( ) const
inlineprotected

Get associated FieldIo object (const reference).

Definition at line 421 of file CFields.h.

References UTIL_CHECK.

Referenced by setFieldIo(), writeBasis(), writeRGrid(), writeRGrid(), and ~CFields().


The documentation for this class was generated from the following files: