Class documentation of Concepts

Loading...
Searching...
No Matches
marking.hh
1#ifndef marking_hh
2#define marking_hh
3
5//#include "meshGraph.hh"
6
7namespace estimator{
8
9// marking refinementstrategies like dörfler are not in that design atm
10
16public:
17 inline const concepts::Set<uint>& marks() const{return mark_;}
18protected:
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
39protected:
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
47class AMarking : public Marking{
48
49public:
53 template<class F= concepts::Real>
54 AMarking(const concepts::Estimator<F>& estimator, uint no){
55
56 const concepts::LocalEstimator<F>* locEstimator = dynamic_cast<const concepts::LocalEstimator<F>*>(&estimator);
57 if(locEstimator){
58
60 typename concepts::LocalEstimator<F>::const_iterator iter;
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
81protected:
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
95class BMarking : public Marking{
96
97public:
101 template<class F= concepts::Real>
102 BMarking(const concepts::Estimator<F>& estimator, concepts::Real theta = 0.7){
103
104 const concepts::LocalEstimator<F>* locEstimator = dynamic_cast<const concepts::LocalEstimator<F>*>(&estimator);
105 if(locEstimator){
106
108 typename concepts::LocalEstimator<F>::const_iterator iter;
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
131protected:
132 virtual std::ostream& info(std::ostream& os) const {
133 return os << "Marking( "<< this->mark_<<")";
134 }
135
136
137
138};
139
151class MVMarking : public Marking{
152public:
158 template<class F= concepts::Real>
159 MVMarking(const concepts::LocalEstimator<F>& estimator, concepts::Real sigma = 0.75): sigma_(sigma){
160 //sum all local errors squared
161 concepts::Real sum = 0.0;
162
163 typename concepts::LocalEstimator<F>::const_iterator iter;
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
177protected:
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
183private:
184 //mean value of error squared : \overline\eta^2
185 concepts::Real oEta_2_;
186 //choose value
187 concepts::Real sigma_;
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
#define conceptsException(exc)
AMarking(const concepts::Estimator< F > &estimator, uint no)
Definition marking.hh:54
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition marking.hh:82
BMarking(const concepts::Estimator< F > &estimator, concepts::Real theta=0.7)
Definition marking.hh:102
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition marking.hh:132
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition marking.hh:178
MVMarking(const concepts::LocalEstimator< F > &estimator, concepts::Real sigma=0.75)
Definition marking.hh:159
double Real
Definition typedefs.hh:39
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition marking.hh:40