Flow123d  release_2.2.0-914-gf1a3a4f
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  * Check if nodes and elements of VTK mesh is compatible with \p mesh.
53  *
54  * - to all nodes of VTK mesh must exists one and only one nodes in second mesh
55  * - the same must occur for elements
56  * - method fill vector \p bulk_elements_id_
57  * - it is necessary to call this method before calling \p get_element_data
58  */
59  void check_compatible_mesh(Mesh &mesh) override;
60 
61  /**
62  * Find header of DataArray section of VTK file given by field_name.
63  */
64  MeshDataHeader & find_header(HeaderQuery &header_query) override;
65 
66 protected:
67  /// Represents data of one VTK file defined in PVD file.
68  struct VtkFileData {
69  /// Constructor
70  VtkFileData(double t, FilePath file) : time(t), file_name(file), reader(nullptr) {}
71 
72  double time; ///< time step of VTK file
73  FilePath file_name; ///< path to VTK file
74  VtkMeshReader * reader; ///< reader is created only if it's needed
75  };
76 
77  /**
78  * private method for reading of nodes
79  */
80  void read_nodes(Mesh * mesh) override;
81 
82  /**
83  * Method for reading of elements.
84  * Input of the mesh allows changing regions within the input file.
85  */
86  void read_elements(Mesh * mesh) override;
87 
88  /**
89  * This method is specified for PVD reader. Table of mesh data headers (same as for GMSH or VTK) is not created,
90  * but list of times and appropriate VTK files is filled.
91  */
92  void make_header_table() override;
93 
94  /**
95  * Implements @p BaseMeshReader::read_element_data.
96  */
97  void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components,
98  bool boundary_domain) override;
99 
100  /// Store list of VTK files and time steps declared in PVD file.
102 
103  /// Path to PVD file allows construct FilePath objects of VTK files.
104  std::string pvd_path_dir_;
105 
106  /// Iterator to items of \p file_list_
108 
109 };
110 
111 #endif /* MSH_PVD_READER_HH */
112 
void read_elements(Mesh *mesh) override
std::string pvd_path_dir_
Path to PVD file allows construct FilePath objects of VTK files.
void check_compatible_mesh(Mesh &mesh) override
PvdMeshReader(const FilePath &file_name)
Represents data of one VTK file defined in PVD file.
Definition: mesh.h:99
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