marking.hh

Go to the documentation of this file.
1 #ifndef marking_hh
2 #define marking_hh
3 
4 #include "estimator/estimator.hh"
5 //#include "meshGraph.hh"
6 
7 namespace estimator{
8 
9 // marking refinementstrategies like dörfler are not in that design atm
10 
16 public:
17  inline const concepts::Set<uint>& marks() const{return mark_;}
18 protected:
20 };
21 
22 
24  error_index(uint elmkey, concepts::Real error):err(error),key(elmkey){};
25 
26  bool operator<(error_index const& right) const {
27  if(this->err == right.err)
28  return this->key < right.key;
29  return this->err < right.err;
30  }
31 
32  bool operator!=(error_index const& right){
33  return (this->err != right.err) || (this->key != right.key);
34  }
35 
37  uint key;
38 
39 protected:
40  virtual std::ostream& info(std::ostream& os) const {
41  return os << "error_index("<<err<<","<<key<<")";
42  }
43 };
44 
45 
46 //Absolute marking, choosing absolute number of cells
47 class AMarking : public Marking{
48 
49 public:
53  template<class F= concepts::Real>
55 
56  const concepts::LocalEstimator<F>* locEstimator = dynamic_cast<const concepts::LocalEstimator<F>*>(&estimator);
57  if(locEstimator){
58 
61  //sort all errors
62  for( iter= locEstimator->begin(); iter != locEstimator->end(); ++iter)
63  locErrors.insert(error_index(iter->first, iter->second));
64 
65  //get the maximal local error = last element in Set
66  //Real maxErr = locErrors.rbegin()->err;
67  concepts::Set<error_index>::const_reverse_iterator iterSet = locErrors.rbegin();
68 
69 
70  for( uint i = 0; (iterSet != locErrors.rend()) && i < no; ++i)
71  this->mark_.insert((iterSet++)->key);
72  }else //just localEstimators are implemented right now
73  throw conceptsException(concepts::MissingFeature("not implemented"));
74 
75 
76  }
77 
78 
79 
80 
81 protected:
82  virtual std::ostream& info(std::ostream& os) const {
83  return os << "Absolute Marking( "<< this->mark_<<")";
84  }
85 };
86 
87 
88 
89 
90 
91 
92 
93 
94 //bulk marking
95 class BMarking : public Marking{
96 
97 public:
101  template<class F= concepts::Real>
103 
104  const concepts::LocalEstimator<F>* locEstimator = dynamic_cast<const concepts::LocalEstimator<F>*>(&estimator);
105  if(locEstimator){
106 
107  concepts::Set<error_index> locErrors;
109  //sort all errors
110  for( iter= locEstimator->begin(); iter != locEstimator->end(); ++iter)
111  locErrors.insert(error_index(iter->first, iter->second));
112 
113  //get the maximal local error = last element in Set
114  concepts::Real maxErr = locErrors.rbegin()->err;
115 
116  //DEBUGL(1, locErrors);
117 
118  for( iter= locEstimator->begin(); iter != locEstimator->end(); ++iter){
119  if(iter->second > theta * maxErr )
120  this->mark_.insert(iter->first);
121  }
122  }else //just localEstimators are implemented right now
123  throw conceptsException(concepts::MissingFeature("not implemented"));
124 
125 
126  }
127 
128 
129 
130 
131 protected:
132  virtual std::ostream& info(std::ostream& os) const {
133  return os << "Marking( "<< this->mark_<<")";
134  }
135 
136 
137 
138 };
139 
151 class MVMarking : public Marking{
152 public:
158  template<class F= concepts::Real>
160  //sum all local errors squared
161  concepts::Real sum = 0.0;
162 
164  for( iter = estimator.begin(); iter != estimator.end(); ++iter)
165  sum += iter->second * iter->second;
166  //compute the mean value
167  oEta_2_ = sum / estimator.nelm();
168 
169  for( iter = estimator.begin(); iter != estimator.end(); ++iter){
170  if (sigma * oEta_2_ < iter->second * iter->second)
171  this->mark_.insert(iter->first);
172  }
173  }
174 
175  //inline const Set<uint>& marks() const{ return mark_;}
176 
177 protected:
178  virtual std::ostream& info(std::ostream& os) const {
179  os << "MVMarking[ mean error = " << oEta_2_ << " << sigma_ = "<< sigma_ << " #marked Elements = "<<this->mark_.size() <<"]";
180  return os << " marked elements : "<< this->mark_ << std::endl;
181  }
182 
183 private:
184  //mean value of error squared : \overline\eta^2
186  //choose value
188 // //set of key of tagged elements
189 // concepts::Set<uint> mark_;
190 
191 };
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 }
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 #endif // marking_hh
error_index(uint elmkey, concepts::Real error)
Definition: marking.hh:24
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: marking.hh:132
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
concepts::Real err
Definition: marking.hh:36
bool operator!=(error_index const &right)
Definition: marking.hh:32
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: marking.hh:82
AMarking(const concepts::Estimator< F > &estimator, uint no)
Marking strategy just marks the cells with theta*100% most error appearence.
Definition: marking.hh:54
concepts::Real sigma_
Definition: marking.hh:187
concepts::Set< uint > mark_
Definition: marking.hh:19
HashMap< Real >::const_iterator const_iterator
Definition: estimator.hh:96
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: marking.hh:178
Abstract class on Marking.
Definition: marking.hh:15
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: marking.hh:40
bool operator<(error_index const &right) const
Definition: marking.hh:26
const concepts::Set< uint > & marks() const
Definition: marking.hh:17
Exception class to express a missing feature.
Definition: exceptions.hh:206
MVMarking(const concepts::LocalEstimator< F > &estimator, concepts::Real sigma=0.75)
Constructor.
Definition: marking.hh:159
Mean value marking strategy.
Definition: marking.hh:151
concepts::Real oEta_2_
Definition: marking.hh:185
BMarking(const concepts::Estimator< F > &estimator, concepts::Real theta=0.7)
Marking strategy just marks the cells with theta*100% most error appearence.
Definition: marking.hh:102
Class providing an output operator.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich