OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dof_application.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 // $Id: dof_application.h 1348 2013-08-16 00:45:07Z secanell $
3 //
4 // Copyright (C) 2006, 2007, 2008, 2009 by Guido Kanschat
5 //
6 // This file is subject to QPL and may not be distributed
7 // without copyright and license information. Please refer
8 // to the file deal.II/doc/license.html for the text and
9 // further information on this license.
10 //
11 //---------------------------------------------------------------------------
12 
13 #ifndef __deal2__appframe__dof_application_h
14 #define __deal2__appframe__dof_application_h
15 
16 #include <appframe/base.h>
17 #include <appframe/residual.h>
18 #include <appframe/mesh_worker.h>
19 #include <boost/shared_ptr.hpp>
20 #include <lac/block_indices.h>
21 #include <grid/grid_out.h>
22 #include <grid/grid_tools.h>
23 #include <lac/constraint_matrix.h>
24 #include <fe/fe_values.h>
25 #include <numerics/data_out.h>
26 #include <numerics/solution_transfer.h>
27 
28 namespace dealii
29 {
30  template <int, int> class Triangulation;
31  template <int, int> class Mapping;
32  template <int, int> class FiniteElement;
33  template <int, int> class DoFHandler;
34 }
35 
36 
37 namespace AppFrame
38 {
39  template<int dim> class DoFApplication;
40 
49  {
55  std::string name;
61  unsigned int block;
71  unsigned int components;
72 
80  dealii::UpdateFlags flags;
81  };
82 
105  template <int dim>
107  {
108  public:
111 
113  LocalIntegrator();
115  virtual ~LocalIntegrator();
116 
118  virtual void cell(FEVector& cell_vector, const CellInfo& cell) = 0;
119 
121  virtual void bdry(FEVector& face_vector, const FaceInfo& face) = 0;
122 
124  virtual void face(FEVector& face_vector1, FEVector& face_vector2,
125  const FaceInfo& face1, const FaceInfo& face2) = 0;
126 
128  virtual void post_loop(FEVector& dst, const FEVectors& srcs);
129 
131  Quadrature<dim> cell_quadrature;
132 
134  Quadrature<dim-1> bdry_quadrature;
135 
137  Quadrature<dim-1> face_quadrature;
138 
147  void set_gauss_quadrature(unsigned int n_cell_points,
148  unsigned int n_bdry_points,
149  unsigned int n_face_points);
150  };
151 
164  template <int dim>
167  {
168  private:
169  SmartPointer<DoFApplication<dim> > app;
170  public:
173  const MeshWorker::BlockInfo& bi,
174  FEVectors& m)
175  {
176  app = a;
178  }
179 
183  void cell(const typename DoFApplication<dim>::CellInfo& cell);
184 
188  void bdry(const typename DoFApplication<dim>::FaceInfo& face);
189 
193  void face(const typename DoFApplication<dim>::FaceInfo& face1,
194  const typename DoFApplication<dim>::FaceInfo& face2);
195  };
196 
210  template <int dim>
213  {
214  private:
215  SmartPointer<DoFApplication<dim> > app;
216  public:
219  const MeshWorker::BlockInfo&,
220  FEVectors& m)
221  {
222  app = a;
224  }
225 
229  void cell(const typename DoFApplication<dim>::CellInfo& cell);
230 
234  void bdry(const typename DoFApplication<dim>::FaceInfo& face);
235 
239  void face(const typename DoFApplication<dim>::FaceInfo& face1,
240  const typename DoFApplication<dim>::FaceInfo& face2);
241  };
242 
243 // /**
244 // * Integrate the residual using
245 // * DoFApplication::integrate_1form(). Optionally, this class can use
246 // * its own LocalIntegrator or use the standard residual of the
247 // * DoFApplication.
248 // *
249 // * @author Guido Kanschat, 2008
250 // */
251 // template <int dim>
252 // class DoFResidual : public Residual
253 // {
254 // public:
255 // /**
256 // * Constructor initializing
257 // * this object to compute the
258 // * residual using
259 // * <tt>application</tt> and the
260 // * provided <tt>local_residual</tt>.
261 // */
262 // DoFResidual(const DoFApplication<dim>& application,
263 // const LocalIntegrator<dim>& local_residual);
264 //
265 // virtual double operator() (FEVector& dst, const FEVectors& src) const;
266 //
267 // private:
268 // /**
269 // * The DoFApplication class
270 // * providing the function
271 // * DoFApplication::integrate_1form().
272 // */
273 // SmartPointer<const DoFApplication<dim> > app;
274 //
275 // /**
276 // * The object integrating the
277 // * local residuals.
278 // */
279 // LocalIntegrator<dim> local_residual;
280 // };
281 //
282 
302  template <int dim>
304  :
305  public ApplicationBase
306  {
307  public:
323  DoFApplication(boost::shared_ptr<ApplicationData> data = boost::shared_ptr<ApplicationData>(),
324  bool multigrid = false);
325 
330  DoFApplication(bool multigrid);
331 
341  bool triangulation_only,
342  bool multigrid = false);
343 
348  ~DoFApplication();
349 
368  virtual void declare_parameters(ParameterHandler& param);
369 
374  void _initialize (ParameterHandler& param);
375 
395  virtual void remesh_dofs();
396 
397  virtual void initialize (ParameterHandler& param);
410  virtual void init_vector (FEVector& dst) const;
411 
416  virtual void remesh();
421  virtual double evaluate(const FEVectors&);
435  virtual double estimate(const FEVectors& src);
436 
449  virtual double residual(FEVector& dst, const FEVectors& src, bool apply_boundaries = true);
450 
464  virtual void residual_constraints(FEVector& dst) const;
465 
467 
468 
472  virtual void grid_out(const std::string& basename);
473 
477  virtual void data_out(const std::string& basename,
478  const FEVectors& src);
479 
483  virtual void data_out(const std::string& basename,
484  const FEVectors& src,
485  const std::vector<std::string>& solution_names);
486 
501  virtual void data_out(const std::string& basename,
502 
503  const FEVector& solution,
504  const std::vector<std::string>& solution_names,
505 
506  const FEVector& postprocessing = FEVector(),
507  const std::vector<std::string>& postprocessing_names = std::vector<std::string>());
508 
513  std::vector< DataComponentInterpretation::DataComponentInterpretation > solution_interpretations;
514 
519  std::vector< DataComponentInterpretation::DataComponentInterpretation > postprocessing_interpretations;
520 
526 
532 
538 
540 
545  unsigned int memory_consumption() const;
546 
554  virtual double cell_estimate(const CellInfo&);
555 
561  virtual double bdry_estimate(const FaceInfo&);
562 
571  virtual double face_estimate(const FaceInfo&,
572  const FaceInfo&);
573 
577  virtual void cell_residual(FEVector& cell_vector,
578  const CellInfo& cell);
579 
583  virtual void bdry_residual(FEVector& face_vector,
584  const FaceInfo& face);
585 
589  virtual void face_residual(FEVector& face_vector1,
590  FEVector& face_vector2,
591  const FaceInfo& face1,
592  const FaceInfo& face2);
606  template<class BOX, class WORKER>
607  void integrate_1form(BOX& box, WORKER& local_forms, FEVector& dst, const FEVectors& src);
608 
636  void integrate_functional(LocalEstimate<dim>& local_forms,
637  FEVectors& dst,
638  const FEVectors& src);
639 
645  {
646  new_tr.copy_triangulation(*this->tr);
647  }
648 
653  AppFrame::FEVector& coarse_solution,
654  AppFrame::FEVector& refined_solution);
655 
659  void read_init_solution(AppFrame::FEVector& dst, bool &good_solution) const;
660 
665  unsigned int verbosity;
666 
667  protected:
672  void constrain_boundary(FEVector& v, bool homogeneous) const;
673 
681  std::map<unsigned int, double> boundary_constraints;
682 
699  ConstraintMatrix hanging_node_constraints;
700 
711  boost::shared_ptr<Mapping<dim> > mapping;
712 
734  unsigned int mapping_degree;
735 
740  boost::shared_ptr<Triangulation<dim> > tr;
741 
747  boost::shared_ptr<FiniteElement<dim> > element;
748 
753  boost::shared_ptr<DoFHandler<dim> > dof;
754 
759  boost::shared_ptr<MGDoFHandler<dim> > mg_dof;
760 
762 
767  // Vector<double> cell_errors;
773 
777  GridOut g_out;
778 
782  DataOut<dim, DoFHandler<dim> > d_out;
783 
787  std::vector<DataComponentInterpretation::DataComponentInterpretation>
789 
793  std::string refinement;
794 
798  unsigned int initial_refinement;
799 
805 
812 
819 
826  Point<dim> sort_direction;
827 
833  std::vector<FEVector*> transfer_vectors;
838  Quadrature<dim> quadrature_residual_cell;
839 
845 
851 
857 
863 
864  public:
865 
870  template <class INFO, typename TYPE>
871  void fill_local_data(const INFO& info,
872  const std::vector<VectorSelector>& data_vector,
873  std::vector<std::vector<std::vector<TYPE> > >& data) const;
874 
875  private:
881  virtual void sort_dofs();
882 
893  virtual void distribute_face_to_cell_errors();
894 
908  virtual double global_from_local_errors() const;
909  friend class LocalResidual<dim>;
910  friend class LocalEstimate<dim>;
911  };
912 }
913 
914 #endif