PSCF v1.1
BlockDescriptor.h
1#ifndef PSCF_BLOCK_DESCRIPTOR_H
2#define PSCF_BLOCK_DESCRIPTOR_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
35 {
36 public:
37
42
46 virtual ~BlockDescriptor();
47
54 template <class Archive>
55 void serialize(Archive& ar, unsigned int versionId);
56
58
59
65 void setId(int id);
66
73 void setVertexIds(int vertexAId, int vertexBId);
74
80 void setMonomerId(int monomerId);
81
89 virtual void setLength(double length);
90
106 void setPolymerType(PolymerType::Enum type);
107
109
111
115 int id() const;
116
120 int monomerId() const;
121
125 const Pair<int>& vertexIds() const;
126
132 int vertexId(int i) const;
133
137 double length() const;
138
142 PolymerType::Enum polymerType() const;
143
145
146 private:
147
149 int id_;
150
152 int monomerId_;
153
155 double length_;
156
158 Pair<int> vertexIds_;
159
161 PolymerType::Enum polymerType_;
162
163 friend
164 std::istream& operator >> (std::istream& in, BlockDescriptor &block);
165
166 friend
167 std::ostream& operator << (std::ostream& out,
168 const BlockDescriptor &block);
169
170 };
171
179 std::istream& operator >> (std::istream& in, BlockDescriptor &block);
180
188 std::ostream& operator << (std::ostream& out, const BlockDescriptor &block);
189
190 // Inline member functions
191
192 /*
193 * Get the id of this block.
194 */
195 inline int BlockDescriptor::id() const
196 { return id_; }
197
198 /*
199 * Get the monomer type id.
200 */
201 inline int BlockDescriptor::monomerId() const
202 { return monomerId_; }
203
204 /*
205 * Get the pair of associated vertex ids.
206 */
208 { return vertexIds_; }
209
210 /*
211 * Get id of an associated vertex.
212 */
213 inline int BlockDescriptor::vertexId(int i) const
214 { return vertexIds_[i]; }
215
216 /*
217 * Get the length (number of monomers) in this block.
218 */
219 inline double BlockDescriptor::length() const
220 { return length_; }
221
222 /*
223 * Get the polymer type (branched or linear).
224 */
225 inline PolymerType::Enum BlockDescriptor::polymerType() const
226 { return polymerType_; }
227
228 /*
229 * Serialize to/from an archive.
230 */
231 template <class Archive>
232 void BlockDescriptor::serialize(Archive& ar, unsigned int)
233 {
234 ar & id_;
235 ar & monomerId_;
236 ar & vertexIds_;
237 ar & length_;
238 }
239
240}
241#endif
Description of a linear homopolymer block within a block polymer.
double length() const
Get the length (number of monomers) in this block.
int vertexId(int i) const
Get id of an associated vertex.
void setId(int id)
Set the id for this block.
friend std::ostream & operator<<(std::ostream &out, const BlockDescriptor &block)
ostream inserter for a BlockDescriptor.
void serialize(Archive &ar, unsigned int versionId)
Serialize to/from archive.
friend std::istream & operator>>(std::istream &in, BlockDescriptor &block)
istream extractor for a BlockDescriptor.
virtual ~BlockDescriptor()
Destructor.
int monomerId() const
Get the monomer type id.
const Pair< int > & vertexIds() const
Get the pair of associated vertex ids.
void setPolymerType(PolymerType::Enum type)
Set the polymer type.
PolymerType::Enum polymerType() const
Get the type of the parent polymer (branched or linear).
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.
An array of exactly 2 objects.
Definition: Pair.h:24
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod: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