PSCF v1.3
Edge.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Edge.h"
9
10namespace Pscf
11{
12
13 /*
14 * Constructor.
15 */
17 : id_(-1),
18 monomerId_(-1),
19 nBead_(-1),
20 length_(-1.0),
21 vertexIds_(),
22 polymerType_(PolymerType::Branched)
23 {
24 // Initialize vertex ids to null value -1.
25 vertexIds_[0] = -1;
26 vertexIds_[1] = -1;
27 }
28
29 /*
30 * Destructor (virtual)
31 */
33 {}
34
35 /*
36 * Set the id for this block.
37 */
38 void Edge::setId(int id)
39 { id_ = id; }
40
41 /*
42 * Set the monomer type id.
43 */
45 { monomerId_ = monomerId; }
46
47 /*
48 * Set the indices of the two associated vertices.
49 */
50 void Edge::setVertexIds(int vertexId0, int vertexId1)
51 {
52 vertexIds_[0] = vertexId0;
53 vertexIds_[1] = vertexId1;
54 }
55
56 /*
57 * Set the number of beads in the block.
58 */
60 {
62 nBead_ = nBead;
63 }
64
65 /*
66 * Set the length of this block.
67 */
69 {
71 length_ = length;
72 }
73
74 /*
75 * Set the type of the polymer containing this block.
76 */
77 void Edge::setPolymerType(PolymerType::Enum type)
78 { polymerType_ = type; }
79
80 /*
81 * Extract a Edge from an istream.
82 */
83 std::istream& operator >> (std::istream& in, Edge& block)
84 {
85 // Read monomer type id
86 in >> block.monomerId_;
87
88 // Read length or nBead
90 in >> block.length_;
91 } else
93 in >> block.nBead_;
94 }
95
96 // For branched polyimers, read topology information
97 if (block.polymerType_ == PolymerType::Branched) {
98 in >> block.vertexIds_[0];
99 in >> block.vertexIds_[1];
100 }
101
102 return in;
103 }
105 /*
106 * Output a Edge to an ostream, without line breaks.
107 */
108 std::ostream& operator << (std::ostream& out,
109 Edge const & block)
110 {
111 // Write monomer type id
112 out << " " << block.monomerId_;
113 out << " ";
114
115 // Write length or nBead
117 out.setf(std::ios::scientific);
118 out.width(20);
119 out.precision(12);
120 out << block.length_;
121 } else
122 if (PolymerModel::isBead()) {
123 out << block.nBead_;
124 }
125
126 // For branched polymer, write topology information
127 if (block.polymerType_ == PolymerType::Branched) {
128 out << " " << block.vertexIds_[0];
129 out << " " << block.vertexIds_[1];
130 }
131
132 return out;
133 }
134
135}
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
void setVertexIds(int vertexId0, int vertexId1)
Set indices of associated vertices.
Definition Edge.cpp:50
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
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
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
#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
Struct containing an enumeration of polymer structure types.
Definition PolymerType.h:27