PSCF v1.1
BlockDescriptor.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 "BlockDescriptor.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 */
38 { id_ = id; }
39
40 /*
41 * Set indices of associated vertices.
42 */
43 void BlockDescriptor::setVertexIds(int vertexId0, int vertexId1)
44 {
45 vertexIds_[0] = vertexId0;
46 vertexIds_[1] = vertexId1;
47 }
48
49 /*
50 * Set the monomer id.
51 */
53 { monomerId_ = monomerId; }
54
55 /*
56 * Set the length of this block.
57 */
58 void BlockDescriptor::setLength(double length)
59 { length_ = length; }
60
61 /*
62 * Set the type of the polymer containing this block.
63 */
64 void BlockDescriptor::setPolymerType(PolymerType::Enum type)
65 { polymerType_ = type; }
66
67 /*
68 * Extract a BlockDescriptor from an istream.
69 */
70 std::istream& operator >> (std::istream& in, BlockDescriptor& 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 BlockDescriptor to an ostream, without line breaks.
83 */
84 std::ostream& operator << (std::ostream& out,
85 BlockDescriptor 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}
Description of a linear homopolymer block within a block polymer.
double length() const
Get the length (number of monomers) in this block.
void setId(int id)
Set the id for this block.
virtual ~BlockDescriptor()
Destructor.
int monomerId() const
Get the monomer type id.
void setPolymerType(PolymerType::Enum type)
Set the polymer type.
virtual void setLength(double length)
Set the length of this block.
void setVertexIds(int vertexAId, int vertexBId)
Set indices of associated vertices.
BlockDescriptor()
Constructor.
int id() const
Get the id of this block.
void setMonomerId(int monomerId)
Set the monomer id.
C++ namespace for polymer self-consistent field theory (PSCF).
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