PSCF v1.2
Vertex.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 "Vertex.h"
9#include "Edge.h"
10#include <util/global.h>
11
12namespace Pscf
13{
14
15 /*
16 * Constructor.
17 */
19 : inPropagatorIds_(),
20 outPropagatorIds_(),
21 id_(-1)
22 {}
23
24 /*
25 * Destructor.
26 */
29
30
31 /*
32 * Set integer id.
33 */
34 void Vertex::setId(int id)
35 { id_ = id; }
36
37 /*
38 * Add a edge to the vertex.
39 */
40 void Vertex::addEdge(const Edge& edge)
41 {
42 // Preconditions
43 if (id_ < 0) {
44 UTIL_THROW("Negative vertex id");
45 }
46 if (edge.id() < 0) {
47 UTIL_THROW("Negative edge id");
48 }
49 if (edge.vertexId(0) < 0) {
50 UTIL_THROW("Error: Negative edge vertexId 0");
51 }
52 if (edge.vertexId(1) < 0) {
53 UTIL_THROW("Error: Negative edge vertexId 1");
54 }
55 if (edge.vertexId(0) == edge.vertexId(1)) {
56 UTIL_THROW("Error: Equal vertex indices in edge");
57 }
58
59 Pair<int> propagatorId;
60 propagatorId[0] = edge.id();
61 if (edge.vertexId(0) == id_) {
62 propagatorId[1] = 0;
63 outPropagatorIds_.append(propagatorId);
64 propagatorId[1] = 1;
65 inPropagatorIds_.append(propagatorId);
66 } else
67 if (edge.vertexId(1) == id_) {
68 propagatorId[1] = 1;
69 outPropagatorIds_.append(propagatorId);
70 propagatorId[1] = 0;
71 inPropagatorIds_.append(propagatorId);
72 } else {
73 UTIL_THROW("Neither edge vertex id matches this vertex");
74 }
75 }
76
77}
Descriptor for a block within an acyclic block polymer.
Definition Edge.h:50
int id() const
Get the id of this block.
Definition Edge.h:229
int vertexId(int i) const
Get id of an associated vertex.
Definition Edge.h:247
void setId(int id)
Set the integer identifier of this vertex.
Definition Vertex.cpp:34
void addEdge(Edge const &block)
Add block to the list of attached blocks.
Definition Vertex.cpp:40
Vertex()
Constructor.
Definition Vertex.cpp:18
~Vertex()
Destructor.
Definition Vertex.cpp:27
int id() const
Get the id of this vertex.
Definition Vertex.h:107
An array of exactly 2 objects.
Definition Pair.h:24
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition global.h:51
PSCF package top-level namespace.
Definition param_pc.dox:1