PSCF v1.3
PolymerSpecies.h
1#ifndef PSCF_POLYMER_SPECIES_H
2#define PSCF_POLYMER_SPECIES_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <pscf/chem/Species.h> // base class
12
13#include <pscf/chem/Vertex.h> // member
14#include <pscf/chem/PolymerType.h> // member
15#include <pscf/chem/PolymerModel.h> // member
16#include <util/containers/Pair.h> // member
17#include <util/containers/DArray.h> // member
18
19namespace Pscf
20{
21
22 // Forward declaration
23 class Edge;
24
25 using namespace Util;
26
70 class PolymerSpecies : public Species
71 {
72
73 public:
74
79
84
94 virtual void readParameters(std::istream& in);
95
98
108 virtual Edge& edge(int id) = 0;
109
115 virtual Edge const& edge(int id) const = 0;
116
124 const Vertex& vertex(int id) const;
125
129
133 int nBlock() const;
134
141 int nVertex() const;
142
146 int nPropagator() const; //
147
153 double length() const;
154
160 int nBead() const;
161
165 PolymerType::Enum type() const;
166
170
192 Pair<int> const & propagatorId(int id) const;
193
212 Pair<int> const & path(int is, int it) const;
213
215
216 protected:
217
221 virtual void allocateBlocks() = 0;
222
228 virtual void readBlocks(std::istream& in) = 0;
229
250 virtual void makePlan();
251
259 void makePaths();
260
261 private:
262
264 DArray<Vertex> vertices_;
265
267 DArray< Pair<int> > propagatorIds_;
268
270 DArray< DArray< Pair<int> > > paths_;
271
273 int nBlock_;
274
276 int nVertex_;
277
279 int nPropagator_;
280
282 PolymerType::Enum type_;
283
289 void isValid();
290
291 };
292
293 // Inline functions
294
295 /*
296 * Number of blocks in this polymer.
297 */
298 inline int PolymerSpecies::nBlock() const
299 { return nBlock_; }
300
301 /*
302 * Number of vertices (ends and/or junctions)
303 */
304 inline int PolymerSpecies::nVertex() const
305 { return nVertex_; }
306
307 /*
308 * Number of propagators in this polymer (2*nBlock).
309 */
311 { return nPropagator_; }
312
313 /*
314 * Get a specified Vertex by const reference.
315 */
316 inline
317 Vertex const & PolymerSpecies::vertex(int id) const
318 { return vertices_[id]; }
319
320 /*
321 * Get a propagator id, indexed in order of computation.
322 */
323 inline
325 {
326 UTIL_CHECK(id >= 0);
327 UTIL_CHECK(id < nPropagator_);
328 return propagatorIds_[id];
329 }
330
331 /*
332 * Get a propagator id that leads from a source vertex towards a target.
333 */
334 inline
335 Pair<int> const & PolymerSpecies::path(int is, int it) const
336 {
337 UTIL_CHECK(is >= 0);
338 UTIL_CHECK(is < nVertex_);
339 UTIL_CHECK(it >= 0);
340 UTIL_CHECK(it < nVertex_);
341 return paths_[is][it];
342 }
343
344 /*
345 * Get the polymer type enumeration value (Branched or Linear).
346 */
347 inline
348 PolymerType::Enum PolymerSpecies::type() const
349 { return type_; }
350
351}
352#endif
Descriptor for a block within a block polymer.
Definition Edge.h:59
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.
virtual Edge const & edge(int id) const =0
Get a specified Edge (block descriptor) by const reference.
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.
int nVertex() const
Number of vertices (junctions and chain ends).
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.
int nPropagator() const
Number of propagators (2*nBlock).
~PolymerSpecies()
Destructor.
int nBead() const
Total number of beads in the polymer (bead model).
int nBlock() const
Number of blocks.
double length() const
Sum of the lengths of all blocks in the polymer (thread model).
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
PolymerType::Enum type() const
Get Polymer type (Branched or Linear)
Species()
Default constructor.
Definition Species.cpp:18
A junction or chain end in a block polymer.
Definition Vertex.h:31
Dynamically allocatable contiguous array template.
Definition DArray.h:32
An array of exactly 2 objects.
Definition Pair.h:24
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
Definition param_pc.dox:1