CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SupercellIO.hh
Go to the documentation of this file.
1 #ifndef CASM_SupercellIO
2 #define CASM_SupercellIO
3 
6 
7 namespace CASM {
8 class Supercell;
9 class SymOp;
10 
11 namespace ScelIO {
12 
13 // --- BaseDatumFormatter-derived classes ---
14 
15 template <typename Base>
16 class SupercellCheckBase : public Base {
17  public:
18  typedef std::tuple<bool, SymOp, Eigen::MatrixXi> result_type;
19 
20  SupercellCheckBase(std::string name, std::string desc);
21 
22  // --- Specialized implementation -----------
23 
25  bool parse_args(const std::string &args) override;
26 
28  bool init(const Supercell &_tmplt) const override;
29 
31  std::vector<std::string> col_header(const Supercell &_tmplt) const override;
32 
33  // --- Shared logic -----------
34 
41  const result_type &_evaluate(const Supercell &scel,
42  const Supercell &unit) const;
43 
44  protected:
46  std::string m_refcell_name;
47 
48  Supercell const &refcell() const;
49 
50  private:
52  mutable const Supercell *m_refcell;
53 
55  mutable const Supercell *m_last_scel;
56  mutable const Supercell *m_last_unit;
57 };
58 
59 class IsSupercellOf : public SupercellCheckBase<BooleanAttribute<Supercell> > {
60  public:
61  static const std::string Name;
62  static const std::string Desc;
63 
64  IsSupercellOf();
65 
66  bool evaluate(const Supercell &scel) const override;
67 
69  std::unique_ptr<IsSupercellOf> clone() const;
70 
71  private:
73  IsSupercellOf *_clone() const override;
74 };
75 
76 class IsUnitcellOf : public SupercellCheckBase<BooleanAttribute<Supercell> > {
77  public:
78  static const std::string Name;
79  static const std::string Desc;
80 
81  IsUnitcellOf();
82 
83  bool evaluate(const Supercell &unit) const override;
84 
86  std::unique_ptr<IsUnitcellOf> clone() const;
87 
88  private:
90  IsUnitcellOf *_clone() const override;
91 };
92 
93 class TransfMat : public SupercellCheckBase<VectorXiAttribute<Supercell> > {
94  public:
95  static const std::string Name;
96  static const std::string Desc;
97 
98  TransfMat();
99 
100  Eigen::VectorXi evaluate(const Supercell &scel) const override;
101 
102  bool validate(const Supercell &scel) const override;
103 
105  std::unique_ptr<TransfMat> clone() const;
106 
108  bool parse_args(const std::string &args) override;
109 
110  private:
112  TransfMat *_clone() const override;
113 };
114 
115 class ConfigCountBase : public IntegerAttribute<Supercell> {
116  public:
117  ConfigCountBase(std::string name, std::string desc);
118 
119  // --- Specialized implementation -----------
120 
122  bool parse_args(const std::string &args) override;
123 
125  std::vector<std::string> col_header(const Supercell &_tmplt) const override;
126 
127  protected:
129  std::string m_type;
130 };
131 
132 class Nconfig : public ConfigCountBase {
133  public:
134  static const std::string Name;
135  static const std::string Desc;
136 
137  Nconfig();
138 
139  Index evaluate(const Supercell &scel) const override;
140 
142  std::unique_ptr<Nconfig> clone() const;
143 
144  private:
146  Nconfig *_clone() const override;
147 };
148 
149 class Ncalc : public ConfigCountBase {
150  public:
151  static const std::string Name;
152  static const std::string Desc;
153 
154  Ncalc();
155 
156  Index evaluate(const Supercell &scel) const override;
157 
159  std::unique_ptr<Ncalc> clone() const;
160 
161  private:
163  Ncalc *_clone() const override;
164 };
165 
166 class Ndata : public ConfigCountBase {
167  public:
168  static const std::string Name;
169  static const std::string Desc;
170 
171  Ndata();
172 
173  Index evaluate(const Supercell &scel) const override;
174 
176  std::unique_ptr<Ndata> clone() const;
177 
178  private:
180  Ndata *_clone() const override;
181 };
182 
183 // --- GenericDatumFormatter generating functions ---
184 
185 template <typename ValueType>
187 
190 
198 
199 } // namespace ScelIO
200 
201 template <>
203 
204 template <>
206 
207 template <>
209 
210 template <>
212 
213 template <>
215 
216 template <>
218 
219 } // namespace CASM
220 
221 #endif
const std::string & name() const
Returns a name for the formatter, which becomes the tag used for parsing.
Base class for creating scalar DatumFormatter.
Parsing dictionary for constructing a DataFormatter<DataObject> object.
A DatumFormatter that returns a 1D value of specified type, via functions that may be specified at ru...
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
std::vector< std::string > col_header(const Supercell &_tmplt) const override
col_header returns: {'short_name(refcell_name)'}
Definition: SupercellIO.cc:144
std::string m_type
Reference supercell name, given meaning by derived class.
Definition: SupercellIO.hh:129
bool parse_args(const std::string &args) override
Expects arguments of the form 'is_supercell_of(scelname)'.
Definition: SupercellIO.cc:128
ConfigCountBase(std::string name, std::string desc)
Definition: SupercellIO.cc:124
bool evaluate(const Supercell &scel) const override
Definition: SupercellIO.cc:34
std::unique_ptr< IsSupercellOf > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:39
static const std::string Desc
Definition: SupercellIO.hh:62
IsSupercellOf * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:44
static const std::string Name
Definition: SupercellIO.hh:61
static const std::string Name
Definition: SupercellIO.hh:78
static const std::string Desc
Definition: SupercellIO.hh:79
std::unique_ptr< IsUnitcellOf > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:63
bool evaluate(const Supercell &unit) const override
Definition: SupercellIO.cc:58
IsUnitcellOf * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:68
static const std::string Desc
Definition: SupercellIO.hh:152
Ncalc * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:197
std::unique_ptr< Ncalc > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:192
static const std::string Name
Definition: SupercellIO.hh:151
Index evaluate(const Supercell &scel) const override
Definition: SupercellIO.cc:183
Index evaluate(const Supercell &scel) const override
Definition: SupercellIO.cc:158
static const std::string Desc
Definition: SupercellIO.hh:135
static const std::string Name
Definition: SupercellIO.hh:134
Nconfig * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:172
std::unique_ptr< Nconfig > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:167
std::unique_ptr< Ndata > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:218
Index evaluate(const Supercell &scel) const override
Definition: SupercellIO.cc:209
static const std::string Name
Definition: SupercellIO.hh:168
static const std::string Desc
Definition: SupercellIO.hh:169
Ndata * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:223
bool init(const Supercell &_tmplt) const override
Set pointer to ref supercell.
SupercellCheckBase(std::string name, std::string desc)
bool parse_args(const std::string &args) override
Expects arguments of the form 'is_supercell_of(scelname)'.
std::tuple< bool, SymOp, Eigen::MatrixXi > result_type
Definition: SupercellIO.hh:18
const result_type & _evaluate(const Supercell &scel, const Supercell &unit) const
const Supercell * m_refcell
Reference supercell, given meaning by derived class.
Definition: SupercellIO.hh:52
Supercell const & refcell() const
std::string m_refcell_name
Reference supercell name, given meaning by derived class.
Definition: SupercellIO.hh:46
std::vector< std::string > col_header(const Supercell &_tmplt) const override
col_header returns: {'short_name(refcell_name)'}
notstd::cloneable_ptr< result_type > m_last_result
Definition: SupercellIO.hh:54
std::unique_ptr< TransfMat > clone() const
Clone using copy constructor.
Definition: SupercellIO.cc:97
Eigen::VectorXi evaluate(const Supercell &scel) const override
Definition: SupercellIO.cc:84
static const std::string Name
Definition: SupercellIO.hh:95
bool validate(const Supercell &scel) const override
Definition: SupercellIO.cc:91
bool parse_args(const std::string &args) override
Expects arguments of the form 'transf_mat(unitcell_name)'.
Definition: SupercellIO.cc:102
TransfMat * _clone() const override
Clone using copy constructor.
Definition: SupercellIO.cc:120
static const std::string Desc
Definition: SupercellIO.hh:96
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
Generic1DDatumFormatter< Eigen::VectorXd, Supercell > GenericVectorXdScelFormatter
Definition: SupercellIO.hh:189
GenericVectorXdScelFormatter lattice_params()
Definition: SupercellIO.cc:276
GenericVectorXdScelFormatter lattice()
Definition: SupercellIO.cc:266
GenericScelFormatter< Index > multiplicity()
Definition: SupercellIO.cc:242
GenericScelFormatter< std::string > pointgroup_name()
Definition: SupercellIO.cc:227
GenericScelFormatter< Index > scel_size()
Definition: SupercellIO.cc:235
GenericScelFormatter< double > volume()
Definition: SupercellIO.cc:258
GenericScelFormatter< Index > factorgroup_size()
Definition: SupercellIO.cc:250
Main CASM namespace.
Definition: APICommand.hh:8
IntegerAttributeDictionary< Supercell > make_integer_dictionary< Supercell >()
Definition: SupercellIO.cc:312
BooleanAttributeDictionary< Supercell > make_boolean_dictionary< Supercell >()
Definition: SupercellIO.cc:302
VectorXiAttributeDictionary< Supercell > make_vectorxi_dictionary< Supercell >()
Definition: SupercellIO.cc:333
GenericDatumFormatter< std::string, DataObject > name()
VectorXdAttributeDictionary< Supercell > make_vectorxd_dictionary< Supercell >()
Definition: SupercellIO.cc:343
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
StringAttributeDictionary< Supercell > make_string_dictionary< Supercell >()
Definition: SupercellIO.cc:291
ScalarAttributeDictionary< Supercell > make_scalar_dictionary< Supercell >()
Definition: SupercellIO.cc:323
ClexDescription & desc
Definition: settings.cc:138