// $Id: adaptor.h,v 1.1.1.1 2000/11/02 08:47:16 fritzi Exp $ #ifndef __adaptor_h #define __adaptor_h #ifndef __triangulation_h #include #endif #ifndef __vector_h #include #endif class AdaptorStatistics { public: Vector distribution; double entropie,sigma; double eta_mean,eta_min,eta_max; double h_min,h_max; }; /* CLASS Adaptor Base class for refinement strategies. KEYWORDS Adaptor OVERVIEW Abstract base class. */ class Adaptor { protected: Triangulation& tr; Adaptor(Triangulation& t) : tr(t) {} public: virtual ~Adaptor(); ////////// // // Virtual operator executing adaption, i.e. marking for refinement. // It takes the result of the global error estimation as argument and // returns true if cells have to be refined. // int refined,double_refined,coarsened; virtual bool operator() (float estimate) = 0; void compute_statistics(AdaptorStatistics&); }; class ThreshAdaptor : public Adaptor { float ref1, ref2, coarse; float TOL; public: ////////// // // Constructor taking as arguments the triangulation as well as a local // tolerance // ThreshAdaptor(Triangulation& t, float tolerance, float refine_thresh = 1., float double_thresh = 1.e30, float coarse_thresh = 0.) : Adaptor(t), ref1(refine_thresh), ref2(double_thresh), coarse(coarse_thresh), TOL(tolerance) {} ////////// // // Change tolerance to a new value // void new_tolerance(float t) { TOL = t; } bool operator() (float); int estimate_N(); bool mark() { return (*this)(0.); } }; /* CLASS RelativeAdaptor Adaptor refining according to maximum criterion(). KEYWORDS Adaptor OVERVIEW In each adaptive step, first the maximum value C of refinement criteria is determined. Afterwards, cells are
  • refined, if crit > C * refine_thresh and
  • coarsened, if crit < C * coarse_thresh.
*/ class RelativeAdaptor : public Adaptor { float ref, coarse; public: ////////// // // Constructor initializing Triangulation, refine_thresh and coarse_thresh RelativeAdaptor(Triangulation& t, float refine_thresh = .5, float coarse_thresh = 0.) : Adaptor(t), ref(refine_thresh), coarse(coarse_thresh) {} bool operator() (float); }; /* CLASS AdaptorSort Provides a sorted list of cells to adapt. KEYWORDS Adaptor OVERVIEW ... */ class AdaptorSort { class AdaptCellPtr { Cell* c; public: AdaptCellPtr(Cell* p = 0) : c(p) {} void operator=(Cell* p) { c = p; } bool operator < (const AdaptCellPtr& p) const { return c->criterion() > p.c->criterion(); } Cell* cell() const { return c; } }; AdaptCellPtr* field; int m; public: ////////// AdaptorSort(); ////////// ~AdaptorSort(); ////////// // // Sort the cells of a triangulation. // void sort(Triangulation& tr); ////////// // // Access to sorted cells in descending order. // Cell* cell(int i) const; ////////// // // Total number of sorted cells. // int n() const { return m; } }; /* CLASS NCAdaptor Numerus clausus Adaptor KEYWORDS Adaptor OVERVIEW This adaptor refines a fixed number of cells specified by the user. The cells are refined from the one with worst criterion. There are two possible applications. You may refine by the same amount in each step or you may specify, that e.g. half of the cells are refined in each step. */ class NCAdaptor : public Adaptor, public AdaptorSort { bool absolute; union { int num; float share; } thr; public: ////////// // // Constructor taking as argument //
  • a number bigger than one to refine up to that number cells // in each step or //
  • a number between 0 and 1 to refine that share of the whole number // of cells.
// NCAdaptor(Triangulation& t, float thresh); bool operator() (float); bool mark() { return (*this)(0.); } bool mark(double, double = 0., double = 0.); }; inline Cell* AdaptorSort::cell(int i) const { THROW2(i>=n(), IntError(IntError::Range,i)); return field[i].cell(); } #endif