Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/bout/hypre_interface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ public:
Element& operator+=(BoutReal value_) {

ASSERT3(finite(value_));
auto column_position = std::find(cbegin(positions), cend(positions), column);
auto column_position = std::ranges::find(positions, column);
if (column_position != cend(positions)) {
const auto i = std::distance(cbegin(positions), column_position);
const auto i = std::distance(begin(positions), column_position);
value += weights[i] * value_;
}
addValues(value_);
Expand Down
4 changes: 2 additions & 2 deletions include/bout/multiostream.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private:

public:
void add(std::basic_ostream<char_type, traits>& str) {
auto pos = std::find(streams_.begin(), streams_.end(), &str);
auto pos = std::ranges::find(streams_, &str);

// Already been added
if (pos != streams_.end()) {
Expand All @@ -28,7 +28,7 @@ public:
}

void remove(std::basic_ostream<char_type, traits>& str) {
auto pos = std::find(streams_.begin(), streams_.end(), &str);
auto pos = std::ranges::find(streams_, &str);

if (pos != streams_.end()) {
streams_.erase(pos);
Expand Down
2 changes: 1 addition & 1 deletion include/bout/petsc_interface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public:
Element& operator+=(BoutReal val) {

ASSERT3(std::isfinite(val));
auto columnPosition = std::find(positions.begin(), positions.end(), petscCol);
auto columnPosition = std::ranges::find(positions, petscCol);
if (columnPosition != positions.end()) {
const int index = std::distance(positions.begin(), columnPosition);
value += weights[index] * val;
Expand Down
3 changes: 1 addition & 2 deletions include/bout/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ protected:
/// Does \p vars contain a field with \p name?
template <class T>
bool contains(const std::vector<VarStr<T>>& vars, const std::string& name) {
const auto in_vars = std::find(begin(vars), end(vars), name);
return in_vars != end(vars);
return std::ranges::find(vars, name, &VarStr<T>::name) != std::ranges::end(vars);
}

/// Vectors of variables to evolve
Expand Down
14 changes: 7 additions & 7 deletions src/field/fieldgroup.cxx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

#include <bout/fieldgroup.hxx>
#include <algorithm>

FieldGroup operator+(const FieldGroup& lhs, const FieldGroup& rhs) {
return FieldGroup(lhs) += rhs;
}

void FieldGroup::makeUnique() {
// Need to sort vector before making unique
std::sort(fvec.begin(), fvec.end());
std::ranges::sort(fvec);

// Remove duplicate entries (doesn't resize vector though)
auto last = std::unique(fvec.begin(), fvec.end());
auto fvec_dupes = std::ranges::unique(fvec);

// Resizes vector to remove memory no longer required
fvec.erase(last, fvec.end());
fvec.erase(fvec_dupes.begin(), fvec_dupes.end());

// Now do the same for the vector of Field3Ds
std::sort(f3vec.begin(), f3vec.end());
auto last_f3 = std::unique(f3vec.begin(), f3vec.end());
f3vec.erase(last_f3, f3vec.end());
std::ranges::sort(f3vec);
auto f3vec_dupes = std::ranges::unique(f3vec);
f3vec.erase(f3vec_dupes.begin(), f3vec_dupes.end());
}
12 changes: 6 additions & 6 deletions src/sys/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -760,13 +760,13 @@ struct ConvertContainer<C<Scalar>> {

Container operator()(int value) {
Container result(similar_to);
std::fill(std::begin(result), std::end(result), static_cast<Scalar>(value));
std::ranges::fill(result, static_cast<Scalar>(value));
return result;
}

Container operator()(BoutReal value) {
Container result(similar_to);
std::fill(std::begin(result), std::end(result), static_cast<Scalar>(value));
std::ranges::fill(result, static_cast<Scalar>(value));
return result;
}

Expand All @@ -779,8 +779,8 @@ struct ConvertContainer<C<Scalar>> {
Container result(similar_to);
result.reshape(value.shape()); // Resize to shape of input

std::transform(std::begin(value), std::end(value), std::begin(result),
[](const OtherScalar& x) { return static_cast<Scalar>(x); });
std::ranges::transform(value, std::begin(result),
[](const auto& x) { return static_cast<Scalar>(x); });
return result;
}

Expand Down Expand Up @@ -877,8 +877,8 @@ Options Options::getUnused(const std::vector<std::string>& exclude_sources) cons
return false;
}
const auto source = option.attributes.at("source").as<std::string>();
return std::find(exclude_sources.begin(), exclude_sources.end(), source)
!= exclude_sources.end();
return std::ranges::find(exclude_sources, source)
!= std::ranges::end(exclude_sources);
};

const auto conditionally_used = [](const Options& option) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/solver/test_solverfactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TEST(SolverFactoryTest, GetDefaultSolverType) {
TEST(SolverFactoryTest, RegisterSolver) {
auto available = SolverFactory::getInstance().listAvailable();

auto found_fake = std::find(begin(available), end(available), "fake_solver");
auto found_fake = std::ranges::find(available, "fake_solver");

EXPECT_NE(found_fake, end(available));
}
Expand Down
Loading