CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigData.hh
Go to the documentation of this file.
1 #ifndef CASM_DB_ConfigData
2 #define CASM_DB_ConfigData
3 
4 #include "casm/casm_io/Log.hh"
9 
10 // To be specialized for calculable 'ConfigType' classes:
11 // Import<ConfigType>::desc
12 // Import<ConfigType>::run
13 // Import<ConfigType>::_import_formatter
14 // Update<ConfigType>::desc
15 // Update<ConfigType>::run
16 // Update<ConfigType>::_update_formatter
17 // Remove<ConfigType>::desc
18 // Remove<ConfigType>::run
19 
20 namespace CASM {
21 
22 class PrimClex;
23 class Supercell;
24 
25 namespace DB {
26 
27 template <typename T>
28 class Selection;
29 template <typename ValueType>
30 class Database;
31 template <typename ValueType>
32 class DatabaseIterator;
33 class PropertiesDatabase;
34 
36 std::string create_report_dir(std::string report_dir);
37 
38 namespace ConfigIO {
39 
41 struct ImportData {
43  : preexisting(false),
44  copy_data(false),
45  copy_more(false),
46  is_best(false) {}
47 
48  // base responsibility:
50  bool copy_data;
51  bool copy_more;
52  bool is_best;
53 };
54 
56 struct Result {
57  Result() : has_data(false), has_complete_data(false), is_new_config(false) {}
58 
59  // Set 'to'/'from' as empty strings if no mapping possible
61 
62  // Path to properties.calc.json or POS file that was imported
63  std::string pos_path;
64 
65  // If a properties.calc.json file is found in standard locations
66  bool has_data;
67 
68  // If all PrimClex required properties exist
70 
71  // If 'to' Configuration did not exist in the database prior to mapping
73 
74  // If mapping failed, stores any error message that may be generated
75  std::string fail_msg;
76 
78 };
79 
81 
83 
85 
87 
89 
91 
93 
95 
97 
99 
101 
103 
105 
107 
109 
111 
113 
115 
118  PropertiesDatabase &db_props);
119 
122  PropertiesDatabase &db_props);
123 
124 } // namespace ConfigIO
125 
126 template <typename T>
127 struct TypeTag {
128  using type = T;
129 };
130 
131 class ConfigData {
132  public:
144 
145  // Otherwise return pos_path
146  static std::string resolve_struc_path(std::string pos_path,
147  PrimClex const &_pclex);
148 
149  template <typename ConfigType>
150  ConfigData(const PrimClex &_primclex, TypeTag<ConfigType>);
151 
152  const PrimClex &primclex() const { return m_primclex; }
153 
155 
156  template <typename ConfigType>
158 
160  PropertiesDatabase &db_props() const;
161 
163  std::string calc_dir(const std::string configname) const;
164 
168  bool has_existing_files(const std::string &to_configname) const;
169 
173  bool has_existing_data(const std::string &to_configname) const;
174 
175  bool has_existing_data_or_files(const std::string &to_configname) const;
176 
178  bool no_change(const std::string &configname) const;
179 
183  void rm_files(const std::string &configname, bool dry_run) const;
184 
187  void cp_files(ConfigIO::Result &res, bool dry_run,
188  bool copy_additional_files) const;
189 
190  private:
193 };
194 
195 // To be specialized for ConfigType (no default implemenation exists)
196 template <typename ConfigType>
198 
199 /*
200  template<typename ConfigType>
201  class StructureMap {
202 
203 public:
204 
205  typedef std::back_insert_iterator<std::vector<ConfigIO::Result> >
206 map_result_inserter;
207 
211 exist or be valid.
213 unknown as with 'casm import'.
217 specied path
221  map_result_inserter map(
222  std::string p,
223  DatabaseIterator<ConfigType> hint,
224  map_result_inserter result) const;
225 };
226 */
227 } // namespace DB
228 } // namespace CASM
229 
230 #endif
bool no_change(const std::string &configname) const
Check if 'properties.calc.json' file has not changed since last read.
Definition: ConfigData.cc:269
Database< ConfigType > & db_config() const
bool has_existing_data_or_files(const std::string &to_configname) const
Definition: ConfigData.cc:261
Database< Supercell > & db_supercell() const
Path to default calctype training_data directory for config.
Definition: ConfigData.cc:230
bool has_existing_files(const std::string &to_configname) const
Return true if there are existing files in the traning_data directory for a particular configuration.
Definition: ConfigData.cc:247
ConfigData(const PrimClex &_primclex, TypeTag< ConfigType >)
std::function< PropertiesDatabase &()> m_db_props_func
Definition: ConfigData.hh:192
PropertiesDatabase & db_props() const
Uses primclex().settings().default_clex().calctype.
Definition: ConfigData.cc:234
std::string calc_dir(const std::string configname) const
Path to default calctype training_data directory for config.
Definition: ConfigData.cc:237
const PrimClex & primclex() const
Definition: ConfigData.hh:152
static std::string resolve_struc_path(std::string pos_path, PrimClex const &_pclex)
Checks if pos_path can be used to resolve a properties.calc.json, and return its path Return path to ...
Definition: ConfigData.cc:222
bool has_existing_data(const std::string &to_configname) const
Return true if there are existing files in the traning_data directory for a particular configuration.
Definition: ConfigData.cc:257
void rm_files(const std::string &configname, bool dry_run) const
Remove existing files in the traning_data directory for a particular configuration.
Definition: ConfigData.cc:282
void cp_files(ConfigIO::Result &res, bool dry_run, bool copy_additional_files) const
Copy files in the same directory as properties.calc.json into the traning_data directory for a partic...
Definition: ConfigData.cc:307
const PrimClex & m_primclex
Definition: ConfigData.hh:191
Parsing dictionary for constructing a DataFormatter<DataObject> object.
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:563
GenericDatumFormatter< std::string, Result > data_origin()
Definition: ConfigData.cc:86
GenericDatumFormatter< double, Result > lattice_deformation_cost()
Definition: ConfigData.cc:126
GenericDatumFormatter< bool, Result > import_additional_files()
Definition: ConfigData.cc:120
GenericDatumFormatter< std::string, Result > final_path()
Definition: ConfigData.cc:75
GenericDatumFormatter< double, Result > score()
GenericDatumFormatter< double, Result > best_score()
GenericDatumFormatter< bool, Result > has_data()
Definition: ConfigData.cc:97
GenericDatumFormatter< bool, Result > import_data()
Definition: ConfigData.cc:113
GenericDatumFormatter< double, Result > energy()
Definition: ConfigData.cc:148
GenericDatumFormatter< bool, Result > preexisting_data()
Definition: ConfigData.cc:107
GenericDatumFormatter< bool, Result > has_complete_data()
Definition: ConfigData.cc:102
GenericDatumFormatter< bool, Result > selected()
Gives a 'selected' column, set all to false.
Definition: ConfigData.cc:189
GenericDatumFormatter< bool, Result > is_new_config()
Gives a 'selected' column, set all to false.
Definition: ConfigData.cc:195
GenericDatumFormatter< std::string, Result > to_configname()
Definition: ConfigData.cc:92
GenericDatumFormatter< double, Result > atomic_deformation_cost()
Definition: ConfigData.cc:137
void default_import_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm import'.
Definition: ConfigData.cc:201
GenericDatumFormatter< std::string, Result > initial_path()
Definition: ConfigData.cc:70
GenericDatumFormatter< std::string, Result > fail_msg()
Definition: ConfigData.cc:81
GenericDatumFormatter< bool, Result > is_best()
void default_update_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm update'.
Definition: ConfigData.cc:209
std::string create_report_dir(std::string report_dir)
Create a new report directory to avoid overwriting existing results.
Definition: ConfigData.cc:58
Main CASM namespace.
Definition: APICommand.hh:8
std::string pos_path(const ConfigType &config, std::string calctype="")
Data structure for data import results.
Definition: ConfigData.hh:41
Data structure for mapping / import results.
Definition: ConfigData.hh:56
MappedProperties properties
Definition: ConfigData.hh:60