Loading...
Searching...
No Matches
composition_masked.h
Go to the documentation of this file.
#pragma once
#include <vector>
#include <set>
#include <unordered_map>
#include <memory>
#include <string>
#include "fourdst/composition/composition_abstract.h"
#include "fourdst/composition/decorators/composition_decorator_abstract.h"
#include "fourdst/composition/iterators/composition_abstract_iterator.h"
#include "fourdst/atomic/atomicSpecies.h"
namespace fourdst::composition {
class MaskedComposition final : public CompositionDecorator {
public:
using iterator = detail::CompositionIterator<false>;
using const_iterator = detail::CompositionIterator<true>;
MaskedComposition(
const CompositionAbstract& baseComposition,
const std::vector<atomic::Species>& activeSpecies
);
[[nodiscard]] bool contains(const atomic::Species &species) const noexcept override;
[[nodiscard]] bool contains(const std::string &symbol) const override;
[[nodiscard]] const std::vector<atomic::Species>& getRegisteredSpecies() const noexcept override;
[[nodiscard]] std::set<std::string> getRegisteredSymbols() const noexcept override;
[[nodiscard]] size_t size() const noexcept override;
[[nodiscard]] std::unordered_map<atomic::Species, double> getMassFraction() const noexcept override;
[[nodiscard]] std::unordered_map<atomic::Species, double> getNumberFraction() const noexcept override;
[[nodiscard]] double getMassFraction(const std::string &symbol) const override;
[[nodiscard]] double getMassFraction(const atomic::Species &species) const override;
[[nodiscard]] double getNumberFraction(const std::string &symbol) const override;
[[nodiscard]] double getNumberFraction(const atomic::Species &species) const override;
[[nodiscard]] double getMolarAbundance(const std::string &symbol) const override;
[[nodiscard]] double getMolarAbundance(const atomic::Species &species) const override;
[[nodiscard]] double getMeanParticleMass() const noexcept override;
[[nodiscard]] double getElectronAbundance() const noexcept override;
[[nodiscard]] std::vector<double> getMassFractionVector() const noexcept override;
[[nodiscard]] std::vector<double> getNumberFractionVector() const noexcept override;
[[nodiscard]] std::vector<double> getMolarAbundanceVector() const noexcept override;
[[nodiscard]] size_t getSpeciesIndex(const std::string &symbol) const override;
[[nodiscard]] size_t getSpeciesIndex(const atomic::Species &species) const override;
[[nodiscard]] atomic::Species getSpeciesAtIndex(size_t index) const override;
[[nodiscard]] std::unique_ptr<CompositionAbstract> clone() const override;
[[nodiscard]] iterator begin() override;
[[nodiscard]] iterator end() override;
[[nodiscard]] const_iterator begin() const override;
[[nodiscard]] const_iterator end() const override;
[[nodiscard]] size_t hash() const override;
private:
std::vector<atomic::Species> m_activeSpecies;
std::vector<double> m_molarAbundances;
};
}
atomicSpecies.h
fourdst::composition::CompositionAbstract
Abstract base class for chemical composition representations.
Definition composition_abstract.h:36
fourdst::composition::CompositionDecorator::CompositionDecorator
CompositionDecorator(std::unique_ptr< CompositionAbstract > decorator)
Definition composition_decorator_abstract.h:18
fourdst::composition::MaskedComposition::contains
bool contains(const atomic::Species &species) const noexcept override
Check if the composition contains the given species.
Definition composition_masked.cpp:37
fourdst::composition::MaskedComposition::hash
size_t hash() const override
Definition composition_masked.cpp:234
fourdst::composition::MaskedComposition::m_activeSpecies
std::vector< atomic::Species > m_activeSpecies
Definition composition_masked.h:65
fourdst::composition::MaskedComposition::getMassFraction
std::unordered_map< atomic::Species, double > getMassFraction() const noexcept override
Get the mass fraction for all registered symbols.
Definition composition_masked.cpp:65
fourdst::composition::MaskedComposition::getNumberFraction
std::unordered_map< atomic::Species, double > getNumberFraction() const noexcept override
Get the number fraction for all registered symbols.
Definition composition_masked.cpp:77
fourdst::composition::MaskedComposition::getMolarAbundance
double getMolarAbundance(const std::string &symbol) const override
Get the molar abundance for a given symbol.
Definition composition_masked.cpp:121
fourdst::composition::MaskedComposition::clone
std::unique_ptr< CompositionAbstract > clone() const override
Definition composition_masked.cpp:214
fourdst::composition::MaskedComposition::getElectronAbundance
double getElectronAbundance() const noexcept override
Get the electron abundance of the composition.
Definition composition_masked.cpp:149
fourdst::composition::MaskedComposition::getMeanParticleMass
double getMeanParticleMass() const noexcept override
Get the mean particle mass of the composition.
Definition composition_masked.cpp:137
fourdst::composition::MaskedComposition::getRegisteredSpecies
const std::vector< atomic::Species > & getRegisteredSpecies() const noexcept override
Get all registered atomic species in the composition.
Definition composition_masked.cpp:49
fourdst::composition::MaskedComposition::size
size_t size() const noexcept override
Definition composition_masked.cpp:61
fourdst::composition::MaskedComposition::getSpeciesIndex
size_t getSpeciesIndex(const std::string &symbol) const override
Get the index of a species by symbol.
Definition composition_masked.cpp:186
fourdst::composition::MaskedComposition::getMassFractionVector
std::vector< double > getMassFractionVector() const noexcept override
Get the mass fraction as a vector.
Definition composition_masked.cpp:159
fourdst::composition::MaskedComposition::MaskedComposition
MaskedComposition(const CompositionAbstract &baseComposition, const std::vector< atomic::Species > &activeSpecies)
Definition composition_masked.cpp:15
fourdst::composition::MaskedComposition::getRegisteredSymbols
std::set< std::string > getRegisteredSymbols() const noexcept override
Get all registered chemical symbols in the composition.
Definition composition_masked.cpp:53
fourdst::composition::MaskedComposition::begin
iterator begin() override
Definition composition_masked.cpp:218
fourdst::composition::MaskedComposition::end
iterator end() override
Definition composition_masked.cpp:222
fourdst::composition::MaskedComposition::m_molarAbundances
std::vector< double > m_molarAbundances
Definition composition_masked.h:66
fourdst::composition::MaskedComposition::getMolarAbundanceVector
std::vector< double > getMolarAbundanceVector() const noexcept override
Get the molar abundance as a vector.
Definition composition_masked.cpp:177
fourdst::composition::MaskedComposition::getSpeciesAtIndex
atomic::Species getSpeciesAtIndex(size_t index) const override
Get the species at a given index.
Definition composition_masked.cpp:205
fourdst::composition::MaskedComposition::const_iterator
detail::CompositionIterator< true > const_iterator
Definition composition_masked.h:18
fourdst::composition::MaskedComposition::getNumberFractionVector
std::vector< double > getNumberFractionVector() const noexcept override
Get the number fraction as a vector.
Definition composition_masked.cpp:168
fourdst::composition::MaskedComposition::iterator
detail::CompositionIterator< false > iterator
Definition composition_masked.h:17
fourdst::composition::detail::CompositionIterator
Definition composition_abstract_iterator.h:13
composition_abstract.h
composition_abstract_iterator.h
composition_decorator_abstract.h
fourdst::atomic
Contains canonical information about atomic species and elements used by 4D-STAR.
fourdst::composition
Utilities and types for representing and manipulating chemical compositions.
fourdst::atomic::Species
Represents an atomic species (isotope) with its fundamental physical properties.
Definition atomicSpecies.h:52