1#ifndef PSCF_POLYMER_TMPL_TPP
2#define PSCF_POLYMER_TMPL_TPP
11#include "PolymerTmpl.h"
12#include <pscf/math/arithmetic.h>
13#include <util/containers/Pair.h>
23 template <
class BT,
class PT,
typename WT>
32 template <
class BT,
class PT,
typename WT>
39 template <
class BT,
class PT,
typename WT>
49 template <
class BT,
class PT,
typename WT>
60 PT * propagatorPtr =
nullptr;
61 PT
const * sourcePtr =
nullptr;
62 Vertex const * headPtr =
nullptr;
63 Vertex const * tailPtr =
nullptr;
65 int blockId, forwardId, reverseId, headId, tailId, i;
67 bool isHeadEnd, isTailEnd;
70 for (blockId = 0; blockId <
nBlock; ++blockId) {
71 for (forwardId = 0; forwardId < 2; ++forwardId) {
73 propagatorPtr = &
block(blockId).propagator(forwardId);
81 headId = block(blockId).vertexId(forwardId);
82 tailId = block(blockId).vertexId(reverseId);
83 headPtr = &PolymerSpeciesT::vertex(headId);
84 tailPtr = &PolymerSpeciesT::vertex(tailId);
87 for (i = 0; i < headPtr->
size(); ++i) {
89 if (propId[0] == blockId) {
93 &block(propId[0]).propagator(propId[1]);
94 propagatorPtr->addSource(*sourcePtr);
99 isHeadEnd = (headPtr->
size() == 1) ? true :
false;
100 isTailEnd = (tailPtr->
size() == 1) ? true :
false;
101 propagatorPtr->setEndFlags(isHeadEnd, isTailEnd);
119 template <
class BT,
class PT,
typename WT>
120 void PolymerTmpl<BT,PT,WT>::isValid()
122 Vertex const * v0Ptr =
nullptr;
123 Vertex const * v1Ptr =
nullptr;
124 PT
const * p0Ptr =
nullptr;
125 PT
const * p1Ptr =
nullptr;
131 for (bId = 0; bId <
nBlock; ++bId) {
132 v0Id =
block(bId).vertexId(0);
133 v1Id =
block(bId).vertexId(1);
139 p0Ptr = &(
block(bId).propagator(0));
140 p1Ptr = &(
block(bId).propagator(1));
145 UTIL_CHECK(p0Ptr->isHeadEnd() == p1Ptr->isTailEnd());
146 UTIL_CHECK(p0Ptr->isTailEnd() == p1Ptr->isHeadEnd());
156 template <
class BT,
class PT,
typename WT>
168 for (
int j = 0; j < nPropagator; ++j) {
170 propagator(j).solve();
175 block(0).propagator(0).computeQ(Q);
189 template <
class BT,
class PT,
typename WT>
191 {
return block(blockId).propagator(directionId); }
196 template <
class BT,
class PT,
typename WT>
199 {
return block(blockId).propagator(directionId); }
204 template <
class BT,
class PT,
typename WT>
Descriptor for a block within a block polymer.
virtual void readParameters(std::istream &in)
const Vertex & vertex(int id) const
Pair< int > const & propagatorId(int id) const
PolymerTmpl()
Constructor.
Propagator & propagator(int blockId, int directionId)
PolymerSpecies< WT > PolymerSpeciesT
Direct (parent) base class.
void readParameters(std::istream &in) override
Read and initialize.
BT & block(int id)
Get a specified Block (solver and descriptor).
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
void allocateBlocks() final
Allocate array of Block objects.
void readBlocks(std::istream &in) final
Read array of data for blocks from parameter file.
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.
void divEq(fftw_complex &a, fftw_complex const &b)
In-place division of fftw_complex numbers, a /= b.
PSCF package top-level namespace.