CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ClexBasisWriter.cc
Go to the documentation of this file.
3 #include "casm/clex/ClexBasis.hh"
7 
8 namespace CASM {
9 
11  PARAM_PACK_TYPE const &param_pack_type) {
12  if (param_pack_type == PARAM_PACK_TYPE::DEFAULT) {
14  } else if (param_pack_type == PARAM_PACK_TYPE::DIFF) {
16  } else {
17  throw std::runtime_error(
18  "Error in ClexBasisWriter: Invalid param_pack_type");
19  }
20 }
21 
23  ParamPackMixIn const &_param_pack_mix_in) {
24  _initialize(_prim, _param_pack_mix_in);
25 }
26 
28  ParamPackMixIn const &_param_pack_mix_in) {
29  m_param_pack_mix_in = _param_pack_mix_in.clone();
30 
31  auto doftypes = xtal::all_local_dof_types(_prim);
32  for (auto const &doftype : doftypes) {
33  auto cv = DoFType::traits(doftype).clust_function_visitors();
34  auto sv = DoFType::traits(doftype).site_function_visitors();
35  for (auto &e : cv) m_clust_visitors.push_back(std::move(e));
36  for (auto &e : sv) m_site_visitors.push_back(std::move(e));
37  }
38 
39  doftypes = xtal::global_dof_types(_prim);
40  for (auto const &doftype : doftypes) {
41  auto cv = DoFType::traits(doftype).clust_function_visitors();
42  auto sv = DoFType::traits(doftype).site_function_visitors();
43  for (auto &e : cv) m_clust_visitors.push_back(std::move(e));
44  for (auto &e : sv) m_site_visitors.push_back(std::move(e));
45  }
46 }
47 
48 namespace ClexBasisWriter_impl {
49 
51  std::string const &class_name, ClexBasis const &clex,
52  ParamPackMixIn const &_param_pack_mix_in,
53  std::vector<std::unique_ptr<OrbitFunctionTraits> > const
54  &orbit_func_writers,
55  Index N_flower, std::string const &indent) {
56  Index N_corr = clex.n_functions();
57 
58  std::stringstream ss;
59 
60  for (auto const &writer_ptr : orbit_func_writers) {
61  writer_ptr->print_typedefs(ss, class_name, indent);
62  }
63 
64  for (auto const &writer_ptr : orbit_func_writers) {
65  writer_ptr->print_eval_table_declarations(ss, class_name, clex, indent);
66  }
67 
68  ss <<
69 
70  indent
71  << "// ParamPack object, which stores temporary data for calculations\n"
72  << indent << "mutable ParamPack m_params;\n\n";
73 
74  Index ispec = 0;
75  for (auto const &specialization :
76  _param_pack_mix_in.scalar_specializations()) {
77  ss <<
78 
79  indent << "// typedef for method pointers of scalar type "
80  << specialization.second << "\n"
81  << indent << "typedef " << specialization.second << " (" << class_name
82  << "::*BasisFuncPtr_" << ispec << ")() const;\n\n"
83  <<
84 
85  indent << "// typedef for method pointers\n"
86  << indent << "typedef " << specialization.second << " (" << class_name
87  << "::*DeltaBasisFuncPtr_" << ispec << ")(int, int) const;\n\n"
88  <<
89 
90  indent
91  << "// array of pointers to member functions for calculating basis "
92  "functions of scalar type "
93  << specialization.second << "\n"
94  << indent << "BasisFuncPtr_" << ispec << " m_orbit_func_table_" << ispec
95  << "[" << N_corr << "];\n\n"
96  <<
97 
98  indent
99  << "// array of pointers to member functions for calculating flower "
100  "functions of scalar type "
101  << specialization.second << "\n"
102  << indent << "BasisFuncPtr_" << ispec << " m_flower_func_table_" << ispec
103  << "[" << N_flower << "][" << N_corr << "];\n\n"
104  <<
105 
106  indent
107  << "// array of pointers to member functions for calculating DELTA "
108  "flower functions of scalar type "
109  << specialization.second << "\n"
110  << indent << "DeltaBasisFuncPtr_" << ispec << " m_delta_func_table_"
111  << ispec << "[" << N_flower << "][" << N_corr << "];\n\n";
112 
113  ++ispec;
114  }
115 
116  for (auto const &dof : clex.site_bases())
118  clex.prim(), dof.second, indent);
119 
120  for (auto const &dof : clex.global_bases())
122  clex.prim(), dof.second, indent);
123 
124  ss << indent << "//ClexParamPack allocation for evaluated correlations \n"
125  << indent << "ParamPack::Key m_corr_param_key;\n";
126 
127  for (auto const &dof : clex.site_bases()) {
128  std::vector<DoFType::ParamAllocation> allo =
129  DoFType::traits(dof.first).param_pack_allocation(clex.prim(),
130  dof.second);
131  if (allo.empty()) continue;
132  ss << indent << "//ClexParamPack allocation for DoF " << dof.first << "\n";
133  for (const auto &el : allo)
134  ss << indent << "ParamPack::Key m_" << el.param_name << "_param_key;\n";
135  ss << "\n";
136  }
137 
138  for (auto const &dof : clex.global_bases()) {
139  std::vector<DoFType::ParamAllocation> allo =
140  DoFType::traits(dof.first).param_pack_allocation(clex.prim(),
141  dof.second);
142  if (allo.empty()) continue;
143  ss << indent << "//ClexParamPack allocation for DoF " << dof.first << "\n";
144  for (const auto &el : allo)
145  ss << indent << "ParamPack::Key m_" << el.param_name << "_param_key;\n";
146  ss << "\n";
147  }
148 
149  return ss.str();
150 }
151 
152 //*******************************************************************************************
153 
155  std::string const &class_name, ClexBasis const &clex,
156  std::string const &indent) {
157  std::stringstream ss;
158  ss <<
159 
160  indent << "/// \\brief Clone the " << class_name << "\n"
161  << indent << "Clexulator_impl::Base *_clone() const override {\n"
162  << indent << " return new " << class_name << "(*this);\n"
163  << indent << "}\n\n"
164  <<
165 
166  indent
167  << "/// \\brief Calculate contribution to global correlations from one "
168  "unit cell\n"
169  << indent << "/// Result is recorded in ClexParamPack\n"
170  << indent << "void _calc_global_corr_contribution() const override;\n\n"
171  <<
172 
173  indent
174  << "/// \\brief Calculate contribution to global correlations from one "
175  "unit cell "
176  << indent
177  << "/// Result is recorded in double array starting at corr_begin\n"
178  << indent
179  << "void _calc_global_corr_contribution(double *corr_begin) const "
180  "override;\n\n"
181  <<
182 
183  indent
184  << "/// \\brief Calculate contribution to select global correlations from "
185  "one unit cell into ClexParamPack\n"
186  << indent << "/// Result is recorded in ClexParamPack\n"
187  << indent
188  << "void _calc_restricted_global_corr_contribution(size_type const "
189  "*ind_list_begin, size_type const *ind_list_end) const override;\n\n"
190  <<
191 
192  indent
193  << "/// \\brief Calculate contribution to select global correlations from "
194  "one unit cell\n"
195  << indent
196  << "/// Result is recorded in double array starting at corr_begin\n"
197  << indent
198  << "void _calc_restricted_global_corr_contribution(double *corr_begin, "
199  "size_type const *ind_list_begin, size_type const *ind_list_end) const "
200  "override;\n\n"
201  <<
202 
203  indent
204  << "/// \\brief Calculate point correlations about neighbor site "
205  "'nlist_ind'\n"
206  << indent
207  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
208  "cell\n"
209  << indent
210  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
211  "neighborhood\n"
212  << indent << "/// Result is recorded in ClexParamPack\n"
213  << indent << "void _calc_point_corr(int nlist_ind) const override;\n\n"
214  <<
215 
216  indent
217  << "/// \\brief Calculate point correlations about neighbor site "
218  "'nlist_ind'\n"
219  << indent
220  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
221  "cell\n"
222  << indent
223  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
224  "neighborhood\n"
225  << indent
226  << "/// Result is recorded in double array starting at corr_begin\n"
227  << indent
228  << "void _calc_point_corr(int nlist_ind, double *corr_begin) const "
229  "override;\n\n"
230  <<
231 
232  indent
233  << "/// \\brief Calculate select point correlations about neighbor site "
234  "'nlist_ind'\n"
235  << indent
236  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
237  "cell\n"
238  << indent
239  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
240  "neighborhood\n"
241  << indent << "/// Result is recorded in ClexParamPack\n"
242  << indent
243  << "void _calc_restricted_point_corr(int nlist_ind, size_type const "
244  "*ind_list_begin, size_type const *ind_list_end) const override;\n\n"
245  <<
246 
247  indent
248  << "/// \\brief Calculate select point correlations about neighbor site "
249  "'nlist_ind'\n"
250  << indent
251  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
252  "cell\n"
253  << indent
254  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
255  "neighborhood\n"
256  << indent
257  << "/// Result is recorded in double array starting at corr_begin\n"
258  << indent
259  << "void _calc_restricted_point_corr(int nlist_ind, double *corr_begin, "
260  "size_type const *ind_list_begin, size_type const *ind_list_end) const "
261  "override;\n\n"
262  <<
263 
264  indent
265  << "/// \\brief Calculate the change in point correlations due to "
266  "changing an occupant at neighbor site 'nlist_ind'\n"
267  << indent
268  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
269  "cell\n"
270  << indent
271  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
272  "neighborhood\n"
273  << indent << "/// Result is recorded in ClexParamPack\n"
274  << indent
275  << "void _calc_delta_point_corr(int nlist_ind, int occ_i, int occ_f) "
276  "const override;\n\n"
277  <<
278 
279  indent
280  << "/// \\brief Calculate the change in point correlations due to "
281  "changing an occupant at neighbor site 'nlist_ind'\n"
282  << indent
283  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
284  "cell\n"
285  << indent
286  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
287  "neighborhood\n"
288  << indent
289  << "/// Result is recorded in double array starting at corr_begin\n"
290  << indent
291  << "void _calc_delta_point_corr(int nlist_ind, int occ_i, int occ_f, "
292  "double *corr_begin) const override;\n\n"
293  <<
294 
295  indent
296  << "/// \\brief Calculate the change in select point correlations due to "
297  "changing an occupant at neighbor site 'nlist_ind'\n"
298  << indent
299  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
300  "cell\n"
301  << indent
302  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
303  "neighborhood\n"
304  << indent << "/// Result is recorded in ClexParamPack\n"
305  << indent
306  << "void _calc_restricted_delta_point_corr(int nlist_ind, int occ_i, int "
307  "occ_f, size_type const *ind_list_begin, size_type const "
308  "*ind_list_end) const override;\n\n"
309  <<
310 
311  indent
312  << "/// \\brief Calculate the change in select point correlations due to "
313  "changing an occupant at neighbor site 'nlist_ind'\n"
314  << indent
315  << "/// For global clexulators, 'nlist_ind' only ranges over sites in the "
316  "cell\n"
317  << indent
318  << "/// For local clexulators, 'nlist_ind' ranges over all sites in the "
319  "neighborhood\n"
320  << indent
321  << "/// Result is recorded in double array starting at corr_begin\n"
322  << indent
323  << "void _calc_restricted_delta_point_corr(int nlist_ind, int occ_i, int "
324  "occ_f, double *corr_begin, size_type const *ind_list_begin, size_type "
325  "const *ind_list_end) const override;\n\n"
326  <<
327 
328  indent << "template<typename Scalar>\n"
329  << indent << "void _global_prepare() const;\n\n"
330  <<
331 
332  indent << "template<typename Scalar>\n"
333  << indent << "void _point_prepare(int nlist_ind) const;\n\n";
334 
335  {
336  auto it(clex.site_bases().begin()), end_it(clex.site_bases().end());
337  for (; it != end_it; ++it) {
338  ss << DoFType::traits(it->first)
340  clex.prim(), it->second, indent);
341  }
342  }
343 
344  {
345  auto it(clex.global_bases().begin()), end_it(clex.global_bases().end());
346  for (; it != end_it; ++it) {
347  ss << DoFType::traits(it->first)
349  clex.prim(), it->second, indent);
350  }
351  }
352 
353  ss << indent << "//default functions for basis function evaluation\n"
354  << indent << "template <typename Scalar>\n"
355  << indent << "Scalar zero_func() const {\n"
356  << indent << " return Scalar(0.0);\n"
357  << indent << "}\n\n"
358  <<
359 
360  indent << "template <typename Scalar>\n"
361  << indent << "Scalar zero_func(int, int) const {\n"
362  << indent << " return Scalar(0.0);\n"
363  << indent << "}\n\n";
364 
365  return ss.str();
366 }
367 
368 //*******************************************************************************************
369 
370 std::string clexulator_public_method_declarations(std::string const &class_name,
371  ClexBasis const &clex,
372  std::string const &indent) {
373  std::stringstream ss;
374  ss << indent << class_name << "();\n\n"
375  << indent << "~" << class_name << "();\n\n"
376  <<
377 
378  indent << "ClexParamPack const &param_pack() const override {\n"
379  << indent << " return m_params;\n"
380  << indent << "}\n\n"
381  <<
382 
383  indent << "ClexParamPack &param_pack() override {\n"
384  << indent << " return m_params;\n"
385  << indent << "}\n\n";
386 
387  {
388  auto it(clex.site_bases().begin()), end_it(clex.site_bases().end());
389  for (; it != end_it; ++it) {
390  ss << DoFType::traits(it->first)
392  clex.prim(), it->second, indent);
393  }
394  }
395  {
396  auto it(clex.global_bases().begin()), end_it(clex.global_bases().end());
397  for (; it != end_it; ++it) {
398  ss << DoFType::traits(it->first)
400  clex.prim(), it->second, indent);
401  }
402  }
403  return ss.str();
404 }
405 
406 //*******************************************************************************************
407 
409  std::string const &class_name, ClexBasis const &clex,
410  ParamPackMixIn const &_param_pack_mix_in, std::string const &indent) {
411  std::stringstream ss;
412  // Write destructor
413  ss << indent << class_name << "::~" << class_name << "() {\n"
414  << indent << " //nothing here for now\n"
415  << indent << "}\n\n";
416 
417  // Write evaluation methods
418  auto specializations = _param_pack_mix_in.scalar_specializations();
419  ss << indent
420  << "/// \\brief Calculate contribution to global correlations from one "
421  "unit cell\n"
422  << indent << "void " << class_name
423  << "::_calc_global_corr_contribution(double *corr_begin) const {\n"
424  << indent << " _calc_global_corr_contribution();\n"
425  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
426  << indent
427  << " *(corr_begin + i) = ParamPack::Val<double>::get(m_params, "
428  "m_corr_param_key, i);\n"
429  << indent << " }\n"
430  << indent << "}\n\n"
431  <<
432 
433  //-----
434 
435  indent
436  << "/// \\brief Calculate contribution to global correlations from one "
437  "unit cell\n"
438  << indent << "void " << class_name
439  << "::_calc_global_corr_contribution() const {\n"
440  << indent << " m_params.pre_eval();\n";
441 
442  Index ispec = 0;
443 
444  for (auto const &specialization : specializations) {
445  if (specializations.size() > 1) {
446  ss << indent << " ";
447  if (ispec > 0) ss << "else ";
448  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
449  }
450  ss << indent << " {\n"
451  << indent << " _global_prepare<" << specialization.second << ">();\n"
452  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
453  << indent << " ParamPack::Val<" << specialization.second
454  << ">::set(m_params, m_corr_param_key, i, (this->*m_orbit_func_table_"
455  << ispec << "[i])());\n"
456  << indent << " }\n"
457  << indent << " }\n";
458  ++ispec;
459  }
460  ss << indent << " m_params.post_eval();\n"
461  << indent << "}\n\n"
462  <<
463 
464  //-----
465 
466  indent
467  << "/// \\brief Calculate contribution to select global correlations from "
468  "one unit cell\n"
469  << indent << "void " << class_name
470  << "::_calc_restricted_global_corr_contribution(double *corr_begin, "
471  "size_type const *ind_list_begin, size_type const *ind_list_end) const "
472  "{\n"
473  << indent
474  << " _calc_restricted_global_corr_contribution(ind_list_begin, "
475  "ind_list_end);\n"
476  << indent << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
477  << indent
478  << " *(corr_begin + *ind_list_begin) = "
479  "ParamPack::Val<double>::get(m_params, m_corr_param_key, "
480  "*ind_list_begin);\n"
481  << indent << " }\n"
482  << indent << "}\n\n"
483  <<
484 
485  //-----
486 
487  indent
488  << "/// \\brief Calculate contribution to select global correlations from "
489  "one unit cell\n"
490  << indent << "void " << class_name
491  << "::_calc_restricted_global_corr_contribution(size_type const "
492  "*ind_list_begin, size_type const *ind_list_end) const {\n"
493  << indent << " m_params.pre_eval();\n";
494 
495  ispec = 0;
496  for (auto const &specialization : specializations) {
497  if (specializations.size() > 1) {
498  ss << indent << " ";
499  if (ispec > 0) ss << "else ";
500  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
501  }
502  ss << indent << " {\n"
503  << indent << " _global_prepare<" << specialization.second << ">();\n"
504  << indent
505  << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
506  << indent << " ParamPack::Val<" << specialization.second
507  << ">::set(m_params, m_corr_param_key, *ind_list_begin, "
508  "(this->*m_orbit_func_table_"
509  << ispec << "[*ind_list_begin])());\n"
510  << indent << " }\n"
511  << indent << " }\n";
512  ++ispec;
513  }
514  ss << indent << " m_params.post_eval();\n"
515  << indent << "}\n\n"
516  <<
517 
518  //-----
519 
520  indent
521  << "/// \\brief Calculate point correlations about basis site "
522  "'nlist_ind'\n"
523  << indent << "void " << class_name
524  << "::_calc_point_corr(int nlist_ind, double *corr_begin) const {\n"
525  << indent << " _calc_point_corr(nlist_ind);\n"
526  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
527  << indent
528  << " *(corr_begin + i) = ParamPack::Val<double>::get(m_params, "
529  "m_corr_param_key, i);\n"
530  << indent << " }\n"
531  << indent << "}\n\n"
532  <<
533 
534  //-----
535 
536  indent
537  << "/// \\brief Calculate point correlations about basis site "
538  "'nlist_ind'\n"
539  << indent << "void " << class_name
540  << "::_calc_point_corr(int nlist_ind) const {\n"
541  << indent << " m_params.pre_eval();\n";
542 
543  ispec = 0;
544  for (auto const &specialization : specializations) {
545  if (specializations.size() > 1) {
546  ss << indent << " ";
547  if (ispec > 0) ss << "else ";
548  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
549  }
550  ss << indent << " {\n"
551  << indent << " _point_prepare<" << specialization.second
552  << ">(nlist_ind);\n"
553  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
554  << indent << " ParamPack::Val<" << specialization.second
555  << ">::set(m_params, m_corr_param_key, i, (this->*m_flower_func_table_"
556  << ispec << "[nlist_ind][i])());\n"
557  << indent << " }\n"
558  << indent << " }\n";
559  ++ispec;
560  }
561  ss << indent << " m_params.post_eval();\n"
562  << indent << "}\n\n"
563  <<
564 
565  //-----
566 
567  indent
568  << "/// \\brief Calculate select point correlations about basis site "
569  "'nlist_ind'\n"
570  << indent << "void " << class_name
571  << "::_calc_restricted_point_corr(int nlist_ind, double *corr_begin, "
572  "size_type const *ind_list_begin, size_type const *ind_list_end) const "
573  "{\n"
574  << indent
575  << " _calc_restricted_point_corr(nlist_ind, ind_list_begin, "
576  "ind_list_end);\n"
577  << indent << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
578  << indent
579  << " *(corr_begin + *ind_list_begin) = "
580  "ParamPack::Val<double>::get(m_params, m_corr_param_key, "
581  "*ind_list_begin);\n"
582  << indent << " }\n"
583  << indent << "}\n\n"
584  <<
585 
586  //-----
587 
588  indent
589  << "/// \\brief Calculate select point correlations about basis site "
590  "'nlist_ind'\n"
591  << indent << "void " << class_name
592  << "::_calc_restricted_point_corr(int nlist_ind, size_type const "
593  "*ind_list_begin, size_type const *ind_list_end) const {\n"
594  << indent << " m_params.pre_eval();\n";
595 
596  ispec = 0;
597  for (auto const &specialization : specializations) {
598  if (specializations.size() > 1) {
599  ss << indent << " ";
600  if (ispec > 0) ss << "else ";
601  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
602  }
603  ss << indent << " {\n"
604  << indent << " _point_prepare<" << specialization.second
605  << ">(nlist_ind);\n"
606  << indent
607  << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
608  << indent << " ParamPack::Val<" << specialization.second
609  << ">::set(m_params, m_corr_param_key, *ind_list_begin, "
610  "(this->*m_flower_func_table_"
611  << ispec << "[nlist_ind][*ind_list_begin])());\n"
612  << indent << " }\n"
613  << indent << " }\n";
614  ++ispec;
615  }
616  ss << indent << " m_params.post_eval();\n"
617  << indent << "}\n\n"
618  <<
619 
620  //-----
621 
622  indent
623  << "/// \\brief Calculate the change in point correlations due to "
624  "changing an occupant\n"
625  << indent << "void " << class_name
626  << "::_calc_delta_point_corr(int nlist_ind, int occ_i, int occ_f, double "
627  "*corr_begin) const {\n"
628  << indent << " _calc_delta_point_corr(nlist_ind, occ_i, occ_f);\n"
629  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
630  << indent
631  << " *(corr_begin + i) = ParamPack::Val<double>::get(m_params, "
632  "m_corr_param_key, i);\n"
633  << indent << " }\n"
634  << indent << "}\n\n"
635  <<
636 
637  //-----
638 
639  indent
640  << "/// \\brief Calculate the change in point correlations due to "
641  "changing an occupant\n"
642  << indent << "void " << class_name
643  << "::_calc_delta_point_corr(int nlist_ind, int occ_i, int occ_f) const "
644  "{\n"
645  << indent << " m_params.pre_eval();\n";
646 
647  ispec = 0;
648  for (auto const &specialization : specializations) {
649  if (specializations.size() > 1) {
650  ss << indent << " ";
651  if (ispec > 0) ss << "else ";
652  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
653  }
654  ss << indent << " {\n"
655  << indent << " _point_prepare<" << specialization.second
656  << ">(nlist_ind);\n"
657  << indent << " for(size_type i = 0; i < corr_size(); i++) {\n"
658  << indent << " ParamPack::Val<" << specialization.second
659  << ">::set(m_params, m_corr_param_key, i, (this->*m_delta_func_table_"
660  << ispec << "[nlist_ind][i])(occ_i, occ_f));\n"
661  << indent << " }\n"
662  << indent << " }\n";
663  ++ispec;
664  }
665  ss << indent << " m_params.post_eval();\n"
666  << indent << "}\n\n"
667  <<
668 
669  //-----
670 
671  indent
672  << "/// \\brief Calculate the change in select point correlations due to "
673  "changing an occupant\n"
674  << indent << "void " << class_name
675  << "::_calc_restricted_delta_point_corr(int nlist_ind, int occ_i, int "
676  "occ_f, double *corr_begin, size_type const *ind_list_begin, size_type "
677  "const *ind_list_end) const {\n"
678  << indent
679  << " _calc_restricted_delta_point_corr(nlist_ind, occ_i, occ_f, "
680  "ind_list_begin, ind_list_end);\n"
681  << indent << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
682  << indent
683  << " *(corr_begin + *ind_list_begin) = "
684  "ParamPack::Val<double>::get(m_params, m_corr_param_key, "
685  "*ind_list_begin);\n"
686  << indent << " }\n"
687  << indent << "}\n\n"
688  <<
689 
690  //-----
691 
692  indent
693  << "/// \\brief Calculate the change in select point correlations due to "
694  "changing an occupant\n"
695  << indent << "void " << class_name
696  << "::_calc_restricted_delta_point_corr(int nlist_ind, int occ_i, int "
697  "occ_f, size_type const *ind_list_begin, size_type const "
698  "*ind_list_end) const {\n"
699  << indent << " m_params.pre_eval();\n";
700 
701  ispec = 0;
702  for (auto const &specialization : specializations) {
703  if (specializations.size() > 1) {
704  ss << indent << " ";
705  if (ispec > 0) ss << "else ";
706  ss << "if(m_params.eval_mode() == " << specialization.first << ")";
707  }
708  ss << indent << " {\n"
709  << indent << " _point_prepare<" << specialization.second
710  << ">(nlist_ind);\n"
711  << indent
712  << " for(; ind_list_begin < ind_list_end; ind_list_begin++) {\n"
713  << indent << " ParamPack::Val<" << specialization.second
714  << ">::set(m_params, m_corr_param_key, *ind_list_begin, "
715  "(this->*m_delta_func_table_"
716  << ispec << "[nlist_ind][*ind_list_begin])(occ_i, occ_f));\n"
717  << indent << " }\n"
718  << indent << " }\n";
719  ++ispec;
720  }
721  ss << indent << " m_params.post_eval();\n" << indent << "}\n\n";
722 
723  return ss.str();
724 }
725 
726 } // namespace ClexBasisWriter_impl
727 } // namespace CASM
std::map< DoFKey, std::vector< BasisSet > > const & site_bases() const
Const access to dictionary of all site BasisSets.
Definition: ClexBasis.hh:95
std::map< DoFKey, std::vector< BasisSet > > const & global_bases() const
Const access to dictionary of all global BasisSets.
Definition: ClexBasis.hh:100
PrimType const & prim() const
Definition: ClexBasis.cc:71
Index n_functions() const
Total number of basis functions.
Definition: ClexBasis.cc:96
notstd::cloneable_ptr< ParamPackMixIn > m_param_pack_mix_in
ClexBasisWriter(Structure const &_prim, PARAM_PACK_TYPE const &param_pack_type)
Construct ClexBasisWriter, collecting requisite DoF info from '_prim'.
std::vector< std::unique_ptr< FunctionVisitor > > m_site_visitors
std::vector< std::unique_ptr< FunctionVisitor > > m_clust_visitors
void _initialize(Structure const &_prim, ParamPackMixIn const &parampack_mix_in)
virtual std::string clexulator_public_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:315
virtual std::string clexulator_private_method_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:331
virtual std::string clexulator_member_declarations_string(Structure const &_prim, std::vector< BasisSet > const &site_bases, std::string const &indent) const
Definition: DoFTraits.cc:269
virtual std::vector< ParamAllocation > param_pack_allocation(Structure const &_prim, std::vector< BasisSet > const &_bases) const
Definition: DoFTraits.cc:443
virtual std::vector< std::unique_ptr< FunctionVisitor > > clust_function_visitors() const
Definition: DoFTraits.cc:499
virtual std::vector< std::unique_ptr< FunctionVisitor > > site_function_visitors(std::string const &nlist_specifier="%n") const
Definition: DoFTraits.cc:491
ParamPackMixIn is interface class to control ClexParamPack portion of Clexulator printing Used primar...
static ParamPackMixIn basic_mix_in()
static factory function for BasicClexParamPack
static ParamPackMixIn diff_mix_in()
static factory function for DiffClexParamPack
std::map< std::string, std::string > const & scalar_specializations() const
Dictionary of pairs ("EvalMode", "ScalarType") These correspond to the underlying scalar type to be u...
std::unique_ptr< ParamPackMixIn > clone() const
Clone the ParamPackMixIn.
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:30
std::vector< DoFKey > all_local_dof_types(BasicStructure const &_struc)
std::vector< DoFKey > global_dof_types(BasicStructure const &_struc)
std::string clexulator_interface_declaration(std::string const &class_name, ClexBasis const &clex, ParamPackMixIn const &_param_pack_mix_in, std::string const &indent)
std::string clexulator_private_method_declarations(std::string const &class_name, ClexBasis const &clex, std::string const &indent)
std::string clexulator_member_declarations(std::string const &class_name, ClexBasis const &clex, ParamPackMixIn const &_param_pack_mix_in, std::vector< std::unique_ptr< OrbitFunctionTraits > > const &orbit_func_traits, Index N_flower, std::string const &indent)
std::string clexulator_public_method_declarations(std::string const &class_name, ClexBasis const &clex, std::string const &indent)
Traits const & traits(std::string const &dof_key)
Lookup DoFType::Traits in the global dictionary.
Definition: DoFTraits.cc:46
Main CASM namespace.
Definition: APICommand.hh:8
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39