PSCF v1.1
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 "BlockDescriptor.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 */
28 {}
29
30
31 /*
32 * Set integer id.
33 */
34 void Vertex::setId(int id)
35 { id_ = id; }
36
37 /*
38 * Add this block to the list.
39 */
41 {
42 // Preconditions
43 if (id_ < 0) {
44 UTIL_THROW("Negative vertex id");
45 }
46 if (block.id() < 0) {
47 UTIL_THROW("Negative block id");
48 }
49 if (block.vertexId(0) < 0) {
50 UTIL_THROW("Error: Negative block vertexId 0");
51 }
52 if (block.vertexId(1) < 0) {
53 UTIL_THROW("Error: Negative block vertexId 1");
54 }
55 if (block.vertexId(0) == block.vertexId(1)) {
56 UTIL_THROW("Error: Equal vertex indices in block");
57 }
58
59 Pair<int> propagatorId;
60 propagatorId[0] = block.id();
61 if (block.vertexId(0) == id_) {
62 propagatorId[1] = 0;
63 outPropagatorIds_.append(propagatorId);
64 propagatorId[1] = 1;
65 inPropagatorIds_.append(propagatorId);
66 } else
67 if (block.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 block vertex id matches this vertex");
74 }
75 }
76
77}
Description of a linear homopolymer block within a block polymer.
int vertexId(int i) const
Get id of an associated vertex.
int id() const
Get the id of this block.
void setId(int id)
Set the integer identifier of this vertex.
Definition: Vertex.cpp:34
void addBlock(BlockDescriptor 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:102
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
C++ namespace for polymer self-consistent field theory (PSCF).