PSCF v1.2
Edge.cpp
1/*
2* PSCF - Polymer Self-Consistent Field Theory
3*
4* Copyright 2016 - 2022, 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 length_(-1.0),
20 vertexIds_(),
21 polymerType_(PolymerType::Branched)
22 {
23 // Initialize vertex ids to null value -1.
24 vertexIds_[0] = -1;
25 vertexIds_[1] = -1;
26 }
27
28 /*
29 * Destructor (virtual)
30 */
32 {}
33
34 /*
35 * Set the id for this block.
36 */
37 void Edge::setId(int id)
38 { id_ = id; }
39
40 /*
41 * Set indices of associated vertices.
42 */
43 void Edge::setVertexIds(int vertexId0, int vertexId1)
44 {
45 vertexIds_[0] = vertexId0;
46 vertexIds_[1] = vertexId1;
47 }
48
49 /*
50 * Set the monomer id.
51 */
52 void Edge::setMonomerId(int monomerId)
53 { monomerId_ = monomerId; }
54
55 /*
56 * Set the length of this block.
57 */
58 void Edge::setLength(double length)
59 { length_ = length; }
60
61 /*
62 * Set the type of the polymer containing this block.
63 */
64 void Edge::setPolymerType(PolymerType::Enum type)
65 { polymerType_ = type; }
66
67 /*
68 * Extract a Edge from an istream.
69 */
70 std::istream& operator >> (std::istream& in, Edge& block)
71 {
72 in >> block.monomerId_;
73 in >> block.length_;
74 if (block.polymerType_ == PolymerType::Branched) {
75 in >> block.vertexIds_[0];
76 in >> block.vertexIds_[1];
77 }
78 return in;
79 }
81 /*
82 * Output a Edge to an ostream, without line breaks.
83 */
84 std::ostream& operator << (std::ostream& out,
85 Edge const & block)
86 {
87 out << " " << block.monomerId_;
88 out << " ";
89 out.setf(std::ios::scientific);
90 out.width(20);
91 out.precision(12);
92 out << block.length_;
93 if (block.polymerType_ == PolymerType::Branched) {
94 out << " " << block.vertexIds_[0];
95 out << " " << block.vertexIds_[1];
96 }
97 return out;
98 }
99
100}
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
virtual void setLength(double length)
Set the length of this block.
Definition Edge.cpp:58
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
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
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