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

A field that specifies an inhomogeneous total monomer concentration. More...

#include <Mask.h>

Public Member Functions

 Mask ()
 Constructor.
 ~Mask ()
 Destructor.
Initialization and Memory Management
void setFieldIo (FieldIo< D, T > const &fieldIo)
 Create association with FieldIo (store pointer).
void setReadUnitCell (UnitCell< D > &cell)
 Set unit cell used when reading a mask field file.
void setWriteUnitCell (UnitCell< D > const &cell)
 Set unit cell used when writing a mask field file.
void allocateBasis (int nBasis)
 Allocate memory for the field in basis format.
void allocateRGrid (IntVec< D > const &dimensions)
 Allocate memory for the field in rgrid format.
Field Mutators
void setBasis (DArray< double > const &field)
 Set field component values, in symmetrized Fourier format.
void setRGrid (RField< D, T > const &field, bool isSymmetric=false)
 Set field values in real-space (r-grid) format.
void readBasis (std::istream &in)
 Read field from input stream in symmetrized basis format.
void readBasis (std::string filename)
 Read field from a named file, in symmetrized basis format.
void readRGrid (std::istream &in, bool isSymmetric=false)
 Reads field from an input stream in real-space (r-grid) format.
void readRGrid (std::string filename, bool isSymmetric=false)
 Reads field from a named file, in real-space (r-grid) format.
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.
Field Accessors
DArray< double > const & basis () const
 Get the field in basis format.
RField< D, T > const & rgrid () const
 Get the field in r-grid format.
double phiTot () const
 Return the volume fraction of unit cell occupied by material.
Signal< void > & signal ()
 Get a signal that notifies observers of field modification.
Boolean Queries
bool isAllocatedBasis () const
 Has memory been allocated in basis format?
bool isAllocatedRGrid () const
 Has memory been allocated in rgrid format?
bool hasData () const
 Has field data been set in either format?
bool isSymmetric () const
 Are field symmetric under all elements of the space group?

Protected Member Functions

IntVec< D > const & meshDimensions () const
 Mesh dimensions in each direction, set by allocation.
int meshSize () const
 Mesh size (number of grid points), set by allocation.
int nBasis () const
 Number of basis functions, set by allocation.
FieldIo< D, T > const & fieldIo () const
 Associated FieldIo object (const reference).

Detailed Description

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

A field that specifies an inhomogeneous total monomer concentration.

A system that contains a Mask must satisfy a modified version of the incompressibility constraint, in which the sum of the concentration (or volume fraction) fields of all monomer types must be equal to the Mask field. The Mask field takes values in the range [0, 1] everywhere. A system without a Mask is equivalent to one in which the mask field is equal to 1 at all points in the unit cell.

Field representations : A Mask <D> contains representations of the mask field in two formats:

  • An RField <D, T> object contains values of the field on nodes of a regular mesh. This is accessed by the rgrid() member function.
  • A DArray <double> contains components of the field in a symmetry-adapted Fourier expansion (i.e., in basis format). This is accessed by the basis() member function.

A Mask is designed to automatically update each of these two representations when the other is modified, as appropriate. An associated FieldIo object is used for these conversions.

The setBasis and readBasis functions allow the user to input field components in basis format, and both internally recompute the values in r-grid format. The setRGrid and readRGrid functions allows the user to input the field in r-grid format, and both recompute the components in basis format if and only if the user explicitly declares that the field is known to be invariant under all symmetries of the space group. A boolean member variable named isSymmetric is used to keep track of whether the current mask field is symmetric, and thus whether the symmetry-adapted basis representation exists.

Signal : A Mask owns an instance of class Util::Signal<void> that notifies all observers whenever the field owned by the Mask is modified. This Signal<void> object is returned by non-const reference by the Rp::Mask::signal() accessor function. The Util::Signal<void>::addObserver member function may used to add an observer object, and to specify a zero-parameter member function of each observer that will be called whenever the field is modified.

Template parameters :

  • D : dimension of space
  • T : a Types class (CPT or CUT)

Definition at line 84 of file Mask.h.

Constructor & Destructor Documentation

◆ Mask()

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

Constructor.

Definition at line 33 of file Mask.tpp.

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

◆ ~Mask()

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

Destructor.

Definition at line 55 of file Mask.tpp.

