Flow123d  master-f44eb46
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 header) override;
88 
89  /// Store list of VTK files and time steps declared in PVD file.
91 
92  /// Path to PVD file allows construct FilePath objects of VTK files.
93  std::string pvd_path_dir_;
94 
95  /// Iterator to items of \p file_list_
97 
98 };
99 
100 #endif /* MSH_PVD_READER_HH */
101 
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
Definition: mesh.h:362
std::vector< VtkFileData > file_list_
Store list of VTK files and time steps declared in PVD file.
void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader header) override
~PvdMeshReader()
Destructor.
void make_header_table() override
std::vector< VtkFileData >::iterator list_it_
Iterator to items of file_list_.
MeshDataHeader & find_header(HeaderQuery &header_query) override
void read_elements(Mesh *mesh) override
void read_physical_names(Mesh *mesh) override
std::string pvd_path_dir_
Path to PVD file allows construct FilePath objects of VTK files.
void read_nodes(Mesh *mesh) override
PvdMeshReader(const FilePath &file_name)
Represents data of one VTK file defined in PVD file.
double time
time step of VTK file
VtkMeshReader * reader
reader is created only if it's needed
FilePath file_name
path to VTK file
VtkFileData(double t, FilePath file)
Constructor.