CASM  1.1.0
A Clusters Approach to Statistical Mechanics
BasisFunctionSpecs.hh
Go to the documentation of this file.
1 #ifndef CASM_BasisFunctionSpecs
2 #define CASM_BasisFunctionSpecs
3 
4 #include <algorithm>
5 #include <map>
6 #include <vector>
7 
11 
12 namespace CASM {
13 
14 // --- Generic BasisFunctionSpecs ---
15 
22 enum class PARAM_PACK_TYPE { DEFAULT, DIFF };
23 
33 class DoFSpecs : public notstd::Cloneable {
35  public:
36  DoFKey name() const;
37 
38  private:
39  virtual DoFKey _name() const = 0;
40 };
41 
46 
98  std::vector<DoFKey> _dof_keys = {},
99  std::vector<notstd::cloneable_ptr<DoFSpecs>> _dof_specs = {},
100  MaxPolyOrder _global_max_poly_order = -1,
101  std::map<OrbitBranchSize, MaxPolyOrder> _orbit_branch_max_poly_order = {},
102  std::vector<Index> _include_functions = {},
103  std::vector<Index> _exclude_functions = {},
104  PARAM_PACK_TYPE _param_pack_type = PARAM_PACK_TYPE::DEFAULT);
105 
107  std::vector<DoFKey> dof_keys;
108 
110  std::vector<notstd::cloneable_ptr<DoFSpecs>> dof_specs;
111 
117 
120  std::map<OrbitBranchSize, MaxPolyOrder> orbit_branch_max_poly_order;
121 
122  // Note: Could allow more customization of max_poly_order, by orbit
123  // std::map<IntegralCluster, Index> orbit_max_poly_order;
124 
127  std::vector<Index> include_functions;
128 
131  std::vector<Index> exclude_functions;
132 
135 };
136 
139 template <typename DoFSpecsType>
140 DoFSpecsType const &get(DoFKey const &key,
141  BasisFunctionSpecs const &basis_function_specs);
142 
143 } // namespace CASM
144 
145 #include <sstream>
146 
147 #include "casm/global/errors.hh"
148 
149 namespace CASM {
150 
151 inline DoFKey DoFSpecs::name() const { return this->_name(); }
152 
154  std::vector<DoFKey> _dof_keys,
155  std::vector<notstd::cloneable_ptr<DoFSpecs>> _dof_specs,
156  MaxPolyOrder _global_max_poly_order,
157  std::map<OrbitBranchSize, MaxPolyOrder> _orbit_branch_max_poly_order,
158  std::vector<Index> _include_functions,
159  std::vector<Index> _exclude_functions, PARAM_PACK_TYPE _param_pack_type)
160  : dof_keys(std::move(_dof_keys)),
161  dof_specs(std::move(_dof_specs)),
162  global_max_poly_order(_global_max_poly_order),
163  orbit_branch_max_poly_order(_orbit_branch_max_poly_order),
164  include_functions(_include_functions),
165  exclude_functions(_exclude_functions),
166  param_pack_type(_param_pack_type) {}
167 
168 template <typename DoFSpecsType>
169 DoFSpecsType const &get(DoFKey const &key,
170  BasisFunctionSpecs const &basis_function_specs) {
171  auto it = std::find_if(basis_function_specs.dof_specs.begin(),
172  basis_function_specs.dof_specs.end(),
173  [&](notstd::cloneable_ptr<DoFSpecs> const &ptr) {
174  return ptr->name() == key;
175  });
176  if (it == basis_function_specs.dof_specs.end()) {
177  std::stringstream ss;
178  ss << "DoFSpecs not found in BasisFunctionSpecs for " << key;
179  throw libcasm_runtime_error{ss.str()};
180  }
181  return static_cast<DoFSpecsType const &>(**it);
182 }
183 
184 } // namespace CASM
185 #endif
DoFKey name() const
virtual DoFKey _name() const =0
Base class for cloning.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
#define ABSTRACT_CLONEABLE(T)
Main CASM namespace.
Definition: APICommand.hh:8
std::string DoFKey
Definition: DoFDecl.hh:7
DoFSpecsType const & get(DoFKey const &key, BasisFunctionSpecs const &basis_function_specs)
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Definition: stream_io.hh:24
Specify how to construct basis functions.
PARAM_PACK_TYPE param_pack_type
Specify the Clexulator underlying data structure type.
BasisFunctionSpecs(std::vector< DoFKey > _dof_keys={}, std::vector< notstd::cloneable_ptr< DoFSpecs >> _dof_specs={}, MaxPolyOrder _global_max_poly_order=-1, std::map< OrbitBranchSize, MaxPolyOrder > _orbit_branch_max_poly_order={}, std::vector< Index > _include_functions={}, std::vector< Index > _exclude_functions={}, PARAM_PACK_TYPE _param_pack_type=PARAM_PACK_TYPE::DEFAULT)
std::vector< Index > include_functions
std::map< OrbitBranchSize, MaxPolyOrder > orbit_branch_max_poly_order
std::vector< Index > exclude_functions
std::vector< DoFKey > dof_keys
Which DoF types to include in the basis functions.
std::vector< notstd::cloneable_ptr< DoFSpecs > > dof_specs
Provides DoF-particular specifications for constructing basis functions.