1 #ifndef CASM_enum_enumerate_configurations_impl
2 #define CASM_enum_enumerate_configurations_impl
78 template <
typename MakeEnumeratorFunction,
typename InputNameValuePairIterator,
82 MakeEnumeratorFunction make_enumerator_f,
83 InputNameValuePairIterator name_value_pairs_begin,
84 InputNameValuePairIterator name_value_pairs_end,
87 std::pair<DB::Database<Configuration>::iterator,
bool> insert_result;
93 Index Ninit = configuration_db.size();
95 log <<
dry_run_msg <<
"# configurations in this project: " << Ninit
97 log <<
dry_run_msg <<
"Begin enumeration" << std::endl << std::endl;
100 std::unique_ptr<FormattedDataFileType> data_out_ptr;
103 notstd::make_unique<FormattedDataFileType>(options.
output_options);
107 auto it = name_value_pairs_begin;
108 for (; it != name_value_pairs_end; ++it) {
109 auto const &input_name_value_pair = *it;
112 Index count_filtered = 0;
113 Index num_before = configuration_db.size();
115 <<
"Enumerate configurations for: " << input_name_value_pair.first
120 input_name_value_pair.second);
125 input_name_value_pair.first,
126 input_name_value_pair.second,
132 if (!configuration.supercell().has_primclex()) {
133 configuration.supercell().set_primclex(options.
primclex_ptr);
138 data.is_excluded_by_filter =
true;
150 !data.is_excluded_by_filter)) {
151 (*data_out_ptr)(formatter, data);
155 Index num_after = configuration_db.size();
157 <<
" (" << (num_after - num_before) <<
" new, " << count_filtered
158 <<
" excluded by filter)." << std::endl
163 log <<
dry_run_msg <<
"Enumeration complete" << std::endl << std::endl;
165 Index Nfinal = configuration_db.size();
166 log <<
dry_run_msg <<
"# new configurations: " << Nfinal - Ninit <<
"\n";
167 log <<
dry_run_msg <<
"# configurations in this project: " << Nfinal <<
"\n"
171 log <<
"Write supercell database... " << std::flush;
172 supercell_db.commit();
173 log <<
"DONE" << std::endl;
175 log <<
"Write configuration database... " << std::flush;
176 configuration_db.commit();
177 log <<
"DONE" << std::endl;
180 log <<
"Write enumerated configurations: "
182 data_out_ptr.reset();
void end_section()
End a section.
void begin_section()
Begin a section, without header.
Log & subsection()
Create a subsection.
static const int standard
PrimClex is the top-level data structure for a CASM project.
Represents a supercell of the primitive parent crystal structure.
DB::Database< T > & db() const
GenericDatumFormatter< Index, ConfigEnumDataType > initial_state_index()
ConfigEnumData< ConfigEnumSiteDoFs, ConfigEnumInput > ConfigEnumDataType
ConfigInsertResult make_canonical_and_insert(Configuration const &configuration, Database< Supercell > &supercell_db, Database< Configuration > &configuration_db, bool primitive_only)
Insert this configuration (in primitive & canonical form) in the database.
std::string dry_run_msg(bool dry_run)
void enumerate_configurations(PrimClex const &primclex, ConfigEnumOptions const &options, MakeEnumeratorFunction make_enumerator_f, InputNameValuePairIterator name_value_pairs_begin, InputNameValuePairIterator name_value_pairs_end, DataFormatter< ConfigEnumDataType > const &formatter)
Enumerate configurations.
INDEX_TYPE Index
For long integer indexing:
Options for the enumerate_configurations function.
bool dry_run
If dry_run==true, do not save results, just print to screen.
FormattedDataFileOptions output_options
Options for construcing FormattedDataFile object.
std::function< bool(Configuration const &)> filter
If filter(configuration)==true, keep configuration, else skip.
bool output_filtered_configurations
If true, include output for configurations that were filtered out.
PrimClex const * primclex_ptr
Use while transitioning Supercell to no longer need a PrimClex const *
bool output_configurations