ESScript
Revision_
Main Page
Namespaces
Classes
Files
File List
File Members
weipa
src
DataVar.h
Go to the documentation of this file.
1
2
/*****************************************************************************
3
*
4
* Copyright (c) 2003-2013 by University of Queensland
5
* http://www.uq.edu.au
6
*
7
* Primary Business: Queensland, Australia
8
* Licensed under the Open Software License version 3.0
9
* http://www.opensource.org/licenses/osl-3.0.php
10
*
11
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12
* Development since 2012 by School of Earth Sciences
13
*
14
*****************************************************************************/
15
16
#ifndef __WEIPA_DATAVAR_H__
17
#define __WEIPA_DATAVAR_H__
18
19
#include <weipa/DomainChunk.h>
20
#include <ostream>
21
22
class
DBfile;
23
class
NcFile;
24
25
namespace
escript {
26
class
Data;
27
}
28
29
namespace
weipa {
30
34
class
DataVar
35
{
36
public
:
38
DataVar
(
const
std::string& name);
39
41
DataVar
(
const
DataVar
& d);
42
44
~DataVar
();
45
50
bool
initFromEscript
(escript::Data& escriptData,
const_DomainChunk_ptr
dom);
51
53
bool
initFromMeshData
(
const_DomainChunk_ptr
dom,
const
IntVec
& data,
54
int
fsCode,
Centering
c,
NodeData_ptr
nodes,
const
IntVec
&
id
);
55
62
bool
initFromFile
(
const
std::string& filename,
const_DomainChunk_ptr
dom);
63
67
bool
writeToSilo
(DBfile* dbfile,
const
std::string& siloPath,
68
const
std::string& units);
69
71
void
writeToVTK
(std::ostream& os,
int
ownIndex);
72
74
int
getRank
()
const
{
return
rank
; }
75
78
bool
isNodeCentered
()
const
;
79
85
std::string
getMeshName
()
const
{
return
meshName
; }
86
90
const
IntVec
&
getShape
()
const
{
return
shape
; }
91
93
std::string
getName
()
const
{
return
varName
; }
94
101
std::string
getTensorDef
()
const
;
102
104
int
getNumberOfSamples
()
const
{
return
numSamples
; }
105
108
const
CoordArray
&
getData
()
const
{
return
dataArray
; }
109
113
float
*
getDataFlat
()
const
;
114
116
int
getNumberOfComponents
()
const
;
117
118
private
:
119
void
cleanup
();
120
126
float
*
averageData
(
const
float
* src,
size_t
stride);
127
130
IndexMap
buildIndexMap
();
131
137
bool
reorderSamples
();
138
140
void
sampleToStream
(std::ostream& os,
int
index);
141
142
bool
initialized
;
143
const_DomainChunk_ptr
domain
;
144
std::string
varName
;
145
int
numSamples
,
rank
,
ptsPerSample
,
funcSpace
;
146
Centering
centering
;
147
IntVec
shape
;
148
IntVec
sampleID
;
149
CoordArray
dataArray
;
150
std::string
meshName
,
siloMeshName
;
151
};
152
153
inline
IndexMap
DataVar::buildIndexMap
()
154
{
155
IndexMap
sampleID2idx;
156
int
idx =
sampleID
.size()-1;
157
// see this thread for why this is done the way it's done:
158
// http://www.tech-archive.net/Archive/VC/microsoft.public.vc.stl/2005-01/0075.html
159
IntVec::const_reverse_iterator idIt =
sampleID
.rbegin();
160
IntVec::const_reverse_iterator endIt =
sampleID
.rend();
161
for
(; idIt != endIt; idIt++, idx--)
162
sampleID2idx[*idIt] = idx;
163
164
return
sampleID2idx;
165
}
166
167
}
// namespace weipa
168
169
#endif // __WEIPA_DATAVAR_H__
170
Generated on Thu Dec 12 2013 03:47:17 for ESScript by
1.8.1.2