3 #include <boost/algorithm/string/classification.hpp>
4 #include <boost/algorithm/string/split.hpp>
5 #include <boost/filesystem.hpp>
16 fs::path casmroot(
".casm");
18 while (!
dir.empty()) {
20 if (fs::is_directory(
dir / casmroot))
return dir;
34 while (
dir != casmroot) {
47 auto it = fs::directory_iterator(p);
48 auto end = fs::directory_iterator();
50 for (; it != end; ++it) {
51 if (fs::is_regular_file(*it)) {
52 log <<
"rm " << *it << std::endl;
58 log <<
"rm " << *it << std::endl;
62 log <<
"rm " << p << std::endl;
70 Index recurs_cp_files_impl(
const fs::path &from_dir,
const fs::path &to_dir,
72 auto it = fs::directory_iterator(from_dir);
73 auto end = fs::directory_iterator();
74 for (; it != end; ++it) {
75 if (fs::is_regular_file(*it)) {
76 log <<
"cp " << *it <<
" " << to_dir << std::endl;
79 fs::copy_file(*it, to_dir / it->path().filename());
82 fs::path new_to_dir = to_dir / it->path().filename();
84 fs::create_directories(new_to_dir);
86 count = recurs_cp_files_impl(*it, new_to_dir, dry_run,
count,
log);
97 recurs_cp_files_impl(from_dir, to_dir, dry_run,
count,
log);
102 _init(fs::absolute(_root));
136 std::string
bset)
const {
178 template <
typename DataObject>
193 template <
typename DataObject>
195 return query_plugins<DataObject>() /
"master_selection";
199 template <
typename DataObject>
201 return query_plugins<DataObject>() /
"aliases.json";
240 std::string
bset)
const {
267 std::string
bset)
const {
268 return bset_dir(
bset) / (project_name +
"_Clexulator.cc");
273 std::string
bset)
const {
274 return bset_dir(
bset) / (project_name +
"_Clexulator.o");
279 std::string
bset)
const {
280 return bset_dir(
bset) / (project_name +
"_Clexulator.so");
383 std::string
ref)
const {
389 return casm_dir() /
"composition_axes.json";
394 std::string
ref)
const {
407 std::string
ref, std::string
bset,
408 std::string
eci)
const {
415 std::string
ref, std::string
bset,
416 std::string
eci)
const {
446 return fs::create_directory(
casm_dir());
471 return fs::create_directories(
477 return fs::create_directories(
482 std::string
ref)
const {
487 std::string
ref, std::string
bset,
488 std::string
eci)
const {
493 std::string
bset)
const {
502 std::string
bset)
const {
509 std::string project_name)
const {
517 return std::string(
"bset.") +
bset;
521 return std::string(
"calctype.") +
calctype;
525 return std::string(
"ref.") +
ref;
529 return std::string(
"clex.") +
property;
533 return std::string(
"eci.") +
eci;
537 return std::string(
"properties.ref_state.") +
std::to_string(index) +
".json";
554 std::string pattern, fs::path location)
const {
555 std::vector<std::string> all;
560 if (!fs::exists(location)) {
563 fs::directory_iterator it(location);
564 fs::directory_iterator end_it;
565 for (; it != end_it; ++it) {
566 if (fs::is_directory(*it)) {
567 dir = it->path().filename().string();
568 if (
dir.substr(0, pattern.size()) == pattern) {
569 all.push_back(
dir.substr(pattern.size(),
dir.size()));
574 std::sort(all.begin(), all.end());
581 throw std::runtime_error(
"Error accessing project: No root directory set.");
588 auto basis_set_specs_path =
dir.
bspecs(basis_set_name);
589 if (!fs::exists(basis_set_specs_path)) {
590 std::stringstream ss;
591 ss <<
"Error accessing bset." << basis_set_name
592 <<
": Does not exist. "
593 "Checked for bspecs at: "
594 << basis_set_specs_path.string();
595 throw std::runtime_error(ss.str());
600 std::string basis_set_name,
603 fs::path clexulator_src_path =
605 if (!fs::exists(clexulator_src_path)) {
606 std::stringstream ss;
607 ss <<
"Error accessing bset." << basis_set_name <<
": "
608 << clexulator_src_path
609 <<
" does not exist. The basis set should be regenerated.";
610 throw std::runtime_error(ss.str());
619 #define INST_DirectoryStructure_all(r, data, type) \
620 template fs::path DirectoryStructure::query_plugins<type>() const; \
621 template fs::path DirectoryStructure::master_selection<type>() const; \
622 template fs::path DirectoryStructure::aliases<type>() const;
#define INST_DirectoryStructure_all(r, data, type)
Specification of CASM project directory structure.
fs::path prim() const
Return prim.json path.
fs::path root_dir() const
Return casm project directory path.
std::string _property(std::string property) const
fs::path casm_dir() const
Return hidden .casm dir path.
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.
fs::path configuration_calc_settings_dir(std::string configname, std::string calctype) const
Return calculation settings directory path, for configuration specific settings.
fs::path SCEL() const
Return SCEL path.
fs::path calculated_properties(std::string configname, std::string calctype) const
Return properties.calc.json file path.
fs::path eci_in(std::string bset) const
Returns path to eci.in, in bset directory.
fs::path ref_dir(std::string calctype, std::string ref) const
Return calculation reference settings directory path, for global settings.
void delete_bset_data(std::string project_name, std::string bset) const
Delete Basis set generated files.
bool new_supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Add calculation settings directory path, for supercell specific settings.
fs::path crystal_point_group() const
Return crystal_point_group.json path.
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.
void _init(const fs::path &_root)
fs::path symmetry_dir() const
Return symmetry directory path.
fs::path symrep_builder_plugins() const
Return SymrepBuilder plugin dir.
std::string m_reports_dir
bool new_calc_settings_dir(std::string calctype) const
Add calculation settings directory path.
fs::path config_list() const
Return master config_list.json file path.
fs::path LAT(std::string scelname) const
Return supercell LAT file path.
fs::path project_settings() const
Return project_settings.json path.
fs::path configuration_calc_dir(std::string configname, std::string calctype) const
Return directory containing properties.calc.json.
fs::path clust(std::string bset) const
fs::path structure_json(std::string configname) const
Return path to standard structure.json file location.
std::string _ref_state(int index) const
bool new_bset_dir(std::string bset) const
Add a basis set directory.
fs::path enumerator_plugins() const
Return enumerators plugin dir.
fs::path reports_dir() const
Returns path to reports directory.
fs::path config_json(std::string configname) const
Return path to standard config.json file location.
fs::path training_data() const
Return 'training_data' directorty path.
bool new_configuration_calc_settings_dir(std::string configname, std::string calctype) const
fs::path configuration_dir(std::string configname) const
Return configuration directory path.
fs::path supercell_dir(std::string scelname) const
Return supercell directory path.
fs::path FCLUST(std::string bset) const
std::string _bset(std::string bset) const
fs::path query_alias() const
Query aliases file (deprecated: now stored in project_settings.json)
std::string _calctype(std::string calctype) const
bool new_clex_dir(std::string property) const
Add a cluster expansion directory.
fs::path clexulator_o(std::string project_name, std::string bset) const
Returns path to clexulator o file.
fs::path chemical_reference(std::string calctype, std::string ref) const
Return chemical reference file path.
fs::path corr_in(std::string bset) const
Returns path to corr.in, in bset directory.
void delete_clexulator(std::string project_name, std::string bset) const
Delete Clexulator files.
std::vector< std::string > all_calctype() const
Check filesystem directory structure and return list of all calctype names.
fs::path query_plugins() const
Return enumerators plugin dir.
void delete_all_clexulators(std::string project_name) const
Delete files for all Clexulators.
bool new_casm_dir() const
Create new project data directory.
fs::path CSPECS(std::string bset) const
Return cluster specs (CSPECS) file path.
std::vector< std::string > all_bset() const
Check filesystem directory structure and return list of all basis set names.
fs::path basis(std::string bset) const
std::string _eci(std::string eci) const
fs::path clex_dir(std::string property) const
Returns path to eci directory.
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 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 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 bset_dir(std::string bset) const
Return path to directory contain basis set info.
std::vector< fs::path > bset_data(std::string project_name, std::string bset) const
Return paths where bset generated data is stored (excludes bspecs.json)
fs::path master_selection() const
fs::path scel_list() const
Return master scel_list.json path.
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...
bool new_reports_dir() const
Create new reports directory.
fs::path clexulator_src(std::string project_name, std::string bset) const
Returns path to clexulator source file.
fs::path aliases() const
File containing DataObject name aliases (not query function aliases)
fs::path composition_axes() const
Return composition axes file path.
fs::path POS(std::string configname) const
Return path to standard POS file location.
bool new_ref_dir(std::string calctype, std::string ref) const
Add a ref directory.
bool new_symmetry_dir() const
Create new symmetry directory.
std::string _ref(std::string ref) const
fs::path dof_plugins() const
Return DoF plugin dir.
fs::path factor_group() const
Return factor_group.json path.
bool new_eci_dir(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Add an eci directory.
fs::path bspecs(std::string bset) const
Return basis function specs (bspecs.json) file path.
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.
std::vector< std::string > all_property() const
Check filesystem directory structure and return list of all property names.
fs::path clexulator_dir(std::string bset) const
Returns path to directory containing clexulator files.
fs::path clexulator_so(std::string project_name, std::string bset) const
Returns path to clexulator so file.
std::string to_string(ENUM val)
Return string representation of enum class.
std::string scelname(const Structure &prim, const Lattice &superlat)
Make supercell name name [deprecated].
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
void throw_if_no_basis_set_specs(std::string basis_set_name, DirectoryStructure const &dir)
void throw_if_no_clexulator_src(std::string project_name, std::string basis_set_name, DirectoryStructure const &dir)
void throw_if_no_root_dir(DirectoryStructure const &dir)
fs::path relative_casmroot(const fs::path &cwd)
fs::path find_casmroot(const fs::path &cwd)
void recurs_rm_files(fs::path p, bool dry_run, Log &log)
Remove files recursively.
Index recurs_cp_files(const fs::path &from_dir, const fs::path &to_dir, bool dry_run, Log &log)
Copy files recursively, and returns a count of copied files.
INDEX_TYPE Index
For long integer indexing:
DirectoryStructure const & dir