hierarchicalsimplexp2localinterpolation.hh
Go to the documentation of this file.00001
00002
00003 #ifndef DUNE_HIERARCHICAL_SIMPLEX_P2_LOCALINTERPOLATION_HH
00004 #define DUNE_HIERARCHICAL_SIMPLEX_P2_LOCALINTERPOLATION_HH
00005
00006 #include <vector>
00007
00008 namespace Dune
00009 {
00013 template<class LB>
00014 class HierarchicalSimplexP2LocalInterpolation
00015 {
00016 public:
00017
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 dune_static_assert(LB::Traits::dimDomain <=3, "LocalInterpolation for HierarchicalSimplexP2 finite elements"
00025 " is only implemented for dimDomain <=3!");
00026
00027 switch ( int(LB::Traits::dimDomain)) {
00028
00029 case 1:
00030
00031 out.resize(3);
00032
00033
00034 x[0] = 0.0; f.evaluate(x, y); out[0] = y;
00035 x[0] = 1.0; f.evaluate(x, y); out[2] = y;
00036
00037
00038 x[0] = 0.5; f.evaluate(x, y);
00039 out[1] = y - 0.5*(out[0] + out[2]);
00040
00041 break;
00042
00043
00044 case 2:
00045
00046 out.resize(6);
00047
00048
00049 x[0] = 0.0; x[1] = 0.0; f.evaluate(x, y); out[0] = y;
00050 x[0] = 1.0; x[1] = 0.0; f.evaluate(x, y); out[2] = y;
00051 x[0] = 0.0; x[1] = 1.0; f.evaluate(x, y); out[5] = y;
00052
00053
00054 x[0] = 0.5; x[1] = 0.0; f.evaluate(x, y);
00055 out[1] = y - 0.5*(out[0] + out[2]);
00056
00057 x[0] = 0.0; x[1] = 0.5; f.evaluate(x, y);
00058 out[3] = y - 0.5*(out[0] + out[5]);
00059
00060 x[0] = 0.5; x[1] = 0.5; f.evaluate(x, y);
00061 out[4] = y - 0.5*(out[2] + out[5]);
00062
00063 break;
00064
00065 case 3:
00066
00067 out.resize(10);
00068
00069
00070 x[0] = 0.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[0] = y;
00071 x[0] = 1.0; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y); out[2] = y;
00072 x[0] = 0.0; x[1] = 1.0; x[2] = 0.0; f.evaluate(x, y); out[5] = y;
00073 x[0] = 0.0; x[1] = 0.0; x[2] = 1.0; f.evaluate(x, y); out[9] = y;
00074
00075
00076 x[0] = 0.5; x[1] = 0.0; x[2] = 0.0; f.evaluate(x, y);
00077 out[1] = y - 0.5*(out[0] + out[2]);
00078
00079 x[0] = 0.0; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
00080 out[3] = y - 0.5*(out[0] + out[5]);
00081
00082 x[0] = 0.5; x[1] = 0.5; x[2] = 0.0; f.evaluate(x, y);
00083 out[4] = y - 0.5*(out[2] + out[5]);
00084
00085 x[0] = 0.0; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
00086 out[6] = y - 0.5*(out[0] + out[9]);
00087
00088 x[0] = 0.5; x[1] = 0.0; x[2] = 0.5; f.evaluate(x, y);
00089 out[7] = y - 0.5*(out[2] + out[9]);
00090
00091 x[0] = 0.0; x[1] = 0.5; x[2] = 0.5; f.evaluate(x, y);
00092 out[8] = y - 0.5*(out[5] + out[9]);
00093
00094 break;
00095
00096 }
00097 }
00098
00099 };
00100 }
00101
00102 #endif