ViennaGrid - The Vienna Grid Library  2.1.0
viennagrid/config/element_config.hpp
Go to the documentation of this file.
00001 #ifndef VIENNAGRID_ELEMENT_CONFIG_HPP
00002 #define VIENNAGRID_ELEMENT_CONFIG_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 "viennagrid/storage/view.hpp"
00018 #include "viennagrid/element/element_orientation.hpp"
00019 #include "viennagrid/config/config.hpp"
00020 #include "viennagrid/topology/polygon.hpp"
00021 
00022 
00027 namespace viennagrid
00028 {
00029   namespace config
00030   {
00031     namespace result_of
00032     {
00034       template<typename storage_layout_tag, int num>
00035       struct boundary_cell_container_tag;
00036 
00037       template<int num>
00038       struct boundary_cell_container_tag<viennagrid::static_layout_tag, num>
00039       {
00040         typedef viennagrid::static_array_tag<num> type;
00041       };
00042 
00043       template<int num>
00044       struct boundary_cell_container_tag<viennagrid::dynamic_layout_tag, num>
00045       {
00046         typedef viennagrid::std_vector_tag type;
00047       };
00048 
00049 
00050 
00051       //
00052       // Generates an element type
00053       //
00054 
00056       template<typename WrappedConfigType, typename element_tag>
00057       struct is_element_present
00058       {
00059         typedef typename query<WrappedConfigType, null_type, element_tag>::type  ElementConfigType;
00060 
00061         static const bool value = !viennagrid::detail::EQUAL<ElementConfigType, viennagrid::not_found>::value;
00062       };
00063 
00064 
00066       template<typename WrappedConfigType, typename element_tag>
00067       struct query_element_id_tag
00068       {
00069         typedef typename query<WrappedConfigType, viennagrid::smart_id_tag<int>, element_tag, element_id_tag>::type  type;
00070       };
00071 
00073       template<typename WrappedConfigType, typename element_tag>
00074       struct query_element_container_tag
00075       {
00076         typedef typename query<WrappedConfigType, viennagrid::handled_container_tag<viennagrid::std_deque_tag, viennagrid::pointer_handle_tag>, element_tag, element_container_tag>::type  type;
00077       };
00078 
00080       template<typename WrappedConfigType, typename element_tag>
00081       struct query_appendix_type
00082       {
00083         typedef typename query<WrappedConfigType, null_type, element_tag, element_appendix_type_tag>::type  type;
00084       };
00085 
00086       template<typename WrappedConfigType>
00087       struct query_appendix_type<WrappedConfigType, plc_tag>
00088       {
00089         typedef typename query_appendix_type<WrappedConfigType, vertex_tag>::type PointType;
00090         typedef std::vector<PointType> type;
00091       };
00092 
00093 
00095       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT, bool is_present = is_element_present<WrappedConfigT, BoundaryElementTagT>::value >
00096       struct has_boundary_helper
00097       {
00098         static const bool value =
00099             !viennagrid::detail::EQUAL<
00100                 typename query<WrappedConfigT, viennagrid::no_handling_tag, HostElementTagT, element_boundary_storage_layout_tag, BoundaryElementTagT>::type,
00101                 viennagrid::no_handling_tag
00102             >::value;
00103       };
00104 
00105       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00106       struct has_boundary_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, false>
00107       {
00108         static const bool value = false;
00109       };
00110 
00111 
00113       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00114       struct has_boundary
00115       {
00116         static const bool is_present = is_element_present<WrappedConfigT, BoundaryElementTagT>::value;
00117         static const bool value = has_boundary_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, is_present>::value;
00118       };
00119 
00120 
00122       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT, bool is_present = is_element_present<WrappedConfigT, BoundaryElementTagT>::value >
00123       struct has_orientation_helper
00124       {
00125         static const bool value =
00126             viennagrid::detail::EQUAL<
00127                 typename query<WrappedConfigT, viennagrid::no_handling_tag, HostElementTagT, element_boundary_storage_layout_tag, BoundaryElementTagT>::type,
00128                 viennagrid::full_handling_tag
00129             >::value
00130                 ||
00131             viennagrid::detail::EQUAL<
00132                 typename query<WrappedConfigT, viennagrid::no_handling_tag, HostElementTagT, element_boundary_storage_layout_tag, BoundaryElementTagT>::type,
00133                 viennagrid::full_lazy_handling_tag
00134             >::value;
00135       };
00136 
00137       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00138       struct has_orientation_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, false>
00139       {
00140         static const bool value = false;
00141       };
00142 
00143 
00145       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00146       struct has_orientation
00147       {
00148         static const bool is_present = is_element_present<WrappedConfigT, BoundaryElementTagT>::value;
00149         static const bool value = has_orientation_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, is_present>::value;
00150       };
00151 
00152 
00153 
00154 
00155 
00156       // TODO: handle possible other tags (lazy_handling_tag, ...)
00158       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT, bool is_present>
00159       struct element_boundary_element_container_helper
00160       {
00161         //
00162         // boundary cell view
00163         //
00164         typedef viennagrid::element<BoundaryElementTagT, WrappedConfigT> boundary_cell_type;
00165 
00166         typedef typename viennagrid::result_of::container<
00167             boundary_cell_type,                                         // the 'value_type', i.e. vertices
00168             typename query_element_container_tag<WrappedConfigT, BoundaryElementTagT>::type
00169         >::type boundary_cell_container;
00170 
00171 
00172         typedef typename boundary_cell_container_tag<
00173                 typename viennagrid::boundary_elements< HostElementTagT, BoundaryElementTagT>::layout_tag,
00174                 viennagrid::boundary_elements< HostElementTagT, BoundaryElementTagT>::num
00175             >::type container_tag;
00176 
00177 
00178         typedef typename viennagrid::result_of::view<
00179                 boundary_cell_container,
00180                 container_tag
00181             >::type
00182         boundary_cell_view;
00183 
00184 
00185 
00186         //
00187         // Orientation
00188         //
00189 
00190         typedef typename viennagrid::result_of::permutator_type<
00191             viennagrid::boundary_elements<
00192                 BoundaryElementTagT,
00193                 typename BoundaryElementTagT::facet_tag
00194             >::num
00195         >::type permutator_type;
00196 
00197         typedef typename boundary_cell_container_tag<
00198                 typename viennagrid::boundary_elements< BoundaryElementTagT, typename BoundaryElementTagT::facet_tag>::layout_tag,
00199                 viennagrid::boundary_elements< BoundaryElementTagT, typename BoundaryElementTagT::facet_tag>::num
00200             >::type orientation_container_tag;
00201 
00202 
00203         typedef typename viennagrid::result_of::container<permutator_type, orientation_container_tag>::type orientation_container_type;
00204         typedef viennagrid::element_orientation<orientation_container_type> facet_orientation_type;
00205 
00206         typedef typename
00207             viennagrid::detail::IF<
00208                 has_orientation< WrappedConfigT, HostElementTagT, BoundaryElementTagT>::value,
00209                 typename viennagrid::result_of::container< facet_orientation_type, container_tag >::type,
00210                 viennagrid::null_type
00211             >::type facet_orientation_container_type;
00212 
00213 
00214         //
00215         // final container pair
00216         //
00217 
00218         typedef viennagrid::static_pair<
00219                         boundary_cell_view,
00220                         facet_orientation_container_type
00221                     > type;
00222       };
00223 
00224       template<typename WrappedConfigT, typename HostElementTagT, bool is_present>
00225       struct element_boundary_element_container_helper<WrappedConfigT, HostElementTagT, vertex_tag, is_present>
00226       {
00227         typedef vertex_tag BoundaryElementTag;
00228 
00229         //
00230         // boundary cell view
00231         //
00232 
00233         typedef viennagrid::element<BoundaryElementTag, WrappedConfigT> boundary_cell_type;
00234 
00235         typedef typename viennagrid::result_of::container<
00236             boundary_cell_type,                                         // the 'value_type', i.e. vertices
00237             typename query_element_container_tag<WrappedConfigT, BoundaryElementTag>::type
00238         >::type boundary_cell_container;
00239 
00240 
00241         typedef typename boundary_cell_container_tag<
00242                 typename viennagrid::boundary_elements< HostElementTagT, BoundaryElementTag>::layout_tag,
00243                 viennagrid::boundary_elements< HostElementTagT, BoundaryElementTag>::num
00244             >::type container_tag;
00245 
00246 
00247         typedef typename viennagrid::result_of::view<
00248                 boundary_cell_container,
00249                 container_tag
00250             >::type
00251         boundary_cell_view;
00252 
00253 
00254 
00255         //
00256         // Orientation
00257         //
00258 
00259         typedef viennagrid::null_type facet_orientation_container_type;
00260 
00261 
00262         //
00263         // final container pair
00264         //
00265 
00266         typedef viennagrid::static_pair<
00267                         boundary_cell_view,
00268                         facet_orientation_container_type
00269                     > type;
00270       };
00271 
00272       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00273       struct element_boundary_element_container_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, false>
00274       {
00275         typedef viennagrid::null_type type;
00276       };
00277 
00278 
00280       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT>
00281       struct element_boundary_element_container
00282       {
00283         static const bool is_present = has_boundary<WrappedConfigT, HostElementTagT, BoundaryElementTagT>::value;
00284 
00285         typedef typename element_boundary_element_container_helper<WrappedConfigT, HostElementTagT, BoundaryElementTagT, is_present>::type type;
00286       };
00287 
00288 
00290       template<typename WrappedConfigT, typename HostElementTagT, typename BoundaryElementTagT = HostElementTagT>
00291       struct element_boundary_element_container_typelist
00292       {
00293         typedef typename BoundaryElementTagT::facet_tag facet_tag;
00294 
00295         typedef typename element_boundary_element_container<WrappedConfigT, HostElementTagT, facet_tag>::type boundary_cell_layer_containers;
00296         typedef typename viennagrid::detail::result_of::push_back<
00297             typename element_boundary_element_container_typelist< WrappedConfigT, HostElementTagT, facet_tag >::type,
00298             boundary_cell_layer_containers
00299         >::type type;
00300       };
00301 
00302       template<typename WrappedConfigT, typename HostElementTagT>
00303       struct element_boundary_element_container_typelist<WrappedConfigT, HostElementTagT, viennagrid::vertex_tag>
00304       {
00305         typedef viennagrid::null_type type;
00306       };
00307     }
00308   }
00309 }
00310 
00311 
00312 #endif