Go to the documentation of this file.00001 #ifndef VIENNAGRID_ALGORITHM_SURFACE_HPP
00002 #define VIENNAGRID_ALGORITHM_SURFACE_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <sstream>
00023 #include <string>
00024 #include <stdexcept>
00025
00026 #include "viennagrid/forwards.h"
00027 #include "viennagrid/algorithm/volume.hpp"
00028 #include "viennagrid/algorithm/boundary.hpp"
00029
00035 namespace viennagrid
00036 {
00037 namespace detail
00038 {
00040 template <typename ContainerType>
00041 typename ContainerType::config_type::numeric_type
00042 surface_domainsegment(ContainerType const & d)
00043 {
00044 typedef ContainerType DomainType;
00045 typedef typename ContainerType::config_type::cell_tag CellTag;
00046
00047 typedef typename viennagrid::result_of::const_ncell_range<DomainType, CellTag::dim-1>::type FacetRange;
00048 typedef typename viennagrid::result_of::iterator<FacetRange>::type FacetIterator;
00049
00050 typename ContainerType::config_type::numeric_type result = 0;
00051
00052 FacetRange facets = viennagrid::ncells(d);
00053 for (FacetIterator fit = facets.begin();
00054 fit != facets.end();
00055 ++fit)
00056 {
00057 if (is_boundary(*fit, d))
00058 result += viennagrid::volume(*fit);
00059 }
00060 return result;
00061 }
00062 }
00063
00064
00065
00066
00067
00068
00070 template <typename ElementType>
00071 typename ElementType::config_type::numeric_type
00072 surface(ElementType const & element)
00073 {
00074 typedef typename ElementType::config_type ConfigType;
00075 typedef typename viennagrid::result_of::const_ncell_range<ElementType, ElementType::tag::dim-1>::type ElementBoundaryRange;
00076 typedef typename viennagrid::result_of::iterator<ElementBoundaryRange>::type ElementBoundaryIterator;
00077
00078 typedef typename ElementType::config_type::numeric_type value_type;
00079
00080 value_type result = 0;
00081
00082 ElementBoundaryRange boundary = viennagrid::ncells(element);
00083 for (ElementBoundaryIterator ebit = boundary.begin();
00084 ebit != boundary.end();
00085 ++ebit)
00086 {
00087 result += viennagrid::volume(*ebit);
00088 }
00089
00090 return result;
00091 }
00092
00093
00095 template <typename ConfigType>
00096 typename ConfigType::numeric_type
00097 surface(domain_t<ConfigType> const & d)
00098 {
00099 return detail::surface_domainsegment(d);
00100 }
00101
00102
00104 template <typename ConfigType>
00105 typename ConfigType::numeric_type
00106 surface(segment_t<ConfigType> const & d)
00107 {
00108 return detail::surface_domainsegment(d);
00109 }
00110
00111 }
00112 #endif