ESScript
Revision_4488
Main Page
Namespaces
Classes
Files
File List
File Members
escript
src
DataTagged.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
17
#if !defined escript_DataTagged_20040615_H
18
#define escript_DataTagged_20040615_H
19
#include "
system_dep.h
"
20
21
#include "
DataReady.h
"
22
#include "
DataTypes.h
"
23
24
#include <vector>
25
#include <map>
26
27
namespace
escript {
28
29
class
DataConstant;
30
42
class
DataTagged
:
public
DataReady
{
43
typedef
DataReady
parent
;
44
public
:
45
46
//
47
// Types for the lists of tags and values.
48
typedef
std::vector<int>
TagListType
;
49
// typedef std::vector<DataArrayView> ValueListType;
50
typedef
DataTypes::ValueType
ValueType
;
51
typedef
std::vector<ValueType::ElementType>
ValueBatchType
;
52
53
//
54
// Map from a tag to an offset into the data array.
55
typedef
std::map<int, int>
DataMapType
;
56
67
ESCRIPT_DLL_API
68
DataTagged
();
69
82
ESCRIPT_DLL_API
83
DataTagged
(
const
FunctionSpace
& what,
84
const
DataTypes::ShapeType
&shape,
85
const
int
tags[],
86
const
ValueType
& data);
87
100
ESCRIPT_DLL_API
101
DataTagged
(
const
FunctionSpace
& what,
102
const
DataTypes::ShapeType
&shape,
103
const
TagListType
& tags,
104
const
ValueType
& data);
105
112
ESCRIPT_DLL_API
113
DataTagged
(
const
DataTagged
& other);
114
122
ESCRIPT_DLL_API
123
DataTagged
(
const
DataConstant
& other);
124
135
ESCRIPT_DLL_API
136
DataTagged
(
const
FunctionSpace
& what,
137
const
DataTypes::ShapeType
& shape,
138
const
DataTypes::ValueType
& defaultvalue,
139
const
DataTagged
* tagsource=0);
140
145
ESCRIPT_DLL_API
146
inline
virtual
147
~DataTagged
() {};
148
149
ESCRIPT_DLL_API
150
bool
151
isTagged
()
const
152
{
153
return
true
;
154
};
155
159
ESCRIPT_DLL_API
160
bool
161
hasNaN
()
const
;
162
166
ESCRIPT_DLL_API
167
virtual
168
DataAbstract
*
169
deepCopy
();
170
171
184
ESCRIPT_DLL_API
185
virtual
186
double
*
187
getSampleDataByTag
(
int
tag);
188
196
ESCRIPT_DLL_API
197
virtual
198
std::string
199
toString
()
const
;
204
ESCRIPT_DLL_API
205
virtual
206
void
207
dump
(
const
std::string fileName)
const
;
208
214
ESCRIPT_DLL_API
215
virtual
int
216
matrixInverse
(
DataAbstract
* out)
const
;
217
222
ESCRIPT_DLL_API
223
virtual
224
void
225
setToZero
();
226
233
ESCRIPT_DLL_API
234
virtual
235
int
236
getTagNumber
(
int
dpno);
237
250
ESCRIPT_DLL_API
251
virtual
252
ValueType::size_type
253
getPointOffset
(
int
sampleNo,
254
int
dataPointNo)
const
;
255
256
ESCRIPT_DLL_API
257
virtual
258
ValueType::size_type
259
getPointOffset
(
int
sampleNo,
260
int
dataPointNo);
261
279
ESCRIPT_DLL_API
280
void
281
addTaggedValues
(
const
TagListType
& tagKeys,
282
const
ValueBatchType
& values,
283
const
ShapeType
& vShape);
284
285
302
ESCRIPT_DLL_API
303
void
304
addTaggedValues
(
const
TagListType
& tagKeys,
305
const
ValueType
& values,
306
const
ShapeType
& vShape);
307
308
309
310
323
ESCRIPT_DLL_API
324
void
325
addTaggedValue
(
int
tagKey,
326
const
DataTypes::ShapeType
& pointshape,
327
const
ValueType
& value,
328
int
dataOffset=0);
329
340
ESCRIPT_DLL_API
341
void
342
addTag
(
int
tagKey);
343
356
ESCRIPT_DLL_API
357
void
358
setTaggedValue
(
int
tagKey,
359
const
DataTypes::ShapeType
& pointshape,
360
const
ValueType
& value,
361
int
dataOffset=0);
362
373
ESCRIPT_DLL_API
374
DataTypes::ValueType::reference
375
getDataByTagRW
(
int
tag,
DataTypes::ValueType::size_type
i);
376
377
ESCRIPT_DLL_API
378
DataTypes::ValueType::const_reference
379
getDataByTagRO
(
int
tag,
DataTypes::ValueType::size_type
i)
const
;
380
381
382
392
ESCRIPT_DLL_API
393
DataTypes::ValueType::size_type
394
getOffsetForTag
(
int
tag)
const
;
395
396
402
ESCRIPT_DLL_API
403
DataTypes::ValueType
&
404
getVectorRW
();
405
406
ESCRIPT_DLL_API
407
const
DataTypes::ValueType
&
408
getVectorRO
()
const
;
409
410
411
420
ESCRIPT_DLL_API
421
const
DataMapType
&
422
getTagLookup
()
const
;
423
435
ESCRIPT_DLL_API
436
bool
437
isCurrentTag
(
int
tag)
const
;
438
448
ESCRIPT_DLL_API
449
DataTypes::ValueType::reference
450
getDefaultValueRW
(
DataTypes::ValueType::size_type
i);
451
452
ESCRIPT_DLL_API
453
DataTypes::ValueType::const_reference
454
getDefaultValueRO
(
DataTypes::ValueType::size_type
i)
const
;
455
456
457
458
459
468
ESCRIPT_DLL_API
469
virtual
470
ValueType::size_type
471
getLength
()
const
;
472
483
ESCRIPT_DLL_API
484
virtual
485
DataAbstract
*
486
getSlice
(
const
DataTypes::RegionType
& region)
const
;
487
499
ESCRIPT_DLL_API
500
DataTagged
(
const
DataTagged
& other,
501
const
DataTypes::RegionType
& region);
502
513
ESCRIPT_DLL_API
514
virtual
515
void
516
setSlice
(
const
DataAbstract
* other,
517
const
DataTypes::RegionType
& region);
518
519
527
ESCRIPT_DLL_API
528
virtual
void
529
symmetric
(
DataAbstract
* ev);
530
538
ESCRIPT_DLL_API
539
virtual
void
540
nonsymmetric
(
DataAbstract
* ev);
541
549
ESCRIPT_DLL_API
550
virtual
void
551
trace
(
DataAbstract
* ev,
int
axis_offset);
552
561
ESCRIPT_DLL_API
562
virtual
void
563
swapaxes
(
DataAbstract
* ev,
int
axis0,
int
axis1);
564
572
ESCRIPT_DLL_API
573
virtual
void
574
transpose
(
DataAbstract
* ev,
int
axis_offset);
575
583
ESCRIPT_DLL_API
584
virtual
void
585
eigenvalues
(
DataAbstract
* ev);
586
598
ESCRIPT_DLL_API
599
virtual
void
600
eigenvalues_and_eigenvectors
(
DataAbstract
* ev,
DataAbstract
*
V
,
const
double
tol=1.e-13);
601
602
606
ESCRIPT_DLL_API
607
DataTypes::ValueType::size_type
608
getDefaultOffset
()
const
;
609
610
protected
:
611
612
private
:
613
614
//
615
// The offset lookup table
616
DataMapType
m_offsetLookup
;
617
618
//
619
// the offset to the default value
620
static
const
int
m_defaultValueOffset
= 0;
621
622
//
623
// The actual data
624
ValueType
m_data
;
625
626
};
627
628
inline
629
bool
630
DataTagged::isCurrentTag
(
int
tag)
const
631
{
632
DataMapType::const_iterator pos(
m_offsetLookup
.find(tag));
633
return
(pos!=
m_offsetLookup
.end());
634
}
635
636
inline
637
DataTypes::ValueType::size_type
638
DataTagged::getDefaultOffset
()
const
639
{
640
return
m_defaultValueOffset
;
641
}
642
643
inline
644
DataTypes::ValueType::reference
645
DataTagged::getDefaultValueRW
(
DataTypes::ValueType::size_type
i)
646
{
647
return
getVectorRW
()[i];
// getVectorRW has exclusive write checks
648
}
649
650
inline
651
DataTypes::ValueType::const_reference
652
DataTagged::getDefaultValueRO
(
DataTypes::ValueType::size_type
i)
const
653
{
654
return
getVectorRO
()[i];
655
}
656
657
inline
658
const
DataTagged::DataMapType
&
659
DataTagged::getTagLookup
()
const
660
{
661
return
m_offsetLookup
;
662
}
663
664
inline
665
DataTypes::ValueType::size_type
666
DataTagged::getLength
()
const
667
{
668
return
m_data
.
size
();
669
}
670
671
}
// end of namespace
672
673
#endif
Generated on Fri Jun 28 2013 11:10:52 for ESScript by
1.8.1.2