dune-localfunctions
2.1.1
|
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set ts=4 sw=2 et sts=2: 00003 #ifndef DUNE_Q1_LOCALINTERPOLATION_HH 00004 #define DUNE_Q1_LOCALINTERPOLATION_HH 00005 00006 #include <vector> 00007 00008 namespace Dune 00009 { 00010 00012 template<int dim, class LB> 00013 class Q1LocalInterpolation 00014 { 00015 public: 00016 00018 template<typename F, typename C> 00019 void interpolate (const F& f, std::vector<C>& out) const 00020 { 00021 typename LB::Traits::DomainType x; 00022 typename LB::Traits::RangeType y; 00023 00024 out.resize(1<<dim); 00025 00026 for (int i=0; i< (1<<dim); i++) { 00027 00028 // Generate coordinate of the i-th corner of the reference cube 00029 // We could use the ReferenceElement for this as well, but it is 00030 // still not clear how dune-localfunctions should have access to them. 00031 for (int j=0; j<dim; j++) 00032 x[j] = (i & (1<<j)) ? 1.0 : 0.0; 00033 00034 f.evaluate(x,y); out[i] = y; 00035 00036 } 00037 } 00038 00039 }; 00040 } 00041 00042 #endif