include/deal.II/multigrid/mg_dof_accessor.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: mg_dof_accessor.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__mg_dof_accessor_h
00013 #define __deal2__mg_dof_accessor_h
00014 
00015 
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/dofs/dof_accessor.h>
00018 #include <deal.II/multigrid/mg_dof_iterator_selector.h>
00019 
00020 DEAL_II_NAMESPACE_OPEN
00021 
00022 template <int dim, int spacedim> class MGDoFHandler;
00023 
00024 template <int structdim, int dim, int spacedim=dim> class MGDoFAccessor;
00025 
00026 namespace internal
00027 {
00028   namespace MGDoFHandler
00029   {
00030     struct Implementation;
00031   }
00032 }
00033 
00034 
00037 
00038 
00039 namespace internal
00040 {
00041   namespace MGDoFAccessor
00042   {
00056     template <int structdim, int dim, int spacedim>
00057     struct Inheritance
00058     {
00064         typedef ::DoFAccessor<structdim, ::DoFHandler<dim,spacedim> > BaseClass;
00065     };
00066 
00067 
00084     template <int dim, int spacedim>
00085     struct Inheritance<dim,dim,spacedim>
00086     {
00092         typedef ::DoFCellAccessor<::DoFHandler<dim,spacedim> > BaseClass;
00093     };
00094   }
00095 }
00096 
00097 
00098 /* -------------------------------------------------------------------------- */
00099 
00100 
00101 
00153 template <int structdim, int dim, int spacedim>
00154 class MGDoFAccessor : public internal::MGDoFAccessor::Inheritance<structdim,dim,spacedim>::BaseClass
00155 {
00156   public:
00163     typedef
00164     typename internal::MGDoFAccessor::Inheritance<structdim,dim,spacedim>::BaseClass
00165     BaseClass;
00166 
00171     typedef MGDoFHandler<dim,spacedim> AccessorData;
00172 
00177     typedef MGDoFHandler<dim, spacedim> Container;
00178 
00191     MGDoFAccessor ();
00192 
00196     MGDoFAccessor (const Triangulation<dim,spacedim> *tria,
00197                    const int                 level,
00198                    const int                 index,
00199                    const AccessorData       *local_data);
00200 
00222     template <int structdim2, int dim2, int spacedim2>
00223     MGDoFAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
00224 
00231     template <int structdim2, int dim2, int spacedim2>
00232     MGDoFAccessor (const MGDoFAccessor<structdim2,dim2,spacedim2> &);
00233 
00257     void get_mg_dof_indices (const int level,
00258                              std::vector<unsigned int> &dof_indices) const;
00259 
00277     template <typename number>
00278     void get_mg_dof_values (const int level,
00279                             const Vector<number> &values,
00280                             Vector<number>       &dof_values) const;
00281 
00288     unsigned int mg_vertex_dof_index (const int level,
00289                                       const unsigned int vertex,
00290                                       const unsigned int i) const;
00291 //TODO: This function is broken for faces
00301     unsigned int mg_dof_index (const int level,
00302                                const unsigned int i) const;
00303 
00319     TriaIterator<MGDoFAccessor<structdim,dim,spacedim> >
00320     child (const unsigned int) const;
00321 
00326     typename internal::MGDoFHandler::Iterators<dim,spacedim>::line_iterator
00327     line (const unsigned int i) const;
00328 
00333     typename internal::MGDoFHandler::Iterators<dim,spacedim>::quad_iterator
00334     quad (const unsigned int i) const;
00335 
00345     const MGDoFHandler<dim,spacedim> &
00346     get_mg_dof_handler () const;
00347 
00352     TriaIterator<MGDoFAccessor<structdim,dim,spacedim> >
00353     parent () const;
00354 
00359     void copy_from (const MGDoFAccessor &a);
00360 
00364     DeclException0 (ExcInvalidObject);
00365 
00366   protected:
00371     MGDoFHandler<dim,spacedim> *mg_dof_handler;
00372 
00376     void set_mg_dof_handler (MGDoFHandler<dim,spacedim> *dh);
00377 
00383     void set_mg_vertex_dof_index (const int level,
00384                                   const unsigned int vertex,
00385                                   const unsigned int i,
00386                                   const unsigned int index) const;
00387 
00393     void set_mg_dof_index (const int level,
00394                            const unsigned int i,
00395                            const unsigned int index) const;
00396 
00397   private:
00415     MGDoFAccessor &
00416     operator = (const MGDoFAccessor &da);
00417 
00418     template <int, int> friend class MGDoFHandler;
00419     friend struct internal::MGDoFHandler::Implementation;
00420 };
00421 
00422 
00423 
00434 template <int spacedim>
00435 class MGDoFAccessor<0,1,spacedim> : public internal::MGDoFAccessor::Inheritance<0,1,spacedim>::BaseClass
00436 {
00437   public:
00444     typedef
00445     typename internal::MGDoFAccessor::Inheritance<0,1,spacedim>::BaseClass
00446     BaseClass;
00447 
00452     typedef MGDoFHandler<1,spacedim> AccessorData;
00453 
00458     typedef MGDoFHandler<1, spacedim> Container;
00459 
00472     MGDoFAccessor ();
00473 
00506     MGDoFAccessor (const Triangulation<1,spacedim> * tria,
00507                    const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
00508                    const unsigned int    vertex_index,
00509                    const MGDoFHandler<1,spacedim> * dof_handler);
00510 
00520     MGDoFAccessor (const Triangulation<1,spacedim> * =  0,
00521                    const int = 0,
00522                    const int = 0,
00523                    const MGDoFHandler<1,spacedim> * = 0);
00524 
00546     template <int structdim2, int dim2, int spacedim2>
00547     MGDoFAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
00548 
00555     template <int structdim2, int dim2, int spacedim2>
00556     MGDoFAccessor (const MGDoFAccessor<structdim2, dim2, spacedim2> &);
00557 
00558 
00565     template <int dim2, int spacedim2>
00566     MGDoFAccessor (const MGDoFCellAccessor<dim2, spacedim2> &);
00567 
00568   protected:
00573     MGDoFHandler<1,spacedim> *mg_dof_handler;
00574 };
00575 
00576 
00577 
00578 /* -------------------------------------------------------------------------- */
00579 
00580 
00581 
00597 template <int dim, int spacedim=dim>
00598 class MGDoFCellAccessor :  public MGDoFAccessor<dim,dim,spacedim>
00599 {
00600   public:
00601     typedef MGDoFAccessor<dim,dim,spacedim> BaseClass;
00602 
00606     typedef
00607     TriaIterator< MGDoFAccessor<dim-1,dim,spacedim> >
00608     face_iterator;
00614     typedef typename MGDoFAccessor<dim,dim,spacedim>::AccessorData  AccessorData;
00615 
00626     MGDoFCellAccessor (const Triangulation<dim,spacedim> *tria,
00627                        const int                 level,
00628                        const int                 index,
00629                        const AccessorData       *local_data);
00630 
00652     template <int structdim2, int dim2, int spacedim2>
00653     MGDoFCellAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
00654 
00661     template <int dim2, class DH2>
00662     MGDoFCellAccessor (const DoFAccessor<dim2, DH2> &);
00663 
00687     void get_mg_dof_indices (std::vector<unsigned int> &dof_indices) const;
00688 
00706     template <typename number>
00707     void get_mg_dof_values (const Vector<number> &values,
00708                             Vector<number>       &dof_values) const;
00709 
00725     TriaIterator<MGDoFCellAccessor<dim,spacedim> >
00726     neighbor (const unsigned int) const;
00727 
00735     TriaIterator<MGDoFCellAccessor<dim,spacedim> >
00736     child (const unsigned int) const;
00737 
00745     typename internal::MGDoFHandler::Iterators<dim,spacedim>::face_iterator
00746     face (const unsigned int i) const;
00747 
00759     typename internal::MGDoFHandler::Iterators<dim,spacedim>::cell_iterator
00760     neighbor_child_on_subface (const unsigned int face_no,
00761                                const unsigned int subface_no) const;
00762 
00774     TriaIterator<MGDoFCellAccessor<dim,spacedim> >
00775     parent () const;
00776 };
00777 
00780 // ------------------- template and inline functions -------------
00781 
00782 #ifndef DOXYGEN
00783 
00784 template <int structdim, int dim, int spacedim>
00785 template <int structdim2, int dim2, int spacedim2>
00786 inline
00787 MGDoFAccessor<structdim,dim,spacedim>::
00788 MGDoFAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &)
00789                 :
00790                 BaseClass (0, -1, -1, 0)
00791 {
00792   Assert (false, ExcInvalidObject());
00793 }
00794 
00795 
00796 
00797 template <int structdim, int dim, int spacedim>
00798 template <int structdim2, int dim2, int spacedim2>
00799 inline
00800 MGDoFAccessor<structdim,dim,spacedim>::
00801 MGDoFAccessor (const MGDoFAccessor<structdim2,dim2,spacedim2> &)
00802                 :
00803                 BaseClass (0, -1, -1, 0)
00804 {
00805   Assert (false, ExcInvalidObject());
00806 }
00807 
00808 
00809 
00810 template <int dim, int spacedim>
00811 template <int structdim2, int dim2, int spacedim2>
00812 inline
00813 MGDoFCellAccessor<dim,spacedim>::
00814 MGDoFCellAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &)
00815                 :
00816                 BaseClass (0, -1, -1, 0)
00817 {
00818   Assert (false, typename BaseClass::ExcInvalidObject());
00819 }
00820 
00821 
00822 
00823 template <int dim, int spacedim>
00824 template <int dim2, class DH>
00825 inline
00826 MGDoFCellAccessor<dim,spacedim>::
00827 MGDoFCellAccessor (const DoFAccessor<dim2,DH> &)
00828                 :
00829                 BaseClass (0, -1, -1, 0)
00830 {
00831   Assert (false, typename BaseClass::ExcInvalidObject());
00832 }
00833 
00834 
00835 #endif
00836 
00837 
00838 
00839 DEAL_II_NAMESPACE_CLOSE
00840 
00841 #endif
00842 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Tue May 22 2012 12:06:17 by doxygen 1.7.3