Flow123d  release_3.0.0-1106-ga3b2e4c
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  * OBSOLETE method - will be replace with Mesh::check_compatible_mesh after merge fields!
60  */
61  void check_compatible_mesh(Mesh &mesh) override;
62 
63  /**
64  * Find header of DataArray section of VTK file given by field_name.
65  */
66  MeshDataHeader & find_header(HeaderQuery &header_query) override;
67 
68 protected:
69  /// Represents data of one VTK file defined in PVD file.
70  struct VtkFileData {
71  /// Constructor
72  VtkFileData(double t, FilePath file) : time(t), file_name(file), reader(nullptr) {}
73 
74  double time; ///< time step of VTK file
75  FilePath file_name; ///< path to VTK file
76  VtkMeshReader * reader; ///< reader is created only if it's needed
77  };
78 
79  /**
80  * private method for reading of nodes
81  */
82  void read_nodes(Mesh * mesh) override;
83 
84  /**
85  * Method for reading of elements.
86  * Input of the mesh allows changing regions within the input file.
87  */
88  void read_elements(Mesh * mesh) override;
89 
90  /**
91  * This method is specified for PVD reader. Table of mesh data headers (same as for GMSH or VTK) is not created,
92  * but list of times and appropriate VTK files is filled.
93  */
94  void make_header_table() override;
95 
96  /**
97  * Implements @p BaseMeshReader::read_element_data.
98  */
99  void read_element_data(ElementDataCacheBase &data_cache, MeshDataHeader actual_header, unsigned int n_components,
100  bool boundary_domain) override;
101 
102  /// Store list of VTK files and time steps declared in PVD file.
104 
105  /// Path to PVD file allows construct FilePath objects of VTK files.
106  std::string pvd_path_dir_;
107 
108  /// Iterator to items of \p file_list_
110 
111 };
112 
113 #endif /* MSH_PVD_READER_HH */
114 
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:76
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