From 2521219e473e3613456aaa942a431854ce79aa1b Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Fri, 22 Mar 2024 16:33:23 +0100 Subject: [PATCH 1/7] [T/M] Use f-string in python output --- .../Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py b/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py index 517ca2ad441..c8ee12b98e3 100644 --- a/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py +++ b/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py @@ -67,9 +67,7 @@ def _init_iteration(self): self._iteration += 1 print( - "BC: a_est={:.4f}, a_prev={:.4f} ({:.4f}, {:.4f})".format( - self._a_est, self._a_prev, self._a_range[0], self._a_range[1] - ) + f"BC: a_est={self._a_est:.4f}, a_prev={self._a_prev:.4f} ({self._a_range[0]:.4f}, {self._a_range[1]:.4f})" ) def getDirichletBCValue(self, t, coords, node_id, primary_vars): From 2d0d335bc306967342defda18cfbfb4a2ab6c2aa Mon Sep 17 00:00:00 2001 From: Tom Fischer Date: Tue, 26 Mar 2024 13:44:42 +0100 Subject: [PATCH 2/7] [GL/IO/NetCDFRasterReader] Include numeric and StringTools --- GeoLib/IO/NetCDFRasterReader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GeoLib/IO/NetCDFRasterReader.cpp b/GeoLib/IO/NetCDFRasterReader.cpp index fe7f4ac6b6c..21859bb0861 100644 --- a/GeoLib/IO/NetCDFRasterReader.cpp +++ b/GeoLib/IO/NetCDFRasterReader.cpp @@ -10,11 +10,13 @@ #include "GeoLib/IO/NetCDFRasterReader.h" #include +#include #ifdef OGS_USE_NETCDF #include #endif #include "BaseLib/ConfigTree.h" +#include "BaseLib/StringTools.h" #include "GeoLib/AABB.h" #include "GeoLib/IO/AsciiRasterInterface.h" From c85a3bba86109d4d943fe52ceec1e4d98a5f9e06 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 27 Mar 2024 13:57:06 +0100 Subject: [PATCH 3/7] [BL] Unify decl. and def. argument names --- BaseLib/ConfigTree.cpp | 12 ++++++------ BaseLib/ConfigTree.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index faa829e5b8a..570c5c75a22 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -115,23 +115,23 @@ ConfigTree& ConfigTree::operator=(ConfigTree&& other) return *this; } -ConfigTree ConfigTree::getConfigParameter(std::string const& root) const +ConfigTree ConfigTree::getConfigParameter(std::string const& param) const { - auto ct = getConfigSubtree(root); + auto ct = getConfigSubtree(param); if (ct.hasChildren()) { - error("Requested parameter <" + root + "> actually is a subtree."); + error("Requested parameter <" + param + "> actually is a subtree."); } return ct; } std::optional ConfigTree::getConfigParameterOptional( - std::string const& root) const + std::string const& param) const { - auto ct = getConfigSubtreeOptional(root); + auto ct = getConfigSubtreeOptional(param); if (ct && ct->hasChildren()) { - error("Requested parameter <" + root + "> actually is a subtree."); + error("Requested parameter <" + param + "> actually is a subtree."); } return ct; } diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index fff3525c9d0..1f97b409168 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -382,7 +382,7 @@ class ConfigTree final * \pre \c param must not have been read before from this ConfigTree. */ std::optional getConfigParameterOptional( - std::string const& root) const; + std::string const& param) const; /*! Fetches all parameters with name \c param from the current level of the * tree. From e4aac2e571815ae7dbe446342520589a92c8712e Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 27 Mar 2024 14:31:31 +0100 Subject: [PATCH 4/7] [MaL] Add fatal error in impossible default case Resolves cppcheck warning about missing return statement. --- MathLib/VectorizedTensor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MathLib/VectorizedTensor.h b/MathLib/VectorizedTensor.h index 3a70bee3b0d..83f3ac2be72 100644 --- a/MathLib/VectorizedTensor.h +++ b/MathLib/VectorizedTensor.h @@ -195,6 +195,8 @@ Type toVector(Eigen::MatrixBase const& tensor) { return tensor.reshaped(); } + OGS_FATAL( + "Not all cases handled in the VectorizedTensor::toVector() function."); } /// Converts a vectorized tensor to a 3x3 matrix. From acfdfcb70e84824259dbacdabaa67729b06f78ad Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 27 Mar 2024 14:36:19 +0100 Subject: [PATCH 5/7] [ParL] Add safety check before vector access The value k could be pointing to the end of the vector if the for loops runs through without fulfilling the if-condition. --- ParameterLib/TimeDependentHeterogeneousParameter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ParameterLib/TimeDependentHeterogeneousParameter.cpp b/ParameterLib/TimeDependentHeterogeneousParameter.cpp index a1f0bc29c01..be1eff3c8b1 100644 --- a/ParameterLib/TimeDependentHeterogeneousParameter.cpp +++ b/ParameterLib/TimeDependentHeterogeneousParameter.cpp @@ -60,6 +60,13 @@ std::vector TimeDependentHeterogeneousParameter::operator()( break; } } + if (k == _time_parameter_mapping.size()) + { + OGS_FATAL( + "Could not find parameter for time {}. There are {:d} " + "time-parameter pairs.", + t, _time_parameter_mapping.size()); + } auto const t0 = _time_parameter_mapping[k - 1].first; auto const t1 = _time_parameter_mapping[k].first; auto const alpha = (t - t0) / (t1 - t0); From d3ae107dda6e488e23b734848de64281aaa6a168 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 27 Mar 2024 14:46:32 +0100 Subject: [PATCH 6/7] [MPL] Add explicit default initialization of pointers --- MaterialLib/MPL/Properties/VolumeFractionAverage.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MaterialLib/MPL/Properties/VolumeFractionAverage.h b/MaterialLib/MPL/Properties/VolumeFractionAverage.h index 51eb93c8faf..a5ab96c5a3f 100644 --- a/MaterialLib/MPL/Properties/VolumeFractionAverage.h +++ b/MaterialLib/MPL/Properties/VolumeFractionAverage.h @@ -45,9 +45,9 @@ class VolumeFractionAverage : public Property // Struct with pointers on the properties of relevant phases struct PhaseProperties { - const Property* liquid; - const Property* frozen; - const Property* porous; + const Property* liquid = nullptr; + const Property* frozen = nullptr; + const Property* porous = nullptr; }; public: From 43a594510f7c051aee846996b10e985809b35c9a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 27 Mar 2024 14:51:22 +0100 Subject: [PATCH 7/7] [doc] Remove unreferenced tags .md-files --- .../ProjectFile/material/porous_medium/porosity/i_porosity.md | 1 - .../material/porous_medium/porosity/t_porosity_parameter.md | 1 - .../ProjectFile/material/porous_medium/porosity/t_type.md | 2 -- .../material/porous_medium/storage/Constant/c_Constant.md | 1 - .../material/porous_medium/storage/Constant/t_value.md | 1 - .../ProjectFile/material/porous_medium/storage/i_storage.md | 1 - .../ProjectFile/material/porous_medium/storage/t_type.md | 1 - 7 files changed, 8 deletions(-) delete mode 100644 Documentation/ProjectFile/material/porous_medium/porosity/i_porosity.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/porosity/t_porosity_parameter.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/porosity/t_type.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/storage/Constant/c_Constant.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/storage/Constant/t_value.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/storage/i_storage.md delete mode 100644 Documentation/ProjectFile/material/porous_medium/storage/t_type.md diff --git a/Documentation/ProjectFile/material/porous_medium/porosity/i_porosity.md b/Documentation/ProjectFile/material/porous_medium/porosity/i_porosity.md deleted file mode 100644 index 5782262fcc9..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/porosity/i_porosity.md +++ /dev/null @@ -1 +0,0 @@ -Defining the porosity relationship. diff --git a/Documentation/ProjectFile/material/porous_medium/porosity/t_porosity_parameter.md b/Documentation/ProjectFile/material/porous_medium/porosity/t_porosity_parameter.md deleted file mode 100644 index dab574ee332..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/porosity/t_porosity_parameter.md +++ /dev/null @@ -1 +0,0 @@ -Name of parameter that is used as the porosity. diff --git a/Documentation/ProjectFile/material/porous_medium/porosity/t_type.md b/Documentation/ProjectFile/material/porous_medium/porosity/t_type.md deleted file mode 100644 index 8f59579f70d..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/porosity/t_type.md +++ /dev/null @@ -1,2 +0,0 @@ -The type of the porosity relationship. At the moment there is only the -relationship 'constant over the time' implemented. diff --git a/Documentation/ProjectFile/material/porous_medium/storage/Constant/c_Constant.md b/Documentation/ProjectFile/material/porous_medium/storage/Constant/c_Constant.md deleted file mode 100644 index 576add64edc..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/storage/Constant/c_Constant.md +++ /dev/null @@ -1 +0,0 @@ -\ogs_missing_documentation diff --git a/Documentation/ProjectFile/material/porous_medium/storage/Constant/t_value.md b/Documentation/ProjectFile/material/porous_medium/storage/Constant/t_value.md deleted file mode 100644 index 576add64edc..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/storage/Constant/t_value.md +++ /dev/null @@ -1 +0,0 @@ -\ogs_missing_documentation diff --git a/Documentation/ProjectFile/material/porous_medium/storage/i_storage.md b/Documentation/ProjectFile/material/porous_medium/storage/i_storage.md deleted file mode 100644 index 576add64edc..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/storage/i_storage.md +++ /dev/null @@ -1 +0,0 @@ -\ogs_missing_documentation diff --git a/Documentation/ProjectFile/material/porous_medium/storage/t_type.md b/Documentation/ProjectFile/material/porous_medium/storage/t_type.md deleted file mode 100644 index 576add64edc..00000000000 --- a/Documentation/ProjectFile/material/porous_medium/storage/t_type.md +++ /dev/null @@ -1 +0,0 @@ -\ogs_missing_documentation