1#ifndef PSCF_POLYMER_TMPL_TPP
2#define PSCF_POLYMER_TMPL_TPP
11#include "PolymerTmpl.h"
21 template <
class BT,
class PT>
30 template <
class BT,
class PT>
37 template <
class BT,
class PT>
39 { blocks_.allocate(
nBlock()); }
44 template <
class BT,
class PT>
51 template <
class BT,
class PT>
62 PT * propagatorPtr =
nullptr;
63 PT
const * sourcePtr =
nullptr;
64 Vertex const * headPtr =
nullptr;
65 Vertex const * tailPtr =
nullptr;
67 int blockId, forwardId, reverseId, headId, tailId, i;
68 bool isHeadEnd, isTailEnd;
71 for (blockId = 0; blockId <
nBlock(); ++blockId) {
72 for (forwardId = 0; forwardId < 2; ++forwardId) {
74 propagatorPtr = &
block(blockId).propagator(forwardId);
82 headId = block(blockId).vertexId(forwardId);
83 tailId = block(blockId).vertexId(reverseId);
84 headPtr = &vertex(headId);
85 tailPtr = &vertex(tailId);
88 for (i = 0; i < headPtr->
size(); ++i) {
90 if (propId[0] == blockId) {
94 &block(propId[0]).propagator(propId[1]);
95 propagatorPtr->addSource(*sourcePtr);
100 isHeadEnd = (headPtr->
size() == 1) ? true :
false;
101 isTailEnd = (tailPtr->
size() == 1) ? true :
false;
102 propagatorPtr->setEndFlags(isHeadEnd, isTailEnd);
120 template <
class BT,
class PT>
121 void PolymerTmpl<BT,PT>::isValid()
123 Vertex const * v0Ptr =
nullptr;
124 Vertex const * v1Ptr =
nullptr;
125 PT
const * p0Ptr =
nullptr;
126 PT
const * p1Ptr =
nullptr;
130 for (bId = 0; bId <
nBlock(); ++bId) {
131 v0Id =
block(bId).vertexId(0);
132 v1Id =
block(bId).vertexId(1);
138 p0Ptr = &(
block(bId).propagator(0));
139 p1Ptr = &(
block(bId).propagator(1));
142 UTIL_CHECK(p0Ptr->isHeadEnd() == p1Ptr->isTailEnd());
152 template <
class BT,
class PT>
163 for (
int j = 0; j < nPropagator(); ++j) {
165 propagator(j).solve();
169 double Q = block(0).propagator(0).computeQ();
183 template <
class BT,
class PT>
185 {
return block(blockId).propagator(directionId); }
190 template <
class BT,
class PT>
193 {
return block(blockId).propagator(directionId); }
198 template <
class BT,
class PT>
Descriptor for a block within a block polymer.
PolymerSpecies()
Constructor.
virtual void readParameters(std::istream &in)
Read parameters and initialize.
const Vertex & vertex(int id) const
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
void readBlocks(std::istream &in) final
Read array of data for blocks from parameter file.
~PolymerTmpl()
Destructor.
PT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
int nPropagator() const
Number of propagators (2*nBlock).
virtual void readParameters(std::istream &in)
Read and initialize.
int nBlock() const
Number of blocks.
PolymerTmpl()
Constructor.
void allocateBlocks() final
Allocate array of Block objects.
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
void setQ(double q)
Set q and compute phi or mu (depending on the ensemble).
A junction or chain end in a block polymer.
int size() const
Get the number of attached blocks.
Pair< int > const & inPropagatorId(int i) const
Get the block and direction of an incoming propagator.
An array of exactly 2 objects.
DArrayParam< Type > & readDArray(std::istream &in, const char *label, DArray< Type > &array, int n)
Add and read a required DArray < Type > parameter.
void setClassName(const char *className)
Set class name string.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
PSCF package top-level namespace.