00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __deal2__dof_accessor_h
00013 #define __deal2__dof_accessor_h
00014
00015
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/grid/tria_accessor.h>
00018 #include <deal.II/dofs/dof_handler.h>
00019 #include <deal.II/hp/dof_handler.h>
00020
00021 #include <vector>
00022
00023 DEAL_II_NAMESPACE_OPEN
00024
00025 template <typename number> class FullMatrix;
00026 template <typename number> class SparseMatrix;
00027 template <typename number> class Vector;
00028 class ConstraintMatrix;
00029
00030 template <typename Accessor> class TriaRawIterator;
00031
00032 namespace internal
00033 {
00034 namespace DoFCellAccessor
00035 {
00036 struct Implementation;
00037 }
00038
00039 namespace DoFHandler
00040 {
00041 struct Implementation;
00042 namespace Policy
00043 {
00044 struct Implementation;
00045 }
00046 }
00047
00048 namespace hp
00049 {
00050 namespace DoFHandler
00051 {
00052 struct Implementation;
00053 }
00054 }
00055 }
00056
00057
00058
00059
00060
00061
00062
00063 namespace internal
00064 {
00065 namespace DoFAccessor
00066 {
00084 template <int structdim, int dim, int spacedim>
00085 struct Inheritance
00086 {
00092 typedef ::TriaAccessor<structdim,dim,spacedim> BaseClass;
00093 };
00094
00095
00101 template <int dim, int spacedim>
00102 struct Inheritance<dim,dim,spacedim>
00103 {
00109 typedef ::CellAccessor<dim,spacedim> BaseClass;
00110 };
00111 }
00112 }
00113
00114
00115
00116
00117
00118
00171 template <int structdim, class DH>
00172 class DoFAccessor : public internal::DoFAccessor::Inheritance<structdim, DH::dimension, DH::space_dimension>::BaseClass
00173 {
00174 public:
00175
00181 static const unsigned int dimension=DH::dimension;
00182
00188 static const unsigned int space_dimension=DH::space_dimension;
00189
00196 typedef
00197 typename internal::DoFAccessor::Inheritance<structdim, dimension, space_dimension>::BaseClass
00198 BaseClass;
00199
00203 typedef DH AccessorData;
00204
00217 DoFAccessor ();
00218
00222 DoFAccessor (const Triangulation<DH::dimension,DH::space_dimension> *tria,
00223 const int level,
00224 const int index,
00225 const DH *local_data);
00226
00248 template <int structdim2, int dim2, int spacedim2>
00249 DoFAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
00250
00257 template <int dim2, class DH2>
00258 DoFAccessor (const DoFAccessor<dim2, DH2> &);
00259
00269 const DH &
00270 get_dof_handler () const;
00271
00276 void copy_from (const DoFAccessor<structdim, DH> &a);
00277
00285 void copy_from (const TriaAccessorBase<structdim, DH::dimension, DH::space_dimension> &da);
00286
00291 TriaIterator<DoFAccessor<structdim,DH> >
00292 parent () const;
00293
00305 TriaIterator<DoFAccessor<structdim,DH> >
00306 child (const unsigned int c) const;
00307
00312 typename internal::DoFHandler::Iterators<DH>::line_iterator
00313 line (const unsigned int i) const;
00314
00319 typename internal::DoFHandler::Iterators<DH>::quad_iterator
00320 quad (const unsigned int i) const;
00321
00404 void get_dof_indices (std::vector<unsigned int> &dof_indices,
00405 const unsigned int fe_index = DH::default_fe_index) const;
00406
00443 unsigned int vertex_dof_index (const unsigned int vertex,
00444 const unsigned int i,
00445 const unsigned int fe_index = DH::default_fe_index) const;
00446
00501 unsigned int dof_index (const unsigned int i,
00502 const unsigned int fe_index = DH::default_fe_index) const;
00503
00535 unsigned int
00536 n_active_fe_indices () const;
00537
00552 unsigned int
00553 nth_active_fe_index (const unsigned int n) const;
00554
00572 bool
00573 fe_index_is_active (const unsigned int fe_index) const;
00574
00583 const FiniteElement<DH::dimension,DH::space_dimension> &
00584 get_fe (const unsigned int fe_index) const;
00585
00595 DeclException0 (ExcInvalidObject);
00601 DeclException0 (ExcVectorNotEmpty);
00607 DeclException0 (ExcVectorDoesNotMatch);
00613 DeclException0 (ExcMatrixDoesNotMatch);
00621 DeclException0 (ExcNotActive);
00627 DeclException0 (ExcCantCompareIterators);
00628
00629 protected:
00630
00635 DH *dof_handler;
00636
00640 bool operator == (const DoFAccessor &) const;
00641
00645 bool operator != (const DoFAccessor &) const;
00646
00650 void set_dof_handler (DH *dh);
00651
00688 void set_dof_index (const unsigned int i,
00689 const unsigned int index,
00690 const unsigned int fe_index = DH::default_fe_index) const;
00691
00728 void set_vertex_dof_index (const unsigned int vertex,
00729 const unsigned int i,
00730 const unsigned int index,
00731 const unsigned int fe_index = DH::default_fe_index) const;
00732
00738 template <typename> friend class TriaRawIterator;
00739
00740
00741 private:
00759 DoFAccessor<structdim,DH> &
00760 operator = (const DoFAccessor<structdim,DH> &da);
00761
00767 template <int dim, int spacedim> friend class DoFHandler;
00768 template <int dim, int spacedim> friend class hp::DoFHandler;
00769
00770 friend struct internal::DoFHandler::Policy::Implementation;
00771 friend struct internal::DoFHandler::Implementation;
00772 friend struct internal::hp::DoFHandler::Implementation;
00773 friend struct internal::DoFCellAccessor::Implementation;
00774 };
00775
00776
00777
00788 template <template <int, int> class DH, int spacedim>
00789 class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
00790 {
00791 public:
00792
00798 static const unsigned int dimension=1;
00799
00805 static const unsigned int space_dimension=spacedim;
00806
00813 typedef TriaAccessor<0,1,spacedim> BaseClass;
00814
00818 typedef DH<1,spacedim> AccessorData;
00819
00832 DoFAccessor ();
00833
00866 DoFAccessor (const Triangulation<1,spacedim> * tria,
00867 const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
00868 const unsigned int vertex_index,
00869 const DH<1,spacedim> * dof_handler);
00870
00880 DoFAccessor (const Triangulation<1,spacedim> *,
00881 const int = 0,
00882 const int = 0,
00883 const DH<1,spacedim> * = 0);
00884
00906 template <int structdim2, int dim2, int spacedim2>
00907 DoFAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
00908
00915 template <int dim2, class DH2>
00916 DoFAccessor (const DoFAccessor<dim2, DH2> &);
00917
00927 const DH<1,spacedim> &
00928 get_dof_handler () const;
00929
00933 DoFAccessor<0,DH<1,spacedim> > &
00934 operator = (const DoFAccessor<0,DH<1,spacedim> > &da);
00935
00940 void copy_from (const DoFAccessor<0, DH<1,spacedim> > &a);
00941
00949 void copy_from (const TriaAccessorBase<0, 1, spacedim> &da);
00950
00955 TriaIterator<DoFAccessor<0,DH<1,spacedim> > >
00956 parent () const;
00957
00969 TriaIterator<DoFAccessor<0,DH<1,spacedim> > >
00970 child (const unsigned int c) const;
00971
00976 typename internal::DoFHandler::Iterators<DH<1,spacedim> >::line_iterator
00977 line (const unsigned int i) const;
00978
00983 typename internal::DoFHandler::Iterators<DH<1,spacedim> >::quad_iterator
00984 quad (const unsigned int i) const;
00985
01068 void get_dof_indices (std::vector<unsigned int> &dof_indices,
01069 const unsigned int fe_index = AccessorData::default_fe_index) const;
01070
01107 unsigned int vertex_dof_index (const unsigned int vertex,
01108 const unsigned int i,
01109 const unsigned int fe_index = AccessorData::default_fe_index) const;
01110
01165 unsigned int dof_index (const unsigned int i,
01166 const unsigned int fe_index = AccessorData::default_fe_index) const;
01167
01199 unsigned int
01200 n_active_fe_indices () const;
01201
01216 unsigned int
01217 nth_active_fe_index (const unsigned int n) const;
01218
01236 bool
01237 fe_index_is_active (const unsigned int fe_index) const;
01238
01247 const FiniteElement<DH<1,spacedim>::dimension,DH<1,spacedim>::space_dimension> &
01248 get_fe (const unsigned int fe_index) const;
01249
01259 DeclException0 (ExcInvalidObject);
01265 DeclException0 (ExcVectorNotEmpty);
01271 DeclException0 (ExcVectorDoesNotMatch);
01277 DeclException0 (ExcMatrixDoesNotMatch);
01285 DeclException0 (ExcNotActive);
01291 DeclException0 (ExcCantCompareIterators);
01292
01293 protected:
01294
01299 DH<1,spacedim> *dof_handler;
01300
01304 bool operator == (const DoFAccessor &) const;
01305
01309 bool operator != (const DoFAccessor &) const;
01310
01314 void set_dof_handler (DH<1,spacedim> *dh);
01315
01352 void set_dof_index (const unsigned int i,
01353 const unsigned int index,
01354 const unsigned int fe_index = AccessorData::default_fe_index) const;
01355
01392 void set_vertex_dof_index (const unsigned int vertex,
01393 const unsigned int i,
01394 const unsigned int index,
01395 const unsigned int fe_index = AccessorData::default_fe_index) const;
01396
01402 template <typename> friend class TriaRawIterator;
01403
01404
01410 template <int, int> friend class DoFHandler;
01411 template <int, int> friend class hp::DoFHandler;
01412
01413 friend struct internal::DoFHandler::Policy::Implementation;
01414 friend struct internal::DoFHandler::Implementation;
01415 friend struct internal::hp::DoFHandler::Implementation;
01416 friend struct internal::DoFCellAccessor::Implementation;
01417 };
01418
01419
01420
01421
01422
01435 template <class DH>
01436 class DoFCellAccessor : public DoFAccessor<DH::dimension,DH>
01437 {
01438 public:
01442 static const unsigned int dim = DH::dimension;
01443
01447 static const unsigned int spacedim = DH::space_dimension;
01448
01455 typedef typename DoFAccessor<DH::dimension,DH>::AccessorData AccessorData;
01456
01463 typedef DoFAccessor<DH::dimension,DH> BaseClass;
01464
01469 typedef DH Container;
01470
01481 DoFCellAccessor (const Triangulation<DH::dimension,DH::space_dimension> *tria,
01482 const int level,
01483 const int index,
01484 const AccessorData *local_data);
01485
01507 template <int structdim2, int dim2, int spacedim2>
01508 DoFCellAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
01509
01516 template <int dim2, class DH2>
01517 DoFCellAccessor (const DoFAccessor<dim2, DH2> &);
01518
01532 typename internal::DoFHandler::Iterators<DH>::cell_iterator
01533 parent () const;
01534
01551 typename internal::DoFHandler::Iterators<DH>::cell_iterator
01552 neighbor (const unsigned int) const;
01553
01563 typename internal::DoFHandler::Iterators<DH>::cell_iterator
01564 child (const unsigned int) const;
01565
01574 typename internal::DoFHandler::Iterators<DH>::face_iterator
01575 face (const unsigned int i) const;
01576
01588 typename internal::DoFHandler::Iterators<DH>::cell_iterator
01589 neighbor_child_on_subface (const unsigned int face_no,
01590 const unsigned int subface_no) const;
01591
01631 template <class InputVector, typename number>
01632 void get_dof_values (const InputVector &values,
01633 Vector<number> &local_values) const;
01634
01663 template <class InputVector, typename ForwardIterator>
01664 void get_dof_values (const InputVector &values,
01665 ForwardIterator local_values_begin,
01666 ForwardIterator local_values_end) const;
01667
01699 template <class InputVector, typename ForwardIterator>
01700 void get_dof_values (const ConstraintMatrix &constraints,
01701 const InputVector &values,
01702 ForwardIterator local_values_begin,
01703 ForwardIterator local_values_end) const;
01704
01739 template <class OutputVector, typename number>
01740 void set_dof_values (const Vector<number> &local_values,
01741 OutputVector &values) const;
01742
01775 template <class InputVector, typename number>
01776 void get_interpolated_dof_values (const InputVector &values,
01777 Vector<number> &interpolated_values) const;
01778
01868 template <class OutputVector, typename number>
01869 void set_dof_values_by_interpolation (const Vector<number> &local_values,
01870 OutputVector &values) const;
01871
01888 template <typename number, typename OutputVector>
01889 void
01890 distribute_local_to_global (const Vector<number> &local_source,
01891 OutputVector &global_destination) const;
01892
01906 template <typename ForwardIterator, typename OutputVector>
01907 void
01908 distribute_local_to_global (ForwardIterator local_source_begin,
01909 ForwardIterator local_source_end,
01910 OutputVector &global_destination) const;
01911
01930 template <typename ForwardIterator, typename OutputVector>
01931 void
01932 distribute_local_to_global (const ConstraintMatrix &constraints,
01933 ForwardIterator local_source_begin,
01934 ForwardIterator local_source_end,
01935 OutputVector &global_destination) const;
01936
01948 template <typename number, typename OutputMatrix>
01949 void
01950 distribute_local_to_global (const FullMatrix<number> &local_source,
01951 OutputMatrix &global_destination) const;
01952
01959 template <typename number, typename OutputMatrix, typename OutputVector>
01960 void
01961 distribute_local_to_global (const FullMatrix<number> &local_matrix,
01962 const Vector<number> &local_vector,
01963 OutputMatrix &global_matrix,
01964 OutputVector &global_vector) const;
01965
02022 void get_dof_indices (std::vector<unsigned int> &dof_indices) const;
02023
02046 const FiniteElement<DH::dimension,DH::space_dimension> &
02047 get_fe () const;
02048
02054 unsigned int active_fe_index () const;
02055
02060 void set_active_fe_index (const unsigned int i);
02072 void set_dof_indices (const std::vector<unsigned int> &dof_indices);
02073
02079 void update_cell_dof_indices_cache () const;
02080
02081 private:
02099 DoFCellAccessor<DH> &
02100 operator = (const DoFCellAccessor<DH> &da);
02101
02108 template <int dim, int spacedim> friend class DoFHandler;
02109 friend struct internal::DoFCellAccessor::Implementation;
02110 };
02111
02112
02113 DEAL_II_NAMESPACE_CLOSE
02114
02115
02116 #include "dof_accessor.templates.h"
02117
02118
02119
02120
02121 #endif
02122
02123