PSCF v1.2
PolymerSpecies.h
1#ifndef PSCF_POLYMER_SPECIES_H
2#define PSCF_POLYMER_SPECIES_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, 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#include <util/param/ParamComposite.h> // base class
13
14#include <pscf/chem/Vertex.h> // member
15#include <pscf/chem/PolymerType.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
56 class PolymerSpecies : public Species, public ParamComposite
57 {
58
59 public:
60
65
70
76 virtual void readParameters(std::istream& in);
77
80
89 virtual Edge& edge(int id) = 0;
90
99 virtual Edge const& edge(int id) const = 0;
100
108 const Vertex& vertex(int id) const;
109
123 Pair<int> const & propagatorId(int id) const;
124
143 Pair<int> const & path(int is, int it) const;
144
148
152 int nBlock() const;
153
160 int nVertex() const;
161
165 int nPropagator() const; //
166
170 double length() const;
171
175 PolymerType::Enum type() const;
179 protected:
180
184 virtual void allocateBlocks() = 0;
185
191 virtual void readBlocks(std::istream& in) = 0;
192
203 virtual void makePlan();
204
211 void makePaths();
212
216 void isValid();
217
218 private:
219
221 DArray<Vertex> vertices_;
222
224 DArray< Pair<int> > propagatorIds_;
225
227 DArray< DArray< Pair<int> > > paths_;
228
230 int nBlock_;
231
233 int nVertex_;
234
236 int nPropagator_;
237
239 PolymerType::Enum type_;
240
241 };
242
243 /*
244 * Number of vertices (ends and/or junctions)
245 */
246 inline int PolymerSpecies::nVertex() const
247 { return nVertex_; }
248
249 /*
250 * Number of blocks in this polymer.
251 */
252 inline int PolymerSpecies::nBlock() const
253 { return nBlock_; }
254
255 /*
256 * Number of propagators in this polymer.
257 */
259 { return nPropagator_; }
260
261 /*
262 * Get a specified Vertex by const reference.
263 */
264 inline
265 Vertex const & PolymerSpecies::vertex(int id) const
266 { return vertices_[id]; }
267
268 /*
269 * Get a propagator id, indexed in order of computation (const).
270 */
271 inline
273 {
274 UTIL_CHECK(id >= 0);
275 UTIL_CHECK(id < nPropagator_);
276 return propagatorIds_[id];
277 }
278
279 /*
280 * Get a propagator id that leads from a source vertex towards a target.
281 */
282 inline
283 Pair<int> const & PolymerSpecies::path(int is, int it) const
284 {
285 UTIL_CHECK(is >= 0);
286 UTIL_CHECK(is < nVertex_);
287 UTIL_CHECK(it >= 0);
288 UTIL_CHECK(it < nVertex_);
289 return paths_[is][it];
290 }
291
292 /*
293 * Get the polymer type enumeration value (Branched or Linear).
294 */
295 inline
296 PolymerType::Enum PolymerSpecies::type() const
297 { return type_; }
298
299}
300#endif
Descriptor for a block within an acyclic block polymer.
Definition Edge.h:50
Descriptor for a linear or acyclic branched block polymer.
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 isValid()
Check validity of graph.
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 nBlock() const
Number of blocks.
double length() const
Sum of the lengths of all blocks in the polymer.
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)
Base class for a molecular species (polymer or solvent).
Definition Species.h:30
A junction or chain end in a block polymer.
Definition Vertex.h:31
Dynamically allocatable contiguous array template.
An array of exactly 2 objects.
Definition Pair.h:24
An object that can read multiple parameters from file.
#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
Utility classes for scientific computation.