diff --git a/BaseSolvers/AgglomerationSolver.h b/BaseSolvers/AgglomerationSolver.h index ff0afeba..6ba7848f 100644 --- a/BaseSolvers/AgglomerationSolver.h +++ b/BaseSolvers/AgglomerationSolver.h @@ -6,87 +6,115 @@ #include "BaseSolver.h" #include +/** + * \brief Agglomeration solver. + */ class CAgglomerationSolver : public CBaseSolver { public: + /** + * \brief Types of agglomeration kernels. + */ enum class EKernels : size_t { - CONSTANT = 0, - SUM = 1, - PRODUCT = 2, - BROWNIAN = 3, - SHEAR = 4, - PEGLOW = 5, - COAGULATION = 6, - GRAVITATIONAL = 7, - EKE = 8, - THOMPSON = 9, - CUSTOM = 10, + CONSTANT = 0, ///< Constant kernel. + SUM = 1, ///< Sum kernel. + PRODUCT = 2, ///< Product kernel. + BROWNIAN = 3, ///< Brownian kernel. + SHEAR = 4, ///< Shear kernel. + PEGLOW = 5, ///< Peglow kernel. + COAGULATION = 6, ///< Coagulation kernel. + GRAVITATIONAL = 7, ///< Gravitational kernel. + EKE = 8, ///< Equipartition kinetic energy kernel. + THOMPSON = 9, ///< Thompson kernel. + CUSTOM = 10, ///< Custom kernel. }; protected: - using u_matr_t = std::vector>; - using d_matr_t = std::vector>; - using u_vect_t = std::vector; - using d_vect_t = std::vector; + using u_matr_t = std::vector>; ///< Matrix of size_t. + using d_matr_t = std::vector>; ///< Matrix of double. + using u_vect_t = std::vector; ///< Vector of size_t. + using d_vect_t = std::vector; ///< Vector of double. - using kernel_t = double(double, double); // Type of the kernel function. + using kernel_t = double(double, double); ///< Type of the kernel function. - EKernels m_kernel{ EKernels::BROWNIAN }; // Selected kernel function. - double m_beta0{ 1.0 }; // Size independent agglomeration rate (set zero for no agglomeration). - std::vector m_parameters; // Additional parameters. - std::vector m_grid; // Diameter-related PSD grid. - std::function m_CutomKernel{}; // Custom kernel function. + EKernels m_kernel{ EKernels::BROWNIAN }; ///< Selected kernel function. + double m_beta0{ 1.0 }; ///< Size independent agglomeration rate (set zero for no agglomeration). + std::vector m_parameters; ///< Additional parameters. + std::vector m_grid; ///< Diameter-related PSD grid. + std::function m_CutomKernel{}; ///< Custom kernel function. public: + /** + * \private + */ CAgglomerationSolver(); + /** + * \private + */ ~CAgglomerationSolver() override = default; + /** + * \private + */ CAgglomerationSolver(const CAgglomerationSolver& _other) = default; + /** + * \private + */ CAgglomerationSolver(CAgglomerationSolver && _other) = default; + /** + * \private + */ CAgglomerationSolver& operator=(const CAgglomerationSolver & _other) = default; + /** + * \private + */ CAgglomerationSolver& operator=(CAgglomerationSolver && _other) = default; - /// - /// Sets all required parameters and calls Initialize() - /// - /// Diameter-related PSD grid - /// Size independent agglomeration rate - /// Type of the agglomeration kernel - /// Additional parameters + /** + * \brief Sets all required parameters and calls Initialize() + * \param _grid Diameter-related PSD grid + * \param _beta0 Size independent agglomeration rate + * \param _kernel Type of the agglomeration kernel + * \param _parameters Additional parameters + */ void Initialize(const d_vect_t& _grid, double _beta0, EKernels _kernel, const d_vect_t& _parameters = d_vect_t()); - /// - /// Sets all required parameters and calls Initialize() - /// - /// Diameter-related PSD grid - /// Size independent agglomeration rate - /// Function of the agglomeration kernel - /// Additional parameters + /** + * \brief Sets all required parameters and calls Initialize() + * \param _grid Diameter-related PSD grid + * \param _beta0 Size independent agglomeration rate + * \param _kernel Function of the agglomeration kernel + * \param _parameters Additional parameters + */ void Initialize(const d_vect_t& _grid, double _beta0, const std::function& _kernel, const d_vect_t& _parameters = d_vect_t()); - /// - /// Actual initialization of the solver. - /// + /** + * \brief Actual initialization of the solver. + */ void Initialize() override; - /// - /// Main calculation function - /// - /// Number distribution - /// Output vector for birth rate - /// Output vector for death rate + /** + * \brief Main calculation function + * \param _n Number distribution + * \param _rateB Output vector for birth rate + * \param _rateD Output vector for death rate + */ virtual void Calculate(const d_vect_t& _n, d_vect_t& _rateB, d_vect_t& _rateD); - /// - /// Main calculation function - /// - /// Number distribution - /// Birth and death rates + /** + * \brief Main calculation function + * \param _n Number distribution + * \return Birth and death rates + */ std::pair Calculate(const d_vect_t& _n); protected: - // Calculates the chosen kernel function for particles with volumes _u and _v. + /** + * Calculates the chosen kernel function for particles with volumes _u and _v. + */ [[nodiscard]] double Kernel(double _u, double _v) const; private: - // Sets all parameters. + /** + * Sets all parameters. + */ void SetParameters(const d_vect_t& _grid, double _beta0, EKernels _kernel, const std::function& _kernelFun, const d_vect_t& _parameters); }; diff --git a/BaseSolvers/BaseSolver.h b/BaseSolvers/BaseSolver.h index f5a83151..b0b78d24 100644 --- a/BaseSolvers/BaseSolver.h +++ b/BaseSolvers/BaseSolver.h @@ -42,67 +42,129 @@ enum class ESolverTypes : uint32_t #define CREATE_SOLVER_FUN(X) MACRO_CONCAT(CREATE_SOLVER_FUNCTION_CONF, X) #define CREATE_SOLVER_FUN_NAME(X) MACRO_TOSTRING(CREATE_SOLVER_FUN(X)) +/** + * \brief Base solver. + */ class CBaseSolver { protected: - ESolverTypes m_type{ ESolverTypes::SOLVER_NONE }; // Type of the solver (SOLVER_AGGLOMERATION_1/SOLVER_PBM_1/...). - std::string m_name{}; // User-friendly name of the solver. - std::string m_authorName{}; // Name of solver's author. - std::string m_uniqueID{}; // Unique identifier of the solver. - std::string m_helpLink{}; // Link to help file for solver. - size_t m_version{}; // Version of the solver. - size_t m_compilerVersion{ COMPILER_VERSION }; // Version of compiler used to build the solver. + ESolverTypes m_type{ ESolverTypes::SOLVER_NONE }; ///< Type of the solver (SOLVER_AGGLOMERATION_1/SOLVER_PBM_1/...). + std::string m_name{}; ///< User-friendly name of the solver. + std::string m_authorName{}; ///< Name of solver's author. + std::string m_uniqueID{}; ///< Unique identifier of the solver. + std::string m_helpLink{}; ///< Link to help file for solver. + size_t m_version{}; ///< Version of the solver. + size_t m_compilerVersion{ COMPILER_VERSION }; ///< Version of compiler used to build the solver. public: + /** + * \private + */ CBaseSolver() = default; + /** + * \private + */ virtual ~CBaseSolver() = default; + /** + * \private + */ CBaseSolver(const CBaseSolver& _other) = default; + /** + * \private + */ CBaseSolver(CBaseSolver&& _other) = default; + /** + * \private + */ CBaseSolver& operator=(const CBaseSolver& _other) = default; + /** + * \private + */ CBaseSolver& operator=(CBaseSolver&& _other) = default; - // Returns type to which belongs this solver. + /** + * \brief Returns type to which belongs this solver. + * \return Solver's type. + */ ESolverTypes GetType() const; - // Returns name of solver. + /** + * \brief Returns name of solver. + * \return Solver's name. + */ std::string GetName() const; - // Returns name of the solver's author. + /** + * \brief Returns name of the solver's author. + * \return Author's type. + */ std::string GetAuthorName() const; - // Returns version of solver. + /** + * \brief Returns version of solver. + * \return Solver's version. + */ size_t GetVersion() const; - // Returns string key, unique for all solvers. + /** + * \brief Returns string key, unique for all solvers. + * \return Solver's unique ID. + */ std::string GetUniqueID() const; /** - * \brief Returns the help link of the solver. - * \return Help link of the solver. - */ + * \brief Returns the help link of the solver. + * \return Help link of the solver. + */ std::string GetHelpLink() const; - // Sets the name of the solver. + /** + * \brief Sets the name of the solver. + * \param _name Solver's name. + */ void SetName(const std::string& _name); - // Sets the name of solver's author. + /** + * \brief Sets the name of solver's author. + * \param _author Solver's author. + */ void SetAuthorName(const std::string& _author); - // Sets the version of the solver. + /** + * \brief Sets the version of the solver. + * \param _version Solver's version. + */ void SetVersion(size_t _version); - // Sets the unique identifier of the solver. + /** + * \brief Sets the unique identifier of the solver. + * \param _id Solver's unique ID. + */ void SetUniqueID(const std::string& _id); /** - * \brief Sets the help link of the solver. - * \param _helpLink Help link of the solver. - */ + * \brief Sets the help link of the solver. + * \param _helpLink Help link of the solver. + */ void SetHelpLink(const std::string& _helpLink); - // Will be called once during creation of the solver (name, author, key, version). + /** + * \brief Will be called once during creation of the solver (name, author, key, version). + */ virtual void CreateBasicInfo() = 0; - // Will be called to initialize the solver. + /** + * \brief Will be called to initialize the solver. + */ virtual void Initialize(); - // Will be called once after the whole simulation is finished. + /** + * \brief Will be called once after the whole simulation is finished. + */ virtual void Finalize(); - // Will be called when storing of current internal state is needed. + /** + * \brief Will be called when storing of current internal state is needed. + */ virtual void SaveState(); - // Will be called when loading of last stored internal state is needed. + /** + * \brief Will be called when loading of last stored internal state is needed. + */ virtual void LoadState(); protected: + /** + * \brief Sets an error state of the solver, prints the message to the simulation log, and requests to stop simulation. + * \param _message Message to show in the simulation log. + */ [[noreturn]] void RaiseError(const std::string& _message) const; }; diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b55f0d4..0c767423 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,6 +226,7 @@ IF(BUILD_DOCS) "BaseSolvers/AgglomerationSolver" "BaseSolvers/BaseSolver" "Utilities/DyssolDefines" + "Utilities/DyssolTypes" ) # Gather all API headers diff --git a/Documentation/004_development/api.rst b/Documentation/004_development/api.rst index 3d0f87b3..0297f6b3 100644 --- a/Documentation/004_development/api.rst +++ b/Documentation/004_development/api.rst @@ -22,7 +22,10 @@ All functions, classes, their member variables and methods, needed to develop ne class_basesolver class_statevariablesmanager class_statevariable + class_point + class_curve class_plot + class_plotmanager class_mixtureenthalpylookup class_matrix2d class_densemdmatrix diff --git a/Documentation/004_development/class_curve.rst b/Documentation/004_development/class_curve.rst new file mode 100644 index 00000000..d80178d4 --- /dev/null +++ b/Documentation/004_development/class_curve.rst @@ -0,0 +1,8 @@ +.. _sec.development.api.class_curve: + +Curve +===== + +.. doxygenclass:: CCurve + :project: dyssol_models_api + :members: \ No newline at end of file diff --git a/Documentation/004_development/class_plot.rst b/Documentation/004_development/class_plot.rst index e620017d..b665404a 100644 --- a/Documentation/004_development/class_plot.rst +++ b/Documentation/004_development/class_plot.rst @@ -4,14 +4,5 @@ Plot ==== .. doxygenclass:: CPlot - :project: dyssol_models_api - :members: - -.. _sec.development.api.class_curve: - -Curve -===== - -.. doxygenclass:: CCurve :project: dyssol_models_api :members: \ No newline at end of file diff --git a/Documentation/004_development/class_plotmanager.rst b/Documentation/004_development/class_plotmanager.rst new file mode 100644 index 00000000..1809f70b --- /dev/null +++ b/Documentation/004_development/class_plotmanager.rst @@ -0,0 +1,8 @@ +.. _sec.development.api.class_plotmanager: + +Plot manager +============ + +.. doxygenclass:: CPlotManager + :project: dyssol_models_api + :members: \ No newline at end of file diff --git a/Documentation/004_development/class_point.rst b/Documentation/004_development/class_point.rst new file mode 100644 index 00000000..75b6e463 --- /dev/null +++ b/Documentation/004_development/class_point.rst @@ -0,0 +1,8 @@ +.. _sec.development.api.class_point: + +Point +===== + +.. doxygenclass:: CPoint + :project: dyssol_models_api + :members: \ No newline at end of file diff --git a/Documentation/004_development/constants.rst b/Documentation/004_development/constants.rst index f91852d5..104372f5 100644 --- a/Documentation/004_development/constants.rst +++ b/Documentation/004_development/constants.rst @@ -67,4 +67,4 @@ Dyssol constants :project: dyssol_models_api .. doxygenenum:: ESolverTypes - :project: dyssol_models_api \ No newline at end of file + :project: dyssol_models_api diff --git a/Documentation/004_development/old_api.rst b/Documentation/004_development/old_api.rst deleted file mode 100644 index 6586338f..00000000 --- a/Documentation/004_development/old_api.rst +++ /dev/null @@ -1,101 +0,0 @@ -.. _sec.old_classes: - -======= -Old API -======= - -Matrices -======== - -Several types of matrix classes, including the following types, are introduced in this section. - -- Dense 2-dimensional matrix: ``CDense2DMatrix``. - -- Dense multidimensional matrix: ``CDenseMDMatrix``. - -| - -Two-dimensional matrix ----------------------- - -Basic information and functions of class ``CDense2DMatrix`` are introduced below. - -| - -.. code-block:: cpp - - CDense2DMatrix(CDense2DMatrix &_matrix) - -**Copy constructor**. Creates matrix with the same dimensions as in ``_matrix`` and copies all data. - -| - -Get data -"""""""" - -.. code-block:: cpp - - double GetValue(unsigned _nRow, unsigned _nColumn) - -Returns data by the specified indexes. Returns ``0`` if such indexes do not exist. - -| - -Set data -"""""""" - -.. code-block:: cpp - - void SetValue(unsigned _nRow, unsigned _ nColumn, double _dValue) - -Sets data ``_dValue`` by the specified indexes. - -| - -Overloaded operators -"""""""""""""""""""" - -.. code-block:: cpp - - CDense2DMatrix& operator=(const CDense2DMatrix &_matrix) - -Sets dimenions and data from the ``_matrix`` to a left matrix. - -| - -Other functions -""""""""""""""" - -.. code-block:: cpp - - void ClearData() - -Sets all elements in matrix to 0. - -| - -Multidimensional matrix ------------------------ - -Basic information and functions of class ``CDenseMDMatrix`` are introduced below. - -| - -.. code-block:: cpp - - CDenseMDMatrix(const CDenseMDMatrix &_source) - -**Copy constructor**. Creates matrix with the same dimensions as in ``_source`` and copies all data from there. - -| - -Overloaded operators -"""""""""""""""""""" - -.. code-block:: cpp - - CDenseMDMatrix& operator=(const CDenseMDMatrix &_matrix) - -Sets dimenions and data from the ``_matrix`` to a left matrix. - -| \ No newline at end of file diff --git a/Documentation/index.rst b/Documentation/index.rst index 178b8e4e..5644b477 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -71,7 +71,6 @@ Contents 004_development/compilation 004_development/models_development 004_development/api - 004_development/old_api | diff --git a/MaterialsDatabase/DefinesMDB.h b/MaterialsDatabase/DefinesMDB.h index 560ee50c..41a2f1c8 100644 --- a/MaterialsDatabase/DefinesMDB.h +++ b/MaterialsDatabase/DefinesMDB.h @@ -20,16 +20,19 @@ namespace MDBDescriptors { - const std::string SIGNATURE_STRING = "DyssolMaterialsDatabase"; - const unsigned VERSION = 3; + const std::string SIGNATURE_STRING = "DyssolMaterialsDatabase"; ///< Signature string to recognize materials database file. + const unsigned VERSION = 3; ///< Version of the materials database file. - const std::string DEFAULT_MDB_FILE_NAME = "Materials.dmdb"; + const std::string DEFAULT_MDB_FILE_NAME = "Materials.dmdb"; ///< Default name of the materials database file. - const double TEMP_MIN = 10; - const double TEMP_MAX = 10000; - const double PRES_MIN = 10e+2; - const double PRES_MAX = 10e+8; + const double TEMP_MIN = 10; ///< Minimum temperature. + const double TEMP_MAX = 10000; ///< Maximum temperature. + const double PRES_MIN = 10e+2; ///< Minimum pressure. + const double PRES_MAX = 10e+8; ///< Maximum pressure. + /** + * \brief Type of the material property. + */ enum class EPropertyType : unsigned { CONSTANT = 0, @@ -37,9 +40,9 @@ namespace MDBDescriptors INTERACTION = 2 }; - const size_t MAX_USER_DEFINED_PROP_NUMBER = 20; /// Number of properties of each type, which user is allowed to add (0, 50]. + const size_t MAX_USER_DEFINED_PROP_NUMBER = 20; ///< Number of properties of each type, which user is allowed to add (0, 50]. - const std::string NEW_LINE_REPLACER = "%@#"; + const std::string NEW_LINE_REPLACER = "%@#"; ///< Symbols to replace the new line symbol. } @@ -64,6 +67,10 @@ enum class ECorrelationTypes : unsigned namespace MDBDescriptors { + /** + * \private + * \brief Description of the correlation property. + */ struct SCorrelationDescriptor { std::string name; @@ -134,7 +141,10 @@ enum ECompoundConstProperties : unsigned namespace MDBDescriptors { - // Base structure to describe initial values of all parameters + /** + * \private + * \brief Base structure to describe initial values of all parameters. + */ struct SCompoundPropertyDescriptor { std::string name; @@ -150,7 +160,10 @@ namespace MDBDescriptors SCompoundPropertyDescriptor& operator=(SCompoundPropertyDescriptor&& _other) = default; }; - // Initial values of all parameters of a CConstProperty + /** + * \private + * \brief Initial values of all parameters of a CConstProperty. + */ struct SCompoundConstPropertyDescriptor : SCompoundPropertyDescriptor { double defaultValue{}; @@ -159,6 +172,9 @@ namespace MDBDescriptors : SCompoundPropertyDescriptor{ _name, _units, _description }, defaultValue{ _defaultValue } {} }; + /** + * \private + */ using constDescr = std::map; // List of initial values of const properties @@ -221,7 +237,10 @@ enum ECompoundTPProperties : unsigned namespace MDBDescriptors { - // Initial values of all parameters of a CTPDProperty + /** + * \private + * \brief Initial values of all parameters of a CTPDProperty. + */ struct SCompoundTPDPropertyDescriptor : SCompoundPropertyDescriptor { ECorrelationTypes defuaultType{ ECorrelationTypes::CONSTANT }; @@ -231,6 +250,9 @@ namespace MDBDescriptors : SCompoundPropertyDescriptor{ _name, _units, _description }, defuaultType{ _defuaultType }, defaultParameters{std::move(_defaultValue)} {} }; + /** + * \private + */ using tpdepDescr = std::map; // List of initial values of temperature/pressure - dependent properties @@ -284,6 +306,9 @@ enum EInteractionProperties : unsigned namespace MDBDescriptors { + /** + * \private + */ using interDescr = std::map; // List of descriptors of temperature/pressure-dependent properties @@ -295,10 +320,14 @@ namespace MDBDescriptors namespace MDBDescriptors { - const unsigned FIRST_CONST_USER_PROP = CONST_PROP_USER_DEFINED_01; - const unsigned FIRST_TPDEP_USER_PROP = TP_PROP_USER_DEFINED_01; - const unsigned FIRST_INTER_USER_PROP = INT_PROP_USER_DEFINED_01; - + const unsigned FIRST_CONST_USER_PROP = CONST_PROP_USER_DEFINED_01; ///< Identifier of the first constant property. + const unsigned FIRST_TPDEP_USER_PROP = TP_PROP_USER_DEFINED_01; ///< Identifier of the first dependent property. + const unsigned FIRST_INTER_USER_PROP = INT_PROP_USER_DEFINED_01; ///< Identifier of the first interaction property. + + /** + * \private + * \brief Descriptor of the material property. + */ struct SPropertyDescriptor { EPropertyType type{ EPropertyType::CONSTANT }; diff --git a/ModelsAPI/ChemicalReaction.cpp b/ModelsAPI/ChemicalReaction.cpp index 44dcd742..6be18ce7 100644 --- a/ModelsAPI/ChemicalReaction.cpp +++ b/ModelsAPI/ChemicalReaction.cpp @@ -1,4 +1,6 @@ -/* Copyright (c) 2021, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2021, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #include "ChemicalReaction.h" #include "MaterialsDatabase.h" @@ -16,7 +18,7 @@ CChemicalReaction::CChemicalReaction(const CChemicalReaction& _other) m_substances.clear(); m_substances.reserve(_other.m_substances.size()); for (const auto& s : _other.m_substances) - m_substances.emplace_back(new SChemicalSubstanse{ *s }); + m_substances.emplace_back(new SChemicalSubstance{ *s }); } CChemicalReaction& CChemicalReaction::operator=(const CChemicalReaction& _other) @@ -44,14 +46,14 @@ std::string CChemicalReaction::GetName() const return m_name; } -CChemicalReaction::SChemicalSubstanse* CChemicalReaction::AddSubstance() +CChemicalReaction::SChemicalSubstance* CChemicalReaction::AddSubstance() { return m_substances.emplace_back().get(); } -void CChemicalReaction::AddSubstance(const SChemicalSubstanse& _substance) +void CChemicalReaction::AddSubstance(const SChemicalSubstance& _substance) { - m_substances.emplace_back(new SChemicalSubstanse{ _substance }); + m_substances.emplace_back(new SChemicalSubstance{ _substance }); } void CChemicalReaction::RemoveSubstance(size_t _index) @@ -60,17 +62,17 @@ void CChemicalReaction::RemoveSubstance(size_t _index) m_substances.erase(m_substances.begin() + _index); } -std::vector CChemicalReaction::GetSubstances() const +std::vector CChemicalReaction::GetSubstances() const { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (const auto& s : m_substances) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances() +std::vector CChemicalReaction::GetSubstances() { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (auto& s : m_substances) res.emplace_back(s.get()); return res; @@ -81,54 +83,54 @@ size_t CChemicalReaction::GetSubstancesNumber() const return m_substances.size(); } -std::vector CChemicalReaction::GetSubstances(EPhase _phase) const +std::vector CChemicalReaction::GetSubstances(EPhase _phase) const { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (const auto& s : m_substances) if (s->phase == _phase) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances(EPhase _phase) +std::vector CChemicalReaction::GetSubstances(EPhase _phase) { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (auto& s : m_substances) if (s->phase == _phase) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances(ESubstance _type) const +std::vector CChemicalReaction::GetSubstances(ESubstance _type) const { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (const auto& s : m_substances) if (_type == s->GetType()) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances(ESubstance _type) +std::vector CChemicalReaction::GetSubstances(ESubstance _type) { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (auto& s : m_substances) if (_type == s->GetType()) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances(EPhase _phase, ESubstance _type) const +std::vector CChemicalReaction::GetSubstances(EPhase _phase, ESubstance _type) const { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (const auto& s : m_substances) if (s->phase == _phase && _type == s->GetType()) res.emplace_back(s.get()); return res; } -std::vector CChemicalReaction::GetSubstances(EPhase _phase, ESubstance _type) +std::vector CChemicalReaction::GetSubstances(EPhase _phase, ESubstance _type) { - auto res = ReservedVector(m_substances.size()); + auto res = ReservedVector(m_substances.size()); for (auto& s : m_substances) if (s->phase == _phase && _type == s->GetType()) res.emplace_back(s.get()); @@ -141,13 +143,13 @@ void CChemicalReaction::SetBaseSubstance(size_t _index) m_iBase = _index; } -const CChemicalReaction::SChemicalSubstanse* CChemicalReaction::GetBaseSubstance() const +const CChemicalReaction::SChemicalSubstance* CChemicalReaction::GetBaseSubstance() const { if (m_iBase >= m_substances.size()) return nullptr; return m_substances[m_iBase].get(); } -CChemicalReaction::SChemicalSubstanse* CChemicalReaction::GetBaseSubstance() +CChemicalReaction::SChemicalSubstance* CChemicalReaction::GetBaseSubstance() { if (m_iBase >= m_substances.size()) return nullptr; return m_substances[m_iBase].get(); @@ -208,7 +210,7 @@ void CChemicalReaction::LoadFromFile(const CH5Handler& _h5File, const std::strin m_substances.reserve(number); for (size_t i = 0; i < number; ++i) { - m_substances.emplace_back(new SChemicalSubstanse); + m_substances.emplace_back(new SChemicalSubstance); const std::string group = _path + "/" + StrConst::Reac_H5Substance + std::to_string(i); _h5File.ReadData(group, StrConst::Reac_H5SubstanceKey , m_substances.back()->key); _h5File.ReadData(group, StrConst::Reac_H5SubstanceNu , m_substances.back()->nu); diff --git a/ModelsAPI/ChemicalReaction.h b/ModelsAPI/ChemicalReaction.h index d79dc558..92944d27 100644 --- a/ModelsAPI/ChemicalReaction.h +++ b/ModelsAPI/ChemicalReaction.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2021, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2021, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #pragma once @@ -11,101 +13,235 @@ class CMaterialsDatabase; class CH5Handler; +/** + * \brief Description of the chemical reaction. + */ class CChemicalReaction { static const unsigned m_saveVersion{ 0 }; // Current version of the saving procedure. public: + /** + * \brief Substance type. + */ enum class ESubstance { - REACTANT, PRODUCT + REACTANT, ///< Educt substance. + PRODUCT, ///< Product substance. }; - struct SChemicalSubstanse + /** + * \brief Description of the chemical substance. + */ + struct SChemicalSubstance { - std::string key; // Unique key of the chemical substance from MDB. - double nu{ 1.0 }; // Stoichiometric coefficient of this substance in the reaction. - double order{ 0.0 }; // Partial order of reaction for this substance. - EPhase phase{ EPhase::UNDEFINED }; // Phase of this substance. - - double MM{}; // Molar mass of this substance. - - SChemicalSubstanse() = default; - // Creates a new substance. _nu > 0: product, _nu < 0: reactant. - SChemicalSubstanse(std::string _key, double _nu, double _order, EPhase _phase) : key{ std::move(_key) }, nu{ _nu }, order{ _order }, phase{ _phase } {} - // Returns type of the substance based on the value of stoichiometric coefficient. + std::string key; ///< Unique key of the chemical substance from MDB. + double nu = 1.0; ///< Stoichiometric coefficient of this substance in the reaction. + double order = 0.0; ///< Partial order of reaction for this substance. + EPhase phase = EPhase::UNDEFINED; ///< Phase of this substance. + + double MM = 0.0; ///< Molar mass of this substance. + + /** + * \brief Default constructor. + */ + SChemicalSubstance() = default; + /** + * \brief Creates a new substance. + * \param _key Unique key of the chemical substance from MDB. + * \param _nu Stoichiometric coefficient of the substance in the reaction. >0 - product, <0 - reactant. + * \param _order Partial order of reaction for the substance. + * \param _phase Phase of the substance. + */ + SChemicalSubstance(std::string _key, double _nu, double _order, EPhase _phase) : key{ std::move(_key) }, nu{ _nu }, order{ _order }, phase{ _phase } {} + /** + * \brief Returns type of the substance based on the value of stoichiometric coefficient. + * \return Type of the substance in the reaction. + */ [[nodiscard]] ESubstance GetType() const { return nu < 0 ? ESubstance::REACTANT : ESubstance::PRODUCT; } }; private: - std::string m_name; // Name of the reaction. - double m_enthalpy{ 0.0 }; // Specific reaction enthalpy [J/mol]. - std::vector> m_substances; // Chemical substances taking part in the reaction. - size_t m_iBase = -1; // Index of the base substance. + std::string m_name; ///< Name of the reaction. + double m_enthalpy{ 0.0 }; ///< Specific reaction enthalpy [J/mol]. + std::vector> m_substances; ///< Chemical substances taking part in the reaction. + size_t m_iBase = -1; ///< Index of the base substance. public: + /** + * \brief Default constructor. + */ CChemicalReaction() = default; + /** + * \brief Copy constructor. + * \param _other Target chemical reaction. + */ CChemicalReaction(const CChemicalReaction& _other); + /** + * \brief Copy assignment operator. + * \param _other Target chemical reaction. + * \return Reference to this reaction. + */ CChemicalReaction& operator=(const CChemicalReaction& _other); + /** + * \brief Move constructor. + * \param _other Target chemical reaction. + */ CChemicalReaction(CChemicalReaction&& _other) = default; + /** + * \brief Move assignment operator. + * \param _other Target chemical reaction. + * \return Reference to this reaction. + */ CChemicalReaction& operator=(CChemicalReaction&& _other) = default; + /** + * \private + * \brief Destructor. + */ ~CChemicalReaction() = default; - // Swaps two reactions. + /** + * \brief Swaps two reactions. + * \param _other Target chemical reaction. + */ void Swap(CChemicalReaction& _other) noexcept; - // Sets name of the reaction. + /** + * \brief Sets name of the reaction. + * \param _name Reaction name. + */ void SetName(const std::string& _name); - // Returns name of the reaction. + /** + * \brief Returns name of the reaction. + * \return Reaction name. + */ [[nodiscard]] std::string GetName() const; - // Adds a new empty chemical substance to the reaction. - SChemicalSubstanse* AddSubstance(); - // Adds a new chemical substance to the reaction. - void AddSubstance(const SChemicalSubstanse& _substance); - // Removes substance with the specified index. + /** + * \brief Adds a new empty chemical substance to the reaction. + * \return Pointer to the added reaction. + */ + SChemicalSubstance* AddSubstance(); + /** + * \brief Adds a new chemical substance to the reaction. + * \param _substance New substance. + */ + void AddSubstance(const SChemicalSubstance& _substance); + /** + * \brief Removes substance with the specified index. + * \param _index Index of the substance. + */ void RemoveSubstance(size_t _index); - // Returns all defined substances. - [[nodiscard]] std::vector GetSubstances() const; - // Returns all defined substances. - std::vector GetSubstances(); - // Returns number of defined substances. + /** + * \brief Returns all defined substances. + * \return Constant pointers to all defined substances. + */ + [[nodiscard]] std::vector GetSubstances() const; + /** + * \brief Returns all defined substances. + * \return Pointers to all defined substances. + */ + std::vector GetSubstances(); + /** + * \brief Returns number of defined substances. + * \return Number of defined substances. + */ [[nodiscard]] size_t GetSubstancesNumber() const; - // Returns all defined substances of the specified phase. - [[nodiscard]] std::vector GetSubstances(EPhase _phase) const; - // Returns all defined substances of the specified phase. - std::vector GetSubstances(EPhase _phase); - - // Returns all defined substances of the specified type. - [[nodiscard]] std::vector GetSubstances(ESubstance _type) const; - // Returns all defined substances of the specified type. - std::vector GetSubstances(ESubstance _type); - - // Returns all defined substances of the specified phase and type. - [[nodiscard]] std::vector GetSubstances(EPhase _phase, ESubstance _type) const; - // Returns all defined substances of the specified phase and type. - std::vector GetSubstances(EPhase _phase, ESubstance _type); - - // Sets index of the base substance. + /** + * \brief Returns all defined substances of the specified phase. + * \param _phase Target phase. + * \return Constant pointers to substances. + */ + [[nodiscard]] std::vector GetSubstances(EPhase _phase) const; + /** + * \brief Returns all defined substances of the specified phase. + * \param _phase Target phase. + * \return Pointers to substances. + */ + std::vector GetSubstances(EPhase _phase); + + /** + * \brief Returns all defined substances of the specified type. + * \param _type Type of the substance. + * \return Constant pointers to substances. + */ + [[nodiscard]] std::vector GetSubstances(ESubstance _type) const; + /** + * \brief Returns all defined substances of the specified type. + * \param _type Type of the substance. + * \return Pointers to substances. + */ + std::vector GetSubstances(ESubstance _type); + + /** + * \brief Returns all defined substances of the specified phase and type. + * \param _phase Target phase. + * \param _type Type of the substance. + * \return Constant pointers to substances. + */ + [[nodiscard]] std::vector GetSubstances(EPhase _phase, ESubstance _type) const; + /** + * \brief Returns all defined substances of the specified phase and type. + * \param _phase Target phase. + * \param _type Type of the substance. + * \return Pointers to substances. + */ + std::vector GetSubstances(EPhase _phase, ESubstance _type); + + /** + * \brief Sets index of the base substance. + * \param _index Index of the substance. + */ void SetBaseSubstance(size_t _index); - // Returns base substance. - [[nodiscard]] const SChemicalSubstanse* GetBaseSubstance() const; - // Returns base substance. - SChemicalSubstanse* GetBaseSubstance(); - // Returns index of the base substance. + /** + * \brief Returns base substance. + * \return Pointer to the substance. + */ + [[nodiscard]] const SChemicalSubstance* GetBaseSubstance() const; + /** + * \brief Returns base substance. + * \return Pointer to the substance. + */ + SChemicalSubstance* GetBaseSubstance(); + /** + * \brief Returns index of the base substance. + * \return Index to the substance. + */ [[nodiscard]] size_t GetBaseSubstanceIndex() const; - // Sets specific reaction enthalpy [J/mol]. + /** + * \brief Sets specific reaction enthalpy [J/mol]. + * \param _enthalpy Reaction enthalpy. + */ void SetEnthalpy(double _enthalpy); - // Returns specific reaction enthalpy [J/mol]. + /** + * \brief Returns specific reaction enthalpy [J/mol]. + * \return Reaction enthalpy. + */ [[nodiscard]] double GetEnthalpy() const; - // Calculates reaction enthalpy and sets molar masses of all substances using the provided materials database. Otherwise these values must be set manually. + /** + * \private + * \brief Initializes the reaction. + * \details Calculates reaction enthalpy and sets molar masses of all substances using the provided materials database. + * Otherwise these values must be set manually. + * \param _materials Reference to the materials database. + */ void Initialize(const CMaterialsDatabase& _materials); - // Saves the reaction into the HDF5 file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; - // Loads the reaction from the HDF5 file. + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile(const CH5Handler& _h5File, const std::string& _path); }; diff --git a/ModelsAPI/MixtureEnthalpyLookup.h b/ModelsAPI/MixtureEnthalpyLookup.h index 232f85cb..6491f9b1 100644 --- a/ModelsAPI/MixtureEnthalpyLookup.h +++ b/ModelsAPI/MixtureEnthalpyLookup.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2020, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #pragma once @@ -12,69 +14,184 @@ class CMaterialsDatabase; */ class CMixtureEnthalpyLookup { - SInterval m_limits{ DEFAULT_ENTHALPY_MIN_T, DEFAULT_ENTHALPY_MAX_T }; // Temperature limits. - size_t m_intervals{ DEFAULT_ENTHALPY_INTERVALS }; // Number of temperature intervals. + SInterval m_limits{ DEFAULT_ENTHALPY_MIN_T, DEFAULT_ENTHALPY_MAX_T }; ///< Temperature limits. + size_t m_intervals{ DEFAULT_ENTHALPY_INTERVALS }; ///< Number of temperature intervals. - CMixtureLookup m_mixtureLookup; // Lookup table for the mixture. - const CMaterialsDatabase* m_materialsDB{}; // Pointer to a materials database. - std::vector m_compounds; // Vector with keys of the chemical compounds which contains this lookup table + CMixtureLookup m_mixtureLookup; ///< Lookup table for the mixture. + const CMaterialsDatabase* m_materialsDB{}; ///< Pointer to a materials database. + std::vector m_compounds; ///< Vector with keys of the chemical compounds which contains this lookup table public: + /** + * \brief Default constructor. + */ CMixtureEnthalpyLookup() = default; + /** + * \brief Constructs lookup table with the pointer to materials database and compounds and default values of limits and number of intervals. + * \param _materialsDB Pointer to materials database. + * \param _compounds List of compounds. + */ CMixtureEnthalpyLookup(const CMaterialsDatabase* _materialsDB, std::vector _compounds); + /** + * \brief Constructs lookup table with the pointer to materials database, compounds, values of limits and number of intervals. + * \param _materialsDB Pointer to materials database. + * \param _compounds List of compounds. + * \param _limits Temperature limits. + * \param _intervalsNumber Number of temperature intervals. + */ CMixtureEnthalpyLookup(const CMaterialsDatabase* _materialsDB, std::vector _compounds, const SInterval& _limits, size_t _intervalsNumber); - // Sets temperature limits and number of intervals for the lookup table. + /** + * \brief Sets temperature limits and number of intervals for the lookup table. + * \param _limits Temperature limits. + * \param _number Number of temperature intervals. + */ void SetLimits(const SInterval& _limits, size_t _number); - // Returns current temperature limits. + /** + * \brief Returns current temperature limits. + * \return Temperature limits. + */ [[nodiscard]] SInterval GetLimits() const; - // Returns current number of temperature intervals. + /** + * \brief Returns current number of temperature intervals. + * \return Number of intervals. + */ [[nodiscard]] size_t GetIntervalsNumber() const; - // Sets pointer to materials database + /** + * \brief Sets pointer to materials database + * \param _materialsDB Pointer to materials database. + */ void SetMaterialsDatabase(const CMaterialsDatabase* _materialsDB); - // Sets new list of _compounds. + /** + * \brief Sets new list of _compounds. + * \param _compounds List of compounds. + */ void SetCompounds(const std::vector& _compounds); - // Sets new _fractions of all compounds. The length of _fractions must be equal to the number of previously defined compounds. + /** + * \brief Sets new fractions of all compounds. + * \details The length of fractions must be equal to the number of previously defined compounds. + * \param _fractions Compounds fractions. + */ void SetCompoundFractions(const std::vector& _fractions); - // Returns current fractions of compounds. + /** + * \brief Returns current fractions of compounds. + * \return Compounds fractions. + */ [[nodiscard]] std::vector GetCompoundFractions() const; - // Returns the number of entries in the lookup table. + /** + * \brief Returns the number of entries in the lookup table. + * \return Number of entries. + */ [[nodiscard]] size_t Size() const; - // Returns enthalpy for the given _temperature. + /** + * \brief Returns enthalpy for the given temperature. + * \param _temperature Temperature. + * \return Enthalpy. + */ [[nodiscard]] double GetEnthalpy(double _temperature) const; - // Returns temperature for the given _enthalpy. + /** + * \brief Returns temperature for the given _enthalpy. + * \param _enthalpy Enthalpy. + * \return Temperature. + */ [[nodiscard]] double GetTemperature(double _enthalpy) const; - // Sets new _fractions of all compounds and returns enthalpy for the given _temperature. The length of _fractions must be equal to the number of previously defined compounds. + /** + * \brief Sets new fractions of all compounds and returns enthalpy for the given temperature. + * \details The length of fractions must be equal to the number of previously defined compounds. + * \param _temperature Temperature. + * \param _fractions Compounds fractions. + * \return Enthalpy. + */ [[nodiscard]] double GetEnthalpy(double _temperature, const std::vector& _fractions); - // Sets new _fractions of all compounds and returns temperature for the given _enthalpy. The length of _fractions must be equal to the number of previously defined compounds. + /** + * \brief Sets new _fractions of all compounds and returns temperature for the given enthalpy. + * \details The length of fractions must be equal to the number of previously defined compounds. + * \param _enthalpy Enthalpy. + * \param _fractions Compounds fractions. + * \return Temperature. + */ [[nodiscard]] double GetTemperature(double _enthalpy, const std::vector& _fractions); - // Removes all information. + /** + * \brief Removes all information. + */ void Clear(); - // Adds _value to each _right (dependent) entry of the mixture table. + /** + * \brief Adds value to each right (dependent) entry of the mixture table. + * \param _value New value. + */ void Add(double _value); - // Adds a _component with some _weight to each _right (dependent) entry of the mixture table. + /** + * \brief Adds a component with some weight to each right (dependent) entry of the mixture table. + * \param _component New component. + * \param _weight Weight of the component. + */ void Add(const CDependentValues& _component, double _weight = 1.); - // Adds another mixture _table with some _weight to each _right (dependent) entry of the mixture table. _table must have the same number of compounds. + /** + * \brief Adds another mixture table with some weight to each right (dependent) entry of the mixture table. + * \details Table must have the same number of compounds. + * \param _table Mixture table. + * \param _weight Weight of the component. + */ void Add(const CMixtureEnthalpyLookup& _table, double _weight = 1.); - // Multiplies each _right (dependent) entry of the mixture table with a _value. + /** + * \brief Multiplies each right (dependent) entry of the mixture table with a value. + * \param _value Value. + */ void Multiply(double _value); + /** + * \brief Adds a value to all entries of the lookup table. + * \param _d Value. + * \return Copy of the lookup table. + */ CMixtureEnthalpyLookup operator+(double _d) const; + /** + * \brief Multiplies all entries of the lookup table with a value. + * \param _d Value. + * \return Copy of the lookup table. + */ CMixtureEnthalpyLookup operator*(double _d) const; + /** + * \brief Adds another lookup table. + * \param _t Lookup table. + * \return Copy of the lookup table. + */ CMixtureEnthalpyLookup operator+(const CMixtureEnthalpyLookup& _t) const; + /** + * \brief Adds a value to all entries of the lookup table. + * \param _d Value. + * \return Reference to the lookup table. + */ CMixtureEnthalpyLookup& operator+=(double _d); + /** + * \brief Multiplies all entries of the lookup table with a value. + * \param _d Value. + * \return Reference to the lookup table. + */ CMixtureEnthalpyLookup& operator*=(double _d); + /** + * \brief Adds another lookup table. + * \param _t Lookup table. + * \return Reference to the lookup table. + */ CMixtureEnthalpyLookup& operator+=(const CMixtureEnthalpyLookup& _t); + /** + * \brief Compares two lookup tables. + * \param _t Lookup table. + * \return Whether lookup tables are the same. + */ bool operator==(const CMixtureEnthalpyLookup& _t) const; private: - // Set enthalpies to the table according to the defined limits, compounds and their fractions. + /** + * \brief Set enthalpies to the table according to the defined limits, compounds and their fractions. + */ void UpdateCompoundsEnthalpies(); }; diff --git a/ModelsAPI/PlotManager.h b/ModelsAPI/PlotManager.h index 09169e3c..8ddab457 100644 --- a/ModelsAPI/PlotManager.h +++ b/ModelsAPI/PlotManager.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2020, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #pragma once @@ -12,54 +14,117 @@ class CH5Handler; // CCurve // +/** + * \brief Curve on the plot. + */ class CCurve { - static const unsigned m_saveVersion{ 1 }; // Current version of the saving procedure. + static const unsigned m_saveVersion{ 1 }; ///< Current version of the saving procedure. - std::string m_name; // Name of the curve. - double m_valueZ{}; // Value of Z axis for which this curve is defined. + std::string m_name; ///< Name of the curve. + double m_valueZ{}; ///< Value of Z axis for which this curve is defined. - std::vector m_values; // Values stored in the curve. + std::vector m_values; ///< Values stored in the curve. public: + /** + * \private + * \brief Constructor. + * \param _name Name of the curve. + */ CCurve(std::string _name); + /** + * \private + * \brief Constructor. + * \param _z Z-value of the curve. + */ CCurve(double _z); - // Returns the name of the curve. + /** + * \brief Returns the name of the curve. + * \return Curve's name. + */ std::string GetName() const; - // Sets new name of the curve. + /** + * \brief Sets new name of the curve. + * \param _name Curve's name. + */ void SetName(const std::string& _name); - // Returns the value of Z axis for which this curve is defined. + /** + * \brief Returns the value of Z axis for which this curve is defined. + * \return Z-value of the curve. + */ double GetZValue() const; - // Sets a new value of Z axis for which this curve is defined. + /** + * \brief Sets a new value of Z axis for which this curve is defined. + * \param _z Z-value of the curve. + */ void SetZValue(double _z); - // Adds a new point to the curve. + /** + * \brief Adds a new point to the curve. + * \param _x X-value of the point. + * \param _y Y-value of the point. + */ void AddPoint(double _x, double _y); - // Adds a new point to the curve. + /** + * \brief Adds a new point to the curve. + * \param _point New point. + */ void AddPoint(const CPoint& _point); - // Adds a new points to the curve. X and Y must have the same length. + /** + * \brief Adds new points to the curve. + * \details Vectors must have the same length. + * \param _x X-values of the points. + * \param _y Y-values of the points. + */ void AddPoints(const std::vector& _x, const std::vector& _y); - // Adds a new points to the curve. + /** + * \brief Adds new points to the curve. + * \param _points New points. + */ void AddPoints(const std::vector& _points); - // Returns X values of all points defined in the curve. + /** + * \brief Returns X values of all points defined in the curve. + * \return X-values of all points. + */ std::vector GetXValues() const; - // Returns Y values of all points defined in the curve. + /** + * \brief Returns Y values of all points defined in the curve. + * \return Y-values of all points. + */ std::vector GetYValues() const; - // Returns all points defined in the curve. + /** + * \brief Returns all points defined in the curve. + * \return All points. + */ std::vector GetPoints() const; - // Removes all defined points from the curve. + /** + * \brief Removes all defined points from the curve. + */ void ClearData(); - // Removes all data from the curve. + /** + * \brief Removes all data from the curve. + */ void Clear(); - // Saves data to file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data in the file. + */ void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; - // Loads data from file. + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data in the file. + */ void LoadFromFile(CH5Handler& _h5File, const std::string& _path); }; @@ -67,112 +132,302 @@ class CCurve // CPlot // +/** + * \brief Plot in the unit. + */ class CPlot { - static const unsigned m_saveVersion{ 1 }; // Current version of the saving procedure. + static const unsigned m_saveVersion{ 1 }; ///< Current version of the saving procedure. protected: - std::string m_name; // Name of the plot. - std::string m_labelX; // Label of the X axis. - std::string m_labelY; // Label of the Y axis. - std::string m_labelZ; // Label of the Z axis. + std::string m_name; ///< Name of the plot. + std::string m_labelX; ///< Label of the X axis. + std::string m_labelY; ///< Label of the Y axis. + std::string m_labelZ; ///< Label of the Z axis. - std::vector> m_curves; // Curves in this plot. + std::vector> m_curves; ///< Curves in this plot. public: + /** + * \private + * \brief Constructor. + * \param _name Name of the plot. + */ CPlot(std::string _name); + /** + * \private + * \brief Constructor. + * \param _name Name of the plot. + * \param _labelX Name of X label. + * \param _labelY Name of Y label. + */ CPlot(std::string _name, std::string _labelX, std::string _labelY); + /** + * \private + * \brief Constructor. + * \param _name Name of the plot. + * \param _labelX Name of X label. + * \param _labelY Name of Y label. + * \param _labelZ Name of Z label. + */ CPlot(std::string _name, std::string _labelX, std::string _labelY, std::string _labelZ); + /** + * \private + * \brief Destructor. + */ ~CPlot() = default; + /** + * \private + * \brief Copy constructor. + * \param _other Target plot. + */ CPlot(const CPlot& _other); + /** + * \private + * \brief Move constructor. + * \param _other Target plot. + */ CPlot(CPlot&& _other) = default; + /** + * \private + * \brief Copy assignment operator. + * \param _other Target plot. + * \return Reference to the plot. + */ CPlot& operator=(const CPlot& _other); + /** + * \private + * \brief Move assignment operator. + * \param _other Target plot. + * \return Reference to the plot. + */ CPlot& operator=(CPlot&& _other) = default; - // Returns the name of the plot. + /** + * \brief Returns the name of the plot. + * \return Plot's name. + */ std::string GetName() const; - // Sets new name of the plot. + /** + * \brief Sets new name of the plot. + * \param _name Plot's name. + */ void SetName(const std::string& _name); - // Returns a label of the X axis. + /** + * \brief Returns a label of the X axis. + * \return X label of the plot. + */ std::string GetLabelX() const; - // Returns a label of the Y axis. + /** + * \brief Returns a label of the Y axis. + * \return Y label of the plot. + */ std::string GetLabelY() const; - // Returns a label of the Z axis. + /** + * \brief Returns a label of the Z axis. + * \return Z label of the plot. + */ std::string GetLabelZ() const; - // Sets a label of the X axis. + /** + * \brief Sets a label of the X axis. + * \param _label X label of the plot. + */ void SetLabelX(const std::string& _label); - // Sets a label of the Y axis. + /** + * \brief Sets a label of the Y axis. + * \param _label Y label of the plot. + */ void SetLabelY(const std::string& _label); - // Sets a label of the Z axis. + /** + * \brief Sets a label of the Z axis. + * \param _label Z label of the plot. + */ void SetLabelZ(const std::string& _label); - // Sets labels of all axes. + /** + * \brief Sets labels of all axes. + * \param _labelX X label of the plot. + * \param _labelY Y label of the plot. + */ void SetLabels(const std::string& _labelX, const std::string& _labelY); - // Sets labels of all axes. + /** + * \brief Sets labels of all axes. + * \param _labelX X label of the plot. + * \param _labelY Y label of the plot. + * \param _labelZ Z label of the plot. + */ void SetLabels(const std::string& _labelX, const std::string& _labelY, const std::string& _labelZ); - // Adds a new curve with the specified name to the plot. If a curve with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified name to the plot. + * \details If a curve with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot's name. + * \return Pointer to the added curve. + */ CCurve* AddCurve(const std::string& _name); - // Adds a new curve with the specified name to the plot and fills it with the given values. X and Y must have the same length. If a curve with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified name to the plot and fills it with the given values. + * \details X and Y must have the same length. If a curve with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot's name. + * \param _x X-values of the points. + * \param _y Y-values of the points. + * \return Pointer to the added curve. + */ CCurve* AddCurve(const std::string& _name, const std::vector& _x, const std::vector& _y); - // Adds a new curve with the specified name to the plot and fills it with the given values. If a curve with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified name to the plot and fills it with the given values. + * \details If a curve with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot's name. + * \param _points Points on the curve. + * \return Pointer to the added curve. + */ CCurve* AddCurve(const std::string& _name, const std::vector& _points); - // Adds several curves with the specified names to the plot. If any curve with the given name value already exists, does nothing, and returns empty vector. + /** + * \brief Adds several curves with the specified names to the plot. + * \details If any curve with the given name value already exists, does nothing, and returns empty vector. + * \param _names Names of the curves. + * \return Pointers to the added curves. + */ std::vector AddCurves(const std::vector& _names); - // Adds a new curve with the specified Z value to the plot. If a curve with the given Z value already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified Z value to the plot. + * \details If a curve with the given Z value already exists, does nothing, and returns nullptr. + * \param _z Z-value of the curve. + * \return Pointer to the added curve. + */ CCurve* AddCurve(double _z); - // Adds a new curve with the specified Z value to the plot and fills it with the given values. X and Y must have the same length. If a curve with the given Z value already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified Z value to the plot and fills it with the given values. + * \details X and Y must have the same length. If a curve with the given Z value already exists, does nothing, and returns nullptr. + * \param _z Z-value of the curve. + * \param _x X-values of the points. + * \param _y Y-values of the points. + * \return Pointer to the added curve. + */ CCurve* AddCurve(double _z, const std::vector& _x, const std::vector& _y); - // Adds a new curve with the specified Z value to the plot and fills it with the given values. If a curve with the given Z value already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new curve with the specified Z value to the plot and fills it with the given values. + * \details If a curve with the given Z value already exists, does nothing, and returns nullptr. + * \param _z Z-value of the curve. + * \param _points New points. + * \return Pointer to the added curve. + */ CCurve* AddCurve(double _z, const std::vector& _points); - // Adds several curves with the specified Z values to the plot. If any curve with the given Z value already exists, does nothing, and returns empty vector. + /** + * \brief Adds several curves with the specified Z values to the plot. + * \details If any curve with the given Z value already exists, does nothing, and returns empty vector. + * \param _z Z-values of the curves. + * \return Pointers to the added curves. + */ std::vector AddCurves(const std::vector& _z); - // Returns a curve with the specified index. + /** + * \brief Returns a curve with the specified index. + * \param _index Index of the curve. + * \return Const pointer to the curve. + */ const CCurve* GetCurve(size_t _index) const; - // Returns a curve with the specified index. + /** + * \brief Returns a curve with the specified index. + * \param _index Index of the curve. + * \return Pointer to the curve. + */ CCurve* GetCurve(size_t _index); - // Returns a curve with the specified name. + /** + * \brief Returns a curve with the specified name. + * \param _name Name of the curve. + * \return Const pointer to the curve. + */ const CCurve* GetCurve(const std::string& _name) const; - // Returns a curve with the specified name. + /** + * \brief Returns a curve with the specified name. + * \param _name Name of the curve. + * \return Pointer to the curve. + */ CCurve* GetCurve(const std::string& _name); - // Returns a curve with the specified Z value. + /** + * \brief Returns a curve with the specified Z value. + * \param _z Z-value of the curve. + * \return Const pointer to the curve. + */ const CCurve* GetCurve(double _z) const; - // Returns a curve with the specified Z value. + /** + * \brief Returns a curve with the specified Z value. + * \param _z Z-value of the curve. + * \return Pointer to the curve. + */ CCurve* GetCurve(double _z); - // Removes a curve with the specified name from the plot. + /** + * \brief Removes a curve with the specified name from the plot. + * \param _name Name of the curve. + */ void RemoveCurve(const std::string& _name); - // Removes a curve with the specified Z value from the plot. + /** + * \brief Removes a curve with the specified Z value from the plot. + * \param _z Z-value of the curve. + */ void RemoveCurve(double _z); - // Returns all curves defined in the plot. + /** + * \brief Returns all curves defined in the plot. + * \return Const pointers to the curves. + */ std::vector GetAllCurves() const; - // Returns all curves defined in the plot. + /** + * \brief Returns all curves defined in the plot. + * \return Pointers to the curves. + */ std::vector GetAllCurves(); - // Returns Z values of all defined curves. + /** + * \brief Returns Z values of all defined curves. + * \return Z values of the curves. + */ std::vector GetZValues() const; - // Checks if the plot is a 2D plot, based on the presence of Z values. + /** + * \brief Checks if the plot is a 2D plot, based on the presence of Z values. + * \return Whether the curve is 2D. + */ bool Is2D() const; - // Returns a number of defined curves. + /** + * \brief Returns a number of defined curves. + * \return Number of curves. + */ size_t GetCurvesNumber() const; - // Removes all defined curves from the plot. + /** + * \brief Removes all defined curves from the plot. + */ void ClearData(); - // Removes all data from the plot. + /** + * \brief Removes all data from the plot. + */ void Clear(); - // Saves data to file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; - // Loads data from file. + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile(CH5Handler& _h5File, const std::string& _path); private: - // Tries to add a new curve with the specified Z value to the plot, without setting any data, omitting name clashes. Returns nullptr on failure. + /** + * \brief Tries to add a new curve with the specified Z value to the plot, without setting any data, omitting name clashes. + * \details Returns nullptr on failure. + */ CCurve* AddEmptyCurve(double _z); }; @@ -180,62 +435,142 @@ class CPlot // CPlotManager // +/** + * \brief Plot manager to access all plots and curves on them. + */ class CPlotManager { - static const unsigned m_saveVersion{ 1 }; // Current version of the saving procedure. + static const unsigned m_saveVersion{ 1 }; ///< Current version of the saving procedure. - std::vector> m_plots; // Plots. - std::vector> m_plotsStored; // A copy of plots used to store data during cyclic recalculations. + std::vector> m_plots; ///< Plots. + std::vector> m_plotsStored; ///< A copy of plots used to store data during cyclic recalculations. public: /** - * \internal + * \private * \brief Copies user-defined data from _plots. * \details Copies information about generated plots. Assumes the corresponding plots structure is the same. * \param _plots Reference to source plots manager. */ void CopyUserData(const CPlotManager& _plots) const; - // Adds a new 2D plot with the specified name. If a plot with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new 2D plot with the specified name. + * \details If a plot with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot name. + * \return Pointer to the added plot. + */ CPlot* AddPlot(const std::string& _name); - // Adds a new 2D plot with the specified name and axes labels. If a plot with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new 2D plot with the specified name and axes labels. + * \details If a plot with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot name. + * \param _labelX X label of the plot. + * \param _labelY Y label of the plot. + * \return Pointer to the added plot. + */ CPlot* AddPlot(const std::string& _name, const std::string& _labelX, const std::string& _labelY); - // Adds a new 3D plot with the specified name and axes labels. If a plot with the given name already exists, does nothing, and returns nullptr. + /** + * \brief Adds a new 3D plot with the specified name and axes labels. + * \details If a plot with the given name already exists, does nothing, and returns nullptr. + * \param _name Plot name. + * \param _labelX X label of the plot. + * \param _labelY Y label of the plot. + * \param _labelZ Z label of the plot. + * \return Pointer to the added plot. + */ CPlot* AddPlot(const std::string& _name, const std::string& _labelX, const std::string& _labelY, const std::string& _labelZ); - // Returns a 2D plot with the specified index. + /** + * \brief Returns a 2D plot with the specified index. + * \param _index Index of the plot. + * \return Const pointer to the plot. + */ const CPlot* GetPlot(size_t _index) const; - // Returns a 2D plot with the specified index. + /** + * \brief Returns a 2D plot with the specified index. + * \param _index Index of the plot. + * \return Pointer to the plot. + */ CPlot* GetPlot(size_t _index); - // Returns a 2D plot with the specified name. + /** + * \brief Returns a 2D plot with the specified name. + * \param _name Plot name. + * \return Const pointer to the plot. + */ const CPlot* GetPlot(const std::string& _name) const; - // Returns a 2D plot with the specified name. + /** + * \brief Returns a 2D plot with the specified name. + * \param _name Plot name. + * \return Pointer to the plot. + */ CPlot* GetPlot(const std::string& _name); - // Removes a 2D plot with the specified name. + /** + * \private + * \brief Removes a 2D plot with the specified name. + * \param _name Plot name. + */ void RemovePlot(const std::string& _name); - // Returns all defined 2D plots. + /** + * \brief Returns all defined 2D plots. + * \return Const pointers to all plots. + */ std::vector GetAllPlots() const; - // Returns all defined 2D plots. + /** + * \brief Returns all defined 2D plots. + * \return Pointers to all plots. + */ std::vector GetAllPlots(); - // Returns a number of defined plots. + /** + * \brief Returns a number of defined plots. + * \return Number of all plots. + */ size_t GetPlotsNumber() const; - // Removes all defined plots. + /** + * \private + * \brief Removes all defined plots. + */ void ClearData(); - // Removes all data. + /** + * \private + * \brief Removes all data. + */ void Clear(); - // Stores the current state of all plots. + /** + * \private + * \brief Stores the current state of all plots. + */ void SaveState(); - // Restores previously stored state of all plots. + /** + * \private + * \brief Restores previously stored state of all plots. + */ void LoadState(); - // Saves data to file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; - // Loads data from file. + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile(CH5Handler& _h5File, const std::string& _path); - // Loads data from file. A compatibility version. + /** + * \private + * \brief Loads data from file. + * \details A compatibility version. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile_v0(const CH5Handler& _h5File, const std::string& _path); }; diff --git a/ModelsAPI/UnitPorts.h b/ModelsAPI/UnitPorts.h index 3f1504d9..e79afc27 100644 --- a/ModelsAPI/UnitPorts.h +++ b/ModelsAPI/UnitPorts.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2020, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #pragma once @@ -15,20 +17,25 @@ class CH5Handler; // /** - * Description of the unit port. - * The main purpose is connecting to material streams. + * \brief Description of the unit port. + * \details The main purpose is connecting to material streams. */ class CUnitPort { - static const unsigned m_saveVersion{ 1 }; // Current version of the saving procedure. + static const unsigned m_saveVersion{ 1 }; ///< Current version of the saving procedure. private: - std::string m_name; // The name of the port, should be unique for the unit. - EUnitPort m_type{ EUnitPort::UNDEFINED }; // Port type: INPUT or OUTPUT. - std::string m_streamKey; // The key of the stream which is connected to this port. - CStream* m_stream{ nullptr }; // Pointer to the connected material stream. + std::string m_name; ///< The name of the port, should be unique for the unit. + EUnitPort m_type{ EUnitPort::UNDEFINED }; ///< Port type: INPUT or OUTPUT. + std::string m_streamKey; ///< The key of the stream which is connected to this port. + CStream* m_stream{ nullptr }; ///< Pointer to the connected material stream. public: + /** + * \brief Constructs unit port with the given name and type. + * \param _name Name of the port. + * \param _type Type of the port. + */ CUnitPort(std::string _name, EUnitPort _type); /** @@ -75,14 +82,29 @@ class CUnitPort */ void SetStream(CStream* _stream); - void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; // Saves data to file. - void LoadFromFile(CH5Handler& _h5File, const std::string& _path); // Loads data from file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ + void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ + void LoadFromFile(CH5Handler& _h5File, const std::string& _path); }; //////////////////////////////////////////////////////////////////////////////// // CPortsManager // +/** + * \brief Manager of unit ports. + */ class CPortsManager { static const unsigned m_saveVersion{ 1 }; // Current version of the saving procedure. @@ -91,7 +113,7 @@ class CPortsManager public: /** - * \internal + * \private * \brief Copies user-defined data from _ports. * \details Copies information about selected streams. Assumes the corresponding ports structure is the same. * \param _ports Reference to source ports manager. @@ -166,13 +188,35 @@ class CPortsManager */ size_t GetPortsNumber() const; - // Saves data to file. + /** + * \private + * \brief Saves data to file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void SaveToFile(CH5Handler& _h5File, const std::string& _path) const; - // Loads data from file. + /** + * \private + * \brief Loads data from file. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile(CH5Handler& _h5File, const std::string& _path); - // Loads data from file. A compatibility version. + /** + * \private + * \brief Loads data from file. + * \details A compatibility version. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile_v0(const CH5Handler& _h5File, const std::string& _path); - // Loads data from file. A compatibility version. + /** + * \private + * \brief Loads data from file. + * \details A compatibility version. + * \param _h5File Reference to the file handler. + * \param _path Path to data. + */ void LoadFromFile_v00(const CH5Handler& _h5File, const std::string& _path); private: diff --git a/Utilities/DyssolDefines.h b/Utilities/DyssolDefines.h index a522a94e..6513f6e2 100644 --- a/Utilities/DyssolDefines.h +++ b/Utilities/DyssolDefines.h @@ -15,38 +15,40 @@ // ========== Initial values // Simulator -#define DEFAULT_MAX_ITERATIONS_NUMBER 500 -#define DEFAULT_SIMULATION_TIME 60 -#define DEFAULT_INIT_TIME_WINDOW 1 -#define DEFAULT_MIN_TIME_WINDOW 1e-9 -#define DEFAULT_MAX_TIME_WINDOW 1000000 -#define DEFAULT_ITERS_UPPER_LIMIT 7 -#define DEFAULT_ITERS_LOWER_LIMIT 3 -#define DEFAULT_ITERS_1ST_UPPER_LIMIT 20 -#define DEFAULT_WINDOW_MAGNIFICATION_RATIO 1.2 -#define DEFAULT_WEGSTEIN_ACCEL_PARAM -0.5 -#define DEFAULT_RELAXATION_PARAM 1 +#define DEFAULT_MAX_ITERATIONS_NUMBER 500 ///< Default value. +#define DEFAULT_SIMULATION_TIME 60 ///< Default value. +#define DEFAULT_INIT_TIME_WINDOW 1 ///< Default value. +#define DEFAULT_MIN_TIME_WINDOW 1e-9 ///< Default value. +#define DEFAULT_MAX_TIME_WINDOW 1000000 ///< Default value. +#define DEFAULT_ITERS_UPPER_LIMIT 7 ///< Default value. +#define DEFAULT_ITERS_LOWER_LIMIT 3 ///< Default value. +#define DEFAULT_ITERS_1ST_UPPER_LIMIT 20 ///< Default value. +#define DEFAULT_WINDOW_MAGNIFICATION_RATIO 1.2 ///< Default value. +#define DEFAULT_WEGSTEIN_ACCEL_PARAM -0.5 ///< Default value. +#define DEFAULT_RELAXATION_PARAM 1 ///< Default value. // Initial tolerances -#define DEFAULT_A_TOL 1e-6 -#define DEFAULT_R_TOL 1e-3 +#define DEFAULT_A_TOL 1e-6 ///< Default value. +#define DEFAULT_R_TOL 1e-3 ///< Default value. // Cache -#define DEFAULT_CACHE_FLAG_STREAMS true -#define DEFAULT_CACHE_FLAG_HOLDUPS false -#define DEFAULT_CACHE_FLAG_INTERNAL false -#define DEFAULT_CACHE_WINDOW 100 +#define DEFAULT_CACHE_FLAG_STREAMS true ///< Default value. +#define DEFAULT_CACHE_FLAG_HOLDUPS false ///< Default value. +#define DEFAULT_CACHE_FLAG_INTERNAL false ///< Default value. +#define DEFAULT_CACHE_WINDOW 100 ///< Default value. // Initial minimal fraction -#define DEFAULT_MIN_FRACTION 0 +#define DEFAULT_MIN_FRACTION 0 ///< Default value. // Enthalpy calculator -#define DEFAULT_ENTHALPY_MIN_T 173 -#define DEFAULT_ENTHALPY_MAX_T 1273 -#define DEFAULT_ENTHALPY_INTERVALS 100 +#define DEFAULT_ENTHALPY_MIN_T 173 ///< Default value. +#define DEFAULT_ENTHALPY_MAX_T 1273 ///< Default value. +#define DEFAULT_ENTHALPY_INTERVALS 100 ///< Default value. -// ========== Convergence methods +/** + * Convergence methods. + */ enum class EConvergenceMethod : uint32_t { DIRECT_SUBSTITUTION = 0, @@ -54,7 +56,9 @@ enum class EConvergenceMethod : uint32_t STEFFENSEN = 2 }; -// ========== Extrapolation methods +/** + * Extrapolation methods. + */ enum class EExtrapolationMethod : uint32_t { LINEAR = 0, @@ -63,7 +67,7 @@ enum class EExtrapolationMethod : uint32_t }; //======== SOLID DISTRIBUTIONS DATABASE [0; 50] =============== -#define DISTRIBUTIONS_NUMBER 15 +#define DISTRIBUTIONS_NUMBER 15 ///< Total number of distributions. // TODO: make enum class /** @@ -90,8 +94,20 @@ enum EDistrTypes : uint32_t DISTR_UNDEFINED = 31, ///< Distribution type is undefined. }; +/** + * \brief Names of all distributed properties. + * \details Must be in the same order as DISTR_TYPES. + */ #define DISTR_NAMES { "Compounds", "Size", "Particle porosity", "Form factor", "Color", "Moisture", "Distribution 1", "Distribution 2", "Distribution 3", "Distribution 4", "Distribution 5", "Distribution 6", "Distribution 7", "Distribution 8", "Distribution 9", "Distribution 10" } +/** + * \brief Types of all distributed properties. + * \details Must be in the same order as DISTR_NAMES. + */ #define DISTR_TYPES { DISTR_COMPOUNDS, DISTR_SIZE, DISTR_PART_POROSITY, DISTR_FORM_FACTOR, DISTR_COLOR, DISTR_MOISTURE, DISTR_USER_DEFINED_01, DISTR_USER_DEFINED_02, DISTR_USER_DEFINED_03, DISTR_USER_DEFINED_04, DISTR_USER_DEFINED_05, DISTR_USER_DEFINED_06, DISTR_USER_DEFINED_07, DISTR_USER_DEFINED_08, DISTR_USER_DEFINED_09, DISTR_USER_DEFINED_10} +/** + * \brief Calculates index of the distributed property from its type. + * \details Indices from DISTR_TYPES. + */ inline int GetDistributionTypeIndex(EDistrTypes _nType) { EDistrTypes vTypes[] = DISTR_TYPES; @@ -101,11 +117,11 @@ inline int GetDistributionTypeIndex(EDistrTypes _nType) return -1; } - +// TODO: Remove // ========== m_StreamMTP indexes -#define MTP_MASS 0 -#define MTP_TEMPERATURE 1 -#define MTP_PRESSURE 2 +#define MTP_MASS 0 ///< Index of mass in MTP. +#define MTP_TEMPERATURE 1 ///< Index of temperature in MTP. +#define MTP_PRESSURE 2 ///< Index of pressure in MTP. /** * \brief Types of grid entries for distributed properties of the solid phase. @@ -117,7 +133,9 @@ enum class EGridEntry : uint32_t GRID_UNDEFINED = 15, ///< Grid type is undefined. }; -// ========== TYPES OF GRID FUNCTIONAL DISTRIBUTIONS +/** + * Types of grid functional distributions. + */ enum class EGridFunction : uint32_t { GRID_FUN_MANUAL = 0, @@ -129,7 +147,9 @@ enum class EGridFunction : uint32_t GRID_FUN_UNDEFINED = 15, }; -// ========== TYPES OF SOLVING STRATEGIES FOR NLSOLVER +/** + * Types of solving strategies for NLSolver. + */ enum class ENLSolverStrategy : uint32_t { Newton, Linesearch, Picard, Fixedpoint @@ -176,7 +196,9 @@ enum EPSDTypes PSD_Q2 = 7 ///< Surface-area-related cumulative distribution: \f$Q_{2,i} = \frac{\sum_{j=0}^i N_j \pi d_j^2}{\sum_j N_j \pi d_j^2}\f$. }; -// ========== For lookup table creation +/** + * For lookup table creation. + */ enum class EDependencyTypes { DEPENDENCE_UNKNOWN = 0, @@ -188,15 +210,15 @@ enum class EDependencyTypes // ========== Non-constant single-phase mixture properties and overall properties [300..399] // TODO: remove them -//#define ENTHALPY 308 // overall -#define FLOW 320 // overall (stream) -#define MASS 320 // overall (holdup) -#define FRACTION 321 -#define PHASE_FRACTION 327 -#define PRESSURE 338 // overall -#define TEMPERATURE 340 // overall -#define TOTAL_FLOW 342 // overall (stream) -#define TOTAL_MASS 342 // overall (holdup) +//#define ENTHALPY 308 ///< overall +#define FLOW 320 ///< overall (stream) +#define MASS 320 ///< overall (holdup) +#define FRACTION 321 ///< phase fraction +#define PHASE_FRACTION 327 ///< phase fraction +#define PRESSURE 338 ///< overall +#define TEMPERATURE 340 ///< overall +#define TOTAL_FLOW 342 ///< overall (stream) +#define TOTAL_MASS 342 ///< overall (holdup) // ========== Universal constants @@ -210,8 +232,9 @@ enum class EDependencyTypes #define STEFAN_BOLTZMANN_CONSTANT 5.670374419e-8 ///< Stefan-Boltzmann constant [W/m2/K4]. #define MATH_PI 3.14159265358979323846 ///< \f$\pi\f$ constant. -// ========== Value basis - +/** + * Value basis. + */ enum eValueBasises { BASIS_MASS, BASIS_MOLL @@ -221,6 +244,9 @@ enum eValueBasises ////////////////////////////////////////////////////////////////////////// /// Common enumerators ////////////////////////////////////////////////////////////////////////// +/** + * Types of distribution functions. + */ enum class EDistrFunction : unsigned { Manual = 0, @@ -231,8 +257,8 @@ enum class EDistrFunction : unsigned }; /** -* \brief Identifiers of grid unit types. -*/ + * \brief Identifiers of grid unit types. + */ enum class EPSDGridType : unsigned { DIAMETER = 0, ///< Diameter-based size-grid [m]. @@ -252,8 +278,8 @@ enum class EPhase : uint32_t }; /** -* \brief Identifiers of time-dependent overall properties. -*/ + * \brief Identifiers of time-dependent overall properties. + */ enum class EOverall : uint32_t { // TODO: rename when corresponding defines are removed @@ -286,7 +312,9 @@ enum class EUnitPort : uint32_t //////////////////////////////////////////////////////////////////////////////// /// Deprecated types -// Identifiers of phase types +/** + * Identifiers of phase types. + */ enum EPhaseTypes : unsigned { SOA_SOLID, @@ -296,6 +324,9 @@ enum EPhaseTypes : unsigned SOA_UNDEFINED }; +/** + * Identifiers of unit ports types. + */ enum EPortType { INPUT_PORT = 0, diff --git a/Utilities/DyssolTypes.h b/Utilities/DyssolTypes.h index 26ed7a88..28f21574 100644 --- a/Utilities/DyssolTypes.h +++ b/Utilities/DyssolTypes.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ +/* Copyright (c) 2020, Dyssol Development Team. + * Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ #pragma once @@ -7,16 +9,29 @@ #include #include -// Time dependent value. +/** + * \private + * \brief Time dependent value. + */ struct STDValue { - double time{ 0.0 }; - double value{ 0.0 }; + double time{ 0.0 }; ///< Time + double value{ 0.0 }; ///< Value + /** + * \brief Default constructor. + */ STDValue() {} + /** + * \brief Constructor with initial time and value. + */ STDValue(double _time, double _value) : time{ _time }, value{ _value } {} bool operator<(const STDValue& _other) const { return time < _other.time; } }; +/** + * \private + * \brief Describes an interval between two values. + */ struct SInterval { double min; @@ -65,6 +80,10 @@ enum class EArguments EXPORT_GRAPH, }; +/** + * \private + * \brief Describes cache settings. + */ struct SCacheSettings { bool isEnabled{ false }; @@ -72,6 +91,10 @@ struct SCacheSettings std::wstring path{ L"" }; }; +/** + * \private + * \brief Describes tolerance settings. + */ struct SToleranceSettings { double toleranceAbs{ DEFAULT_A_TOL }; // Absolute tolerance. @@ -79,12 +102,20 @@ struct SToleranceSettings double minFraction{ DEFAULT_MIN_FRACTION }; // Minimum considering fraction in MD distributions. }; +/** + * \private + * \brief Describes thermodynamics settings. + */ struct SThermodynamicsSettings { SInterval limits{ DEFAULT_ENTHALPY_MIN_T, DEFAULT_ENTHALPY_MAX_T }; size_t intervals{ DEFAULT_ENTHALPY_INTERVALS }; }; +/** + * \private + * \brief Descriptor of the phase. + */ struct SPhaseDescriptor { EPhase state; // Phase state. @@ -92,6 +123,10 @@ struct SPhaseDescriptor bool operator==(const SPhaseDescriptor& _other) const { return state == _other.state && name == _other.name; } }; +/** + * \private + * \brief Descriptor of the overall property. + */ struct SOverallDescriptor { EOverall type; @@ -99,16 +134,42 @@ struct SOverallDescriptor std::string units; }; -// Describes a 2D point. +/** + * Describes a 2D point. + */ class CPoint { public: - double x{}; - double y{}; + double x = 0.0; ///< X-value. + double y = 0.0; ///< Y-value. + /** + * \brief Default constructor. + */ CPoint() = default; + /** + * \brief Creates a point with default value. + * \param _x X-value of the point. + * \param _y Y-value of the point. + */ CPoint(double _x, double _y) : x{ _x }, y{ _y } {} + /** + * \brief Number of values in the point. + * \return 2. + */ static size_t Size() { return 2; } + /** + * \brief Returns value with the given index. + * \details Index may be 0 or 1, otherwise std::out_of_range exception is thrown. + * \param _i Index. + * \return Target value. + */ double operator[](size_t _i) const { switch (_i) { case 0: return x; case 1: return y; default: throw std::out_of_range("CPoint::operator[size_t] : index is out of range"); } } + /** + * \brief Returns reference to value with the given index. + * \details Index may be 0 or 1, otherwise std::out_of_range exception is thrown. + * \param _i Index. + * \return Returns to target value. + */ double& operator[](size_t _i) { switch (_i) { case 0: return x; case 1: return y; default: throw std::out_of_range("CPoint::operator[size_t] : index is out of range"); } } }; @@ -117,8 +178,9 @@ enum class EDirection UP, DOWN }; -/* - * Describes a single connection between two units in the flowsheet. +/** + * \private + * \brief Describes a single connection between two units in the flowsheet. */ struct SFlowsheetConnection {