Member Function Documentation

◆ setFieldIo()

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

Create association with FieldIo (store pointer).

Parameters
fieldIoassociated FieldIo object

Definition at line 62 of file Mask.tpp.

References fieldIo().

◆ setReadUnitCell()

template<int D, class T>
void Pscf::Rp::Mask< D, T >::setReadUnitCell ( UnitCell< D > & cell)

Set unit cell used when reading a mask field file.

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

Parameters
cellunit cell that is modified by readBasis and readRGrid.

Definition at line 69 of file Mask.tpp.

References UTIL_CHECK.

◆ setWriteUnitCell()

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

Set unit cell used when writing a mask field file.

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 80 of file Mask.tpp.

References UTIL_CHECK.

◆ allocateBasis()

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

Allocate memory for the field in basis format.

An Exception will be thrown if this is called more than once.

Parameters
nBasisnumber of basis functions

Definition at line 90 of file Mask.tpp.

References nBasis().

◆ allocateRGrid()

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

Allocate memory for the field in rgrid format.

An Exception will be thrown if this is called more than once.

Parameters
dimensionsdimensions of spatial mesh

Definition at line 107 of file Mask.tpp.

References meshDimensions(), and UTIL_CHECK.

◆ setBasis()

template<int D, class T>
void Pscf::Rp::Mask< D, T >::setBasis ( DArray< double > const & field)

Set field component values, in symmetrized Fourier format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

The associated basis must be initialized on entry. As needed, r-grid and/or basis fields may be allocated within this function.

Parameters
fieldcomponents of field in basis format

Definition at line 128 of file Mask.tpp.

◆ setRGrid()

template<int D, class T>
void Pscf::Rp::Mask< D, T >::setRGrid ( RField< D, T > const & field,
bool isSymmetric = false )

Set field values in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the field are known to be symmetric and so computes and stores the corresponding basis components. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this function. If the isSymmetric parameter is true, then a basis must be initialized prior to entry.

Parameters
fieldnew field in r-grid format
isSymmetricis this field symmetric under the space group?

Definition at line 164 of file Mask.tpp.

References isSymmetric().

◆ readBasis() [1/2]

template<int D, class T>
void Pscf::Rp::Mask< D, T >::readBasis ( std::istream & in)

Read field from input stream in symmetrized basis format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

This object must already be allocated and associated with a a FieldIo object to run this function.

As needed, r-grid and/or basis fields may be allocated within this functions, if not allocated on entry. An associated basis will be initialized if it is not initialized on entry.

Parameters
ininput stream from which to read field

Definition at line 202 of file Mask.tpp.

Referenced by readBasis().

◆ readBasis() [2/2]

template<int D, class T>
void Pscf::Rp::Mask< D, T >::readBasis ( std::string filename)

Read field from a named file, in symmetrized basis format.

This function also computes and stores the corresponding r-grid representation. On return, hasData and isSymmetric are both true.

As needed, r-grid and/or basis fields may be allocated within this functions, if not allocated on entry. An associated basis will be initialized if it is not initialized on entry.

Parameters
filenamefile from which to read field

Definition at line 252 of file Mask.tpp.

References fieldIo(), and readBasis().

◆ readRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::Mask< D, T >::readRGrid ( std::istream & in,
bool isSymmetric = false )

Reads field from an input stream in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the field is known to be symmetric and so computes and stores the corresponding basis format. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this functions, if not allocated on entry. An associated basis will be initialized if it is not initialized on entry.

Parameters
ininput stream from which to read field
isSymmetricis this field symmetric under the space group?

Definition at line 269 of file Mask.tpp.

References isSymmetric().

Referenced by readRGrid().

◆ readRGrid() [2/2]

template<int D, class T>
void Pscf::Rp::Mask< D, T >::readRGrid ( std::string filename,
bool isSymmetric = false )

Reads field from a named file, in real-space (r-grid) format.

If the isSymmetric parameter is true, this function assumes that the field is known to be symmetric and so computes and stores the corresponding basis format. If isSymmetric is false, it only sets the values in the r-grid format.

On return, hasData is true and the persistent isSymmetric flag defined by the class is set to the value of the isSymmetric input parameter.

