Skip to content
Snippets Groups Projects
Commit e8f3f180 authored by Ivan Buntic's avatar Ivan Buntic
Browse files

Merge branch 'feature/update-subgrid' into 'master'

[io][grid] Add function for updating a subgrid.

See merge request !3633
parents 0f97595f c018cd70
No related branches found
No related tags found
1 merge request!3633[io][grid] Add function for updating a subgrid.
Pipeline #35150 failed
+5
......@@ -73,7 +73,8 @@ public:
const ES& selector,
const std::string& paramGroup = "")
{
this->gridPtr() = createGrid_(hostGrid, selector, paramGroup);
this->gridPtr() = std::make_unique<Grid>(hostGrid);
updateSubGrid_(selector);
loadBalance();
}
......@@ -86,7 +87,8 @@ public:
const std::string& paramGroup = "")
{
initHostGrid_(paramGroup);
this->gridPtr() = createGrid_(hostGridManager_->grid(), selector, paramGroup);
this->gridPtr() = std::make_unique<Grid>(hostGridManager_->grid());
updateSubGrid_(selector);
loadBalance();
}
......@@ -99,19 +101,27 @@ public:
this->grid().loadBalance();
}
/*!
* \brief Update the existing subgrid.
*/
template<class ES,
typename std::enable_if_t<Dune::models<Concept::ElementSelector<HostElement>, ES>(), int> = 0>
void update(const ES& selector)
{
updateSubGrid_(selector);
loadBalance();
}
protected:
/*!
* \brief Make the subgrid.
* \brief Update the subgrid.
*/
template<class ES,
typename std::enable_if_t<Dune::models<Concept::ElementSelector<HostElement>, ES>(), int> = 0>
static std::unique_ptr<Grid> createGrid_(HostGrid& hostGrid,
const ES& selector,
const std::string& paramGroup = "")
void updateSubGrid_(const ES& selector)
{
// A unique pointer to the subgrid.
auto subgridPtr = std::make_unique<Grid>(hostGrid);
auto& subgridPtr = this->gridPtr();
// A container to store the host grid elements' ids.
std::set<typename HostGrid::Traits::GlobalIdSet::IdType> elementsForSubgrid;
......@@ -132,9 +142,6 @@ protected:
subgridPtr->insertSetPartial(elementsForSubgrid);
subgridPtr->createEnd();
// Return a unique pointer to the subgrid.
return subgridPtr;
}
void initHostGrid_(const std::string& paramGroup)
......@@ -314,9 +321,15 @@ private:
// create the grid
if (repeated)
this->gridPtr() = this->createGrid_(this->hostGrid_(), repeatedElementSelector, paramGroup);
{
this->gridPtr() = std::make_unique<Grid>(this->hostGrid_());
this->updateSubGrid_(repeatedElementSelector);
}
else
this->gridPtr() = this->createGrid_(this->hostGrid_(), elementSelector, paramGroup);
{
this->gridPtr() = std::make_unique<Grid>(this->hostGrid_());
this->updateSubGrid_(elementSelector);
}
this->loadBalance();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment