PSCF v1.1
Species.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 "Species.h"
9
10namespace Pscf
11{
12
13 using namespace Util;
14
16 : ensemble_(Species::Closed)
17 {}
18
19 /*
20 * Extract a Species::Ensemble from an istream as a string.
21 */
22 std::istream& operator >> (std::istream& in, Species::Ensemble& policy)
23 {
24 std::string buffer;
25 in >> buffer;
26 if (buffer == "Closed" || buffer == "closed") {
27 policy = Species::Closed;
28 } else
29 if (buffer == "Open" || buffer == "open") {
30 policy = Species::Open;
31 } else {
32 UTIL_THROW("Invalid Species::Ensemble string in operator >>");
33 }
34 return in;
35 }
36
37 /*
38 * Insert a Species::Ensemble to an ostream as a string.
39 */
40 std::ostream& operator<<(std::ostream& out, Species::Ensemble policy)
41 {
42 if (policy == Species::Closed) {
43 out << "Closed";
44 } else
45 if (policy == Species::Open) {
46 out << "Open";
47 } else
48 if (policy == Species::Unknown) {
49 out << "Unknown";
50 } else {
51 std::cout << "Invalid Species::Ensemble value on input" << std::endl;
52 UTIL_THROW("Unrecognized value for Species::Ensemble");
53 }
54 return out;
55 }
56
57} // namespace Pscf
Base class for a molecular species (polymer or solvent).
Definition: Species.h:30
Species()
Default constructor.
Definition: Species.cpp:15
Ensemble
Statistical ensemble for number of molecules.
Definition: Species.h:36
#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).
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