Commit 32ac085e authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

decoupled adaptive: works now in parallel, yet without dynamic loadbalancing

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@11561 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 03725898
......@@ -21,6 +21,7 @@
#include <dumux/decoupled/common/impetproperties.hh>
#include <dumux/decoupled/2p/2pproperties.hh>
#include <dumux/linear/vectorexchange.hh>
/**
* @file
......@@ -47,6 +48,7 @@ private:
typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes;
typedef typename SolutionTypes::ScalarSolution ScalarSolutionType;
typedef typename SolutionTypes::ElementMapper ElementMapper;
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
......@@ -140,6 +142,19 @@ public:
refineBound_ = refinetol_*globaldelta;
coarsenBound_ = coarsentol_*globaldelta;
#if HAVE_MPI
// communicate updated values
typedef VectorExchange<ElementMapper, ScalarSolutionType> DataHandle;
DataHandle dataHandle(problem_.elementMapper(), indicatorVector_);
problem_.gridView().template communicate<DataHandle>(dataHandle,
Dune::InteriorBorder_All_Interface,
Dune::ForwardCommunication);
refineBound_ = problem_.gridView().comm().max(refineBound_);
coarsenBound_ = problem_.gridView().comm().max(coarsenBound_);
#endif
}
/*! \brief Indicator function for marking of grid cells for refinement
......
......@@ -45,17 +45,16 @@ class GridAdapt
{
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
//*******************************
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GridView::Grid Grid;
typedef typename Grid::LeafGridView LeafGridView;
typedef typename GridView::Grid Grid;
typedef typename Grid::LeafGridView LeafGridView;
typedef typename LeafGridView::template Codim<0>::Iterator LeafIterator;
typedef typename GridView::IntersectionIterator LeafIntersectionIterator;
typedef typename Grid::template Codim<0>::Entity Element;
typedef typename Grid::template Codim<0>::EntityPointer ElementPointer;
typedef typename GridView::IntersectionIterator LeafIntersectionIterator;
typedef typename Grid::template Codim<0>::Entity Element;
typedef typename Grid::template Codim<0>::EntityPointer ElementPointer;
typedef typename GET_PROP_TYPE(TypeTag, CellData) CellData;
typedef typename GET_PROP_TYPE(TypeTag, AdaptionIndicator) AdaptionIndicator;
typedef typename GET_PROP_TYPE(TypeTag, AdaptionInitializationIndicator) AdaptionInitializationIndicator;
......@@ -103,7 +102,8 @@ public:
break;
}
if (adaptionInitIndicator.initializeModel())
int shouldInitialize = adaptionInitIndicator.initializeModel();
if (problem_.grid().comm().max(shouldInitialize))
problem_.model().initialize();
iter++;
......@@ -164,8 +164,9 @@ public:
markElements(indicator);
// abort if nothing in grid is marked
if (problem_.grid().comm().sum(marked_) == 0
&& problem_.grid().comm().sum(coarsened_) == 0)
int sumMarked = problem_.grid().comm().sum(marked_);
int sumCoarsened = problem_.grid().comm().sum(coarsened_);
if (sumMarked == 0 && sumCoarsened == 0)
return;
else
Dune::dinfo << marked_ << " cells have been marked_ to be refined, "
......@@ -196,7 +197,7 @@ public:
problem_.grid().postAdapt();
// call method in problem for potential output etc.
problem_.grid().postAdapt();
problem_.postAdapt();
return;
}
......@@ -291,8 +292,10 @@ public:
*/
bool wasAdapted()
{
return (problem_.grid().comm().sum(marked_) != 0
|| problem_.grid().comm().sum(coarsened_) != 0);
int sumMarked = problem_.grid().comm().sum(marked_);
int sumCoarsened = problem_.grid().comm().sum(coarsened_);
return (sumMarked != 0 || sumCoarsened != 0);
}
/*!
......
......@@ -155,6 +155,10 @@ public:
LevelGridView levelView = grid_.levelView(level);
for (LevelIterator eIt = levelView.template begin<0>(); eIt != levelView.template end<0>(); ++eIt)
{
// only treat non-ghosts, ghost data is communicated afterwards
if (eIt->partitionType() == Dune::GhostEntity)
continue;
if (!eIt->isNew())
{
//entry is in map, write in leaf
......@@ -205,6 +209,17 @@ public:
#else
adaptationMap_.clear();
#endif
#if HAVE_MPI
// communicate ghost data
typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes;
typedef typename SolutionTypes::ElementMapper ElementMapper;
typedef VectorExchange<ElementMapper, std::vector<CellData> > DataHandle;
DataHandle dataHandle(problem.elementMapper(), this->cellDataGlobal());
problem.gridView().template communicate<DataHandle>(dataHandle,
Dune::InteriorBorder_All_Interface,
Dune::ForwardCommunication);
#endif
}
};
......
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