Reference documentation for deal.II version 8.4.2
point_value_history.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii__point_value_history_h
18 #define dealii__point_value_history_h
19 
20 #include <deal.II/base/point.h>
21 #include <deal.II/base/smartpointer.h>
22 #include <deal.II/base/utilities.h>
23 #include <deal.II/base/exceptions.h>
24 #include <deal.II/base/quadrature_lib.h>
25 #include <deal.II/lac/vector.h>
26 #include <deal.II/grid/grid_tools.h>
27 #include <deal.II/dofs/dof_accessor.h>
28 #include <deal.II/dofs/dof_handler.h>
29 #include <deal.II/fe/fe_q.h>
30 #include <deal.II/fe/mapping.h>
31 #include <deal.II/fe/mapping_q1.h>
32 #include <deal.II/fe/fe_values.h>
33 #include <deal.II/fe/component_mask.h>
34 #include <deal.II/numerics/data_postprocessor.h>
35 
36 #include <vector>
37 #include <iostream>
38 #include <fstream>
39 #include <sstream>
40 #include <string>
41 #include <map>
42 
43 DEAL_II_NAMESPACE_OPEN
44 
45 namespace internal
46 {
47  namespace PointValueHistory
48  {
49  template <int dim> class PointGeometryData;
50  }
51 }
52 
53 
54 
55 namespace internal
56 {
57  namespace PointValueHistory
58  {
63  template <int dim>
64  class PointGeometryData
65  {
66  public:
67  PointGeometryData(const Point <dim> &new_requested_location, const std::vector <Point <dim> > &new_locations,
68  const std::vector <types::global_dof_index> &new_sol_indices);
69  Point <dim> requested_location;
70  std::vector <Point <dim> > support_point_locations;
71  std::vector <types::global_dof_index> solution_indices;
72  };
73  }
74 }
75 
76 
77 
212 template <int dim>
214 {
215 public:
221  PointValueHistory (const unsigned int n_independent_variables = 0);
222 
237  PointValueHistory (const DoFHandler<dim> &dof_handler,
238  const unsigned int n_independent_variables = 0);
239 
245  PointValueHistory (const PointValueHistory &point_value_history);
246 
254  PointValueHistory &operator=(const PointValueHistory &point_value_history);
255 
259  ~PointValueHistory ();
260 
268  void add_point(const Point <dim> &location);
269 
280  void add_points (const std::vector <Point <dim> > &locations);
281 
282 
283 
291  void add_field_name(const std::string &vector_name,
292  const ComponentMask &component_mask = ComponentMask());
293 
302  void add_field_name(const std::string &vector_name,
303  const unsigned int n_components);
304 
309  void add_component_names(const std::string &vector_name,
310  const std::vector <std::string> &component_names);
311 
316  void add_independent_names(const std::vector <std::string> &independent_names);
317 
318 
319 
328  template <class VectorType>
329  void evaluate_field(const std::string &name,
330  const VectorType &solution);
331 
332 
350  template <class VectorType>
351  void evaluate_field(const std::vector <std::string> &names,
352  const VectorType &solution,
353  const DataPostprocessor<dim> &data_postprocessor,
354  const Quadrature<dim> &quadrature);
355 
361  template <class VectorType>
362  void evaluate_field(const std::string &name,
363  const VectorType &solution,
364  const DataPostprocessor<dim> &data_postprocessor,
365  const Quadrature<dim> &quadrature);
366 
367 
380  template <class VectorType>
381  void evaluate_field_at_requested_location(const std::string &name,
382  const VectorType &solution);
383 
384 
393  void start_new_dataset (const double key);
394 
401  void push_back_independent (const std::vector <double> &independent_values);
402 
403 
421  void write_gnuplot (const std::string &base_name,
422  const std::vector <Point <dim> > postprocessor_locations = std::vector <Point <dim> > ());
423 
424 
447  Vector<double> mark_support_locations();
448 
456  void get_support_locations (std::vector <std::vector<Point <dim> > > &locations);
457 
466  void get_points (std::vector <std::vector<Point <dim> > > &locations);
467 
477  void get_postprocessor_locations (const Quadrature<dim> &quadrature,
478  std::vector<Point <dim> > &locations);
479 
491  void close();
492 
493 
503  void clear();
504 
510  void status(std::ostream &out);
511 
512 
521  bool deep_check (const bool strict);
522 
526  DeclExceptionMsg(ExcNoIndependent,
527  "A call has been made to push_back_independent() when "
528  "no independent values were requested.");
529 
533  DeclExceptionMsg(ExcDataLostSync,
534  "This error is thrown to indicate that the data sets appear to be out of "
535  "sync. The class requires that the number of dataset keys is the same as "
536  "the number of independent values sets and mesh linked value sets. The "
537  "number of each of these is allowed to differ by one to allow new values "
538  "to be added with out restricting the order the user choses to do so. "
539  "Special cases of no FHandler and no independent values should not "
540  "trigger this error.");
541 
542 
546  DeclExceptionMsg(ExcDoFHandlerRequired,
547  "A method which requires access to a @p DoFHandler to be meaningful has "
548  "been called when have_dof_handler is false (most likely due to default "
549  "constructor being called). Only independent variables may be logged with "
550  "no DoFHandler.");
551 
555  DeclExceptionMsg(ExcDoFHandlerChanged,
556  "The triangulation has been refined or coarsened in some way. This "
557  "suggests that the internal DoF indices stored by the current "
558  "object are no longer meaningful.");
559 
560 private:
565  std::vector <double> dataset_key;
566 
570  std::vector <std::vector <double> > independent_values;
571 
577  std::vector<std::string> indep_names;
578 
586  std::map <std::string, std::vector <std::vector <double> > > data_store;
587 
591  std::map <std::string, ComponentMask> component_mask;
592 
593 
598  std::map <std::string, std::vector<std::string> > component_names_map;
599 
603  std::vector <internal::PointValueHistory::PointGeometryData <dim> >
605 
606 
610  bool closed;
611 
615  bool cleared;
616 
617 
623 
624 
631 
637 
641  boost::signals2::connection tria_listener;
642 
646  unsigned int n_indep;
647 
648 
656  void tria_change_listener ();
657 };
658 
659 
660 DEAL_II_NAMESPACE_CLOSE
661 #endif /* dealii__point_value_history_h */
std::map< std::string, std::vector< std::vector< double > > > data_store
std::vector< double > dataset_key
std::vector< std::string > indep_names
std::vector< internal::PointValueHistory::PointGeometryData< dim > > point_geometry_data
boost::signals2::connection tria_listener
std::vector< std::vector< double > > independent_values
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:533
SmartPointer< const DoFHandler< dim >, PointValueHistory< dim > > dof_handler
std::map< std::string, ComponentMask > component_mask
std::map< std::string, std::vector< std::string > > component_names_map