-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'species_set' into 'master'
Add a species_set class with all the species objects See merge request npneq/inq!1098
- Loading branch information
Showing
9 changed files
with
282 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* -*- indent-tabs-mode: t -*- */ | ||
|
||
#ifndef INQ__IONIC__SPECIES_SET | ||
#define INQ__IONIC__SPECIES_SET | ||
|
||
// Copyright (C) 2019-2024 Lawrence Livermore National Security, LLC., Xavier Andrade, Alfredo A. Correa | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#include <input/species.hpp> | ||
|
||
namespace inq { | ||
namespace ionic { | ||
|
||
class species_set { | ||
|
||
using container_type = std::unordered_map<std::string, input::species>; | ||
|
||
container_type list_; | ||
|
||
public: | ||
|
||
auto size() const { | ||
return (long) list_.size(); | ||
} | ||
|
||
auto & list() const { | ||
return list_; | ||
} | ||
|
||
auto insert(input::species const & sp) { | ||
list_.insert_or_assign(sp.symbol(), sp); | ||
} | ||
|
||
auto & operator[](std::string const & symbol) const{ | ||
return list_.at(symbol); | ||
} | ||
|
||
struct const_iterator { | ||
|
||
container_type::const_iterator base_iter; | ||
|
||
auto operator!=(const_iterator const & other) const { | ||
return base_iter != other.base_iter; | ||
} | ||
|
||
auto operator++() { | ||
return const_iterator{++base_iter}; | ||
} | ||
|
||
auto operator*() const { | ||
return base_iter->second; | ||
} | ||
|
||
}; | ||
|
||
auto begin() const { | ||
return const_iterator{list_.begin()}; | ||
} | ||
|
||
auto end() const { | ||
return const_iterator{list_.end()}; | ||
} | ||
|
||
}; | ||
|
||
} | ||
} | ||
#endif | ||
|
||
#ifdef INQ_IONIC_SPECIES_SET_UNIT_TEST | ||
#undef INQ_IONIC_SPECIES_SET_UNIT_TEST | ||
|
||
#include <catch2/catch_all.hpp> | ||
|
||
TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG) { | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.