ViennaGrid - The Vienna Grid Library  2.1.0
viennagrid/io/vtk_common.hpp
Go to the documentation of this file.
00001 #ifndef VIENNAGRID_IO_VTK_COMMON_HPP
00002 #define VIENNAGRID_IO_VTK_COMMON_HPP
00003 
00004 /* =======================================================================
00005    Copyright (c) 2011-2014, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008 
00009                             -----------------
00010                      ViennaGrid - The Vienna Grid Library
00011                             -----------------
00012 
00013    License:      MIT (X11), see file LICENSE in the base directory
00014 ======================================================================= */
00015 
00016 
00017 #include <fstream>
00018 #include <iostream>
00019 #include "viennagrid/io/helper.hpp"
00020 #include "viennagrid/topology/all.hpp"
00021 #include "viennagrid/forwards.hpp"
00022 
00027 namespace viennagrid
00028 {
00029   namespace io
00030   {
00031     namespace detail
00032     {
00039       template <typename ElementTag>
00040       struct ELEMENT_TAG_TO_VTK_TYPE
00041       {
00042         static const int value = ElementTag::ERROR_ELEMENT_TYPE_NOT_SUPPORTED;
00043       };
00044 
00046       template <>
00047       struct ELEMENT_TAG_TO_VTK_TYPE<hexahedron_tag>
00048       {
00049         static const int value = 12;
00050       };
00051 
00053       template <>
00054       struct ELEMENT_TAG_TO_VTK_TYPE<tetrahedron_tag>
00055       {
00056         static const int value = 10;
00057       };
00058 
00060       template <>
00061       struct ELEMENT_TAG_TO_VTK_TYPE<quadrilateral_tag>
00062       {
00063         static const int value = 9;
00064       };
00065 
00067       template <>
00068       struct ELEMENT_TAG_TO_VTK_TYPE<triangle_tag>
00069       {
00070         static const int value = 5;
00071       };
00072 
00074       template <>
00075       struct ELEMENT_TAG_TO_VTK_TYPE<hypercube_tag<1> >
00076       {
00077         static const int value = 3;
00078       };
00079 
00081       template <>
00082       struct ELEMENT_TAG_TO_VTK_TYPE<simplex_tag<1> >
00083       {
00084         static const int value = 3;
00085       };
00086 
00091       template <typename CellTag>
00092       struct vtk_to_viennagrid_orientations
00093       {
00094         std::size_t operator()(std::size_t j) const { return j; }  //default case: do nothing
00095       };
00096 
00101       template <typename CellTag>
00102       struct viennagrid_to_vtk_orientations
00103       {
00104         std::size_t operator()(std::size_t j) const { return j; }  //default case: do nothing
00105       };
00106 
00108       template <>
00109       struct vtk_to_viennagrid_orientations<quadrilateral_tag>
00110       {
00111         std::size_t operator()(std::size_t j) const
00112         {
00113           switch (j)
00114           {
00115             case 2: return 3;
00116             case 3: return 2;
00117             default: return j;
00118           }
00119           //return j;  //unreachable code
00120         }
00121       };
00122 
00124       template <>
00125       struct viennagrid_to_vtk_orientations<quadrilateral_tag>
00126       {
00127         std::size_t operator()(std::size_t j) const
00128         {
00129           return vtk_to_viennagrid_orientations<quadrilateral_tag>()(j);
00130         }
00131       };
00132 
00133       // for hexahedra:
00135       template <>
00136       struct vtk_to_viennagrid_orientations<hexahedron_tag>
00137       {
00138         std::size_t operator()(std::size_t j) const
00139         {
00140           switch (j)
00141           {
00142             case 2: return 3;
00143             case 3: return 2;
00144             case 6: return 7;
00145             case 7: return 6;
00146             default: return j;
00147           }
00148           //return j;  //unreachable code
00149         }
00150       };
00151 
00153       template <>
00154       struct viennagrid_to_vtk_orientations<hexahedron_tag>
00155       {
00156         std::size_t operator()(std::size_t j) const
00157         {
00158           return vtk_to_viennagrid_orientations<hexahedron_tag>()(j);
00159         }
00160       };
00161     } //namespace detail
00162   } //namespace io
00163 } //namespace viennagrid
00164 
00165 #endif
00166