|
PSCF v1.5.0
|
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). | |
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:
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 :
| Pscf::Rp::Mask< D, T >::Mask | ( | ) |
Constructor.
Definition at line 33 of file Mask.tpp.
Referenced by Pscf::Rp::System< D, T >::System().
| Pscf::Rp::Mask< D, T >::~Mask | ( | ) |
| void Pscf::Rp::Mask< D, T >::setFieldIo | ( | FieldIo< D, T > const & | fieldIo | ) |
| 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.
| cell | unit cell that is modified by readBasis and readRGrid. |
Definition at line 69 of file Mask.tpp.
References UTIL_CHECK.
| 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.
| cell | unit cell that is used by writeBasis and writeRGrid. |
Definition at line 80 of file Mask.tpp.
References UTIL_CHECK.
| void Pscf::Rp::Mask< D, T >::allocateBasis | ( | int | nBasis | ) |
| 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.
| dimensions | dimensions of spatial mesh |
Definition at line 107 of file Mask.tpp.
References meshDimensions(), and UTIL_CHECK.
| 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.
| field | components of field in basis format |
| 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.
| field | new field in r-grid format |
| isSymmetric | is this field symmetric under the space group? |
Definition at line 164 of file Mask.tpp.
References isSymmetric().
| 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.
| in | input stream from which to read field |
Definition at line 202 of file Mask.tpp.
Referenced by readBasis().
| 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.
| filename | file from which to read field |
Definition at line 252 of file Mask.tpp.
References fieldIo(), and readBasis().
| 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.
| in | input stream from which to read field |
| isSymmetric | is this field symmetric under the space group? |
Definition at line 269 of file Mask.tpp.
References isSymmetric().
Referenced by readRGrid().
| 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.
| filename | file from which to read field |
| isSymmetric | is this field symmetric under the space group? |
Definition at line 307 of file Mask.tpp.
References fieldIo(), isSymmetric(), and readRGrid().
| void Pscf::Rp::Mask< D, T >::writeBasis | ( | std::ostream & | out | ) | const |
Write fields to an input stream in symmetrized basis format.
| out | output stream to which to write fields |
Definition at line 342 of file Mask.tpp.
References fieldIo(), and UTIL_CHECK.
Referenced by writeBasis().
| void Pscf::Rp::Mask< D, T >::writeBasis | ( | std::string | filename | ) | const |
Write fields to a named file, in symmetrized basis format.
| filename | name of file to which to write fields |
Definition at line 358 of file Mask.tpp.
References fieldIo(), and writeBasis().
| void Pscf::Rp::Mask< D, T >::writeRGrid | ( | std::ostream & | out | ) | const |
Writes fields to an input stream in real-space (r-grid) format.
| out | output stream to which to write fields |
Definition at line 370 of file Mask.tpp.
References fieldIo(), and UTIL_CHECK.
Referenced by writeRGrid().
| void Pscf::Rp::Mask< D, T >::writeRGrid | ( | std::string | filename | ) | const |
Writes fields to a named file in real-space (r-grid) format.
| filename | name of file to which to write fields |
Definition at line 388 of file Mask.tpp.
References fieldIo(), and writeRGrid().
|
inline |
Get the field in basis format.
Definition at line 473 of file Mask.h.
References UTIL_ASSERT.
Referenced by phiTot().
|
inline |
Get the field in r-grid format.
Definition at line 482 of file Mask.h.
References UTIL_ASSERT.
Referenced by phiTot().
| 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< 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.
|
inline |
|
inline |
|
inline |
|
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().
|
inlineprotected |
Mesh dimensions in each direction, set by allocation.
Definition at line 371 of file Mask.h.
Referenced by allocateRGrid().
|
inlineprotected |
|
inlineprotected |
Number of basis functions, set by allocation.
Definition at line 383 of file Mask.h.
Referenced by allocateBasis().
|
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().