Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
mesh
msh_gmshreader.h
Go to the documentation of this file.
1
/*!
2
*
3
* Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4
*
5
* Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6
* especially for academic research:
7
* Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8
*
9
* This program is free software; you can redistribute it and/or modify it under the terms
10
* of the GNU General Public License version 3 as published by the Free Software Foundation.
11
*
12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
* See the GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along with this program; if not,
17
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18
*
19
*
20
* $Id$
21
* $Revision$
22
* $LastChangedBy$
23
* $LastChangedDate$
24
*
25
*
26
* @file msh_gmshreader.h
27
* @author dalibor
28
*
29
* @date October 3, 2010, 11:23 AM
30
*/
31
32
#ifndef _GMSHMESHREADER_H
33
#define _GMSHMESHREADER_H
34
35
#include <string>
36
#include <istream>
37
#include <vector>
38
#include <map>
39
40
41
#include "
system/tokenizer.hh
"
42
#include "
mesh/region.hh
"
43
44
class
Mesh
;
45
class
FilePath
;
46
47
48
49
/***********************************
50
* Structure to store the information from a header of $ElementData section.
51
*
52
* Format of GMSH ASCII data sections
53
*
54
number-of-string-tags (== 2)
55
field_name
56
interpolation_scheme_name
57
number-of-real-tags (==1)
58
time_of_dataset
59
number-of-integer-tags
60
time_step_index (starting from zero)
61
number_of_field_components (1, 3, or 9 - i.e. 3d scalar, vector or tensor data)
62
number_of entities (nodes or elements)
63
partition_index (0 == no partition, not clear if GMSH support reading different partition from different files)
64
elm-number value ...
65
*
66
*/
67
68
struct
GMSH_DataHeader
{
69
/// True if the stream position is just after the header.
70
/// False either before first header is found or at EOF.
71
bool
actual
;
72
std::string
field_name
;
73
/// Currently ont used
74
std::string
interpolation_scheme
;
75
double
time
;
76
/// Currently ont used
77
unsigned
int
time_index
;
78
/// Number of values on one row
79
unsigned
int
n_components
;
80
/// Number of rows
81
unsigned
int
n_entities
;
82
/// ?? Currently ont used
83
unsigned
int
partition_index
;
84
};
85
86
87
class
GmshMeshReader
{
88
public
:
89
/**
90
* Construct the GMSH format reader from given filename.
91
* This opens the file for reading.
92
*/
93
GmshMeshReader
(
const
FilePath
&file_name);
94
/**
95
* Construct the GMSH format reader from given input stream.
96
* The input stream should be correctly opened. To get correct information about
97
* line numbers there should be no previous reading from the stream.
98
*/
99
GmshMeshReader
(std::istream &in);
100
101
/**
102
* Destructor close the file if opened.
103
*/
104
~GmshMeshReader
();
105
106
/**
107
* Reads @p mesh from the GMSH file.
108
*/
109
void
read_mesh
(
Mesh
* mesh,
const
RegionDB::MapElementIDToRegionID
*el_to_reg_map=NULL);
110
111
/**
112
* Reads ElementData sections of opened GMSH file. The file is serached for the $ElementData section with header
113
* that match the given @p search_header (same field_name, time of the next section is the first greater then
114
* that given in the @p search_header). If such section has not been yet read, we read the data section into
115
* raw buffer @p data. The map @p id_to_idx is used to convert IDs that marks individual input rows/entities into
116
* indexes to the raw buffer. The buffer must have size at least @p search_header.n_components * @p search_header.n_entities.
117
* Indexes in the map must be smaller then @p search_header.n_entities.
118
* If the @p data buffer is updated we set search_header.actual to true.
119
*
120
* Possible optimizations:
121
* If the map ID lookup seem slow, we may assume that IDs are in increasing order, use simple array of IDs instead of map
122
* and just check that they comes in in correct order.
123
*/
124
void
read_element_data
(
GMSH_DataHeader
&search_header,
125
double
*data,
std::vector<int>
const
& el_ids);
126
127
private
:
128
/**
129
* Read section '$PhysicalNames' of the GMSH file and save the physical sections as regions in the RegionDB.
130
*
131
* Region Labels starting with '!' are treated as boundary regions. Elements of these regions are used just to
132
* assign regions to the boundary and are not used in actual FEM computations.
133
*/
134
void
read_physical_names
(Tokenizer &in,
Mesh
* mesh);
135
136
/**
137
* private method for reading of nodes
138
*/
139
void
read_nodes
(Tokenizer &in,
Mesh
*);
140
/**
141
* private method for reading of elements - in process of implementation
142
*/
143
void
read_elements
(Tokenizer &in,
Mesh
*,
const
RegionDB::MapElementIDToRegionID
*el_to_reg_map=NULL);
144
/**
145
*
146
*/
147
void
read_data_header
(Tokenizer &tok,
GMSH_DataHeader
&head);
148
149
150
/// Tokenizer used for reading ASCII GMSH file format.
151
Tokenizer
tok_
;
152
/// Last read header of ElementData section.
153
GMSH_DataHeader
last_header
;
154
};
155
156
#endif
/* _GMSHMESHREADER_H */
157
Generated on Thu May 29 2014 23:14:49 for Flow123d by
1.8.4