00001 #ifndef VIENNAFEM_BASES_ALL_HPP
00002 #define VIENNAFEM_BASES_ALL_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "viennafem/forwards.h"
00018
00019 #include "viennafem/bases/line.hpp"
00020
00021 #include "viennafem/bases/quadrilateral.hpp"
00022 #include "viennafem/bases/triangle.hpp"
00023
00024 #include "viennafem/bases/hexahedron.hpp"
00025 #include "viennafem/bases/tetrahedron.hpp"
00026
00031 namespace viennafem
00032 {
00033
00035 template <typename InterfaceType,
00036 typename BasisTag = viennafem::none>
00037 struct basis_factory
00038 {
00039 typedef viennamath::rt_expr<InterfaceType> expression_type;
00040
00041 template <typename T>
00042 static std::vector<expression_type> get(std::size_t space_id, T const & reference_cell)
00043 {
00044 switch (space_id)
00045 {
00046 case space_to_id< lagrange_tag<1> >::value: return basis_factory<InterfaceType, lagrange_tag<1> >::get(reference_cell);
00047 case space_to_id< lagrange_tag<2> >::value: return basis_factory<InterfaceType, lagrange_tag<2> >::get(reference_cell);
00048
00049 }
00050
00051 std::cerr << "Space ID unknown!" << std::endl;
00052 throw "unknown";
00053
00054 return std::vector<expression_type>();
00055 }
00056
00057 };
00058
00060 template <typename InterfaceType>
00061 struct basis_factory <InterfaceType, lagrange_tag<1> >
00062 {
00063 typedef viennamath::rt_expr<InterfaceType> expression_type;
00064 typedef lagrange_tag<1> basis_tag;
00065
00066 static std::vector<expression_type> get(viennafem::unit_interval)
00067 {
00068 std::vector<expression_type> ret;
00069 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 0>::get() );
00070 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 1>::get() );
00071
00072 return ret;
00073 }
00074
00075 static std::vector<expression_type> get(viennafem::unit_square)
00076 {
00077 std::vector<expression_type> ret;
00078 ret.reserve(4);
00079 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 0>::get() );
00080 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 1>::get() );
00081 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 2>::get() );
00082 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 3>::get() );
00083
00084 return ret;
00085 }
00086
00087 static std::vector<expression_type> get(viennafem::unit_triangle)
00088 {
00089 std::vector<expression_type> ret;
00090 ret.reserve(3);
00091 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 0>::get() );
00092 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 1>::get() );
00093 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 2>::get() );
00094
00095 return ret;
00096 }
00097
00098 static std::vector<expression_type> get(viennafem::unit_cube)
00099 {
00100 std::vector<expression_type> ret;
00101 ret.reserve(8);
00102 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 0>::get() );
00103 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 1>::get() );
00104 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 2>::get() );
00105 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 3>::get() );
00106
00107 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 4>::get() );
00108 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 5>::get() );
00109 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 6>::get() );
00110 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 7>::get() );
00111
00112 return ret;
00113 }
00114
00115 static std::vector<expression_type> get(viennafem::unit_tetrahedron)
00116 {
00117 std::vector<expression_type> ret;
00118 ret.reserve(4);
00119 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 0>::get() );
00120 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 1>::get() );
00121 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 2>::get() );
00122 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 3>::get() );
00123
00124 return ret;
00125 }
00126
00127 };
00128
00129
00130
00131
00132
00134 template <typename InterfaceType>
00135 struct basis_factory <InterfaceType, lagrange_tag<2> >
00136 {
00137 typedef viennamath::rt_expr<InterfaceType> expression_type;
00138 typedef lagrange_tag<2> basis_tag;
00139
00140 static std::vector<expression_type> get(viennafem::unit_interval)
00141 {
00142 std::vector<expression_type> ret;
00143 ret.reserve(3);
00144 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 0>::get() );
00145 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 1>::get() );
00146 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 1, 0>::get() );
00147
00148 return ret;
00149 }
00150
00151 static std::vector<expression_type> get(viennafem::unit_square)
00152 {
00153 std::vector<expression_type> ret;
00154 ret.reserve(8);
00155 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 0>::get() );
00156 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 1>::get() );
00157 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 2>::get() );
00158 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 0, 3>::get() );
00159
00160 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 1, 0>::get() );
00161 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 1, 1>::get() );
00162 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 1, 2>::get() );
00163 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_square, 1, 3>::get() );
00164
00165 return ret;
00166 }
00167
00168 static std::vector<expression_type> get(viennafem::unit_triangle)
00169 {
00170 std::vector<expression_type> ret;
00171 ret.reserve(6);
00172 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 0>::get() );
00173 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 1>::get() );
00174 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 0, 2>::get() );
00175
00176 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 1, 0>::get() );
00177 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 1, 1>::get() );
00178 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_triangle, 1, 2>::get() );
00179
00180 return ret;
00181 }
00182
00183 static std::vector<expression_type> get(viennafem::unit_cube)
00184 {
00185 std::vector<expression_type> ret;
00186 ret.reserve(20);
00187 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 0>::get() );
00188 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 1>::get() );
00189 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 2>::get() );
00190 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 3>::get() );
00191
00192 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 4>::get() );
00193 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 5>::get() );
00194 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 6>::get() );
00195 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 0, 7>::get() );
00196
00197
00198 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 0>::get() );
00199 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 1>::get() );
00200 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 2>::get() );
00201 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 3>::get() );
00202
00203 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 4>::get() );
00204 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 5>::get() );
00205 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 6>::get() );
00206 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 7>::get() );
00207
00208 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 8>::get() );
00209 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 9>::get() );
00210 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 10>::get() );
00211 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_cube, 1, 11>::get() );
00212
00213 return ret;
00214 }
00215
00216 static std::vector<expression_type> get(viennafem::unit_tetrahedron)
00217 {
00218 std::vector<expression_type> ret;
00219 ret.reserve(10);
00220 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 0>::get() );
00221 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 1>::get() );
00222 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 2>::get() );
00223 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 0, 3>::get() );
00224
00225 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 0>::get() );
00226 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 1>::get() );
00227 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 2>::get() );
00228 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 3>::get() );
00229 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 4>::get() );
00230 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_tetrahedron, 1, 5>::get() );
00231
00232 return ret;
00233 }
00234
00235 };
00236
00237
00238
00239
00240
00242 template <typename InterfaceType>
00243 struct basis_factory <InterfaceType, lagrange_tag<3> >
00244 {
00245 typedef viennamath::rt_expr<InterfaceType> expression_type;
00246 typedef lagrange_tag<3> basis_tag;
00247
00248 static std::vector<expression_type> get(viennafem::unit_interval)
00249 {
00250 std::vector<expression_type> ret;
00251 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 0>::get() );
00252 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 0, 1>::get() );
00253 ret.push_back( local_basis<InterfaceType, basis_tag, viennafem::unit_interval, 1, 0>::get() );
00254
00255 return ret;
00256 }
00257
00258
00259 template <typename T>
00260 static std::vector<expression_type> get(T)
00261 {
00262 typedef typename T::ERROR_BASIS_FUNCTION_NOT_IMPLEMENTED error_type;
00263 return std::vector<expression_type>(1);
00264 }
00265 };
00266 }
00267
00268
00269 #endif