ViennaGrid - The Vienna Grid Library  2.1.0
viennagrid/topology/hexahedron.hpp
Go to the documentation of this file.
00001 #ifndef VIENNAGRID_CONFIG_HEXAHEDRON_HPP
00002 #define VIENNAGRID_CONFIG_HEXAHEDRON_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 #include "viennagrid/forwards.hpp"
00017 #include "viennagrid/topology/line.hpp"
00018 #include "viennagrid/topology/quadrilateral.hpp"
00019 
00024 namespace viennagrid
00025 {
00026 
00028   template <>
00029   struct hypercube_tag<3>
00030   {
00031     typedef hypercube_tag<2> facet_tag;
00032 
00033     static const int dim = 3;
00034     static std::string name() { return "hexahedron"; }
00035   };
00036 
00038   template <>
00039   struct boundary_elements<hypercube_tag<3>, hypercube_tag<2> >
00040   {
00041     typedef static_layout_tag     layout_tag;
00042     static const int num = 6;
00043   };
00044 
00046   template <>
00047   struct boundary_elements<hypercube_tag<3>, simplex_tag<1> >
00048   {
00049     typedef static_layout_tag     layout_tag;
00050     static const int num = 12;
00051   };
00052 
00054   template <>
00055   struct boundary_elements<hypercube_tag<3>, simplex_tag<0> >
00056   {
00057     typedef static_layout_tag     layout_tag;
00058     static const int num = 8;
00059   };
00060 
00061 
00062 
00063   namespace detail
00064   {
00065 //         //fill edges according to reference orientation (use monospaced font for Full-HD ascii-art):
00066 //         //
00067 //         //              e11
00068 //         //    v6-----------------v7
00069 //         // e9  /|            e10/|
00070 //         //    / |   e8      v5 / |
00071 //         // v4------------------  |e7
00072 //         //   |  |e6           |  |
00073 //         // e2|  |______e5_____|__|
00074 //         //   |  /v2         e4| /  v3
00075 //         //   | /e1            |/ e3
00076 //         // v0 ----------------  v1
00077 //         //           e0
00078 //         //
00079 
00080     template<typename BoundaryElementType>
00081     struct boundary_element_generator<hypercube_tag<3>, simplex_tag<1>, BoundaryElementType>
00082     {
00083       template<typename element_type, typename inserter_type>
00084       static void create_boundary_elements(element_type & element, inserter_type & inserter)
00085       {
00086         BoundaryElementType boundary_element( inserter.get_physical_container_collection() );
00087         std::size_t index = 0;
00088 
00089         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00090         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 1 );
00091         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00092 
00093         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00094         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 1 );
00095         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00096 
00097         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00098         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 1 );
00099         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00100 
00101         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 0 );
00102         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 1 );
00103         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00104 
00105         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 0 );
00106         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 1 );
00107         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00108 
00109         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 0 );
00110         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 1 );
00111         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00112 
00113         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 0 );
00114         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 1 );
00115         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00116 
00117         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 0 );
00118         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 1 );
00119         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00120 
00121         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 0 );
00122         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 1 );
00123         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00124 
00125         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 0 );
00126         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(6), 1 );
00127         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00128 
00129         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 0 );
00130         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 1 );
00131         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00132 
00133         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(6), 0 );
00134         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 1 );
00135         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00136       }
00137     };
00138 
00139 
00140 
00141 
00142 //         //fill edges according to reference orientation (use monospaced font for Full-HD ascii-art):
00143 //         //
00144 //         //
00145 //         //    v6-----------------v7
00146 //         //     /|      f5       /|
00147 //         //    / |           v5 / |
00148 //         // v4------------------  |
00149 //         //   |f2|  (f4-back)  |f3|
00150 //         //   |  |_____________|__|
00151 //         //   |  /v2   f1      | /  v3
00152 //         //   | /              |/
00153 //         // v0 ----------------  v1
00154 //         //       (f0-bottom)
00155 //         //
00156 //         // orientation is such that facet normals point out of the cell
00157 
00158     template<typename BoundaryElementType>
00159     struct boundary_element_generator<hypercube_tag<3>, hypercube_tag<2>, BoundaryElementType>
00160     {
00161       template<typename element_type, typename inserter_type>
00162       static void create_boundary_elements(element_type & element, inserter_type & inserter)
00163       {
00164         BoundaryElementType boundary_element( inserter.get_physical_container_collection() );
00165         std::size_t index = 0;
00166 
00167         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00168         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 1 );
00169         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 2 );
00170         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 3 );
00171         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00172 
00173         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00174         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 1 );
00175         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 2 );
00176         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 3 );
00177         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00178 
00179         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 0 );
00180         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 1 );
00181         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 2 );
00182         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(6), 3 );
00183         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00184 
00185         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(1), 0 );
00186         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 1 );
00187         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 2 );
00188         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 3 );
00189         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00190 
00191         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(2), 0 );
00192         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(3), 1 );
00193         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(6), 2 );
00194         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 3 );
00195         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00196 
00197         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(4), 0 );
00198         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(5), 1 );
00199         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(6), 2 );
00200         boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(7), 3 );
00201         element.set_boundary_element( boundary_element, inserter.template insert<true, true>(boundary_element), index++ );
00202       }
00203     };
00204 
00205   } //topology
00206 }
00207 
00208 #endif
00209