Commit 8a0d8643 authored by Müller, Felix's avatar Müller, Felix Committed by Praetorius, Simon

Changed template parameter of Marker class from Grid to Traits

parent e746ee51
......@@ -8,8 +8,8 @@ namespace AMDiS {
using std::pow;
template <class Grid>
Marker<Grid>* Marker<Grid>::createMarker(std::string name, int row, const EstType& est, Grid* grid)
template <class Traits>
Marker<Traits>* Marker<Traits>::createMarker(std::string name, int row, const EstType& est, Grid* grid)
{
int strategy = 0;
Parameters::get(name + "->strategy", strategy);
......@@ -21,19 +21,19 @@ namespace AMDiS {
break;
case 1:
msg("Creating global refinement (GR) marker\n");
marker = new GRMarker<Grid>(name, row, est, grid);
marker = new GRMarker<Traits>(name, row, est, grid);
break;
case 2:
msg("Creating maximum strategy (MS) marker\n");
marker = new MSMarker<Grid>(name, row, est, grid);
marker = new MSMarker<Traits>(name, row, est, grid);
break;
case 3:
msg("Creating equidistribution strategy (ES) marker\n");
marker = new ESMarker<Grid>(name, row, est, grid);
marker = new ESMarker<Traits>(name, row, est, grid);
break;
case 4:
msg("Creating guaranteed error reduction strategy (GERS) marker\n");
marker = new GERSMarker<Grid>(name, row, est, grid);
marker = new GERSMarker<Traits>(name, row, est, grid);
break;
default:
error_exit("invalid strategy\n");
......@@ -44,8 +44,8 @@ namespace AMDiS {
template <class Grid>
void Marker<Grid>::initMarking(AdaptInfo& adaptInfo)
template <class Traits>
void Marker<Traits>::initMarking(AdaptInfo& adaptInfo)
{
int row_ = row == -1 ? 0 : row;
......@@ -57,8 +57,8 @@ namespace AMDiS {
template <class Grid>
void Marker<Grid>::finishMarking(AdaptInfo& adaptInfo)
template <class Traits>
void Marker<Traits>::finishMarking(AdaptInfo& adaptInfo)
{
msg(elMarkRefine, " elements marked for refinement\n");
msg(elMarkCoarsen, " elements marked for coarsening\n");
......@@ -66,12 +66,12 @@ namespace AMDiS {
template <class Grid>
void Marker<Grid>::markElement(AdaptInfo& adaptInfo, const Element& elem)
template <class Traits>
void Marker<Traits>::markElement(AdaptInfo& adaptInfo, const Element& elem)
{
int row_ = row == -1 ? 0 : row;
const auto& index = grid->leafIndexSet().index(elem);
double lError = est[index][row_];
double lError = est[index];
if (adaptInfo.isRefinementAllowed(row_) && lError > markRLimit) {
if (maxRefineLevel == -1 || elem.level() < maxRefineLevel) {
......@@ -91,8 +91,8 @@ namespace AMDiS {
template <class Grid>
Flag Marker<Grid>::markGrid(AdaptInfo& adaptInfo)
template <class Traits>
Flag Marker<Traits>::markGrid(AdaptInfo& adaptInfo)
{
test_exit(grid, "No grid!\n");
......@@ -120,10 +120,10 @@ namespace AMDiS {
}
template <class Grid>
void MSMarker<Grid>::initMarking(AdaptInfo& adaptInfo)
template <class Traits>
void MSMarker<Traits>::initMarking(AdaptInfo& adaptInfo)
{
Marker<Grid>::initMarking(adaptInfo);
Marker<Traits>::initMarking(adaptInfo);
int row_ = this->row == -1 ? 0 : this->row;
......@@ -137,10 +137,10 @@ namespace AMDiS {
}
template <class Grid>
void ESMarker<Grid>::initMarking(AdaptInfo& adaptInfo)
template <class Traits>
void ESMarker<Traits>::initMarking(AdaptInfo& adaptInfo)
{
Marker<Grid>::initMarking(adaptInfo);
Marker<Traits>::initMarking(adaptInfo);
int row_ = this->row == -1 ? 0 : this->row;
......@@ -160,10 +160,10 @@ namespace AMDiS {
}
template <class Grid>
Flag GERSMarker<Grid>::markGrid(AdaptInfo& adaptInfo)
template <class Traits>
Flag GERSMarker<Traits>::markGrid(AdaptInfo& adaptInfo)
{
Marker<Grid>::initMarking(adaptInfo);
Marker<Traits>::initMarking(adaptInfo);
int row_ = this->row == -1 ? 0 : this->row;
......@@ -225,7 +225,7 @@ namespace AMDiS {
msg("GERS coarsening with gamma = ", GERSGamma, "\n");
}
Marker<Grid>::finishMarking(adaptInfo);
Marker<Traits>::finishMarking(adaptInfo);
Flag markFlag;
if (this->elMarkRefine)
......@@ -237,11 +237,11 @@ namespace AMDiS {
}
template <class Grid>
void GERSMarker<Grid>::markElementForRefinement(AdaptInfo& adaptInfo, const Element& elem)
template <class Traits>
void GERSMarker<Traits>::markElementForRefinement(AdaptInfo& adaptInfo, const Element& elem)
{
int row_ = this->row == -1 ? 0 : this->row;
double lError = (this->est)[(this->grid->leafIndexSet()).index(elem)][row_];
double lError = (this->est)[(this->grid->leafIndexSet()).index(elem)];
if (lError > this->markRLimit) {
GERSSum += lError;
......@@ -250,11 +250,11 @@ namespace AMDiS {
}
template <class Grid>
void GERSMarker<Grid>::markElementForCoarsening(AdaptInfo& adaptInfo, const Element& elem)
template <class Traits>
void GERSMarker<Traits>::markElementForCoarsening(AdaptInfo& adaptInfo, const Element& elem)
{
int row_ = this->row == -1 ? 0 : this->row;
double lError = (this->est)[(this->grid->leafIndexSet()).index(elem)][row_];
double lError = (this->est)[(this->grid->leafIndexSet()).index(elem)];
if ((this->grid)->getMark(elem) <= 0) {
/* if (elem->getElementData()->getElementData(COARSENABLE))*/
......
......@@ -17,14 +17,15 @@ namespace AMDiS {
* \brief
* Base class for all scalar markers.
*/
template <class Grid>
template <class Traits>
class Marker
{
using GridView = typename Grid::LeafGridView;
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Grid = typename GridView::Grid;
using IndexSet = typename GridView::IndexSet;
using Element = typename GridView::template Codim<0>::Entity;
using EstType = std::vector<std::vector<double> >;
using EstType = std::vector<double>;
public:
/// Constructor.
......@@ -113,7 +114,7 @@ namespace AMDiS {
}
/// Creates a scalar marker depending on the strategy set in parameters.
static Marker<Grid>* createMarker(std::string name, int row_, const EstType& est_, Grid* grid_);
static Marker<Traits>* createMarker(std::string name, int row_, const EstType& est_, Grid* grid_);
protected:
/// Name of the scalar marker.
......@@ -173,18 +174,20 @@ namespace AMDiS {
* \brief
* Global refinement.
*/
template <class Grid>
class GRMarker : public Marker<Grid>
template <class Traits>
class GRMarker : public Marker<Traits>
{
using GridView = typename Grid::LeafGridView;
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Grid = typename GridView::Grid;
using IndexSet = typename GridView::IndexSet;
using Element = typename GridView::template Codim<0>::Entity;
using EstType = std::vector<std::vector<double> >;
using EstType = std::vector<double>;
public:
/// Constructor.
GRMarker(std::string name_, int row_, const EstType& est_, Grid* grid_)
: Marker<Grid>(name_, row_, est_, grid_)
: Marker<Traits>(name_, row_, est_, grid_)
{}
/// Implementation of Marker::markElement().
......@@ -203,18 +206,20 @@ namespace AMDiS {
* Maximum strategy.
*/
template <class Grid>
class MSMarker : public Marker<Grid>
template <class Traits>
class MSMarker : public Marker<Traits>
{
using GridView = typename Grid::LeafGridView;
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Grid = typename GridView::Grid;
using IndexSet = typename GridView::IndexSet;
using Element = typename GridView::template Codim<0>::Entity;
using EstType = std::vector<std::vector<double> >;
using EstType = std::vector<double>;
public:
/// Constructor.
MSMarker(std::string name_, int row_, const EstType& est_, Grid* grid_)
: Marker<Grid>(name_, row_, est_, grid_),
: Marker<Traits>(name_, row_, est_, grid_),
MSGamma(0.5),
MSGammaC(0.1)
{
......@@ -241,18 +246,20 @@ namespace AMDiS {
* Equidistribution strategy
*/
template <class Grid>
class ESMarker : public Marker<Grid>
template <class Traits>
class ESMarker : public Marker<Traits>
{
using GridView = typename Grid::LeafGridView;
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Grid = typename GridView::Grid;
using IndexSet = typename GridView::IndexSet;
using Element = typename GridView::template Codim<0>::Entity;
using EstType = std::vector<std::vector<double> >;
using EstType = std::vector<double>;
public:
/// Constructor.
ESMarker(std::string name_, int row_, const EstType& est_, Grid* grid_)
: Marker<Grid>(name_, row_, est_, grid_),
: Marker<Traits>(name_, row_, est_, grid_),
ESTheta(0.9),
ESThetaC(0.2)
{
......@@ -279,18 +286,20 @@ namespace AMDiS {
* Guaranteed error reduction strategy
*/
template <class Grid>
class GERSMarker : public Marker<Grid>
template <class Traits>
class GERSMarker : public Marker<Traits>
{
using GridView = typename Grid::LeafGridView;
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Grid = typename GridView::Grid;
using IndexSet = typename GridView::IndexSet;
using Element = typename GridView::template Codim<0>::Entity;
using EstType = std::vector<std::vector<double> >;
using EstType = std::vector<double>;
public:
/// Constructor.
GERSMarker(std::string name_, int row_, const EstType& est_, Grid* grid_)
: Marker<Grid>(name_, row_, est_, grid_),
: Marker<Traits>(name_, row_, est_, grid_),
oldErrSum(0.0),
GERSThetaStar(0.6),
GERSNu(0.1),
......
......@@ -35,6 +35,7 @@
#include <amdis/io/FileWriterInterface.hpp>
#include <amdis/utility/TreeData.hpp>
#include <amdis/utility/TreePath.hpp>
namespace AMDiS
......@@ -75,8 +76,8 @@ namespace AMDiS
, name_(std::move(name))
{}
/// Constructor taking additionally a reference to a mesh that is used
/// instead of the default created mesh, \ref ProblemStat
/// Constructor taking additionally a reference to a grid that is used
/// instead of the default created grid, \ref ProblemStat
ProblemStat(std::string name, Grid& grid)
: ProblemStat(std::move(name))
{
......@@ -213,7 +214,7 @@ namespace AMDiS
/// Return a pointer to the grid, \ref grid
std::shared_ptr<Grid> getGrid() { return grid_; }
/// Set the mesh. Stores pointer to passed reference and initializes feSpaces
/// Set the grid. Stores pointer to passed reference and initializes feSpaces
/// matrices and vectors, as well as the file-writer.
void setGrid(Grid& grid)
{
......@@ -247,7 +248,7 @@ namespace AMDiS
{
gridName_ = "";
Parameters::get(name_ + "->mesh", gridName_);
test_exit(!gridName_.empty(), "No mesh name specified for '", name_, "->mesh'!");
test_exit(!gridName_.empty(), "No grid name specified for '", name_, "->mesh'!");
grid_ = MeshCreator<Grid>::create(gridName_);
......@@ -329,15 +330,17 @@ namespace AMDiS
marker.resize(nComponents);
for (std::size_t i = 0; i < nComponents; i++) {
marker[i] = Marker<Grid>::
//treePath =
marker[i] = Marker<Traits>:: // must use the same treePath as corresponding estimator
createMarker(name + "->marker[" + std::to_string(i) + "]", i,
estimates, componentGrids[i]);
estimates[i]/*[treePath]*/, componentGrids[i]);
if (marker[i]) {
nMarkersCreated++;
// If there is more than one marker, and all components are defined
// on the same mesh, the maximum marking has to be enabled.
// on the same grid, the maximum marking has to be enabled.
// TODO: What about two markers each for two grids?
if (nMarkersCreated > 1 && nGrids == 1)
marker[i]->setMaximumMarking(true);
}
......@@ -393,7 +396,7 @@ namespace AMDiS
/// Number of grids
int nGrids = 1;
/// Name of the mesh
/// Name of the grid
std::string gridName_ = "none";
/// FE spaces of this problem.
......@@ -404,7 +407,7 @@ namespace AMDiS
std::list<std::shared_ptr<FileWriterInterface>> filewriter_;
/// Pointer to the adaptation markers
std::vector<Marker<Grid>* > marker;
std::vector<Marker<Traits>* > marker;
/// Pointer to the estimators for this problem
// std::vector<Estimator*> estimator;
......@@ -419,6 +422,7 @@ namespace AMDiS
std::shared_ptr<SystemVector> solution_;
/// A vector with the local element error estimates
/// reverse indexed by [component index][element index]
std::vector<std::vector<double> > estimates;
/// A block-vector (load-vector) corresponding to the right.hand side
......@@ -431,6 +435,8 @@ namespace AMDiS
MatrixOperators<GlobalBasis> matrixOperators_;
VectorOperators<GlobalBasis> rhsOperators_;
Constraints<GlobalBasis> constraints_;
// VectorData<GlobalBasis, TODO: NodeData> estimates_;
};
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
......
Markdown is supported
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