dune-localfunctions
2.1.1
|
00001 // -*- tab-width: 8; indent-tabs-mode: nil -*- 00002 // vi: set ts=8 sw=2 et sts=2: 00003 #ifndef DUNE_REFINED_P0_LOCALINTERPOLATION_HH 00004 #define DUNE_REFINED_P0_LOCALINTERPOLATION_HH 00005 00006 #include <dune/localfunctions/refined/refinedp0/refinedp0localbasis.hh> 00007 00008 namespace Dune 00009 { 00010 template<class LB> 00011 class RefinedP0LocalInterpolation 00012 {}; 00013 00014 template<class D, class R> 00015 class RefinedP0LocalInterpolation<RefinedP0LocalBasis<D,R,2> > 00016 { 00017 typedef RefinedP0LocalBasis<D,R,2> LB; 00018 typedef typename LB::Traits::DomainType DT; 00019 00020 public: 00021 RefinedP0LocalInterpolation() : 00022 interpolationPoints_(4) 00023 { 00024 // Interpolation is done by evaluating at the subtriangle centers 00025 interpolationPoints_[0][0] = 1.0/6; 00026 interpolationPoints_[0][1] = 1.0/6; 00027 00028 interpolationPoints_[1][0] = 4.0/6; 00029 interpolationPoints_[1][1] = 1.0/6; 00030 00031 interpolationPoints_[2][0] = 1.0/6; 00032 interpolationPoints_[2][1] = 4.0/6; 00033 00034 interpolationPoints_[3][0] = 2.0/6; 00035 interpolationPoints_[3][1] = 2.0/6; 00036 } 00037 00038 00039 template<typename F, typename C> 00040 void interpolate (const F& f, std::vector<C>& out) const 00041 { 00042 typename LB::Traits::RangeType y; 00043 out.resize(interpolationPoints_.size()); 00044 for (int i = 0; i < out.size(); ++i) 00045 { 00046 f.evaluate(interpolationPoints_[i], y); 00047 out[i] = y; 00048 } 00049 } 00050 00051 private: 00052 std::vector<DT> interpolationPoints_; 00053 }; 00054 00055 template<class D, class R> 00056 class RefinedP0LocalInterpolation<RefinedP0LocalBasis<D,R,3> > 00057 { 00058 typedef RefinedP0LocalBasis<D,R,3> LB; 00059 typedef typename LB::Traits::DomainType DT; 00060 00061 public: 00062 RefinedP0LocalInterpolation() : 00063 interpolationPoints_(8) 00064 { 00065 // Interpolation is done by evaluating at the subtriangle centers 00066 interpolationPoints_[0][0] = 1.0/8; 00067 interpolationPoints_[0][1] = 1.0/8; 00068 interpolationPoints_[0][2] = 1.0/8; 00069 00070 interpolationPoints_[1][0] = 5.0/8; 00071 interpolationPoints_[1][1] = 1.0/8; 00072 interpolationPoints_[1][2] = 1.0/8; 00073 00074 interpolationPoints_[2][0] = 1.0/8; 00075 interpolationPoints_[2][1] = 5.0/8; 00076 interpolationPoints_[2][2] = 1.0/8; 00077 00078 interpolationPoints_[3][0] = 1.0/8; 00079 interpolationPoints_[3][1] = 1.0/8; 00080 interpolationPoints_[3][2] = 5.0/8; 00081 00082 interpolationPoints_[4][0] = 1.0/4; 00083 interpolationPoints_[4][1] = 1.0/8; 00084 interpolationPoints_[4][2] = 1.0/4; 00085 00086 interpolationPoints_[5][0] = 3.0/8; 00087 interpolationPoints_[5][1] = 1.0/4; 00088 interpolationPoints_[5][2] = 1.0/8; 00089 00090 interpolationPoints_[6][0] = 1.0/8; 00091 interpolationPoints_[6][1] = 1.0/4; 00092 interpolationPoints_[6][2] = 3.0/8; 00093 00094 interpolationPoints_[7][0] = 1.0/4; 00095 interpolationPoints_[7][1] = 3.0/8; 00096 interpolationPoints_[7][2] = 1.0/4; 00097 } 00098 00099 00100 template<typename F, typename C> 00101 void interpolate (const F& f, std::vector<C>& out) const 00102 { 00103 typename LB::Traits::RangeType y; 00104 out.resize(interpolationPoints_.size()); 00105 for (int i = 0; i < out.size(); ++i) 00106 { 00107 f.evaluate(interpolationPoints_[i], y); 00108 out[i] = y; 00109 } 00110 } 00111 00112 private: 00113 std::vector<DT> interpolationPoints_; 00114 }; 00115 } 00116 00117 #endif