Flow123d  JS_before_hm-1013-g06f2edc
msh_pvdreader.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file msh_pvdreader.hh
15  * @brief
16  * @author dalibor
17  */
18 
19 #ifndef MSH_PVD_READER_HH
20 #define MSH_PVD_READER_HH
21 
22 #include <string>
23 #include <istream>
24 
25 #include "io/msh_basereader.hh"
26 #include "system/file_path.hh"
27 
28 
29 class VtkMeshReader;
30 
31 
32 class PvdMeshReader : public BaseMeshReader {
33 public:
34  /**
35  * Construct the PVD reader from given FilePath.
36  * This opens the file for reading.
37  */
38  PvdMeshReader(const FilePath &file_name);
39 
40  /// Destructor
42 
43  /**
44  * Read regions from the VTK file and save the physical sections as regions in the RegionDB.
45  *
46  * Region Labels starting with '!' are treated as boundary regions. Elements of these regions are used just to
47  * assign regions to the boundary and are not used in actual FEM computations.
48  */
49  void read_physical_names(Mesh * mesh) override;
50 
51  /**
52  * Find header of DataArray section of VTK file given by field_name.
53  */
54  MeshDataHeader & find_header(HeaderQuery &header_query) override;
55 
56 protected:
57  /// Represents data of one VTK file defined in PVD file.
58  struct VtkFileData {
59  /// Constructor
60  VtkFileData(double t, FilePath file) : time(t), file_name(file), reader(nullptr) {}
61 
62  double time; ///< time step of VTK file
63  FilePath file_name; ///< path to VTK file
64  VtkMeshReader * reader; ///< reader is created only if it's needed
65  };
66 
67  /**
68  * private method for reading of nodes
69  */
70  void read_nodes(Mesh * mesh) override;
71 
72  /**
73  * Method for reading of elements.
74  * Input of the mesh allows changing regions within the input file.
75  */
76  void read_elements(Mesh * mesh) override;
77 
78  /**
79  * This method is specified for PVD reader. Table of mesh data headers (same as for GMSH or VTK) is not created,
80  * but list of times and appropriate VTK files is filled.
81  */
82  void make_header_table() override;
83 
84  /**
85  * Implements @p BaseMeshReader::read_element_data.
86  */
87  void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components,
88  bool boundary_domain) override;
89 
90  /// Store list of VTK files and time steps declared in PVD file.
92 
93  /// Path to PVD file allows construct FilePath objects of VTK files.
94  std::string pvd_path_dir_;
95 
96  /// Iterator to items of \p file_list_
98 
99 };
100 
101 #endif /* MSH_PVD_READER_HH */
102 
void read_elements(Mesh *mesh) override
std::string pvd_path_dir_
Path to PVD file allows construct FilePath objects of VTK files.
PvdMeshReader(const FilePath &file_name)
Represents data of one VTK file defined in PVD file.
Definition: mesh.h:78
void make_header_table() override
std::vector< VtkFileData > file_list_
Store list of VTK files and time steps declared in PVD file.
double time
time step of VTK file
void read_physical_names(Mesh *mesh) override
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
~PvdMeshReader()
Destructor.
VtkFileData(double t, FilePath file)
Constructor.
std::vector< VtkFileData >::iterator list_it_
Iterator to items of file_list_.
void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components, bool boundary_domain) override
FilePath file_name
path to VTK file
MeshDataHeader & find_header(HeaderQuery &header_query) override
void read_nodes(Mesh *mesh) override
VtkMeshReader * reader
reader is created only if it&#39;s needed