00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __deal2__solution_transfer_h
00013 #define __deal2__solution_transfer_h
00014
00015
00016
00017
00018
00019 #include <deal.II/base/config.h>
00020 #include <deal.II/base/smartpointer.h>
00021 #include <deal.II/lac/vector.h>
00022 #include <deal.II/base/exceptions.h>
00023 #include <deal.II/dofs/dof_handler.h>
00024
00025 #include <vector>
00026
00027 DEAL_II_NAMESPACE_OPEN
00028
00199 template<int dim, typename VECTOR=Vector<double>, class DH=DoFHandler<dim> >
00200 class SolutionTransfer
00201 {
00202 public:
00203
00208 SolutionTransfer(const DH &dof);
00209
00213 ~SolutionTransfer();
00214
00220 void clear();
00221
00230 void prepare_for_pure_refinement();
00231
00243 void prepare_for_coarsening_and_refinement (const std::vector<VECTOR> &all_in);
00244
00250 void prepare_for_coarsening_and_refinement (const VECTOR &in);
00251
00270 void refine_interpolate (const VECTOR &in,
00271 VECTOR &out) const;
00272
00307 void interpolate (const std::vector<VECTOR>&all_in,
00308 std::vector<VECTOR> &all_out) const;
00309
00323 void interpolate (const VECTOR &in,
00324 VECTOR &out) const;
00325
00331 std::size_t memory_consumption () const;
00332
00336 DeclException0(ExcNotPrepared);
00337
00341 DeclException0(ExcAlreadyPrepForRef);
00342
00346 DeclException0(ExcAlreadyPrepForCoarseAndRef);
00347
00351 DeclException0(ExcTriaPrepCoarseningNotCalledBefore);
00352
00356 DeclException0(ExcNoInVectorsGiven);
00357
00361 DeclException0(ExcVectorsDifferFromInVectors);
00362
00366 DeclException0(ExcNumberOfDoFsPerCellHasChanged);
00367
00368 private:
00369
00374 SmartPointer<const DH,SolutionTransfer<dim,VECTOR,DH> > dof_handler;
00375
00380 unsigned int n_dofs_old;
00381
00393 enum PreparationState {
00394 none, pure_refinement, coarsening_and_refinement
00395 };
00396
00400 PreparationState prepared_for;
00401
00402
00410 std::vector<std::vector<unsigned int> > indices_on_cell;
00411
00431 struct Pointerstruct {
00432 Pointerstruct() : indices_ptr(0), dof_values_ptr(0), active_fe_index(0) {};
00433 Pointerstruct(std::vector<unsigned int> *indices_ptr_in,
00434 const unsigned int active_fe_index_in = 0)
00435 :
00436 indices_ptr(indices_ptr_in),
00437 dof_values_ptr (0),
00438 active_fe_index(active_fe_index_in) {};
00439 Pointerstruct(std::vector<Vector<typename VECTOR::value_type> > *dof_values_ptr_in,
00440 const unsigned int active_fe_index_in = 0) :
00441 indices_ptr (0),
00442 dof_values_ptr(dof_values_ptr_in),
00443 active_fe_index(active_fe_index_in) {};
00444 std::size_t memory_consumption () const;
00445
00446 std::vector<unsigned int> *indices_ptr;
00447 std::vector<Vector<typename VECTOR::value_type> > *dof_values_ptr;
00448 unsigned int active_fe_index;
00449 };
00450
00460 std::map<std::pair<unsigned int, unsigned int>, Pointerstruct> cell_map;
00461
00469 std::vector<std::vector<Vector<typename VECTOR::value_type> > > dof_values_on_cell;
00470 };
00471
00472
00473 DEAL_II_NAMESPACE_CLOSE
00474
00475
00476
00477 #endif
00478
00479