8#include "PolymerSpecies.h"
10#include <pscf/chem/Edge.h>
11#include <util/containers/GArray.h>
12#include <util/containers/FArray.h>
13#include <util/containers/DMatrix.h>
46 type_ = PolymerType::Linear;
52 nVertex_ = nBlock_ + 1;
56 vertices_.allocate(nVertex_);
57 propagatorIds_.allocate(2*nBlock_);
60 for (
int edgeId = 0; edgeId < nBlock_; ++edgeId) {
66 for (
int vertexId = 0; vertexId < nVertex_; ++vertexId) {
67 vertices_[vertexId].setId(vertexId);
71 if (type_ == PolymerType::Linear) {
73 for (
int blockId = 0; blockId < nBlock_; ++blockId) {
87 int vertexId0, vertexId1;
89 for (
int edgeId = 0; edgeId < nBlock_; ++edgeId) {
90 edgePtr = &(
edge(edgeId));
93 vertices_[vertexId0].addEdge(*edgePtr);
94 vertices_[vertexId1].addEdge(*edgePtr);
116 if (nPropagator_ != 0) {
123 for (
int iBlock = 0; iBlock < nBlock_; ++iBlock) {
124 for (
int iDirection = 0; iDirection < 2; ++iDirection) {
125 isFinished(iBlock, iDirection) =
false;
133 while (nPropagator_ < nBlock_*2) {
134 for (
int iBlock = 0; iBlock < nBlock_; ++iBlock) {
135 for (
int iDirection = 0; iDirection < 2; ++iDirection) {
136 if (isFinished(iBlock, iDirection) ==
false) {
138 inVertexPtr = &vertices_[inVertexId];
140 for (
int j = 0; j < inVertexPtr->
size(); ++j) {
142 if (propId[0] != iBlock) {
143 if (!isFinished(propId[0], propId[1])){
150 propagatorIds_[nPropagator_][0] = iBlock;
151 propagatorIds_[nPropagator_][1] = iDirection;
152 isFinished(iBlock, iDirection) =
true;
186 for (is = 0; is < nVertex_; ++is) {
187 sendPaths[is].clear();
188 recvPaths[is].clear();
189 oldPaths[is].clear();
193 for (is = 0; is < nVertex_; ++is) {
197 sendPaths[is].append(
path);
207 for (ir = 0; is < nVertex_; ++is) {
213 for (is = 0; is < nVertex_; ++is) {
216 int n = sendPaths[is].size();
222 for (j = 0; j < sender.
size(); ++j) {
234 for (k = 0; k < n; ++k) {
235 path = sendPaths[is][k];
240 recvPaths[ir].append(
path);
249 for (is = 0; is < nVertex_; ++is) {
252 n = sendPaths[is].size();
254 for (k = 0; k < n; ++k) {
255 path = sendPaths[is][k];
256 oldPaths[is].append(
path);
259 sendPaths[is].clear();
262 n = recvPaths[is].size();
264 for (k = 0; k < n; ++k) {
265 sendPaths[is].append(recvPaths[is][k]);
268 recvPaths[is].clear();
276 paths_.allocate(nVertex_);
277 for (is = 0; is < nVertex_; ++is) {
278 paths_[is].allocate(nVertex_);
279 for (ir = 0; ir < nVertex_; ++ir) {
280 paths_[is][ir][0] = -1;
281 paths_[is][ir][1] = -1;
286 for (is = 0; is < nVertex_; ++is) {
287 n = oldPaths[is].size();
289 for (k = 0; k < n; ++k) {
290 path = oldPaths[is][k];
308 paths_[is][ir][0] =
path[1];
309 paths_[is][ir][1] =
path[2];
314 std::cout << std::endl <<
"Paths:" ;
315 for (is = 0; is < nVertex_; ++is) {
316 for (ir = 0; ir < nVertex_; ++ir) {
317 pId = paths_[is][ir];
318 std::cout << std::endl;
319 std::cout << is << ir << pId[0] << pId[1];
322 std::cout << std::endl;
330 void PolymerSpecies::isValid()
333 int ib, iv, ip, id, iv0, iv1, n;
336 for (ib = 0; ib < nBlock_; ++ib) {
348 for (iv = 0; iv < nVertex_; ++iv) {
351 for (ip = 0; ip < n; ++ip) {
364 for (iv = 0; iv < nVertex_; ++iv) {
367 for (ip = 0; ip < n; ++ip) {
384 for (iv0 = 0; iv0 < nVertex_; ++iv0) {
385 for (iv1 = 0; iv1 < nVertex_; ++iv1) {
386 pair =
path(iv0, iv1);
407 for (
int blockId = 0; blockId < nBlock_; ++blockId) {
420 for (
int blockId = 0; blockId < nBlock_; ++blockId) {
Descriptor for a block within a block polymer.
void setPolymerType(PolymerType::Enum type)
Set the type of the parent polymer (branched or linear).
void setVertexIds(int vertexId0, int vertexId1)
Set indices of associated vertices.
int nBead() const
Get the number of beads in this block, in the bead model.
int vertexId(int i) const
Get the id of one associated vertex.
void setId(int id)
Set the id for this block.
double length() const
Get the length of this block, in the thread model.
const Vertex & vertex(int id) const
Get a specified Vertex by const reference.
virtual void readBlocks(std::istream &in)=0
Read array of blocks from parameter file.
PolymerSpecies()
Constructor.
void makePaths()
Create a matrix of vertex-to-vertex path signposts.
Pair< int > const & path(int is, int it) const
Get an id for a propagator from one vertex towards a target.
virtual void allocateBlocks()=0
Allocate array of blocks.
virtual Edge & edge(int id)=0
Get a specified Edge (block descriptor) by non-const reference.
virtual void readParameters(std::istream &in)
Read parameters and initialize.
virtual void makePlan()
Make a plan for order in which propagators should be computed.
~PolymerSpecies()
Destructor.
int nBead() const
Total number of beads in the polymer (bead model).
double length() const
Sum of the lengths of all blocks in the polymer (thread model).
virtual void readParameters(std::istream &in)
Read phi or mu (but not both) and set ensemble accordingly.
Species()
Default constructor.
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.
Pair< int > const & outPropagatorId(int i) const
Get the block and direction of an outgoing propagator.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
Dynamically allocated Matrix.
void allocate(int capacity1, int capacity2)
Allocate memory for a matrix.
A fixed size (static) contiguous array template.
An array of exactly 2 objects.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool isThread()
Is the thread model in use ?
bool isBead()
Is the bead model in use ?
PSCF package top-level namespace.
Struct containing an enumeration of polymer structure types.