CASM  1.1.0
A Clusters Approach to Statistical Mechanics
OrbitPrinter.hh
Go to the documentation of this file.
1 #ifndef CASM_cluterography_io_OrbitPrinter
2 #define CASM_cluterography_io_OrbitPrinter
3 
4 #include "casm/casm_io/Log.hh"
10 #include "casm/global/enum.hh"
12 
13 namespace CASM {
14 
15 class IntegralCluster;
16 class Structure;
17 
18 enum class ORBIT_PRINT_MODE { PROTO, FULL };
19 
23 
25  int indent_space = 6;
26  char delim = '\n';
27  int prec = 7;
28  COORD_TYPE coord_type = FRAC;
31  bool itemize_orbits = false;
32  int max_line_width = 100;
33  bool print_coordinates = true;
34  bool print_equivalence_map = false;
35  bool print_invariant_group = false;
36 };
37 
39 
41 void from_json(OrbitPrinterOptions &opt, const jsonParser &json);
42 
43 template <>
45  static OrbitPrinterOptions from_json(const jsonParser &json);
46 };
47 
48 struct PrinterBase {
50 
52 
53  void coord_type(Log &out);
54 
55  void increase_indent(Log &out) const {
57  }
58  void decrease_indent(Log &out) const {
60  }
61 
62  template <typename OrbitType>
63  void print_equivalence_map(const OrbitType &orbit, Index equiv_index,
64  Log &out) const;
65 
66  template <typename OrbitType>
67  void print_equivalence_map(const OrbitType &orbit, Index equiv_index,
68  jsonParser &json) const;
69 
70  template <typename OrbitType>
71  void print_equivalence_map(const OrbitType &orbit, Log &out) const;
72 
73  template <typename OrbitType, typename Element>
74  void print_invariant_group(const OrbitType &orbit, const Element &element,
75  Log &out) const;
76 
77  template <typename OrbitType, typename Element>
78  void print_invariant_group(const OrbitType &orbit, const Element &element,
79  jsonParser &json) const;
80 };
81 
82 template <typename _Element>
83 struct Printer : public PrinterBase {
84  typedef _Element Element;
85 
87  : PrinterBase(_opt) {}
88 
89  void print(const Element &element, Log &out) const {
90  xtal::COORD_MODE printer_mode(opt.coord_type);
91  out << element;
92  }
93 };
94 
95 template <>
98  static const std::string element_name;
99 
101  : PrinterBase(_opt) {}
102 
103  void print(const Element &element, Log &out) const;
104 };
105 
107 
108 template <typename _Element, ORBIT_PRINT_MODE>
109 struct OrbitPrinter {};
110 
112 template <typename _Element>
114  : public Printer<_Element> {
117 
119  : Printer<_Element>(_opt) {}
120 
121  template <typename OrbitType>
122  void operator()(const OrbitType &orbit, Log &out, Index orbit_index,
123  Index Norbits) const;
124 
125  template <typename OrbitType>
126  jsonParser &to_json(const OrbitType &orbit, jsonParser &json,
127  Index orbit_index, Index Norbits) const;
128 };
129 
130 template <typename _Element>
132 
134 
136 template <typename _Element>
138  : public Printer<_Element> {
141 
143  : Printer<_Element>(_opt) {}
144 
145  template <typename OrbitType>
146  void operator()(const OrbitType &orbit, Log &out, Index orbit_index,
147  Index Norbits) const;
148 
149  template <typename OrbitType>
150  jsonParser &to_json(const OrbitType &orbit, jsonParser &json,
151  Index orbit_index, Index Norbits) const;
152 };
153 
154 template <typename _Element>
156 
158 
160 template <typename ClusterOrbitIterator, typename OrbitPrinter>
161 void print_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, Log &out,
162  OrbitPrinter printer);
163 
165 template <typename ClusterOrbitIterator>
166 void print_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, Log &out,
168 
169 // ---------- clust.json IO
170 // ------------------------------------------------------------------
171 
173 template <typename ClusterOutputIterator, typename SymCompareType>
174 ClusterOutputIterator read_clust(ClusterOutputIterator result,
175  const jsonParser &json, const Structure &prim,
176  const SymGroup &generating_grp,
177  const SymCompareType &sym_compare);
178 
180 template <typename ClusterOutputIterator>
181 ClusterOutputIterator read_clust(ClusterOutputIterator result,
182  const jsonParser &json, const Structure &prim);
183 
185 template <typename ClusterOrbitIterator, typename Printer>
186 jsonParser &write_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end,
187  jsonParser &json, Printer printer);
188 
190 template <typename ClusterOrbitIterator>
191 jsonParser &write_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end,
192  jsonParser &json,
194 
196 template <typename ClusterOrbitIterator, typename Printer>
197 jsonParser &write_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end,
198  jsonParser &json, Printer printer,
199  const jsonParser &bspecs);
200 
201 } // namespace CASM
202 
203 #endif
#define ENUM_TRAITS(ENUM)
Definition: io_traits.hh:213
#define ENUM_JSON_IO_DECL(ENUM)
Definition: json_io.hh:10
#define ENUM_IO_DECL(ENUM)
Definition: stream_io.hh:8
Definition: Log.hh:48
void decrease_indent_spaces(int n)
Definition: Log.hh:287
void increase_indent_spaces(int n)
Definition: Log.hh:285
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
COORD_MODE specifies the current coordinate mode (Fractional or Cartesian)
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & write_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, jsonParser &json, Printer printer)
Write Orbit<SymCompareType> to JSON.
Printer< IntegralCluster > SitesPrinter
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void print_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, Log &out, OrbitPrinter printer)
Print IntegralCluster orbits.
COORD_TYPE
Definition: enum.hh:6
const COORD_TYPE FRAC
Definition: enum.hh:8
FullOrbitPrinter< IntegralCluster > FullSitesPrinter
void print_coordinates(OrbitPrinter &printer, const Element &element, Log &out)
ORBIT_PRINT_MODE
Definition: OrbitPrinter.hh:18
void from_json(ClexDescription &desc, const jsonParser &json)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
PrototypePrinter< IntegralCluster > ProtoSitesPrinter
ClusterOutputIterator read_clust(ClusterOutputIterator result, const jsonParser &json, const Structure &prim, const SymGroup &generating_grp, const SymCompareType &sym_compare)
Read JSON containing Orbit<SymCompareType> prototypes.
Print Orbit<SymCompareType>, including all equivalents.
OrbitPrinter(const OrbitPrinterOptions &_opt=OrbitPrinterOptions())
Print Orbit<SymCompareType>, including only prototypes.
OrbitPrinter(const OrbitPrinterOptions &_opt=OrbitPrinterOptions())
SymInfoOptions sym_info_opt
Definition: OrbitPrinter.hh:30
Printer(const OrbitPrinterOptions &_opt=OrbitPrinterOptions())
static const std::string element_name
Definition: OrbitPrinter.hh:98
void decrease_indent(Log &out) const
Definition: OrbitPrinter.hh:58
void coord_type(Log &out)
Definition: OrbitPrinter.cc:54
void print_invariant_group(const OrbitType &orbit, const Element &element, Log &out) const
OrbitPrinterOptions opt
Definition: OrbitPrinter.hh:49
PrinterBase(const OrbitPrinterOptions &_opt=OrbitPrinterOptions())
Definition: OrbitPrinter.cc:52
void increase_indent(Log &out) const
Definition: OrbitPrinter.hh:55
void print_equivalence_map(const OrbitType &orbit, Index equiv_index, Log &out) const
void print(const Element &element, Log &out) const
Definition: OrbitPrinter.hh:89
_Element Element
Definition: OrbitPrinter.hh:84
Printer(const OrbitPrinterOptions &_opt=OrbitPrinterOptions())
Definition: OrbitPrinter.hh:86
Options for printing SymInfo.
Helper struct for constructing objects that need additional data.
Definition: jsonParser.hh:548
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:551