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

MDE solver for one direction of one block. More...

#include <PropagatorBase.h>

Inheritance diagram for Pscf::Rp::PropagatorBase< D, T >:
Pscf::PropagatorTmpl< Propagator< D, T > >

Public Types

using PropagatorTmplT = PropagatorTmpl< Propagator<D,T> >
 Direct (parent) base class.

Public Member Functions

void setBlock (Block< D, T > &block)
 Associate this propagator with a block.
virtual void allocate (int ns, const Mesh< D > &mesh)
 Allocate memory used by this propagator.
virtual void reallocate (int ns)
 Reallocate memory used by this propagator.
void solve ()
 Solve the modified diffusion equation (MDE) for this block.
void solve (RField< D, T > const &head)
 Solve the MDE for a specified initial condition.
void computeQ (double &Q) const
 Compute and return partition function for the polymer molecule.
RField< D, T > const & q (int i) const
 Return q-field at a specified step.
RField< D, T > const & head () const
 Return q-field at the initial (head) vertex.
RField< D, T > const & tail () const
 Return q-field at the terminal (tail) vertex.
Block< D, T > const & block () const
 Get the associated Block object by const reference.
Mesh< D > const & mesh () const
 Return the associated Mesh object by const reference.
int ns () const
 Get the number of values of s (or slices), including head and tail.
bool isAllocated () const
 Has memory been allocated for this propagator?
const Propagator< D, T > & source (int id) const
 Get a source propagator.
const Propagator< D, T > & partner () const
 Get partner propagator.
Public Member Functions inherited from Pscf::PropagatorTmpl< Propagator< D, T > >
void setDirectionId (int directionId)
 Associate this propagator with a direction index.
void setPartner (const Propagator< D, T > &partner)
 Set the partner of this propagator.
void addSource (const Propagator< D, T > &source)
 Add a propagator to the list of sources for this one.
void setIsSolved (bool isSolved)
 Set the isSolved flag to true or false.
void setEndFlags (bool isHeadEnd, bool isTailEnd)
 Set flags indicating whether vertices are chain ends.
const Propagator< D, T > & source (int id) const
 Get a source propagator.
const Propagator< D, T > & partner () const
 Get partner propagator.
int directionId () const
 Get direction index for this propagator.
int nSource () const
 Number of source / prerequisite propagators.
bool hasPartner () const
 Does this have a partner propagator?
bool isHeadEnd () const
 Is the head vertex a chain end?
bool isTailEnd () const
 Is the tail vertex a chain end?
bool isSolved () const
 Has the modified diffusion equation been solved?
bool isReady () const
 Are all source propagators solved?

Protected Member Functions

 PropagatorBase ()
 Constructor.
 ~PropagatorBase ()
 Destructor.
void computeHead ()
 Compute initial q-field at the head vertex.
void solveMde ()
 Compute solution of modified diffusion equation (MDE).
Block< D, T > & block ()
 Get the associated Block object by non-const reference.
Protected Member Functions inherited from Pscf::PropagatorTmpl< Propagator< D, T > >
 PropagatorTmpl ()
 Constructor.

Protected Attributes

DArray< RField< D, T > > qFields_
 Array of propagator slices at different contour variable values.
int ns_
 Number of slices, including head and tail slices.
bool isAllocated_
 Is this propagator allocated?

Detailed Description

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

MDE solver for one direction of one block.

Template parameters :

  • D dimension of space
  • T class with aliases for use in a program-level namespace.

Description :

Explicit partial specializations of the Propagator <D, T> class template with different values for the template identifier class T are derived from corresponding specializations of the PropagatorBase class template.

A fully initialized PropagatorBase has associations with a parent Block object that owns this propagator, and with a partner Propagator that solves the MDE within the same block in the opposite direction. It also has an association with a Mesh<D> that describes a spatial grid, and associations with zero or more source Propagator objects that are used to compute an initial condition for this propagator at its head vertex.

The parent Block stores information required to numerically solve the modified diffusion equation (MDE), including quantities that depend upon the w-field associated with this block, the unit cell parameters and (in the thread model) the contour step size. These quantities are set and stored by the block because their values are the same for the two propagators owned by each block, but may be different for different blocks. The algorithm used by a propagator to solve the MDE repeatedly calls step functions provided by the parent Block.

Contour Discretization :

A propagator contains ns_ slices, in which slice 0 is the head and slice ns_ - 1 is the tail.

In a bead model, slices 1 through ns_ - 2 represent beads, while the head and tail represent dangling ends that are connected to terminal beads by half bonds. In this model, the tail slice is not computed or defined for chain ends, for which isTailEnd() == true.

In a thread model, the contour is divided into ns_ - 1 steps, each of contour length ds = length / (ns_ - 1).

Definition at line 81 of file PropagatorBase.h.

Member Typedef Documentation

◆ PropagatorTmplT

template<int D, class T>
using Pscf::Rp::PropagatorBase< D, T >::PropagatorTmplT = PropagatorTmpl< Propagator<D,T> >

