ASPECT
visualization.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2019 by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _aspect_postprocess_visualization_h
23 #define _aspect_postprocess_visualization_h
24 
27 #include <aspect/plugins.h>
28 
29 #include <deal.II/base/thread_management.h>
30 #include <deal.II/numerics/data_postprocessor.h>
31 #include <deal.II/base/data_out_base.h>
32 #include <deal.II/numerics/data_out.h>
33 
34 namespace aspect
35 {
36  namespace Postprocess
37  {
38  namespace VisualizationPostprocessors
39  {
102  template <int dim>
103  class Interface
104  {
105  public:
110  virtual
111  ~Interface ();
112 
116  virtual void initialize ();
117 
121  virtual void update();
122 
136  static
137  void
139 
146  virtual
147  void
149 
164  virtual
165  std::list<std::string>
167 
168 
190  virtual
191  void save (std::map<std::string, std::string> &status_strings) const;
192 
204  virtual
205  void load (const std::map<std::string, std::string> &status_strings);
206  };
207 
208 
209 
222  template <int dim>
223  class CellDataVectorCreator : public Interface<dim>
224  {
225  public:
229  ~CellDataVectorCreator () override = default;
230 
249  virtual
250  std::pair<std::string, Vector<float> *>
251  execute () const = 0;
252  };
253  }
254 
255 
271  template <int dim>
272  class Visualization : public Interface<dim>, public ::aspect::SimulatorAccess<dim>
273  {
274  public:
278  Visualization ();
279 
283  std::pair<std::string,std::string>
284  execute (TableHandler &statistics) override;
285 
289  void
290  update () override;
291 
310  static
311  void
312  register_visualization_postprocessor (const std::string &name,
313  const std::string &description,
314  void (*declare_parameters_function) (ParameterHandler &),
315  VisualizationPostprocessors::Interface<dim> *(*factory_function) ());
316 
324  std::list<std::string>
325  required_other_postprocessors () const override;
326 
330  static
331  void
333 
337  void
338  parse_parameters (ParameterHandler &prm) override;
339 
343  void save (std::map<std::string, std::string> &status_strings) const override;
344 
348  void load (const std::map<std::string, std::string> &status_strings) override;
349 
354  template <class Archive>
355  void serialize (Archive &ar, const unsigned int version);
356 
357 
367  static
368  void
369  write_plugin_graph (std::ostream &output_stream);
370 
374  DeclException1 (ExcPostprocessorNameNotFound,
375  std::string,
376  << "Could not find entry <"
377  << arg1
378  << "> among the names of registered postprocessors.");
379 
380  private:
387 
393 
401 
406  unsigned int last_output_timestep;
407 
412  unsigned int output_file_number;
413 
417  std::string output_format;
418 
425  unsigned int group_files;
426 
435 
447 
456 
469 
477 
485 
494  void set_last_output_time (const double current_time);
495 
500  void mesh_changed_signal ();
501 
509  static
510  void writer (const std::string filename,
511  const std::string temporary_filename,
512  const std::string *file_contents);
513 
518  std::list<std::unique_ptr<VisualizationPostprocessors::Interface<dim> > > postprocessors;
519 
527  {
531  OutputHistory ();
532 
538  ~OutputHistory ();
539 
544  template <class Archive>
545  void serialize (Archive &ar, const unsigned int version);
546 
552 
557  std::string last_mesh_file_name;
558 
567  std::vector<std::pair<double,std::string> > times_and_pvtu_names;
568 
574  std::vector<std::vector<std::string> > output_file_names_by_timestep;
575 
582  std::vector<XDMFEntry> xdmf_entries;
583 
590  };
591 
597 
615  template <typename DataOutType>
616  void write_master_files (const DataOutType &data_out,
617  const std::string &solution_file_prefix,
618  const std::vector<std::string> &filenames,
619  OutputHistory &output_history) const;
620 
621 
631  template <typename DataOutType>
632  std::string write_data_out_data(DataOutType &data_out,
633  OutputHistory &output_history) const;
634  };
635  }
636 
637 
644 #define ASPECT_REGISTER_VISUALIZATION_POSTPROCESSOR(classname,name,description) \
645  template class classname<2>; \
646  template class classname<3>; \
647  namespace ASPECT_REGISTER_VISUALIZATION_POSTPROCESSOR_ ## classname \
648  { \
649  aspect::internal::Plugins::RegisterHelper<aspect::Postprocess::VisualizationPostprocessors::Interface<2>,classname<2> > \
650  dummy_ ## classname ## _2d (&aspect::Postprocess::Visualization<2>::register_visualization_postprocessor, \
651  name, description); \
652  aspect::internal::Plugins::RegisterHelper<aspect::Postprocess::VisualizationPostprocessors::Interface<3>,classname<3> > \
653  dummy_ ## classname ## _3d (&aspect::Postprocess::Visualization<3>::register_visualization_postprocessor, \
654  name, description); \
655  }
656 }
657 
658 
659 #endif
void write_plugin_graph(std::ostream &output_stream)
virtual void save(std::map< std::string, std::string > &status_strings) const
std::vector< std::pair< double, std::string > > times_and_pvtu_names
virtual std::list< std::string > required_other_postprocessors() const
#define DeclException1(Exception1, type1, outsequence)
std::list< std::unique_ptr< VisualizationPostprocessors::Interface< dim > > > postprocessors
std::vector< std::vector< std::string > > output_file_names_by_timestep
Definition: compat.h:53
static void declare_parameters(ParameterHandler &prm)
virtual void parse_parameters(ParameterHandler &prm)
virtual void load(const std::map< std::string, std::string > &status_strings)