PSCF v1.2
paramIdConversions.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 "paramIdConversions.h"
9
10namespace Pscf {
11namespace Prdc {
12
13 template <>
14 int convertFullParamIdToReduced<1>(const int fullId,
15 const typename UnitCell<1>::LatticeSystem lattice)
16 {
17 UTIL_CHECK(fullId == 0);
18 UTIL_CHECK(lattice != UnitCell<1>::Null);
19 return 0;
20 }
21
22 template <>
23 int convertFullParamIdToReduced<2>(const int fullId,
24 const typename UnitCell<2>::LatticeSystem lattice)
25 {
26 UTIL_CHECK((fullId > -1) && (fullId < 3));
27 UTIL_CHECK(lattice != UnitCell<2>::Null);
28
29 if (fullId == 0) {
30 return 0;
31 } else if (fullId == 1) {
32 if ((lattice == UnitCell<2>::Rectangular) ||
33 (lattice == UnitCell<2>::Oblique)) {
34 return 1;
35 } else {
36 return 0;
37 }
38 } else { // fullId == 2
39 if (lattice == UnitCell<2>::Oblique) {
40 return 2;
41 } else if (lattice == UnitCell<2>::Rhombic) {
42 return 1;
43 } else {
44 return -1;
45 }
46 }
47 }
48
49 template <>
50 int convertFullParamIdToReduced<3>(const int fullId,
51 const typename UnitCell<3>::LatticeSystem lattice)
52 {
53 UTIL_CHECK((fullId > -1) && (fullId < 6));
54 UTIL_CHECK(lattice != UnitCell<3>::Null);
55 if (fullId == 0) {
56 return 0;
57 } else if (fullId == 1) {
58 if ((lattice == UnitCell<3>::Orthorhombic) ||
59 (lattice == UnitCell<3>::Monoclinic) ||
60 (lattice == UnitCell<3>::Triclinic)) {
61 return 1;
62 } else {
63 return 0;
64 }
65 } else if (fullId == 2) {
66 if ((lattice == UnitCell<3>::Cubic) ||
67 (lattice == UnitCell<3>::Rhombohedral)) {
68 return 0;
69 } else if ((lattice == UnitCell<3>::Tetragonal) ||
70 (lattice == UnitCell<3>::Hexagonal)) {
71 return 1;
72 } else { // lattice is Orthorhombic, Monoclinic, or Triclinic
73 return 2;
74 }
75 } else if ((fullId == 3) || (fullId == 5)) {
76 if (lattice == UnitCell<3>::Triclinic) {
77 return fullId;
78 } else if (lattice == UnitCell<3>::Rhombohedral) {
79 return 1;
80 } else {
81 return -1;
82 }
83 } else { // fullId == 4
84 if (lattice == UnitCell<3>::Triclinic) {
85 return fullId;
86 } else if (lattice == UnitCell<3>::Monoclinic) {
87 return 3;
88 }else if (lattice == UnitCell<3>::Rhombohedral) {
89 return 1;
90 } else {
91 return -1;
92 }
93 }
94 }
95
96 template <>
97 int convertReducedParamIdToFull<1>(const int reducedId,
98 const typename UnitCell<1>::LatticeSystem lattice)
99 {
100 UTIL_CHECK(reducedId == 0);
101 UTIL_CHECK(lattice != UnitCell<1>::Null);
102 return 0;
103 }
104
105 template <>
106 int convertReducedParamIdToFull<2>(const int reducedId,
107 const typename UnitCell<2>::LatticeSystem lattice)
108 {
109 UTIL_CHECK(reducedId > -1);
110 if ((lattice == UnitCell<2>::Square) ||
111 (lattice == UnitCell<2>::Hexagonal)) {
112 UTIL_CHECK(reducedId == 0);
113 return reducedId;
114 } else if (lattice == UnitCell<2>::Rectangular) {
115 UTIL_CHECK(reducedId < 2);
116 return reducedId;
117 } else if (lattice == UnitCell<2>::Rhombic) {
118 UTIL_CHECK(reducedId < 2);
119 if (reducedId == 0) {
120 return 0;
121 } else { // reducedId == 1
122 return 2;
123 }
124 } else { // lattice == Oblique
125 UTIL_CHECK(reducedId < 3);
126 return reducedId;
127 }
128 }
129
130 template <>
131 int convertReducedParamIdToFull<3>(const int reducedId,
132 const typename UnitCell<3>::LatticeSystem lattice)
133 {
134 UTIL_CHECK(reducedId > -1);
135 if (lattice == UnitCell<3>::Cubic) {
136 UTIL_CHECK(reducedId == 0);
137 return reducedId;
138 } else if ((lattice == UnitCell<3>::Hexagonal) ||
139 (lattice == UnitCell<3>::Tetragonal)) {
140 UTIL_CHECK(reducedId < 2);
141 if (reducedId == 0) {
142 return 0;
143 } else { // reducedId == 1
144 return 2;
145 }
146 } else if (lattice == UnitCell<3>::Rhombohedral) {
147 UTIL_CHECK(reducedId < 2);
148 if (reducedId == 0) {
149 return 0;
150 } else { // reducedId == 1
151 return 3;
152 }
153 } else if (lattice == UnitCell<3>::Orthorhombic) {
154 UTIL_CHECK(reducedId < 3);
155 return reducedId;
156 } else if (lattice == UnitCell<3>::Monoclinic) {
157 UTIL_CHECK(reducedId < 4);
158 if (reducedId < 3) {
159 return reducedId;
160 } else { // reducedId == 3
161 return 4;
162 }
163 } else { // lattice == Triclinic
164 UTIL_CHECK(reducedId < 6);
165 return reducedId;
166 }
167 }
168
169}
170}
LatticeSystem
Enumeration of 1D lattice system types.
Definition UnitCell.h:137
LatticeSystem
Enumeration of 2D lattice system types.
Definition UnitCell.h:280
LatticeSystem
Enumeration of the 7 possible 3D Bravais lattice systems.
Definition UnitCell.h:425
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
Definition param_pc.dox:1