ViennaGrid - The Vienna Grid Library
2.1.0
|
00001 #ifndef VIENNAGRID_TOPOLOGY_POLYGON_HPP 00002 #define VIENNAGRID_TOPOLOGY_POLYGON_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/simplex.hpp" 00018 00023 namespace viennagrid 00024 { 00025 00027 struct polygon_tag 00028 { 00029 typedef simplex_tag<1> facet_tag; 00030 00031 static const int dim = 2; 00032 static std::string name() { return "polygon"; } 00033 }; 00034 00035 00036 //Line: 00038 template <> 00039 struct boundary_elements<polygon_tag, vertex_tag> 00040 { 00041 typedef dynamic_layout_tag layout_tag; 00042 static const int num = -1; 00043 }; 00044 00046 template <> 00047 struct boundary_elements<polygon_tag, line_tag> 00048 { 00049 typedef dynamic_layout_tag layout_tag; 00050 static const int num = -1; 00051 }; 00052 00053 00054 namespace detail 00055 { 00056 template<typename BoundaryElementType> 00057 struct boundary_element_generator<polygon_tag, simplex_tag<1>, BoundaryElementType> 00058 { 00059 template<typename element_type, typename inserter_type> 00060 static void create_boundary_elements(element_type & element, inserter_type & inserter) 00061 { 00062 BoundaryElementType boundary_element( inserter.get_physical_container_collection() ); 00063 00064 std::size_t index = 0; 00065 for (std::size_t i = 0; i < element.container( dimension_tag<0>() ).size()-1; ++i) 00066 { 00067 boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(i), 0 ); 00068 boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(i+1), 1 ); 00069 element.set_boundary_element( boundary_element, inserter(boundary_element), index++ ); 00070 } 00071 00072 00073 boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at( element.container( dimension_tag<0>() ).size()-1 ), 0 ); 00074 boundary_element.container(dimension_tag<0>()).set_handle( element.container( dimension_tag<0>() ).handle_at(0), 1 ); 00075 element.set_boundary_element( boundary_element, inserter(boundary_element), index++ ); 00076 } 00077 }; 00078 00079 00080 } //topology 00081 } 00082 00083 #endif 00084