Go to the documentation of this file.00001 #ifndef VIENNAGRID_DOMAIN_HPP
00002 #define VIENNAGRID_DOMAIN_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023 #include <vector>
00024 #include <deque>
00025 #include <list>
00026 #include <set>
00027 #include <map>
00028 #include <stack>
00029 #include <algorithm>
00030 #include "viennagrid/forwards.h"
00031 #include "viennagrid/traits/container.hpp"
00032 #include "viennagrid/detail/domain_iterators.hpp"
00033 #include "viennagrid/detail/domain_layers.hpp"
00034
00039 namespace viennagrid
00040 {
00041
00042
00043
00044
00045 namespace result_of
00046 {
00053 template <typename ConfigType,
00054 long dim,
00055 long cell_level >
00056 struct element_container< domain_t<ConfigType>, dim, cell_level >
00057 {
00058 typedef typename result_of::ncell<ConfigType, dim>::type element_type;
00059
00060 typedef std::map< element_key<ConfigType, element_type>, element_type > type;
00061 };
00062
00063
00065 template <typename ConfigType, long cell_level>
00066 struct element_container< domain_t<ConfigType>, 0, cell_level>
00067 {
00068 typedef typename result_of::ncell<ConfigType, 0>::type element_type;
00069
00070
00071 typedef std::deque< element_type > type;
00072 };
00073
00074
00076 template <typename ConfigType, long cell_level>
00077 struct element_container< domain_t<ConfigType>, cell_level, cell_level>
00078 {
00079 typedef typename result_of::ncell<ConfigType, cell_level>::type element_type;
00080
00081
00082 typedef std::deque< element_type > type;
00083 };
00084
00086 template <typename ConfigType>
00087 struct domain
00088 {
00089 typedef domain_t<ConfigType> type;
00090 };
00091
00092 }
00093
00094
00095
00096
00102 template <typename Config>
00103 class domain_t : public detail::domain_layers<Config,
00104 Config::cell_tag::dim,
00105 true,
00106 full_handling_tag>
00107 {
00108 typedef detail::domain_layers<Config, Config::cell_tag::dim, true> base_type;
00109 typedef domain_t<Config> self_type;
00110
00111 public:
00113 typedef Config config_type;
00115 typedef std::size_t size_type;
00117 typedef segment_t<Config> segment_type;
00118
00119 typedef detail::domain_segment_container<self_type, segment_type> segment_container;
00120
00125 domain_t() : segments_(this) {}
00126
00128 template <typename OtherDomainType, typename RefinementTag>
00129 domain_t(refinement_proxy<OtherDomainType, RefinementTag> const & proxy) : segments_(this)
00130 {
00131 detail::refine_impl(proxy.get(), *this, proxy.tag());
00132 }
00133
00135 ~domain_t() { viennadata::erase<viennadata::all, viennadata::all>()(*this); }
00136
00137 using base_type::push_back;
00138
00140 template <typename OtherDomainType, typename RefinementTag>
00141 self_type & operator=(refinement_proxy<OtherDomainType, RefinementTag> const & proxy)
00142 {
00143 detail::refine_impl(proxy.get(), *this, proxy.tag());
00144 return *this;
00145 }
00146
00148 segment_container & segments() { return segments_; }
00150 segment_container const & segments() const { return segments_; }
00151
00152 private:
00153 segment_container segments_;
00154 };
00155
00157 template <typename ConfigType>
00158 typename domain_t<ConfigType>::segment_container &
00159 segments(domain_t<ConfigType> & domain)
00160 {
00161 return domain.segments();
00162 }
00163
00165 template <typename ConfigType>
00166 typename domain_t<ConfigType>::segment_container const &
00167 segments(domain_t<ConfigType> const & domain)
00168 {
00169 return domain.segments();
00170 }
00171
00172 }
00173 #endif