Reference documentation for deal.II version 9.0.0
point_value_history.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2018 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 PointValueHistoryImplementation
48  {
53  template <int dim>
55  {
56  public:
57  PointGeometryData(const Point <dim> &new_requested_location, const std::vector <Point <dim> > &new_locations,
58  const std::vector <types::global_dof_index> &new_sol_indices);
59  Point <dim> requested_location;
60  std::vector <Point <dim> > support_point_locations;
61  std::vector <types::global_dof_index> solution_indices;
62  };
63  }
64 }
65 
66 
67 
202 template <int dim>
204 {
205 public:
211  PointValueHistory (const unsigned int n_independent_variables = 0);
212 
228  const unsigned int n_independent_variables = 0);
229 
235  PointValueHistory (const PointValueHistory &point_value_history);
236 
244  PointValueHistory &operator=(const PointValueHistory &point_value_history);
245 
250 
258  void add_point(const Point <dim> &location);
259 
270  void add_points (const std::vector <Point <dim> > &locations);
271 
272 
273 
281  void add_field_name(const std::string &vector_name,
283 
292  void add_field_name(const std::string &vector_name,
293  const unsigned int n_components);
294 
299  void add_component_names(const std::string &vector_name,
300  const std::vector <std::string> &component_names);
301 
306  void add_independent_names(const std::vector <std::string> &independent_names);
307 
308 
309 
318  template <class VectorType>
319  void evaluate_field(const std::string &name,
320  const VectorType &solution);
321 
322 
340  template <class VectorType>
341  void evaluate_field(const std::vector <std::string> &names,
342  const VectorType &solution,
343  const DataPostprocessor<dim> &data_postprocessor,
344  const Quadrature<dim> &quadrature);
345 
351  template <class VectorType>
352  void evaluate_field(const std::string &name,
353  const VectorType &solution,
354  const DataPostprocessor<dim> &data_postprocessor,
355  const Quadrature<dim> &quadrature);
356 
357 
370  template <class VectorType>
371  void evaluate_field_at_requested_location(const std::string &name,
372  const VectorType &solution);
373 
374 
383  void start_new_dataset (const double key);
384 
391  void push_back_independent (const std::vector <double> &independent_values);
392 
393 
411  void write_gnuplot (const std::string &base_name,
412  const std::vector <Point <dim> > &postprocessor_locations = std::vector <Point <dim> > ());
413 
414 
438 
446  void get_support_locations (std::vector <std::vector<Point <dim> > > &locations);
447 
456  void get_points (std::vector <std::vector<Point <dim> > > &locations);
457 
467  void get_postprocessor_locations (const Quadrature<dim> &quadrature,
468  std::vector<Point <dim> > &locations);
469 
481  void close();
482 
483 
493  void clear();
494 
500  void status(std::ostream &out);
501 
502 
511  bool deep_check (const bool strict);
512 
517  "A call has been made to push_back_independent() when "
518  "no independent values were requested.");
519 
524  "This error is thrown to indicate that the data sets appear to be out of "
525  "sync. The class requires that the number of dataset keys is the same as "
526  "the number of independent values sets and mesh linked value sets. The "
527  "number of each of these is allowed to differ by one to allow new values "
528  "to be added with out restricting the order the user choses to do so. "
529  "Special cases of no FHandler and no independent values should not "
530  "trigger this error.");
531 
532 
537  "A method which requires access to a @p DoFHandler to be meaningful has "
538  "been called when have_dof_handler is false (most likely due to default "
539  "constructor being called). Only independent variables may be logged with "
540  "no DoFHandler.");
541 
546  "The triangulation has been refined or coarsened in some way. This "
547  "suggests that the internal DoF indices stored by the current "
548  "object are no longer meaningful.");
549 
550 private:
555  std::vector <double> dataset_key;
556 
560  std::vector <std::vector <double> > independent_values;
561 
567  std::vector<std::string> indep_names;
568 
576  std::map <std::string, std::vector <std::vector <double> > > data_store;
577 
581  std::map <std::string, ComponentMask> component_mask;
582 
583 
588  std::map <std::string, std::vector<std::string> > component_names_map;
589 
593  std::vector <internal::PointValueHistoryImplementation::PointGeometryData <dim> >
595 
596 
600  bool closed;
601 
605  bool cleared;
606 
607 
613 
614 
621 
627 
631  boost::signals2::connection tria_listener;
632 
636  unsigned int n_indep;
637 
638 
646  void tria_change_listener ();
647 };
648 
649 
650 DEAL_II_NAMESPACE_CLOSE
651 #endif /* dealii_point_value_history_h */
std::map< std::string, std::vector< std::vector< double > > > data_store
static ::ExceptionBase & ExcDataLostSync()
void get_postprocessor_locations(const Quadrature< dim > &quadrature, std::vector< Point< dim > > &locations)
PointValueHistory(const unsigned int n_independent_variables=0)
static ::ExceptionBase & ExcDoFHandlerChanged()
std::vector< double > dataset_key
std::vector< std::string > indep_names
void add_points(const std::vector< Point< dim > > &locations)
static ::ExceptionBase & ExcNoIndependent()
void add_component_names(const std::string &vector_name, const std::vector< std::string > &component_names)
void add_field_name(const std::string &vector_name, const ComponentMask &component_mask=ComponentMask())
boost::signals2::connection tria_listener
void evaluate_field_at_requested_location(const std::string &name, const VectorType &solution)
std::vector< std::vector< double > > independent_values
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:335
void evaluate_field(const std::string &name, const VectorType &solution)
void start_new_dataset(const double key)
SmartPointer< const DoFHandler< dim >, PointValueHistory< dim > > dof_handler
PointValueHistory & operator=(const PointValueHistory &point_value_history)
void write_gnuplot(const std::string &base_name, const std::vector< Point< dim > > &postprocessor_locations=std::vector< Point< dim > >())
void add_independent_names(const std::vector< std::string > &independent_names)
std::vector< internal::PointValueHistoryImplementation::PointGeometryData< dim > > point_geometry_data
Vector< double > mark_support_locations()
bool deep_check(const bool strict)
std::map< std::string, ComponentMask > component_mask
void status(std::ostream &out)
void add_point(const Point< dim > &location)
void get_points(std::vector< std::vector< Point< dim > > > &locations)
std::map< std::string, std::vector< std::string > > component_names_map
void get_support_locations(std::vector< std::vector< Point< dim > > > &locations)
static ::ExceptionBase & ExcDoFHandlerRequired()
PointGeometryData(const Point< dim > &new_requested_location, const std::vector< Point< dim > > &new_locations, const std::vector< types::global_dof_index > &new_sol_indices)
Only a constructor needed for this class (a struct really)
void push_back_independent(const std::vector< double > &independent_values)