/[escript]/trunk/escript/src/DataAbstract.cpp
ViewVC logotype

Contents of /trunk/escript/src/DataAbstract.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 950 - (show annotations)
Tue Feb 6 07:01:11 2007 UTC (11 years, 11 months ago) by gross
File size: 5508 byte(s)
escript data objects can now be saved to netCDF files, see http://www.unidata.ucar.edu/software/netcdf/.
Currently only constant data are implemented with expanded and tagged data to follow.
There are two new functions to dump a data object

   s=Data(...)
   s.dump(<filename>)

and to recover it

   s=load(<filename>, domain)

Notice that the function space of s is recovered but domain is still need. 

dump and load will replace archive and extract.

The installation needs now the netCDF installed. 


1 // $Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
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 ************************************************************
12 */
13
14 #include "DataAbstract.h"
15 #include "DataException.h"
16
17 using namespace std;
18
19 namespace escript {
20
21 DataAbstract::DataAbstract(const FunctionSpace& what):
22 m_noDataPointsPerSample(what.getNumDPPSample()),
23 m_noSamples(what.getNumSamples()),
24 m_functionSpace(what)
25 {
26 }
27
28 DataAbstract::~DataAbstract()
29 {
30 }
31
32 void
33 DataAbstract::setPointDataView(const DataArrayView& input)
34 {
35 m_pointDataView.reset(new DataArrayView(input.getData(),input.getShape(),input.getOffset()));
36 }
37
38 void
39 DataAbstract::resetPointDataView()
40 {
41 m_pointDataView.reset(new DataArrayView());
42 }
43
44 void
45 DataAbstract::operandCheck(const DataAbstract& right) const
46 {
47 if ((right.getNumDPPSample()!=getNumDPPSample()) ||
48 (right.getNumSamples()!=getNumSamples()) ||
49 (right.getFunctionSpace()!=getFunctionSpace())) {
50 stringstream temp;
51 temp << "Error - Right hand argument sample shape or function space "
52 << "incompatible with left." << endl
53 << "LHS: (" << getNumSamples() << ","
54 << getNumDPPSample() << ") " << getFunctionSpace().toString()
55 << endl
56 << "RHS: (" << right.getNumSamples() << ","
57 << right.getNumDPPSample() << ") "
58 << right.getFunctionSpace().toString();
59 throw DataException(temp.str());
60 }
61
62 //
63 // Check the shape of the point data, a rank of 0(scalar) is okay
64 if (!((right.getPointDataView().getRank()==0) ||
65 (right.getPointDataView().getShape()==getPointDataView().getShape())))
66 {
67 stringstream temp;
68 temp << "Error - Right hand argument point data shape: "
69 << DataArrayView::shapeToString(right.getPointDataView().getShape())
70 << " doesn't match left: "
71 << DataArrayView::shapeToString(getPointDataView().getShape());
72 throw DataException(temp.str());
73 }
74 }
75
76 void
77 DataAbstract::dump(const std::string fileName) const
78 {
79 throw DataException("Error - DataAbstract:: dump: not implemented.");
80 }
81
82
83
84 DataAbstract::ValueType::value_type*
85 DataAbstract::getSampleDataByTag(int tag)
86 {
87 throw DataException("Error - DataAbstract::getSampleDataByTag: Data type does not have tag values.");
88 }
89
90 void
91 DataAbstract::setTaggedValue(int tagKey,
92 const DataArrayView& value)
93 {
94 throw DataException("Error - DataAbstract::setTaggedValue: Data type does not have tag values.");
95 }
96
97 int
98 DataAbstract::getTagNumber(int dpno)
99 {
100 throw DataException("Error - DataAbstract::getTagNumber: Data type cannot be accessed by tag values.");
101 return (0);
102 }
103
104 void
105 DataAbstract::setValueByReferenceNumber(int ref,
106 const DataArray& value)
107 {
108 throw DataException("Error - DataAbstract::setValueByReferenceNumber: Data type cannot be accessed by reference values.");
109 }
110
111 void
112 DataAbstract::getValueByReferenceNumber(int ref,
113 DataArray& value)
114 {
115 throw DataException("Error - DataAbstract::getValueByReferenceNumber: Data type cannot be accessed by reference values.");
116 }
117
118 int
119 DataAbstract::archiveData(ofstream& archiveFile,
120 const ValueType::size_type noValues) const
121 {
122 return 0;
123 }
124
125 int
126 DataAbstract::extractData(ifstream& archiveFile,
127 const ValueType::size_type noValues)
128 {
129 return 0;
130 }
131
132 void
133 DataAbstract::copyAll(const boost::python::numeric::array& value)
134 {
135 throw DataException("Error - DataAbstract::copying data from numarray objects is not supported.");
136 }
137 void
138 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
139 {
140 throw DataException("Error - DataAbstract::copying data from double value to a single data point is not supported.");
141 }
142 void
143 DataAbstract::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value)
144 {
145 throw DataException("Error - DataAbstract::copying data from numarray objects to a single data point is not supported.");
146 }
147
148 void
149 DataAbstract::symmetric(DataAbstract* ev)
150 {
151 throw DataException("Error - DataAbstract::symmetric is not supported.");
152 }
153
154 void
155 DataAbstract::nonsymmetric(DataAbstract* ev)
156 {
157 throw DataException("Error - DataAbstract::nonsymmetric is not supported.");
158 }
159
160 void
161 DataAbstract::trace(DataAbstract* ev, int axis_offset)
162 {
163 throw DataException("Error - DataAbstract::trace is not supported.");
164 }
165
166 void
167 DataAbstract::swapaxes(DataAbstract* ev, int axis0, int axis1)
168 {
169 throw DataException("Error - DataAbstract::component swapaxes is not supported.");
170 }
171 void
172 DataAbstract::transpose(DataAbstract* ev, int axis_offset)
173 {
174 throw DataException("Error - DataAbstract::transpose is not supported.");
175 }
176
177 void
178 DataAbstract::eigenvalues(DataAbstract* ev)
179 {
180 throw DataException("Error - DataAbstract::eigenvalues is not supported.");
181
182 }
183 void
184 DataAbstract::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
185 {
186 throw DataException("Error - DataAbstract::eigenvalues_and_eigenvectors is not supported.");
187
188 }
189
190
191
192 } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26