5#include "estimator/marking.hh"
15#define EPS DBL_EPSILON
19#define MAX_D std::numeric_limits<double>::max()
39 virtual std::ostream&
info(std::ostream& os)
const = 0;
58template<
class F = Real, u
short dim = 2>
67 std::unique_ptr<hp2D::hpAdaptiveSpaceH1::Scan> sc(spc->
scan());
75 if((iter = adjusts_.find(K)) != adjusts_.end())
76 spc->
adjust(*quad, iter->second);
98template<
class F = Real, u
short dim = 2>
107 enum Mode {H = 0 , P = 1};
123 const Real hdec = sqrt(4.0),
const Real pdec = sqrt(0.4),
const Real nRdec = 1.0):
124 hdecay_(hdec), pdecay_(pdec), noRefdecay_(nRdec)
130 std::unique_ptr<hp2D::hpAdaptiveSpaceH1::Scan> sc(spc->
scan());
136 pred_[K] = mode ? MAX_D : 0;
138 cells_[K] = &elm.
cell();
146 const ushort* pMax = hpfull.
innerDof(*cntr);
151 bool hasVDof = (hpfull.
vtxDof(*cntr, 0) || hpfull.
vtxDof(*cntr, 1) ||
156 for(ushort i = 0 ; i < dim; ++i)
172 for(ushort i = 0 ; i < dim; ++i)
195 for( ; cIter != cells_.end(); ++cIter){
197 uint K = cIter->first;
201 if (estimator(K) > pred_[K]){
206 hRefCurCells_.push_back(cIter->second);
210 pred_[K] = 0.5 * hdecay_ * std::pow(0.5,p_[K][0] ) * estimator(K);
222 p_[K][0] += 1; p_[K][1] += 1;
224 pred_[K] = pdecay_ * estimator(K);
231 pred_[K] = noRefdecay_ * pred_[K];
239 HP_Refinement<F,dim>::apply(space);
241 this->adjusts_.erase(this->adjusts_.begin(), this->adjusts_.end());
246 for(cIter = hRefCurCells_.begin(); cIter != hRefCurCells_.end(); ++cIter){
249 uint K = (*cIter)->connector().key().key();
254 for( ; (child = (*cIter)->
child(i)) !=0 ; ++i){
259 for(ushort i = 0 ; i < dim; ++i)
260 p_[cK][i] = p_[K][i];
262 pred_[cK] = pred_[K];
267 p_.erase(p_.find(K));
269 pred_.erase(pred_.find(K));
271 cells_.erase(cells_.find(K));
276 hRefCurCells_.erase(hRefCurCells_.begin(), hRefCurCells_.end());
282 virtual std::ostream&
info(std::ostream& os)
const{
283 os <<
" Prediction[ type = hprefinement Strategy ]" << std::endl;
284 os <<
"refinement chooses : "<< std::endl;
285 return os << this->adjusts_;
465template<
class F = Real, u
short dim = 2>
474 attrbs_.insert(attrb);
476 std::unique_ptr<typename concepts::SpaceOnCells<F>::Scanner> sc(space.
scan());
482 cells_[K] = &elm.
cell();
489 void addVertex(
const uint attrb){
490 attrbs_.insert(attrb);
508 for( uint i = 0; (vertex = cntr->
vertex(i) ) != 0; ++i){
528 virtual std::ostream&
info(std::ostream& os)
const{
529 return os <<
" AprioriVertex[ type = hp - Refinement Strategy ]";
#define conceptsException(exc)
uint attrib() const
Returns the attribute.
bool exist(F val) const
Returns true, if a value is in the set.
virtual Cell * child(uint i)=0
virtual Connector & connector() const =0
Returns the connector.
virtual Connector0 * vertex(uint i) const =0
const Key & key() const
Returns the key of the connector.
const Attribute & attrib() const
Returns the attribute of the connector.
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
uint key() const
Returns the key.
virtual Scanner * scan() const =0
Returns a scanner to iterate over the elements of the space.
AprioriVertex(const concepts::SpaceOnCells< F > &space, const uint attrb)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Prediction(const concepts::SpaceOnCells< F > &space, enum Mode mode=P, const Real hdec=sqrt(4.0), const Real pdec=sqrt(0.4), const Real nRdec=1.0)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const =0
Returns information in an output stream.
virtual const concepts::Quad & support() const
void rebuild(bool sameIndices=false)
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
virtual void adjust(const concepts::Element< F > &elm, const concepts::AdaptiveAdjustP< 2 > &a)
virtual const ushort * innerDof(const concepts::Connector2 &cntr) const
virtual bool vtxDof(const concepts::Connector2 &cntr, uint i) const
#define conceptsAssert(cond, exc)
Set< F > makeSet(uint n, const F &first,...)