Skip to content
Snippets Groups Projects

Feature/amg memory management

Merged Christian Engwer requested to merge feature/amg-memory-management into master
1 unresolved thread
@@ -110,12 +110,17 @@ namespace Dune
*/
Hierarchy(const std::shared_ptr<MemberType> & first);
Hierarchy() = default;
/**
* @brief Construct an empty hierarchy.
*/
Hierarchy() : levels_(0)
{}
/**
* @brief Copy constructor (deep copy!).
*/
Hierarchy(const Hierarchy& other);
/**
* @brief Add an element on a coarser level.
* @param args The arguments needed for the construction.
@@ -1243,11 +1248,14 @@ namespace Dune
}
finest_ = std::allocate_shared<Element>(allocator_);
std::shared_ptr<Element> finer_;
std::shared_ptr<Element> current_ = finest_;
std::shared_ptr<Element> otherCurrent_ = other.finest_;
std::shared_ptr<Element> current_ = finest_;
std::weak_ptr<Element> otherWeak_ = other.finest_;
while(otherCurrent_)
while(! otherWeak_.expired())
{
// create shared_ptr from weak_ptr, we just checked that this is safe
std::shared_ptr<Element> otherCurrent_ = std::shared_ptr<Element>(otherWeak_);
// clone current level
#warning should we use the allocator?
current_->element_ =
std::make_shared<MemberType>(*(otherCurrent_->element_));
@@ -1262,7 +1270,8 @@ namespace Dune
current_->coarser_ = c;
current_ = c;
}
otherCurrent_ = std::shared_ptr<Element>(otherCurrent_->coarser_);
// go to coarser level
otherWeak_ = otherCurrent_->coarser_;
}
coarsest_=current_;
}
Loading