CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ProjectSettings.hh
Go to the documentation of this file.
1 #ifndef CASM_ProjectSettings
2 #define CASM_ProjectSettings
3 
4 #include <string>
5 #include <vector>
6 
11 #include "casm/app/QueryHandler.hh"
12 
14 #include "casm/casm_io/Log.hh"
17 
18 namespace CASM {
19 
20  class Configuration;
21 
22  template <bool IsConst>
25 
26  namespace ConfigIO {
27  class Selected;
28  }
29 
45  struct ClexDescription {
58 
59  ClexDescription(std::string _name,
60  std::string _property,
61  std::string _calctype,
62  std::string _ref,
63  std::string _bset,
64  std::string _eci) :
65  name(_name), property(_property), calctype(_calctype), ref(_ref), bset(_bset), eci(_eci) {}
66 
67  void print(std::ostream &sout, bool is_default, int indent = 0) const;
68 
69  std::string name;
70  std::string property;
71  std::string calctype;
72  std::string ref;
73  std::string bset;
74  std::string eci;
75  };
76 
78  bool operator<(const ClexDescription &A, const ClexDescription &B);
79 
81 
82  void from_json(ClexDescription &desc, const jsonParser &json);
83 
85 
86 
92  class ProjectSettings : public Logging {
93 
94  public:
95 
98 
104  explicit ProjectSettings(fs::path root, std::string name, const Logging &logging = Logging());
105 
110  explicit ProjectSettings(fs::path root, const Logging &logging = Logging());
111 
112 
114  std::string name() const;
115 
116  const DirectoryStructure &dir() const {
117  return m_dir;
118  }
119 
121  const std::vector<std::string> &properties() const;
122 
123 
124  const std::map<std::string, ClexDescription> &cluster_expansions() const;
125 
126  bool has_clex(std::string name) const;
127 
128  const ClexDescription &clex(std::string name) const;
129 
130  const ClexDescription &default_clex() const;
131 
132  bool new_clex(const ClexDescription &desc);
133 
134  bool erase_clex(const ClexDescription &desc);
135 
136  bool set_default_clex(const std::string &clex_name);
137 
139 
140 
143 
145  const std::set<int> &nlist_sublat_indices() const;
146 
148  std::pair<std::string, std::string> cxx() const;
149 
151  std::pair<std::string, std::string> cxxflags() const;
152 
154  std::pair<std::string, std::string> soflags() const;
155 
157  std::pair<fs::path, std::string> casm_includedir() const;
158 
160  std::pair<fs::path, std::string> casm_libdir() const;
161 
163  std::pair<fs::path, std::string> boost_includedir() const;
164 
166  std::pair<fs::path, std::string> boost_libdir() const;
167 
169  std::string compile_options() const;
170 
172  std::string so_options() const;
173 
175  std::string view_command() const;
176 
178  double crystallography_tol() const;
179 
181  double lin_alg_tol() const;
182 
183 
184  // ** Enumerators **
185 
187  if(!m_enumerator_handler) {
188  m_enumerator_handler = notstd::make_cloneable<EnumeratorHandler>(*this);
189  }
190  return *m_enumerator_handler;
191  }
192 
194  return const_cast<ProjectSettings &>(*this).enumerator_handler();
195  }
196 
197  // ** Queries **
198 
199  template<typename DataObject>
202  if(res == m_query_handler.end()) {
203  res = m_query_handler.insert(
204  std::make_pair(
207  )
208  ).first;
209  }
210  return static_cast<QueryHandler<DataObject>& >(*res->second);
211  }
212 
213  template<typename DataObject>
215  return const_cast<ProjectSettings &>(*this).query_handler<DataObject>();
216  }
217 
218 
219  // ** Clexulator names **
220 
221  std::string clexulator() const;
222 
223 
224  // ** Add directories for additional project data **
225 
227  bool new_casm_dir() const;
228 
230  bool new_symmetry_dir() const;
231 
233  bool new_bset_dir(std::string bset) const;
234 
236  bool new_clex_dir(std::string clex) const;
237 
238 
240  bool new_calc_settings_dir(std::string calctype) const;
241 
243  bool new_supercell_calc_settings_dir(std::string scelname, std::string calctype) const;
244 
246  bool new_configuration_calc_settings_dir(std::string configname, std::string calctype) const;
247 
248 
250  bool new_ref_dir(std::string calctype, std::string ref) const;
251 
252 
254  bool new_eci_dir(std::string clex, std::string calctype, std::string ref, std::string bset, std::string eci) const;
255 
256 
257  // ** Change current settings **
258 
260  std::vector<std::string> &properties();
261 
262 
266 
269  template<typename SublatIterator>
270  bool set_nlist_sublat_indices(SublatIterator begin, SublatIterator end);
271 
272 
274  bool set_cxx(std::string opt);
275 
277  bool set_cxxflags(std::string opt);
278 
280  bool set_soflags(std::string opt);
281 
282 
285 
288 
291 
292 
295 
298 
301 
302 
304  bool set_view_command(std::string opt);
305 
307  bool set_crystallography_tol(double _tol);
308 
310  bool set_lin_alg_tol(double _tol);
311 
312 
314  void commit() const;
315 
317  jsonParser &to_json(jsonParser &json) const;
318 
321 
323  void print_summary(Log &log) const;
324 
326  bool set_compile_options(std::string opt);
327 
329  bool set_so_options(std::string opt);
330 
331 
332 
333  private:
334 
336  void _reset_clexulators();
337 
339  void _load_default_options();
340 
341 
343 
344  std::string m_name;
345 
347  std::map<std::string, notstd::cloneable_ptr<notstd::Cloneable> > m_query_handler;
348 
349  // CASM project current settings
350 
351  // name : ClexDescription map
352  std::map<std::string, ClexDescription> m_clex;
353 
354  // name of default cluster expansion
355  std::string m_default_clex;
356 
357  // neighbor list settings
359  std::set<int> m_nlist_sublat_indices;
360 
361  // Properties to read from calculations
362  std::vector<std::string> m_properties;
363 
364  // Runtime library compilation settings: compilation options
365  std::pair<std::string, std::string> m_cxx;
366  std::pair<std::string, std::string> m_cxxflags;
367  std::pair<std::string, std::string> m_soflags;
368  std::pair<fs::path, std::string> m_casm_includedir;
369  std::pair<fs::path, std::string> m_casm_libdir;
370  std::pair<fs::path, std::string> m_boost_includedir;
371  std::pair<fs::path, std::string> m_boost_libdir;
372 
373  // deprecated reading exactly from settings file
375  // deprecated reading exactly from settings file
376  std::string m_depr_so_options;
377 
378  // Command executed by 'casm view'
379  std::string m_view_command;
380 
381  // Crystallography tolerance
383 
384  // Linear algebra tolerance
386 
387  };
388 
390 
391 
394  template<typename SublatIterator>
395  bool ProjectSettings::set_nlist_sublat_indices(SublatIterator begin, SublatIterator end) {
397  m_nlist_sublat_indices = std::set<int>(begin, end);
398  return true;
399  }
400 
402 }
403 
404 #endif
pair_type eci
Definition: settings.cc:112
ClexDescription & desc
Definition: settings.cc:104
Specifies a particular cluster expansion.
void commit() const
Save settings to project settings file.
Eigen::Matrix3l m_nlist_weight_matrix
std::pair< std::string, std::string > cxxflags() const
Get c++ compiler options.
void from_json(ClexDescription &desc, const jsonParser &json)
bool new_supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Add calculation settings directory path, for supercell specific settings.
Eigen::Matrix3l nlist_weight_matrix() const
Get neighbor list weight matrix.
bool set_casm_prefix(fs::path dir)
Set casm prefix (empty string to use default)
std::pair< fs::path, std::string > boost_includedir() const
Get boost includedir.
Specification of CASM project directory structure.
void print_compiler_settings_summary(Log &log) const
Print summary of compiler settings, as for 'casm settings -l'.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
std::string m_depr_compile_options
std::pair< std::string, std::string > m_cxx
void _reset_clexulators()
Changing the neighbor list properties requires updating Clexulator source code.
ClexDescription(std::string _name, std::string _property, std::string _calctype, std::string _ref, std::string _bset, std::string _eci)
bool operator<(const ClexDescription &A, const ClexDescription &B)
Compare using name strings: A.name < B.name.
std::string so_options() const
Get current shared library options string.
bool set_default_clex(const std::string &clex_name)
const std::set< int > & nlist_sublat_indices() const
Get set of sublattice indices to include in neighbor lists.
Main CASM namespace.
Definition: complete.cpp:8
bool new_eci_dir(std::string clex, std::string calctype, std::string ref, std::string bset, std::string eci) const
Add an eci directory.
std::pair< fs::path, std::string > m_boost_includedir
void print_summary(Log &log) const
Print summary of ProjectSettings, as for 'casm settings -l'.
bool new_casm_dir() const
Create new project data directory.
Log & log() const
Definition: Log.hh:255
bool new_ref_dir(std::string calctype, std::string ref) const
Add a ref directory.
bool set_view_command(std::string opt)
Set command used by 'casm view'.
std::vector< std::string > m_properties
ProjectSettings & set
Definition: settings.cc:103
bool set_cxx(std::string opt)
Set c++ compiler (empty string to use default)
bool clex_exists(const DirectoryStructure &dir, const ClexDescription &desc)
pair_type ref
Definition: settings.cc:110
std::map< std::string, ClexDescription > m_clex
std::string name() const
Get project name.
bool set_crystallography_tol(double _tol)
Set crystallography tolerance.
EnumeratorHandler & enumerator_handler()
const std::vector< std::string > & properties() const
Get current properties.
const ClexDescription & clex(std::string name) const
Logging(Log &log=default_log(), Log &debug_log=default_log(), Log &err_log=default_err_log())
Definition: Log.hh:250
notstd::cloneable_ptr< EnumeratorHandler > m_enumerator_handler
std::pair< fs::path, std::string > m_casm_includedir
Read/modify settings of an already existing CASM project.
bool set_compile_options(std::string opt)
(deprecated) Set compile options to 'opt' (empty string to use default)
std::pair< fs::path, std::string > m_casm_libdir
QueryHandler< DataObject > & query_handler()
std::pair< fs::path, std::string > casm_libdir() const
Get casm libdir.
std::set< int > m_nlist_sublat_indices
std::pair< fs::path, std::string > casm_includedir() const
Get casm includedir.
bool set_boost_prefix(fs::path dir)
Set boost prefix (empty string to use default)
pair_type calctype
Definition: settings.cc:109
std::map< std::string, notstd::cloneable_ptr< notstd::Cloneable > > m_query_handler
bool set_boost_libdir(fs::path dir)
Set boost libdir (empty string to use default)
bool new_symmetry_dir() const
Create new symmetry directory.
bool has_clex(std::string name) const
bool new_configuration_calc_settings_dir(std::string configname, std::string calctype) const
Add calculation settings directory path, for configuration specific settings.
std::string compile_options() const
Get current compilation options string.
bool set_so_options(std::string opt)
(deprecated) Set shared library options to 'opt' (empty string to use default)
bool new_bset_dir(std::string bset) const
Add a basis set directory.
ProjectSettings()
Default constructor.
bool set_casm_libdir(fs::path dir)
Set casm libdir (empty string to use default)
bool new_clex_dir(std::string clex) const
Add a cluster expansion directory.
std::pair< std::string, std::string > m_cxxflags
bool set_soflags(std::string opt)
Set shared object options (empty string to use default)
std::string clexulator() const
jsonParser & to_json(jsonParser &json) const
Output as JSON.
const std::map< std::string, ClexDescription > & cluster_expansions() const
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:340
bool set_lin_alg_tol(double _tol)
Set linear algebra tolerance.
DirectoryStructure & dir
Definition: settings.cc:102
bool set_casm_includedir(fs::path dir)
Set casm includedir (empty string to use default)
double crystallography_tol() const
Get current project crystallography tolerance.
bool new_calc_settings_dir(std::string calctype) const
Add calculation settings directory path.
bool erase_clex(const ClexDescription &desc)
ConfigSelection< true > ConstConfigSelection
bool set_nlist_sublat_indices(SublatIterator begin, SublatIterator end)
Set range of sublattice indices to include in neighbor lists (will delete existing Clexulator source ...
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
std::pair< fs::path, std::string > boost_libdir() const
Get boost libdir.
std::pair< std::string, std::string > m_soflags
Matrix< long int, 3, 3 > Matrix3l
Definition: Log.hh:9
void _load_default_options()
initialize default compiler options
std::pair< fs::path, std::string > m_boost_libdir
bool new_clex(const ClexDescription &desc)
std::string view_command() const
Get current command used by 'casm view'.
pair_type bset
Definition: settings.cc:111
ConfigIO::GenericConfigFormatter< std::string > scelname()
Definition: ConfigIO.cc:348
void print(std::ostream &sout, bool is_default, int indent=0) const
std::pair< std::string, std::string > soflags() const
Get shared object options.
std::pair< std::string, std::string > cxx() const
Get c++ compiler.
const ClexDescription & default_clex() const
const DirectoryStructure & dir() const
DirectoryStructure m_dir
bool set_boost_includedir(fs::path dir)
Set boost includedir (empty string to use default)
const EnumeratorHandler & enumerator_handler() const
bool set_cxxflags(std::string opt)
Set c++ compiler options (empty string to use default)
bool set_nlist_weight_matrix(Eigen::Matrix3l M)
Set neighbor list weight matrix (will delete existing Clexulator source and compiled code) ...
Returns true if configuration is specified in given selection (default: MASTER)
const QueryHandler< DataObject > & query_handler() const
double lin_alg_tol() const
Get current project linear algebra tolerance.