PSCF v1.3
Edge.h
1#ifndef PSCF_EDGE_H
2#define PSCF_EDGE_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 "PolymerType.h"
12#include "PolymerModel.h"
13#include <util/containers/Pair.h>
14
15#include <iostream>
16
17namespace Pscf
18{
19
20 using namespace Util;
21
58 class Edge
59 {
60 public:
61
65 Edge();
66
70 virtual ~Edge();
71
78 template <class Archive>
79 void serialize(Archive& ar, unsigned int versionId);
80
82
83
89 void setId(int id);
90
96 void setMonomerId(int monomerId);
97
104 void setVertexIds(int vertexId0, int vertexId1);
105
116 virtual void setLength(double length);
117
125 virtual void setNBead(int nBead);
126
138 void setPolymerType(PolymerType::Enum type);
139
141
143
147 int id() const;
148
152 int monomerId() const;
153
157 const Pair<int>& vertexIds() const;
158
164 int vertexId(int i) const;
165
171 double length() const;
172
178 int nBead() const;
179
183 PolymerType::Enum polymerType() const;
184
186
187 private:
188
190 int id_;
191
193 int monomerId_;
194
197 int nBead_;
198
201 double length_;
202
204 Pair<int> vertexIds_;
205
207 PolymerType::Enum polymerType_;
208
209 friend
210 std::istream& operator >> (std::istream& in, Edge &block);
211
212 friend
213 std::ostream& operator << (std::ostream& out,
214 const Edge &block);
215
216 };
217
256 std::istream& operator >> (std::istream& in, Edge &block);
257
270 std::ostream&
271 operator << (std::ostream& out, const Edge &block);
272
273 // Inline member functions
274
275 /*
276 * Get the id of this block.
277 */
278 inline int Edge::id() const
279 { return id_; }
280
281 /*
282 * Get the monomer type id.
283 */
284 inline int Edge::monomerId() const
285 { return monomerId_; }
286
287 /*
288 * Get the pair of associated vertex ids.
289 */
290 inline const Pair<int>& Edge::vertexIds() const
291 { return vertexIds_; }
292
293 /*
294 * Get id of an associated vertex.
295 */
296 inline int Edge::vertexId(int i) const
297 { return vertexIds_[i]; }
298
299 /*
300 * Get the number of beads in this block (bead model).
301 */
302 inline int Edge::nBead() const
303 {
305 return nBead_;
306 }
307
308 /*
309 * Get the length (number of monomers) in this block.
310 */
311 inline double Edge::length() const
312 {
314 return length_;
315 }
316
317 /*
318 * Get the polymer type (branched or linear).
319 */
320 inline PolymerType::Enum Edge::polymerType() const
321 { return polymerType_; }
322
323 /*
324 * Serialize to/from an archive.
325 */
326 template <class Archive>
327 void Edge::serialize(Archive& ar, unsigned int)
328 {
329 ar & id_;
330 ar & monomerId_;
331 ar & vertexIds_;
332 ar & length_;
333 }
334
335}
336#endif
Descriptor for a block within a block polymer.
Definition Edge.h:59
virtual void setNBead(int nBead)
Set the number of beads in this block (only valid for bead model).
Definition Edge.cpp:59
int id() const
Get the id of this block (unique within the polymer).
Definition Edge.h:278
void setPolymerType(PolymerType::Enum type)
Set the type of the parent polymer (branched or linear).
Definition Edge.cpp:77
PolymerType::Enum polymerType() const
Get the type of the parent polymer (branched or linear).
Definition Edge.h:320
friend std::istream & operator>>(std::istream &in, Edge &block)
Input stream extractor (>>) for a Edge.
Definition Edge.cpp:83
void setVertexIds(int vertexId0, int vertexId1)
Set indices of associated vertices.
Definition Edge.cpp:50
const Pair< int > & vertexIds() const
Get the pair of associated vertex ids.
Definition Edge.h:290
friend std::ostream & operator<<(std::ostream &out, const Edge &block)
Output stream inserter (<<) for a Edge.
Definition Edge.cpp:108
int nBead() const
Get the number of beads in this block, in the bead model.
Definition Edge.h:302
virtual void setLength(double length)
Set the length of this block (only valid for thread model).
Definition Edge.cpp:68
void serialize(Archive &ar, unsigned int versionId)
Serialize to/from archive.
Definition Edge.h:327
int monomerId() const
Get the monomer type id for this block.
Definition Edge.h:284
virtual ~Edge()
Destructor.
Definition Edge.cpp:32
Edge()
Constructor.
Definition Edge.cpp:16
int vertexId(int i) const
Get the id of one associated vertex.
Definition Edge.h:296
void setMonomerId(int monomerId)
Set the monomer type id.
Definition Edge.cpp:44
void setId(int id)
Set the id for this block.
Definition Edge.cpp:38
double length() const
Get the length of this block, in the thread model.
Definition Edge.h:311
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
bool isThread()
Is the thread model in use ?
bool isBead()
Is the bead model in use ?
PSCF package top-level namespace.
Definition param_pc.dox:1
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