Skip to content
Snippets Groups Projects
Commit eff5f7c9 authored by Marcin Kirsz's avatar Marcin Kirsz
Browse files

Counting structures

parent 382a22e1
No related branches found
No related tags found
No related merge requests found
Pipeline #37187 passed
Pipeline: Tadah.MLIP

#37188

    ...@@ -199,7 +199,6 @@ int Structure::next_structure(std::ifstream &ifs) { ...@@ -199,7 +199,6 @@ int Structure::next_structure(std::ifstream &ifs) {
    while(std::getline(ifs,line)) { while(std::getline(ifs,line)) {
    if(line.empty()) break; if(line.empty()) break;
    if(line == "\r") break; // detects windows newline if(line == "\r") break; // detects windows newline
    } }
    return 0; return 0;
    } }
    ...@@ -259,7 +259,7 @@ struct Structure { ...@@ -259,7 +259,7 @@ struct Structure {
    // move iterator forward to the next structure // move iterator forward to the next structure
    // return 0 if success // return 0 if success
    // return 1 if there is no more structures // return 1 if there is no more structures
    static int next_structure(std::ifstream &ifs) const; static int next_structure(std::ifstream &ifs);
    private: private:
    const static size_t w=15; // controls output width const static size_t w=15; // controls output width
    ......
    ...@@ -78,14 +78,14 @@ std::unordered_set<Element> StructureDB::get_unique_elements() { ...@@ -78,14 +78,14 @@ std::unordered_set<Element> StructureDB::get_unique_elements() {
    st.unique_elements.begin(),st.unique_elements.end()); st.unique_elements.begin(),st.unique_elements.end());
    return s; return s;
    } }
    int StructureDB::count_structures(const Config &c) { int StructureDB::count_structures(const Config &config) {
    int count=0; int count=0;
    for (const std::string &s : config("DBFILE")) { for (const std::string &fn : config("DBFILE")) {
    count += count_structures(fn)'' count += count_structures(fn);
    } }
    return count; return count;
    } }
    int StructureDB::count_structures(const std::string fn) const { int StructureDB::count_structures(const std::string fn){
    int count=0; int count=0;
    std::ifstream ifs(fn); std::ifstream ifs(fn);
    ...@@ -93,7 +93,7 @@ int StructureDB::count_structures(const std::string fn) const { ...@@ -93,7 +93,7 @@ int StructureDB::count_structures(const std::string fn) const {
    throw std::runtime_error("DBFILE does not exist: "+fn); throw std::runtime_error("DBFILE does not exist: "+fn);
    } }
    while(Structure::next_structure(ifs)) { while(!Structure::next_structure(ifs)) {
    count++; count++;
    } }
    ......
    ...@@ -124,7 +124,7 @@ struct StructureDB { ...@@ -124,7 +124,7 @@ struct StructureDB {
    /** Return unique elements for all Structures */ /** Return unique elements for all Structures */
    std::unordered_set<Element> get_unique_elements(); std::unordered_set<Element> get_unique_elements();
    static int count_structures(const Config &c) const; static int count_structures(const Config &c);
    static int count_structures(const std::string fn) const; static int count_structures(const std::string fn);
    }; };
    #endif #endif
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment