CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
DirectoryStructure.hh
Go to the documentation of this file.
1 #ifndef CASM_DirectoryStructure
2 #define CASM_DirectoryStructure
3 
4 #include <string>
5 #include <vector>
6 
8 
9 
10 namespace CASM {
11 
18  template<typename DataObject>
19  struct QueryTraits;
20  class Log;
21 
24  inline fs::path find_casmroot(const fs::path &cwd) {
25  fs::path dir(cwd);
26  fs::path casmroot(".casm");
27 
28  while(!dir.empty()) {
29  // if cwd contains ".casm", return cwd
30  if(fs::is_directory(dir / casmroot))
31  return dir;
32  dir = dir.parent_path();
33  }
34  return dir;
35  };
36 
39  inline fs::path relative_casmroot(const fs::path &cwd) {
40  fs::path dir(cwd);
41  fs::path casmroot = find_casmroot(cwd);
42  fs::path relpath("");
43 
44  while(dir != casmroot) {
45  dir = dir.parent_path();
46  relpath /= "..";
47  }
48  return relpath;
49  };
50 
52  void recurs_rm_files(fs::path p, bool dry_run, Log &log);
53 
56 
57  public:
58 
60 
62  _init(fs::absolute(_root));
63  }
64 
65 
66  // ** Query filesystem **
67 
69  std::vector<std::string> all_bset() const {
70  return _all_settings("bset", m_root / m_bset_dir);
71  }
72 
74  std::vector<std::string> all_calctype() const {
75  return _all_settings("calctype", m_root / m_calc_dir / m_set_dir);
76  }
77 
79  std::vector<std::string> all_ref(std::string calctype) const {
80  return _all_settings("ref", calc_settings_dir(calctype));
81  }
82 
84  std::vector<std::string> all_property() const {
85  return _all_settings("clex", m_root / m_clex_dir);
86  }
87 
89  std::vector<std::string> all_eci(std::string property, std::string calctype, std::string ref, std::string bset) const {
90  return _all_settings("eci", m_root / m_clex_dir / _property(property) / _calctype(calctype) / _ref(ref) / _bset(bset));
91  }
92 
93 
94  // ** File and Directory paths **
95 
96 
97  // -- Project directory --------
98 
100  fs::path root_dir() const {
101  return m_root;
102  }
103 
105  fs::path prim() const {
106  return m_root / "prim.json";
107  }
108 
110  fs::path PRIM() const {
111  return m_root / "PRIM";
112  }
113 
114 
115  // -- Hidden .casm directory --------
116 
118  fs::path casm_dir() const {
119  return m_root / m_casm_dir;
120  }
121 
124  return m_root / m_casm_dir / "project_settings.json";
125  }
126 
128  fs::path scel_list(std::string scelname) const {
129  return m_root / m_casm_dir / "scel_list.json";
130  }
131 
134  return m_root / m_casm_dir / "config_list.json";
135  }
136 
139  return m_root / m_casm_dir / "enumerators";
140  }
141 
143  template<typename DataObject>
145  return m_root / m_casm_dir / "query" / QueryTraits<DataObject>::name;
146  }
147 
148  // -- Symmetry --------
149 
152  return m_root / m_sym_dir;
153  }
154 
157  return m_root / m_sym_dir / "lattice_point_group.json";
158  }
159 
162  return m_root / m_sym_dir / "factor_group.json";
163  }
164 
167  return m_root / m_sym_dir / "crystal_point_group.json";
168  }
169 
170 
171  // -- Basis sets --------
172 
174  fs::path bset_dir(std::string bset) const {
175  return m_root / m_bset_dir / _bset(bset);
176  }
177 
179  fs::path bspecs(std::string bset) const {
180  return bset_dir(bset) / "bspecs.json";
181  }
182 
183  // \brief Returns path to the clust.json file
184  fs::path clust(std::string bset) const {
185  return bset_dir(bset) / "clust.json";
186  }
187 
188  // \brief Returns path to the basis.json file
189  fs::path basis(std::string bset) const {
190  return bset_dir(bset) / "basis.json";
191  }
192 
194  fs::path clexulator_dir(std::string bset) const {
195  return bset_dir(bset);
196  }
197 
199  fs::path clexulator_src(std::string project, std::string bset) const {
200  return bset_dir(bset) / (project + "_Clexulator.cc");
201  }
202 
204  fs::path clexulator_o(std::string project, std::string bset) const {
205  return bset_dir(bset) / (project + "_Clexulator.o");
206  }
207 
209  fs::path clexulator_so(std::string project, std::string bset) const {
210  return bset_dir(bset) / (project + "_Clexulator.so");
211  }
212 
214  fs::path eci_in(std::string bset) const {
215  return bset_dir(bset) / "eci.in";
216  }
217 
219  fs::path corr_in(std::string bset) const {
220  return bset_dir(bset) / "corr.in";
221  }
222 
223 
224  // -- Calculations and reference --------
225 
228  return m_root / m_calc_dir;
229  }
230 
232  fs::path SCEL() const {
233  return m_root / m_calc_dir / "SCEL";
234  }
235 
237  fs::path supercell_dir(std::string scelname) const {
238  return m_root / m_calc_dir / scelname;
239  }
240 
242  fs::path configuration_dir(std::string configname) const {
243  return m_root / m_calc_dir / configname;
244  }
245 
247  fs::path POS(std::string configname) const {
248  return configuration_dir(configname) / "POS";
249  }
250 
252  fs::path calc_settings_dir(std::string calctype) const {
253  return m_root / m_calc_dir / m_set_dir / _calctype(calctype);
254  }
255 
257  fs::path supercell_calc_settings_dir(std::string scelname, std::string calctype) const {
258  return supercell_dir(scelname) / m_set_dir / _calctype(calctype);
259  }
260 
263  return configuration_dir(configname) / m_set_dir / _calctype(calctype);
264  }
265 
267  fs::path configuration_calc_dir(std::string configname, std::string calctype) const {
268  return configuration_dir(configname) / _calctype(calctype);
269  }
270 
272  fs::path calculated_properties(std::string configname, std::string calctype) const {
273  return configuration_dir(configname) / _calctype(calctype) / "properties.calc.json";
274  }
275 
277  fs::path calc_status(std::string configname, std::string calctype) const {
278  return configuration_dir(configname) / _calctype(calctype) / "status.json";
279  }
280 
281 
283  fs::path ref_dir(std::string calctype, std::string ref) const {
284  return calc_settings_dir(calctype) / _ref(ref);
285  }
286 
289  return casm_dir() / "composition_axes.json";
290  }
291 
293  fs::path chemical_reference(std::string calctype, std::string ref) const {
294  return ref_dir(calctype, ref) / "chemical_reference.json";
295  }
296 
297 
298  // -- Cluster expansions --------
299 
301  fs::path clex_dir(std::string property) const {
302  return m_root / m_clex_dir / _property(property);
303  }
304 
306  fs::path eci_dir(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const {
307  return clex_dir(property) / _calctype(calctype) / _ref(ref) / _bset(bset) / _eci(eci);
308  }
309 
311  fs::path eci(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const {
312  return eci_dir(property, calctype, ref, bset, eci) / "eci.json";
313  }
314 
315 
316  // -- other maybe temporary --------------------------
317 
319  fs::path CSPECS(std::string bset) const {
320  return bset_dir(bset) / "CSPECS";
321  }
322 
323  // \brief Returns path to the clust.json file
324  fs::path FCLUST(std::string bset) const {
325  return bset_dir(bset) / "FCLUST.json";
326  }
327 
328  // -- deprecated ------------------------------------
329 
331  fs::path eci_out(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const {
332  return eci_dir(property, calctype, ref, bset, eci) / "eci.out";
333  }
334 
337  return m_root / m_casm_dir / "query_alias.json";
338  }
339 
340 
341  private:
342 
343  std::string _bset(std::string bset) const {
344  return std::string("bset.") + bset;
345  }
346 
347  std::string _calctype(std::string calctype) const {
348  return std::string("calctype.") + calctype;
349  }
350 
351  std::string _ref(std::string ref) const {
352  return std::string("ref.") + ref;
353  }
354 
355  std::string _property(std::string property) const {
356  return std::string("clex.") + property;
357  }
358 
359  std::string _eci(std::string eci) const {
360  return std::string("eci.") + eci;
361  }
362 
363  std::string _ref_state(int index) const {
364  return std::string("properties.ref_state.") + std::to_string(index) + ".json";
365  }
366 
367 
368  void _init(const fs::path &_root) {
369  m_root = _root;
370  m_casm_dir = ".casm";
371  m_bset_dir = "basis_sets";
372  m_calc_dir = "training_data";
373  m_set_dir = "settings";
374  m_sym_dir = "symmetry";
375  m_clex_dir = "cluster_expansions";
376  }
377 
380  std::vector<std::string> _all_settings(std::string pattern, fs::path location) const {
381 
382  std::vector<std::string> all;
383  std::string dir;
384  pattern += ".";
385 
386  // get all
387  if(!fs::exists(location)) {
388  return all;
389  }
390  fs::directory_iterator it(location);
391  fs::directory_iterator end_it;
392  for(; it != end_it; ++it) {
393  if(fs::is_directory(*it)) {
394  dir = it->path().filename().string();
395  if(dir.substr(0, pattern.size()) == pattern) {
396  all.push_back(dir.substr(pattern.size(), dir.size()));
397  }
398  }
399  }
400 
401  std::sort(all.begin(), all.end());
402 
403  return all;
404  }
405 
407  std::string m_casm_dir;
408  std::string m_bset_dir;
409  std::string m_calc_dir;
410  std::string m_set_dir;
411  std::string m_sym_dir;
412  std::string m_clex_dir;
413 
414  };
415 
417 }
418 
419 #endif
fs::path eci(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci.json.
fs::path CSPECS(std::string bset) const
Return cluster specs (CSPECS) file path.
std::string _property(std::string property) const
fs::path composition_axes() const
Return composition axes file path.
fs::path SCEL() const
Return SCEL path.
Specification of CASM project directory structure.
fs::path calculated_properties(std::string configname, std::string calctype) const
Return calculated properties file path.
fs::path query_alias() const
Query aliases file.
fs::path calc_settings_dir(std::string calctype) const
Return calculation settings directory path, for global settings.
fs::path supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Return calculation settings directory path, for supercell specific settings.
fs::path configuration_calc_settings_dir(std::string configname, std::string calctype) const
Return calculation settings directory path, for configuration specific settings.
std::vector< std::string > _all_settings(std::string pattern, fs::path location) const
Find all directories at 'location' that match 'pattern.something' and return a std::vector of the 'so...
std::string _bset(std::string bset) const
fs::path configuration_calc_dir(std::string configname, std::string calctype) const
Return calculated properties file path.
Main CASM namespace.
Definition: complete.cpp:8
std::string to_string(ENUM val)
Return string representation of enum class.
Definition: EnumIO.hh:83
Log & log
Definition: settings.cc:105
fs::path prim() const
Return prim.json path.
fs::path relative_casmroot(const fs::path &cwd)
std::vector< std::string > all_eci(std::string property, std::string calctype, std::string ref, std::string bset) const
Check filesystem directory structure and return list of all eci names.
std::string _calctype(std::string calctype) const
std::vector< std::string > all_property() const
Check filesystem directory structure and return list of all property names.
fs::path ref_dir(std::string calctype, std::string ref) const
Return calculation reference settings directory path, for global settings.
fs::path find_casmroot(const fs::path &cwd)
fs::path enumerator_plugins() const
Return enumerators plugin dir.
pair_type ref
Definition: settings.cc:110
fs::path bspecs(std::string bset) const
Return basis function specs (bspecs.json) file path.
std::string _ref_state(int index) const
fs::path crystal_point_group() const
Return crystal_point_group.json path.
fs::path clex_dir(std::string property) const
Returns path to eci directory.
fs::path project_settings() const
Return project_settings.json path.
fs::path configuration_dir(std::string configname) const
Return configuration directory path (configname has format SCELV_A_B_C_D_E_F/I)
fs::path clexulator_so(std::string project, std::string bset) const
Returns path to global clexulator so file.
fs::path clust(std::string bset) const
pair_type property
Definition: settings.cc:108
fs::path eci_out(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci.out.
fs::path clexulator_src(std::string project, std::string bset) const
Returns path to global clexulator source file.
pair_type calctype
Definition: settings.cc:109
fs::path basis(std::string bset) const
fs::path root_dir() const
Return casm project directory path.
fs::path PRIM() const
Return PRIM path.
void recurs_rm_files(fs::path p, bool dry_run, Log &log)
Remove files recursively.
fs::path FCLUST(std::string bset) const
std::string _ref(std::string ref) const
fs::path supercell_dir(std::string scelname) const
Return supercell directory path (scelname has format SCELV_A_B_C_D_E_F)
fs::path casm_dir() const
Return hidden .casm dir path.
std::string _eci(std::string eci) const
fs::path calc_status(std::string configname, std::string calctype) const
Return calculation status file path.
fs::path lattice_point_group() const
Return lattice_point_group.json path.
fs::path scel_list(std::string scelname) const
Return master scel_list.json path.
fs::path corr_in(std::string bset) const
Returns path to corr.in, in bset directory.
fs::path POS(std::string configname) const
Return path to POS file.
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:340
DirectoryStructure & dir
Definition: settings.cc:102
fs::path config_list() const
Return master config_list.json file path.
fs::path bset_dir(std::string bset) const
Return path to directory contain basis set info.
fs::path eci_in(std::string bset) const
Returns path to eci.in, in bset directory.
fs::path clexulator_o(std::string project, std::string bset) const
Returns path to global clexulator o file.
fs::path symmetry_dir() const
Return symmetry directory path.
fs::path query_plugins() const
Return enumerators plugin dir.
std::vector< std::string > all_calctype() const
Check filesystem directory structure and return list of all calctype names.
fs::path eci_dir(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci directory.
fs::path clexulator_dir(std::string bset) const
Returns path to directory containing global clexulator.
Definition: Log.hh:9
pair_type bset
Definition: settings.cc:111
ConfigIO::GenericConfigFormatter< std::string > scelname()
Definition: ConfigIO.cc:348
fs::path factor_group() const
Return factor_group.json path.
std::vector< std::string > all_bset() const
Check filesystem directory structure and return list of all basis set names.
fs::path chemical_reference(std::string calctype, std::string ref) const
Return chemical reference file path.
DirectoryStructure(const fs::path _root)
std::vector< std::string > all_ref(std::string calctype) const
Check filesystem directory structure and return list of all ref names for a given calctype...
fs::path training_data() const
Return 'training_data' directorty path.
void _init(const fs::path &_root)