Skip to content
Snippets Groups Projects
Commit 01ddd2b7 authored by Müller, Felix's avatar Müller, Felix Committed by Praetorius, Simon
Browse files

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

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