CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ProjectSettings.hh
Go to the documentation of this file.
1 #ifndef CASM_ProjectSettings
2 #define CASM_ProjectSettings
3 
4 #include <map>
5 #include <set>
6 #include <string>
7 #include <vector>
8 
11 #include "casm/global/eigen.hh"
13 
14 namespace CASM {
15 
16 class Configuration;
17 class jsonParser;
18 class EnumeratorHandler;
19 template <typename T>
20 class QueryHandler;
21 class HamiltonianModules;
22 
45 bool is_valid_project_name(std::string project_name);
46 
48 void throw_if_project_name_is_not_valid(std::string project_name);
49 
131 // considered calculated.
133  public:
139  explicit ProjectSettings(std::string project_name);
140 
148  explicit ProjectSettings(std::string project_name, fs::path root);
149 
151 
153  std::string project_name() const;
154 
155  // --- optional: root_dir & DirectoryStructure ---
156 
158  bool has_dir() const;
159 
161  DirectoryStructure const &dir() const;
162 
164  bool set_root_dir(fs::path root);
165 
167  fs::path root_dir() const;
168 
169  // --- required properties settings ---
170 
171  typedef std::string ObjectTypeName;
172  typedef std::string CalcTypeName;
173 
177  typedef std::map<ObjectTypeName,
178  std::map<CalcTypeName, std::vector<std::string>>>
180 
188 
196  required_properties_map_type const &_required_properties);
197 
202  std::vector<std::string> const &required_properties(
203  std::string type_name, std::string calctype) const;
204 
210  std::string type_name, std::string calctype,
211  std::vector<std::string> const &_required_properties);
212 
213  // --- cluster expansion settings: ClexDescription, by ClexDescription.name
214  // ---
215 
217  std::map<std::string, ClexDescription> const &cluster_expansions() const;
218 
220  bool has_clex(std::string clex_name) const;
221 
223  ClexDescription const &clex(std::string clex_name) const;
224 
227  bool insert_clex(ClexDescription const &desc);
228 
232  bool erase_clex(ClexDescription const &desc);
233 
235  std::string default_clex_name() const;
236 
238  bool set_default_clex_name(std::string const &clex_name);
239 
241  ClexDescription const &default_clex() const;
242 
246 
247  // --- compiler and linker settings ---
248 
250  std::pair<std::string, std::string> cxx() const;
251 
253  std::pair<std::string, std::string> cxxflags() const;
254 
256  std::pair<std::string, std::string> soflags() const;
257 
259  std::pair<fs::path, std::string> casm_includedir() const;
260 
262  std::pair<fs::path, std::string> casm_libdir() const;
263 
265  std::pair<fs::path, std::string> boost_includedir() const;
266 
268  std::pair<fs::path, std::string> boost_libdir() const;
269 
272  std::string compile_options() const;
273 
276  std::string so_options() const;
277 
279  std::string view_command() const;
280 
282  std::string view_command_video() const;
283 
285  double crystallography_tol() const;
286 
288  double lin_alg_tol() const;
289 
290  // ** Enumerators **
291 
293 
294  EnumeratorHandler const &enumerator_handler() const;
295 
296  // ** Database **
297 
299  void set_default_database_name(std::string _default_database_name);
300 
302  std::string default_database_name() const;
303 
304  // ** Querie aliases **
305 
306  typedef std::string QueryAliasName;
307  typedef std::string QueryAliasValue;
308 
312  typedef std::map<ObjectTypeName, std::map<QueryAliasName, QueryAliasValue>>
314 
321  query_alias_map_type const &query_alias() const;
322 
329  void set_query_alias(query_alias_map_type const &_query_alias);
330 
337  void set_query_alias(std::string type_name, std::string alias_name,
338  std::string alias_value);
339 
340  template <typename DataObject>
342 
343  template <typename DataObject>
345 
346  // ** Hamiltonian Modules **
347 
349 
351 
352  // ** Clexulator names **
353 
355  std::string global_clexulator_name() const;
356 
358  bool has_m_nlist_weight_matrix() const;
359 
362 
372 
374  bool has_nlist_sublat_indices() const;
375 
377  std::set<int> const &nlist_sublat_indices() const;
378 
386  bool set_nlist_sublat_indices(std::set<int> value);
387 
389  bool set_cxx(std::string opt);
390 
392  bool set_cxxflags(std::string opt);
393 
395  bool set_soflags(std::string opt);
396 
398  bool set_casm_prefix(fs::path dir);
399 
401  bool set_casm_includedir(fs::path dir);
402 
404  bool set_casm_libdir(fs::path dir);
405 
407  bool set_boost_prefix(fs::path dir);
408 
410  bool set_boost_includedir(fs::path dir);
411 
413  bool set_boost_libdir(fs::path dir);
414 
416  bool set_view_command(std::string opt);
417 
419  bool set_view_command_video(std::string opt);
420 
422  bool set_crystallography_tol(double _tol);
423 
425  bool set_lin_alg_tol(double _tol);
426 
427  private:
428  // project name
429  std::string m_project_name;
430 
431  // directory structure (may be empty)
433 
434  // EnumeratorHandler (type erased)
436 
437  // Datatype name : QueryHandler<DataType> map (type erased)
438  std::map<std::string, notstd::cloneable_ptr<notstd::Cloneable>>
440 
441  // traits<ObjecType>::name -> std::pair{alias name, alias value}
443 
444  // HamiltonianModules (type erased)
446 
447  // CASM project current settings
448 
449  // name : ClexDescription map
450  std::map<std::string, ClexDescription> m_clex;
451 
452  // name of default cluster expansion
453  std::string m_default_clex_name;
454 
455  // neighbor list parameters (may be empty)
458 
459  // Properties required to be read from calculations
460  // traits<ObjecType>::name -> calctype -> {prop1, prop2, ...}
462 
463  // Runtime library compilation settings: compilation options
464  std::pair<std::string, std::string> m_cxx;
465  std::pair<std::string, std::string> m_cxxflags;
466  std::pair<std::string, std::string> m_soflags;
467  std::pair<fs::path, std::string> m_casm_includedir;
468  std::pair<fs::path, std::string> m_casm_libdir;
469  std::pair<fs::path, std::string> m_boost_includedir;
470  std::pair<fs::path, std::string> m_boost_libdir;
471 
472  // Command executed by 'casm view'
473  std::string m_view_command;
474 
475  // Command executed by 'casm view'
476  std::string m_view_command_video;
477 
478  // Crystallography tolerance
480 
481  // Linear algebra tolerance
483 
484  // Database
486 };
487 
493 
496 
498 void print_summary(ProjectSettings const &set, Log &log);
499 
502 
503 template <typename T>
504 struct jsonConstructor;
505 
506 template <>
515  static ProjectSettings from_json(jsonParser const &json);
516 };
517 
523  fs::path project_settings_path);
524 
532 ProjectSettings read_project_settings(fs::path project_settings_path);
533 
537 void commit(ProjectSettings const &set);
538 
547 ProjectSettings open_project_settings(fs::path path_in_project);
548 
550 } // namespace CASM
551 
552 #endif
Specification of CASM project directory structure.
Definition: Log.hh:48
void set_query_alias(query_alias_map_type const &_query_alias)
notstd::cloneable_ptr< Eigen::Matrix3l > m_nlist_weight_matrix
std::pair< fs::path, std::string > boost_includedir() const
Get boost includedir (pair of value and source for the value)
double lin_alg_tol() const
Get current project linear algebra tolerance.
ClexDescription const & clex(std::string clex_name) const
Get a ClexDescription by name.
notstd::cloneable_ptr< std::set< int > > m_nlist_sublat_indices
std::pair< std::string, std::string > m_soflags
std::string view_command() const
Get current command used by 'casm view'.
bool set_crystallography_tol(double _tol)
Set crystallography tolerance.
bool set_view_command(std::string opt)
Set command used by 'casm view'.
bool has_dir() const
Check if DirectoryStructure exists.
std::pair< fs::path, std::string > casm_libdir() const
Get casm libdir (pair of value and source for the value)
bool insert_clex(ClexDescription const &desc)
notstd::cloneable_ptr< notstd::Cloneable > m_hamiltonian_modules
Eigen::Matrix3l nlist_weight_matrix() const
Get neighbor list weight matrix.
bool set_nlist_sublat_indices(std::set< int > value)
std::map< std::string, ClexDescription > const & cluster_expansions() const
Const access map of all ClexDescription.
notstd::cloneable_ptr< DirectoryStructure > m_dir
bool set_cxxflags(std::string opt)
Set c++ compiler options (empty string to use default)
std::map< std::string, notstd::cloneable_ptr< notstd::Cloneable > > m_query_handler
std::string default_clex_name() const
Get default ClexDescription name.
bool set_boost_libdir(fs::path dir)
Set boost libdir (empty string to use default)
bool has_m_nlist_weight_matrix() const
Check if neighbor list weight matrix exists.
std::string global_clexulator_name() const
Name to use for clexulator printing.
required_properties_map_type m_required_properties
DirectoryStructure const & dir() const
Access DirectoryStructure object. Throw if not set.
EnumeratorHandler & enumerator_handler()
std::pair< std::string, std::string > m_cxx
std::string compile_options() const
bool set_boost_prefix(fs::path dir)
Set boost prefix (empty string to use default)
HamiltonianModules & hamiltonian_modules()
query_alias_map_type const & query_alias() const
bool set_nlist_weight_matrix(Eigen::Matrix3l M)
std::pair< fs::path, std::string > casm_includedir() const
Get casm includedir (pair of value and source for the value)
std::string m_view_command_video
notstd::cloneable_ptr< notstd::Cloneable > m_enumerator_handler
bool set_default_clex_name(std::string const &clex_name)
Set default ClexDescription by name.
std::string m_default_clex_name
std::pair< fs::path, std::string > boost_libdir() const
Get boost libdir (pair of value and source for the value)
query_alias_map_type m_query_alias
bool set_casm_includedir(fs::path dir)
Set casm includedir (empty string to use default)
std::string m_default_database_name
std::map< ObjectTypeName, std::map< QueryAliasName, QueryAliasValue > > query_alias_map_type
std::map< ObjectTypeName, std::map< CalcTypeName, std::vector< std::string > > > required_properties_map_type
std::pair< fs::path, std::string > m_boost_includedir
std::string project_name() const
Get project name.
std::map< std::string, ClexDescription > m_clex
std::pair< fs::path, std::string > m_boost_libdir
bool set_casm_prefix(fs::path dir)
Set casm prefix (empty string to use default)
bool has_clex(std::string clex_name) const
Check if a ClexDescription exists.
ClexDescription const & default_clex() const
Get default ClexDescription.
fs::path root_dir() const
Access dir().root_dir(). Throw if not set.
QueryHandler< DataObject > & query_handler()
std::pair< std::string, std::string > soflags() const
Get shared object options (pair of value and source for the value)
std::pair< std::string, std::string > m_cxxflags
required_properties_map_type const & required_properties() const
bool has_nlist_sublat_indices() const
Check if set of sublattice indices to include in neighbor lists exists.
bool set_view_command_video(std::string opt)
Set video viewing command used by 'casm view'.
std::pair< fs::path, std::string > m_casm_includedir
bool set_lin_alg_tol(double _tol)
Set linear algebra tolerance.
std::string so_options() const
std::set< int > const & nlist_sublat_indices() const
Get set of sublattice indices to include in neighbor lists.
std::pair< std::string, std::string > cxx() const
Get c++ compiler (pair of value and source for the value)
bool set_default_clex(ClexDescription const &desc)
double crystallography_tol() const
Get current project crystallography tolerance.
bool set_soflags(std::string opt)
Set shared object options (empty string to use default)
void set_default_database_name(std::string _default_database_name)
Set default database type name (for future)
std::pair< fs::path, std::string > m_casm_libdir
void set_required_properties(required_properties_map_type const &_required_properties)
bool erase_clex(ClexDescription const &desc)
bool set_casm_libdir(fs::path dir)
Set casm libdir (empty string to use default)
bool set_boost_includedir(fs::path dir)
Set boost includedir (empty string to use default)
bool set_cxx(std::string opt)
Set c++ compiler (empty string to use default)
bool set_root_dir(fs::path root)
Set DirectoryStructure.
std::pair< std::string, std::string > cxxflags() const
Get c++ compiler options (pair of value and source for the value)
ProjectSettings(std::string project_name)
std::string view_command_video() const
Get current video viewing command used by 'casm view'.
std::string default_database_name() const
Get default database type name.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
void commit(ProjectSettings const &set)
ProjectSettings open_project_settings(fs::path path_in_project)
void print_summary(ProjectSettings const &set, Log &log)
Print summary of ProjectSettings, as for 'casm settings -l'.
bool is_valid_project_name(std::string project_name)
bool create_all_directories(ProjectSettings const &set)
void throw_if_project_name_is_not_valid(std::string project_name)
Throw if project name is invalid.
void print_compiler_settings_summary(ProjectSettings const &set, Log &log)
Print summary of compiler settings, as for 'casm settings -l'.
void write_project_settings(ProjectSettings const &set, fs::path project_settings_path)
ProjectSettings read_project_settings(fs::path project_settings_path)
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
std::string type_name()
Definition: TypeInfo.hh:19
Log & log()
Definition: Log.hh:424
Matrix< long int, 3, 3 > Matrix3l
Definition: eigen.hh:12
ClexDescription & desc
Definition: settings.cc:138
pair_type calctype
Definition: settings.cc:143
ProjectSettings & set
Definition: settings.cc:137
Specifies a particular cluster expansion.
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