PSCF v1.2
Edge.h
1#ifndef PSCF_EDGE_H
2#define PSCF_EDGE_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 "PolymerType.h"
12#include <util/containers/Pair.h>
13
14#include <iostream>
15
16namespace Pscf
17{
18
19 using namespace Util;
20
49 class Edge
50 {
51 public:
52
56 Edge();
57
61 virtual ~Edge();
62
69 template <class Archive>
70 void serialize(Archive& ar, unsigned int versionId);
71
73
74
80 void setId(int id);
81
88 void setVertexIds(int vertexAId, int vertexBId);
89
95 void setMonomerId(int monomerId);
96
104 virtual void setLength(double length);
105
117 void setPolymerType(PolymerType::Enum type);
118
120
122
126 int id() const;
127
131 int monomerId() const;
132
136 const Pair<int>& vertexIds() const;
137
143 int vertexId(int i) const;
144
148 double length() const;
149
153 PolymerType::Enum polymerType() const;
154
156
157 private:
158
160 int id_;
161
163 int monomerId_;
164
166 double length_;
167
169 Pair<int> vertexIds_;
170
172 PolymerType::Enum polymerType_;
173
174 friend
175 std::istream& operator >> (std::istream& in, Edge &block);
176
177 friend
178 std::ostream& operator << (std::ostream& out,
179 const Edge &block);
180
181 };
182
207 std::istream& operator >> (std::istream& in, Edge &block);
208
221 std::ostream&
222 operator << (std::ostream& out, const Edge &block);
223
224 // Inline member functions
225
226 /*
227 * Get the id of this block.
228 */
229 inline int Edge::id() const
230 { return id_; }
231
232 /*
233 * Get the monomer type id.
234 */
235 inline int Edge::monomerId() const
236 { return monomerId_; }
237
238 /*
239 * Get the pair of associated vertex ids.
240 */
241 inline const Pair<int>& Edge::vertexIds() const
242 { return vertexIds_; }
243
244 /*
245 * Get id of an associated vertex.
246 */
247 inline int Edge::vertexId(int i) const
248 { return vertexIds_[i]; }
249
250 /*
251 * Get the length (number of monomers) in this block.
252 */
253 inline double Edge::length() const
254 { return length_; }
255
256 /*
257 * Get the polymer type (branched or linear).
258 */
259 inline PolymerType::Enum Edge::polymerType() const
260 { return polymerType_; }
261
262 /*
263 * Serialize to/from an archive.
264 */
265 template <class Archive>
266 void Edge::serialize(Archive& ar, unsigned int)
267 {
268 ar & id_;
269 ar & monomerId_;
270 ar & vertexIds_;
271 ar & length_;
272 }
273
274}
275#endif
Descriptor for a block within an acyclic block polymer.
Definition Edge.h:50
void setVertexIds(int vertexAId, int vertexBId)
Set indices of associated vertices.
Definition Edge.cpp:43
int id() const
Get the id of this block.
Definition Edge.h:229
void setPolymerType(PolymerType::Enum type)
Set the polymer type (branched or linear).
Definition Edge.cpp:64
PolymerType::Enum polymerType() const
Get the type of the parent polymer (branched or linear).
Definition Edge.h:259
friend std::istream & operator>>(std::istream &in, Edge &block)
Input stream extractor (>>) for a Edge.
Definition Edge.cpp:70
const Pair< int > & vertexIds() const
Get the pair of associated vertex ids.
Definition Edge.h:241
friend std::ostream & operator<<(std::ostream &out, const Edge &block)
Output stream inserter (<<) for a Edge.
Definition Edge.cpp:84
virtual void setLength(double length)
Set the length of this block.
Definition Edge.cpp:58
void serialize(Archive &ar, unsigned int versionId)
Serialize to/from archive.
Definition Edge.h:266
int monomerId() const
Get the monomer type id.
Definition Edge.h:235
virtual ~Edge()
Destructor.
Definition Edge.cpp:31
Edge()
Constructor.
Definition Edge.cpp:16
int vertexId(int i) const
Get id of an associated vertex.
Definition Edge.h:247
void setMonomerId(int monomerId)
Set the monomer type id.
Definition Edge.cpp:52
void setId(int id)
Set the id for this block.
Definition Edge.cpp:37
double length() const
Get the length (number of monomers) in this block.
Definition Edge.h:253
An array of exactly 2 objects.
Definition Pair.h:24
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
Definition Pair.h:44
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
Definition Pair.h:57