As needed, r-grid and/or basis fields may be allocated within this functions, if not allocated on entry. An associated basis will be initialized if it is not initialized on entry.

Parameters
filenamefile from which to read field
isSymmetricis this field symmetric under the space group?

Definition at line 307 of file Mask.tpp.

References fieldIo(), isSymmetric(), and readRGrid().

◆ writeBasis() [1/2]

template<int D, class T>
void Pscf::Rp::Mask< 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 342 of file Mask.tpp.

References fieldIo(), and UTIL_CHECK.

Referenced by writeBasis().

◆ writeBasis() [2/2]

template<int D, class T>
void Pscf::Rp::Mask< 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 358 of file Mask.tpp.

References fieldIo(), and writeBasis().

◆ writeRGrid() [1/2]

template<int D, class T>
void Pscf::Rp::Mask< 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 370 of file Mask.tpp.

References fieldIo(), and UTIL_CHECK.

Referenced by writeRGrid().

◆ writeRGrid() [2/2]

template<int D, class T>
void Pscf::Rp::Mask< 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 388 of file Mask.tpp.

References fieldIo(), and writeRGrid().

◆ basis()

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

Get the field in basis format.

Definition at line 473 of file Mask.h.

References UTIL_ASSERT.

Referenced by phiTot().

◆ rgrid()

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

Get the field in r-grid format.

Definition at line 482 of file Mask.h.

References UTIL_ASSERT.

Referenced by phiTot().

◆ phiTot()

template<int D, class T>
double Pscf::Rp::Mask< D, T >::phiTot ( ) const

Return the volume fraction of unit cell occupied by material.

This value is equivalent to the spatial average of the mask, which is the q=0 coefficient of the discrete Fourier transform.

If hasData == true and isSymmetric == false (i.e., data only exists in rgrid format), then this object must be associated with a FieldIo object in order to call phiTot(). In other cases, the FieldIo association is not necessary.

Definition at line 321 of file Mask.tpp.

References basis(), hasData(), isSymmetric(), rgrid(), and Pscf::Reduce::sum().

◆ signal()

template<int D, class T>
Signal< void > & Pscf::Rp::Mask< D, T >::signal ( )

Get a signal that notifies observers of field modification.

The Signal<void>::notify method is called by within all member functions that modify the field, to notify observers of this event. The Signal<void>::addObserver function may be applied to the Signal object returned by this function to add one or more observers.

Definition at line 402 of file Mask.tpp.

References UTIL_CHECK.

◆ isAllocatedBasis()

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

Has memory been allocated in basis format?

Definition at line 490 of file Mask.h.

◆ isAllocatedRGrid()

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

Has memory been allocated in rgrid format?

Definition at line 495 of file Mask.h.

◆ hasData()

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

Has field data been set in either format?

This flag is set true in setBasis and setRGrid.

Definition at line 500 of file Mask.h.

Referenced by phiTot().

◆ isSymmetric()

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

Are field symmetric under all elements of the space group?

A valid basis format exists if and only if isSymmetric is true. This flat is set true if the field were input in basis format by the function setBasis, or if they were set in grid format by the function setRGrid but isSymmetric was set true.

Definition at line 505 of file Mask.h.

Referenced by phiTot(), readRGrid(), readRGrid(), and setRGrid().

◆ meshDimensions()

template<int D, class T>
IntVec< D > const & Pscf::Rp::Mask< D, T >::meshDimensions ( ) const
inlineprotected

Mesh dimensions in each direction, set by allocation.

Definition at line 371 of file Mask.h.

Referenced by allocateRGrid().

◆ meshSize()

template<int D, class T>
int Pscf::Rp::Mask< D, T >::meshSize ( ) const
inlineprotected

Mesh size (number of grid points), set by allocation.

Definition at line 377 of file Mask.h.

◆ nBasis()

template<int D, class T>
int Pscf::Rp::Mask< D, T >::nBasis ( ) const
inlineprotected

Number of basis functions, set by allocation.

Definition at line 383 of file Mask.h.

Referenced by allocateBasis().

◆ fieldIo()

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

Associated FieldIo object (const reference).

Definition at line 389 of file Mask.h.

References UTIL_CHECK.

Referenced by readBasis(), readRGrid(), setFieldIo(), writeBasis(), writeBasis(), writeRGrid(), and writeRGrid().


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