Skip to content

Commit

Permalink
Merge branch 'SmallFixes' into 'master'
Browse files Browse the repository at this point in the history
Various small fixes mostly from cppcheck

See merge request ogs/ogs!4964
  • Loading branch information
endJunction committed Mar 27, 2024
2 parents 002de0a + 43a5945 commit 48e85f4
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 21 deletions.
12 changes: 6 additions & 6 deletions BaseLib/ConfigTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion BaseLib/ConfigTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class ConfigTree final
* \pre \c param must not have been read before from this ConfigTree.
*/
std::optional<ConfigTree> 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.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions GeoLib/IO/NetCDFRasterReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include "GeoLib/IO/NetCDFRasterReader.h"

#include <filesystem>
#include <numeric>
#ifdef OGS_USE_NETCDF
#include <netcdf>
#endif

#include "BaseLib/ConfigTree.h"
#include "BaseLib/StringTools.h"
#include "GeoLib/AABB.h"
#include "GeoLib/IO/AsciiRasterInterface.h"

Expand Down
6 changes: 3 additions & 3 deletions MaterialLib/MPL/Properties/VolumeFractionAverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions MathLib/VectorizedTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ Type<DisplacementDim> toVector(Eigen::MatrixBase<Derived> const& tensor)
{
return tensor.reshaped();
}
OGS_FATAL(
"Not all cases handled in the VectorizedTensor::toVector() function.");
}

/// Converts a vectorized tensor to a 3x3 matrix.
Expand Down
7 changes: 7 additions & 0 deletions ParameterLib/TimeDependentHeterogeneousParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ std::vector<double> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 48e85f4

Please sign in to comment.