• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

/export/development/ViennaGrid/release/ViennaGrid-1.0.0/viennagrid/algorithm/surface.hpp

Go to the documentation of this file.
00001 #ifndef VIENNAGRID_ALGORITHM_SURFACE_HPP
00002 #define VIENNAGRID_ALGORITHM_SURFACE_HPP
00003 
00004 /* =======================================================================
00005    Copyright (c) 2011, Institute for Microelectronics,
00006                        Institute for Analysis and Scientific Computing,
00007                        TU Wien.
00008 
00009                             -----------------
00010                      ViennaGrid - The Vienna Grid Library
00011                             -----------------
00012 
00013    Authors:      Karl Rupp                           rupp@iue.tuwien.ac.at
00014                  Josef Weinbub                    weinbub@iue.tuwien.ac.at
00015                
00016    (A list of additional contributors can be found in the PDF manual)
00017 
00018    License:      MIT (X11), see file LICENSE in the base directory
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   } //namespace detail
00063   
00064   
00065   
00066   //
00067   // The public interface functions
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   //special case: domain
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   //special case: segment
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 } //namespace viennagrid
00112 #endif

Generated on Wed Sep 14 2011 19:21:30 for ViennaGrid by  doxygen 1.7.1