Direct (parent) base class.

Definition at line 204 of file PropagatorBase.h.

Constructor & Destructor Documentation

◆ PropagatorBase()

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

Constructor.

Definition at line 28 of file PropagatorBase.tpp.

References isAllocated_, and ns_.

◆ ~PropagatorBase()

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

Destructor.

Definition at line 40 of file PropagatorBase.tpp.

Member Function Documentation

◆ setBlock()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::setBlock ( Block< D, T > & block)
inline

Associate this propagator with a block.

Parameters
blockassociated Block object

Definition at line 352 of file PropagatorBase.h.

References block().

◆ allocate()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::allocate ( int ns,
const Mesh< D > & mesh )
virtual

Allocate memory used by this propagator.

The parameter ns is the number of values of s at which q(r,s) is calculated, including the end values at the terminating vertices. See docs for the function ns(), which returns this value.

The address of the associated Mesh<D> object is retained.

An Exception is thrown if the propagator is already allocated.

Parameters
nsnumber of slices (including end points at vertices)
meshspatial discretization mesh

Reimplemented in Pscf::Rp::Propagator< D, CPT >, and Pscf::Rp::Propagator< D, CUT >.

Definition at line 47 of file PropagatorBase.tpp.

References isAllocated_, mesh(), ns(), ns_, and UTIL_CHECK.

◆ reallocate()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::reallocate ( int ns)
virtual

Reallocate memory used by this propagator.

This function is used when the value of ns is changed, which can occur during some parameter sweeps. See docs for allocate and ns.

An Exception is thrown if the propagator has not been previously allocated, or if it is allocated but the value of ns is unchanged.

Parameters
nsnumber of slices (including end points)

Reimplemented in Pscf::Rp::Propagator< D, CPT >, and Pscf::Rp::Propagator< D, CUT >.

Definition at line 58 of file PropagatorBase.tpp.

References isAllocated_, ns(), ns_, and UTIL_CHECK.

◆ solve() [1/2]

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::solve ( )

Solve the modified diffusion equation (MDE) for this block.

This function computes an initial q-field at the head of this block, and then solves the modified diffusion equation (MDE) to propagate the solution from the head to the tail. Algorithms for the thread or bead model may be used, depending on the value of PolymerModel::model().

Definition at line 103 of file PropagatorBase.tpp.

References computeHead(), Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), Pscf::PropagatorTmpl< Propagator< D, T > >::setIsSolved(), solveMde(), and UTIL_CHECK.

◆ solve() [2/2]

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::solve ( RField< D, T > const & head)

Solve the MDE for a specified initial condition.

This function solves the modified diffusion equation (MDE) for this block with a specified initial condition, which is given by the function parameter "head".

Parameters
headinitial condition of q-field at head of block

Definition at line 121 of file PropagatorBase.tpp.

References Pscf::VecOp::eqV(), head(), isAllocated_, Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), mesh(), qFields_, Pscf::PropagatorTmpl< Propagator< D, T > >::setIsSolved(), solveMde(), and UTIL_CHECK.

◆ computeQ()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::computeQ ( double & Q) const

Compute and return partition function for the polymer molecule.

This function computes the partition function Q for the molecule as a spatial average of the pointwise product of the initial/head slice for this propagator and the final/tail slice of its partner.

Parameters
Qoutput value, spatial average of q*q^{+} at head

Definition at line 195 of file PropagatorBase.tpp.

References Pscf::PropagatorTmpl< Propagator< D, T > >::hasPartner(), head(), Pscf::Reduce::innerProduct(), isAllocated_, Pscf::PolymerModel::isBead(), Pscf::PropagatorTmpl< Propagator< D, T > >::isHeadEnd(), Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), Pscf::PropagatorTmpl< Propagator< D, T > >::isTailEnd(), mesh(), ns_, partner(), q(), qFields_, Pscf::Reduce::sum(), tail(), UTIL_CHECK, and UTIL_THROW.

◆ q()

template<int D, class T>
RField< D, T > const & Pscf::Rp::PropagatorBase< D, T >::q ( int i) const
inline

Return q-field at a specified step.

Parameters
istep index, 0 <= i < ns

Definition at line 298 of file PropagatorBase.h.

References Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), qFields_, and UTIL_CHECK.

Referenced by computeQ().

◆ head()

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

Return q-field at the initial (head) vertex.

Definition at line 277 of file PropagatorBase.h.

References Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), qFields_, and UTIL_CHECK.

Referenced by computeQ(), and solve().

◆ tail()

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

Return q-field at the terminal (tail) vertex.

This function throws an Exception if invoked while the bead model is in use (i.e., if PolymerModel::isThread() == false) and the tail for this propagator is a chain end (i.e., if isTailEnd() == true). In this case, the tail slice is not needed, and so is not computed.

Definition at line 287 of file PropagatorBase.h.

References Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), Pscf::PropagatorTmpl< Propagator< D, T > >::isTailEnd(), Pscf::PolymerModel::isThread(), ns_, qFields_, and UTIL_CHECK.

Referenced by computeHead(), and computeQ().

◆ block() [1/2]

template<int D, class T>
Block< D, T > const & Pscf::Rp::PropagatorBase< D, T >::block ( ) const
inline

Get the associated Block object by const reference.

Definition at line 308 of file PropagatorBase.h.

References UTIL_ASSERT.

Referenced by setBlock(), and solveMde().

◆ mesh()

template<int D, class T>
Mesh< D > const & Pscf::Rp::PropagatorBase< D, T >::mesh ( ) const
inline

Return the associated Mesh object by const reference.

Definition at line 328 of file PropagatorBase.h.

References UTIL_ASSERT.

Referenced by allocate(), computeQ(), and solve().

◆ ns()

template<int D, class T>
int Pscf::Rp::PropagatorBase< D, T >::ns ( ) const
inline

Get the number of values of s (or slices), including head and tail.

The value of ns is the number of values of s at which q(r,s) is calculated, including the end values at the terminating vertices (the head and tail). In the bead model, this is two more than the number of beads in the block. In the thread model, this is one more than the number length/ds of contour length steps.

Definition at line 338 of file PropagatorBase.h.

References ns_.

Referenced by allocate(), computeHead(), and reallocate().

◆ isAllocated()

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

Has memory been allocated for this propagator?

Definition at line 345 of file PropagatorBase.h.

References isAllocated_.

◆ computeHead()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::computeHead ( )
protected

Compute initial q-field at the head vertex.

In either the thread or bead model, the head slice of each propagator is the product of tail slices for incoming propagators from other bonds that terminate at the head vertex, or 1 for a chain end. On return, hasComputeHead_ == true.

Definition at line 70 of file PropagatorBase.tpp.

References Pscf::VecOp::eqS(), isAllocated_, Pscf::PropagatorTmpl< Propagator< D, T > >::isHeadEnd(), Pscf::PropagatorTmpl< Propagator< D, T > >::isSolved(), Pscf::VecOp::mulEqV(), ns(), Pscf::PropagatorTmpl< Propagator< D, T > >::nSource(), qFields_, source(), tail(), UTIL_CHECK, and UTIL_THROW.

Referenced by solve().

◆ solveMde()

template<int D, class T>
void Pscf::Rp::PropagatorBase< D, T >::solveMde ( )
protected

Compute solution of modified diffusion equation (MDE).

This function accesses a precomputed head slice qFields_[0] and computes the rest of the propagator.

Definition at line 145 of file PropagatorBase.tpp.

References block(), Pscf::VecOp::eqV(), isAllocated_, Pscf::PolymerModel::isBead(), Pscf::PropagatorTmpl< Propagator< D, T > >::isHeadEnd(), Pscf::PropagatorTmpl< Propagator< D, T > >::isTailEnd(), Pscf::PolymerModel::isThread(), ns_, qFields_, Pscf::PropagatorTmpl< Propagator< D, T > >::setIsSolved(), UTIL_CHECK, and UTIL_THROW.

Referenced by solve(), and solve().

◆ block() [2/2]

template<int D, class T>
Block< D, T > & Pscf::Rp::PropagatorBase< D, T >::block ( )
inlineprotected

Get the associated Block object by non-const reference.

Definition at line 318 of file PropagatorBase.h.

References UTIL_ASSERT.

◆ source()

template<int D, class T>
const Propagator< D, T > & Pscf::PropagatorTmpl< Propagator< D, T > >::source ( int id) const

Get a source propagator.

Parameters
idindex of source propagator, < nSource

Referenced by computeHead().

◆ partner()

template<int D, class T>
const Propagator< D, T > & Pscf::PropagatorTmpl< Propagator< D, T > >::partner ( ) const

Get partner propagator.

Referenced by computeQ().

Member Data Documentation

◆ qFields_

template<int D, class T>
DArray<RField<D,T> > Pscf::Rp::PropagatorBase< D, T >::qFields_
protected

Array of propagator slices at different contour variable values.

Definition at line 250 of file PropagatorBase.h.

Referenced by computeHead(), computeQ(), head(), q(), solve(), solveMde(), and tail().

◆ ns_

template<int D, class T>
int Pscf::Rp::PropagatorBase< D, T >::ns_
protected

Number of slices, including head and tail slices.

Definition at line 253 of file PropagatorBase.h.

Referenced by allocate(), computeQ(), ns(), PropagatorBase(), reallocate(), solveMde(), and tail().

◆ isAllocated_

template<int D, class T>
bool Pscf::Rp::PropagatorBase< D, T >::isAllocated_
protected

Is this propagator allocated?

Definition at line 256 of file PropagatorBase.h.

Referenced by allocate(), computeHead(), computeQ(), isAllocated(), PropagatorBase(), reallocate(), solve(), and solveMde().


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