Commit 342e7182 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/lambda_return_Type' into 'master'

Add explicit return type for lambdas

See merge request !48
parents 37d31160 30a457d9
...@@ -146,7 +146,7 @@ namespace AMDiS ...@@ -146,7 +146,7 @@ namespace AMDiS
if (!segment.boundary()) if (!segment.boundary())
continue; continue;
Dune::Hybrid::ifElse(Dune::Std::is_detected<HasBoundaryId, Segment>{}, [&](auto id) { Dune::Hybrid::ifElse(Dune::Std::is_detected<HasBoundaryId, Segment>{}, [&](auto id) -> void {
auto index = segment.boundarySegmentIndex(); auto index = segment.boundarySegmentIndex();
boundaryIds_[index] = id(segment).boundaryId(); boundaryIds_[index] = id(segment).boundaryId();
}); });
......
...@@ -179,7 +179,7 @@ void ProblemStat<Traits>::createMatricesAndVectors() ...@@ -179,7 +179,7 @@ void ProblemStat<Traits>::createMatricesAndVectors()
rhs_ = std::make_shared<SystemVector>(globalBasis_, DataTransferOperation::NO_OPERATION); rhs_ = std::make_shared<SystemVector>(globalBasis_, DataTransferOperation::NO_OPERATION);
auto localView = globalBasis_->localView(); auto localView = globalBasis_->localView();
for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void
{ {
std::string i = to_string(treePath); std::string i = to_string(treePath);
estimates_[i].resize(globalBasis_->gridView().indexSet().size(0)); estimates_[i].resize(globalBasis_->gridView().indexSet().size(0));
...@@ -207,7 +207,7 @@ void ProblemStat<Traits>::createMarker() ...@@ -207,7 +207,7 @@ void ProblemStat<Traits>::createMarker()
{ {
marker_.clear(); marker_.clear();
auto localView = globalBasis_->localView(); auto localView = globalBasis_->localView();
for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void
{ {
std::string componentName = name_ + "->marker[" + to_string(treePath) + "]"; std::string componentName = name_ + "->marker[" + to_string(treePath) + "]";
...@@ -228,7 +228,7 @@ void ProblemStat<Traits>::createFileWriter() ...@@ -228,7 +228,7 @@ void ProblemStat<Traits>::createFileWriter()
{ {
filewriter_.clear(); filewriter_.clear();
auto localView = globalBasis_->localView(); auto localView = globalBasis_->localView();
for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) for_each_node(localView.tree(), [&,this](auto const& node, auto treePath) -> void
{ {
std::string componentName = name_ + "->output[" + to_string(treePath) + "]"; std::string componentName = name_ + "->output[" + to_string(treePath) + "]";
...@@ -380,11 +380,11 @@ globalRefine(int refCount) ...@@ -380,11 +380,11 @@ globalRefine(int refCount)
Dune::Timer t; Dune::Timer t;
bool adapted = false; bool adapted = false;
Dune::Hybrid::ifElse(Dune::Std::is_detected<HasGlobalRefineADHI, Grid>{}, Dune::Hybrid::ifElse(Dune::Std::is_detected<HasGlobalRefineADHI, Grid>{},
/*then*/ [&](auto id) { /*then*/ [&](auto id) -> void {
// TODO(FM): Add a way to pass a GridTransfer as ADH with *globalBasis_ argument // TODO(FM): Add a way to pass a GridTransfer as ADH with *globalBasis_ argument
id(grid_)->globalRefine(refCount, GridTransferManager::gridTransfer(*grid_)); id(grid_)->globalRefine(refCount, GridTransferManager::gridTransfer(*grid_));
}, },
/*else*/ [&](auto id) { /*else*/ [&](auto id) -> void {
for (int i = 0; i < refCount; ++i) { for (int i = 0; i < refCount; ++i) {
// mark all entities for grid refinement // mark all entities for grid refinement
for (const auto& element : elements(grid_->leafGridView())) for (const auto& element : elements(grid_->leafGridView()))
...@@ -423,9 +423,9 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as ...@@ -423,9 +423,9 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as
rhs_->init(asmVector); rhs_->init(asmVector);
auto localView = globalBasis_->localView(); auto localView = globalBasis_->localView();
for_each_node(localView.tree(), [&,this](auto const& rowNode, auto rowTp) { for_each_node(localView.tree(), [&,this](auto const& rowNode, auto rowTp) -> void {
auto rowBasis = Dune::Functions::subspaceBasis(*globalBasis_, rowTp); auto rowBasis = Dune::Functions::subspaceBasis(*globalBasis_, rowTp);
for_each_node(localView.tree(), [&,this](auto const& colNode, auto colTp) { for_each_node(localView.tree(), [&,this](auto const& colNode, auto colTp) -> void {
auto colBasis = Dune::Functions::subspaceBasis(*globalBasis_, colTp); auto colBasis = Dune::Functions::subspaceBasis(*globalBasis_, colTp);
for (auto bc : dirichletBCs_[rowNode][colNode]) for (auto bc : dirichletBCs_[rowNode][colNode])
bc->init(rowBasis, colBasis); bc->init(rowBasis, colBasis);
...@@ -451,8 +451,8 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as ...@@ -451,8 +451,8 @@ buildAfterAdapt(AdaptInfo& /*adaptInfo*/, Flag /*flag*/, bool asmMatrix, bool as
systemMatrix_->finish(asmMatrix); systemMatrix_->finish(asmMatrix);
rhs_->finish(asmVector); rhs_->finish(asmVector);
for_each_node(localView.tree(), [&,this](auto const& rowNode, auto row_tp) { for_each_node(localView.tree(), [&,this](auto const& rowNode, auto row_tp) -> void {
for_each_node(localView.tree(), [&,this](auto const& colNode, auto col_tp) { for_each_node(localView.tree(), [&,this](auto const& colNode, auto col_tp) -> void {
// finish boundary condition // finish boundary condition
for (auto bc : dirichletBCs_[rowNode][colNode]) for (auto bc : dirichletBCs_[rowNode][colNode])
bc->fillBoundaryCondition(*systemMatrix_, *solution_, *rhs_, rowNode, row_tp, colNode, col_tp); bc->fillBoundaryCondition(*systemMatrix_, *solution_, *rhs_, rowNode, row_tp, colNode, col_tp);
......
...@@ -184,8 +184,8 @@ namespace AMDiS ...@@ -184,8 +184,8 @@ namespace AMDiS
{ {
using Concept = Dune::Std::is_detected<HasLocalFunctionOrder, LocalFct>; using Concept = Dune::Std::is_detected<HasLocalFunctionOrder, LocalFct>;
return Dune::Hybrid::ifElse(Concept{}, return Dune::Hybrid::ifElse(Concept{},
[&](auto id) { return order(id(localFct)); }, [&](auto id) -> int { return order(id(localFct)); },
[] (auto) { return 0; }); [] (auto) -> int { return 0; });
} }
template <class T, int N> template <class T, int N>
......
...@@ -96,7 +96,7 @@ namespace AMDiS { ...@@ -96,7 +96,7 @@ namespace AMDiS {
if constexpr(visitChild) if constexpr(visitChild)
applyToTree(child, childTP, visitor); applyToTree(child, childTP, visitor);
#else // AMDIS_HAS_CXX_CONSTEXPR_IF #else // AMDIS_HAS_CXX_CONSTEXPR_IF
Dune::Hybrid::ifElse(bool_t<visitChild>{}, [&] (auto /*id*/) { Dune::Hybrid::ifElse(bool_t<visitChild>{}, [&] (auto /*id*/) -> void {
applyToTree(child, childTP, visitor); applyToTree(child, childTP, visitor);
}); });
#endif // AMDIS_HAS_CXX_CONSTEXPR_IF #endif // AMDIS_HAS_CXX_CONSTEXPR_IF
......
...@@ -120,7 +120,9 @@ namespace AMDiS ...@@ -120,7 +120,9 @@ namespace AMDiS
assert(initialized_); assert(initialized_);
assert(data_.size() > node.treeIndex()); assert(data_.size() > node.treeIndex());
using NodePtr = NodeData<Node>*; using NodePtr = NodeData<Node>*;
return *NodePtr(data_[node.treeIndex()]); auto* nodePtr = NodePtr(data_[node.treeIndex()]);
assert(nodePtr);
return *nodePtr;
} }
//! Get reference to data associated to given node //! Get reference to data associated to given node
...@@ -130,7 +132,9 @@ namespace AMDiS ...@@ -130,7 +132,9 @@ namespace AMDiS
assert(initialized_); assert(initialized_);
assert(data_.size() > node.treeIndex()); assert(data_.size() > node.treeIndex());
using NodePtr = NodeData<Node>*; using NodePtr = NodeData<Node>*;
return *NodePtr(data_[node.treeIndex()]); auto* nodePtr = NodePtr(data_[node.treeIndex()]);
assert(nodePtr);
return *nodePtr;
} }
//! Swap tree and data container with `other` //! Swap tree and data container with `other`
...@@ -152,12 +156,12 @@ namespace AMDiS ...@@ -152,12 +156,12 @@ namespace AMDiS
void initData() void initData()
{ {
std::size_t s = 0; std::size_t s = 0;
apply([&s](const auto& node, auto) { apply([&s](const auto& node, auto) -> void {
s = std::max(s, node.treeIndex()+1); s = std::max(s, node.treeIndex()+1);
}); });
data_.resize(s, nullptr); data_.resize(s, nullptr);
apply([this](const auto& node, auto) { apply([this](const auto& node, auto) -> void {
using Node = std::remove_reference_t<decltype(node)>; using Node = std::remove_reference_t<decltype(node)>;
data_[node.treeIndex()] = new NodeData<Node>; data_[node.treeIndex()] = new NodeData<Node>;
}); });
...@@ -167,7 +171,7 @@ namespace AMDiS ...@@ -167,7 +171,7 @@ namespace AMDiS
// Deep copy of node data // Deep copy of node data
void copyData(const TreeData& other) void copyData(const TreeData& other)
{ {
apply([&other,this](const auto& node, auto) { apply([&other,this](const auto& node, auto) -> void {
(*this)[node] = other[node]; (*this)[node] = other[node];
}); });
} }
...@@ -175,7 +179,7 @@ namespace AMDiS ...@@ -175,7 +179,7 @@ namespace AMDiS
// For each node, delete the allocated node data // For each node, delete the allocated node data
void destroyData() void destroyData()
{ {
apply([this](const auto& node, auto) { apply([this](const auto& node, auto) -> void {
using Node = std::remove_reference_t<decltype(node)>; using Node = std::remove_reference_t<decltype(node)>;
using NodePtr = NodeData<Node>*; using NodePtr = NodeData<Node>*;
auto* p = NodePtr(data_[node.treeIndex()]); auto* p = NodePtr(data_[node.treeIndex()]);
......
...@@ -57,8 +57,8 @@ namespace AMDiS ...@@ -57,8 +57,8 @@ namespace AMDiS
void bind(LocalFunction const& localFct) final void bind(LocalFunction const& localFct) final
{ {
order_ = Dune::Hybrid::ifElse(Concept{}, order_ = Dune::Hybrid::ifElse(Concept{},
[&](auto id) { return AMDiS::order(id(localFct)); }, [&](auto id) -> int { return AMDiS::order(id(localFct)); },
[] (auto) { return -1; }); [] (auto) -> int { return -1; });
} }
int order() const final { return order_; } int order() const final { return order_; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment