Commit 01ddd2b7 authored by Müller, Felix's avatar Müller, Felix Committed by Praetorius, Simon

*Marker replaced with shared_ptr<Marker>, removed unneccessary line breaks in output

parent 53f1571d
......@@ -9,35 +9,34 @@ namespace AMDiS {
using std::pow;
template <class Traits>
Marker<Traits>* Marker<Traits>::createMarker(std::string name, std::string component, const EstType& est, Grid* grid)
std::shared_ptr<Marker<Traits> > Marker<Traits>::createMarker(std::string name, std::string component, const EstType& est, std::shared_ptr<Grid> grid)
{
int strategy = 0;
Parameters::get(name + "->strategy", strategy);
Marker *marker = NULL;
std::shared_ptr<Marker<Traits> > marker;
switch (strategy) {
case 0: // no refinement/coarsening
marker = NULL;
break;
case 1:
msg("Creating global refinement (GR) marker\n");
marker = new GRMarker<Traits>(name, component, est, grid);
msg("Creating global refinement (GR) marker");
marker = std::make_shared<GRMarker<Traits> >(name, component, est, grid);
break;
case 2:
msg("Creating maximum strategy (MS) marker\n");
marker = new MSMarker<Traits>(name, component, est, grid);
msg("Creating maximum strategy (MS) marker");
marker = std::make_shared<MSMarker<Traits> >(name, component, est, grid);
break;
case 3:
msg("Creating equidistribution strategy (ES) marker\n");
marker = new ESMarker<Traits>(name, component, est, grid);
msg("Creating equidistribution strategy (ES) marker");
marker = std::make_shared<ESMarker<Traits> >(name, component, est, grid);
break;
case 4:
msg("Creating guaranteed error reduction strategy (GERS) marker\n");
marker = new GERSMarker<Traits>(name, component, est, grid);
msg("Creating guaranteed error reduction strategy (GERS) marker");
marker = std::make_shared<GERSMarker<Traits> >(name, component, est, grid);
break;
default:
error_exit("invalid strategy\n");
error_exit("invalid strategy");
}
return marker;
......@@ -61,8 +60,8 @@ namespace AMDiS {
template <class Traits>
void Marker<Traits>::finishMarking(AdaptInfo& adaptInfo)
{
msg(elMarkRefine, " elements marked for refinement\n");
msg(elMarkCoarsen, " elements marked for coarsening\n");
msg(elMarkRefine, " elements marked for refinement");
msg(elMarkCoarsen, " elements marked for coarsening");
}
......@@ -91,7 +90,8 @@ namespace AMDiS {
template <class Traits>
Flag Marker<Traits>::markGrid(AdaptInfo& adaptInfo)
{
test_exit(grid, "No grid!\n");
if (!(grid))
error_exit("No grid!");
initMarking(adaptInfo);
......@@ -126,7 +126,7 @@ namespace AMDiS {
this->markRLimit = MSGammaP * adaptInfo.getEstMax(this->component);
this->markCLimit = MSGammaCP * adaptInfo.getEstMax(this->component);
msg("start max_est: ", adaptInfo.getEstMax(this->component), ", mark_limits: ", this->markRLimit, ", " , this->markCLimit, "\n");
msg("start max_est: ", adaptInfo.getEstMax(this->component), ", mark_limits: ", this->markRLimit, ", " , this->markCLimit);
}
......@@ -147,7 +147,7 @@ namespace AMDiS {
this->markRLimit = ESThetaP * epsP / nLeaves;
this->markCLimit = ESThetaCP * epsP / nLeaves;
msg("start mark_limits: ", this->markRLimit, ", " , this->markCLimit, "; nt = ", nLeaves , "\n");
msg("start mark_limits: ", this->markRLimit, ", " , this->markCLimit, "; nt = ", nLeaves);
}
......@@ -173,7 +173,7 @@ namespace AMDiS {
if (redfac < 1.0) {
LTheta *= redfac;
msg("GERS: use extrapolated theta_star = ", pow(LTheta, 1.0 / this->p), "\n");
msg("GERS: use extrapolated theta_star = ", pow(LTheta, 1.0 / this->p));
}
}
......@@ -193,7 +193,7 @@ namespace AMDiS {
} while((GERSGamma > 0) && (GERSSum < LTheta * this->estSum));
}
msg("GERS refinement with gamma = ", GERSGamma, "\n");
msg("GERS refinement with gamma = ", GERSGamma);
}
if (this->coarsenAllowed) {
......@@ -208,10 +208,10 @@ namespace AMDiS {
for (const auto& elem : Dune::elements(this->grid->leafGridView()))
markElementForCoarsening(adaptInfo, elem);
msg("coarse loop: gamma = ", GERSGamma, ", sum = ", GERSSum, ", limit = ", LTheta, "\n");
msg("coarse loop: gamma = ", GERSGamma, ", sum = ", GERSSum, ", limit = ", LTheta);
} while(GERSSum > LTheta);
msg("GERS coarsening with gamma = ", GERSGamma, "\n");
msg("GERS coarsening with gamma = ", GERSGamma);
}
Marker<Traits>::finishMarking(adaptInfo);
......
......@@ -32,7 +32,7 @@ namespace AMDiS {
Marker() {}
/// Constructor.
Marker(std::string name_, std::string component_, const EstType& est_, Grid* grid_)
Marker(std::string name_, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_)
: name(name_),
component(component_),
grid(grid_),
......@@ -116,7 +116,7 @@ namespace AMDiS {
}
/// Creates a scalar marker depending on the strategy set in parameters.
static Marker<Traits>* createMarker(std::string name, std::string component_, const EstType& est_, Grid* grid_);
static std::shared_ptr<Marker<Traits> > createMarker(std::string name, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_);
protected:
/// Name of the scalar marker.
......@@ -126,7 +126,7 @@ namespace AMDiS {
std::string component;
/// Pointer to the grid
Grid* grid;
std::shared_ptr<Grid> grid;
/// Pointer to the local error estimates
EstType est;
......@@ -191,7 +191,7 @@ namespace AMDiS {
public:
/// Constructor.
GRMarker(std::string name_, std::string component_, const EstType& est_, Grid* grid_)
GRMarker(std::string name_, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_)
: Marker<Traits>(name_, component_, est_, grid_)
{}
......@@ -223,7 +223,7 @@ namespace AMDiS {
public:
/// Constructor.
MSMarker(std::string name_, std::string component_, const EstType& est_, Grid* grid_)
MSMarker(std::string name_, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_)
: Marker<Traits>(name_, component_, est_, grid_),
MSGamma(0.5),
MSGammaC(0.1)
......@@ -263,7 +263,7 @@ namespace AMDiS {
public:
/// Constructor.
ESMarker(std::string name_, std::string component_, const EstType& est_, Grid* grid_)
ESMarker(std::string name_, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_)
: Marker<Traits>(name_, component_, est_, grid_),
ESTheta(0.9),
ESThetaC(0.2)
......@@ -303,7 +303,7 @@ namespace AMDiS {
public:
/// Constructor.
GERSMarker(std::string name_, std::string component_, const EstType& est_, Grid* grid_)
GERSMarker(std::string name_, std::string component_, const EstType& est_, std::shared_ptr<Grid> grid_)
: Marker<Traits>(name_, component_, est_, grid_),
oldErrSum(0.0),
GERSThetaStar(0.6),
......
......@@ -390,7 +390,7 @@ namespace AMDiS
std::list<std::shared_ptr<FileWriterInterface>> filewriter_;
/// Pointer to the adaptation markers
std::list<Marker<Traits>* > marker;
std::list<std::shared_ptr<Marker<Traits> > > marker;
/// Pointer to the estimators for this problem
// std::vector<Estimator*> estimator;
......
......@@ -143,11 +143,12 @@ void ProblemStat<Traits>::createMarker()
int i = std::stoi(to_string(treePath)); // TODO: To be removed
// replace i with treePath once supported
auto marker_ = Marker<Traits>::createMarker(
componentName, std::to_string(i), estimates[std::to_string(i)], componentGrids[i]);
if (marker_)
marker.push_back(marker_);
auto newMarker = Marker<Traits>::createMarker(
componentName, std::to_string(i), estimates[std::to_string(i)], grid);
if (newMarker)
{
marker.push_back(std::move(newMarker));
}
// If there is more than one marker, and all components are defined
// on the same grid, the maximum marking has to be enabled.
// TODO: What about two markers each for two grids?
......@@ -363,8 +364,8 @@ Flag ProblemStat<Traits>::markElements(AdaptInfo& adaptInfo)
Dune::Timer t;
Flag markFlag = 0;
for (auto marker_ : marker)
markFlag |= marker_->markGrid(adaptInfo);
for (auto currentMarker : marker)
markFlag |= currentMarker->markGrid(adaptInfo);
msg("markElements needed ", t.elapsed(), " seconds");
......
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