42 #include "esysUtils/Esys_MPI.h"
47 #include <boost/shared_ptr.hpp>
48 #include <boost/python/object.hpp>
49 #include <boost/python/tuple.hpp>
121 bool expanded=
false);
138 bool expanded=
false);
162 Data(
const boost::python::object& value,
164 bool expanded=
false);
178 bool expanded=
false);
191 Data(
const boost::python::object& value,
200 const boost::python::tuple& shape=boost::python::make_tuple(),
202 bool expanded=
false);
282 const boost::python::object
313 const boost::python::object
465 return m_data->getFunctionSpace();
544 return m_data->getNumSamples();
556 return m_data->getNumDPPSample();
568 return m_data->getNoValues();
578 dump(
const std::string fileName)
const;
587 const boost::python::object
628 return m_data->getSampleDataByTag(tag);
663 return m_data->getPointOffset(sampleNo,dataPointNo);
675 return m_data->getShape();
683 const boost::python::tuple
725 const boost::python::object& value);
739 const boost::python::object& value);
795 double undef,
Data& B,
double Bmin,
double Bstep,
Data& C,
796 double Cmin,
double Cstep,
bool check_boundaries);
801 double undef,
Data& B,
double Bmin,
double Bstep,
bool check_boundaries);
806 double undef,
bool check_boundaries);
812 Data& B,
double Bmin,
double Bstep,
Data& C,
double Cmin,
double Cstep,
double undef,
bool check_boundaries);
818 Data& B,
double Bmin,
double Bstep,
double undef,
bool check_boundaries);
823 double undef,
bool check_boundaries);
827 nonuniforminterp(boost::python::object in, boost::python::object out,
bool check_boundaries);
831 nonuniformslope(boost::python::object in, boost::python::object out,
bool check_boundaries);
852 boost::python::object
861 boost::python::object
1024 const boost::python::tuple
1035 const boost::python::tuple
1075 trace(
int axis_offset)
const;
1106 const boost::python::tuple
1116 swapaxes(
const int axis0,
const int axis1)
const;
1310 powO(
const boost::python::object& right)
const;
1322 rpowO(
const boost::python::object& left)
const;
1397 boost::python::object
__add__(
const boost::python::object& right);
1405 boost::python::object
__sub__(
const boost::python::object& right);
1412 boost::python::object
__rsub__(
const boost::python::object& right);
1419 boost::python::object
__mul__(
const boost::python::object& right);
1426 boost::python::object
__div__(
const boost::python::object& right);
1433 boost::python::object
__rdiv__(
const boost::python::object& right);
1467 getItem(
const boost::python::object& key)
const;
1482 setItemD(
const boost::python::object& key,
1487 setItemO(
const boost::python::object& key,
1488 const boost::python::object& value);
1497 template <
class UnaryFunction>
1604 template <
class BinaryOp>
1621 boost::python::object
1658 template <
class BinaryFunction>
1662 double initial_value)
const;
1671 template <
class BinaryFunction>
1675 double initial_value)
const;
1685 template <
class BinaryFunction>
1689 BinaryFunction operation);
1800 if (omp_in_parallel())
1802 throw DataException(
"Please do not call forceResolve() in a parallel region.");
1816 if (omp_in_parallel())
1819 throw DataException(
"Programming error. Please do not run exclusiveWrite() in multi-threaded sections.");
1837 throw DataException(
"Programming error. ExclusiveWrite required - please call requireWrite()");
1851 #ifdef IKNOWWHATIMDOING
1860 #ifdef IKNOWWHATIMDOING
1899 EsysAssert((dr!=0),
"Error - casting to DataReady.");
1908 EsysAssert((dr!=0),
"Error - casting to DataReady.");
1920 EsysAssert((dr.get()!=0),
"Error - casting to DataReady.");
1930 EsysAssert((dr.get()!=0),
"Error - casting to DataReady.");
1940 throw DataException(
"Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
1954 return &((*res)[offset]);
1969 inline double rpow(
double x,
double y)
2098 return *
this / right;
2132 template <
class BinaryFunction>
2136 BinaryFunction operation)
2141 throw DataException(
"Error - attempt to update rank zero object with object with rank bigger than zero.");
2146 throw DataException(
"Programmer error - attempt to call binaryOp with Lazy Data.");
2150 Data tempRight(right);
2157 std::string msg=
"Error - attempt to combine incompatible FunctionSpaces.";
2166 tempRight=
Data(right,fsl);
2171 Data tempLeft(*
this,fsr);
2187 EsysAssert((leftC!=0),
"Programming error - casting to DataExpanded.");
2194 EsysAssert((leftC!=0),
"Programming error - casting to DataTagged.");
2197 EsysAssert((rightC!=0),
"Programming error - casting to DataTagged.");
2201 EsysAssert((rightC!=0),
"Programming error - casting to DataConstant.");
2207 EsysAssert((leftC!=0 && rightC!=0),
"Programming error - casting to DataConstant.");
2219 template <
class BinaryFunction>
2226 EsysAssert((leftC!=0),
"Programming error - casting to DataExpanded.");
2230 EsysAssert((leftC!=0),
"Programming error - casting to DataTagged.");
2234 EsysAssert((leftC!=0),
"Programming error - casting to DataConstant.");
2237 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2239 throw DataException(
"Error - Operations not permitted on instances of DataLazy.");
2241 throw DataException(
"Error - Data encapsulates an unknown type.");
2253 template <
class BinaryFunction>
2259 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2265 EsysAssert((dataE!=0),
"Programming error - casting data to DataExpanded.");
2266 EsysAssert((resultE!=0),
"Programming error - casting result to DataExpanded.");
2272 EsysAssert((dataT!=0),
"Programming error - casting data to DataTagged.");
2277 return Data(resultT);
2283 EsysAssert((dataC!=0),
"Programming error - casting data to DataConstant.");
2284 EsysAssert((resultC!=0),
"Programming error - casting result to DataConstant.");
2288 throw DataException(
"Error - Operations not permitted on instances of DataLazy.");
2290 throw DataException(
"Error - Data encapsulates an unknown type.");
2301 template <
typename BinaryFunction>
2306 BinaryFunction operation)
2310 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2314 throw DataException(
"Error - Operations not permitted on lazy data.");
2317 Data arg_0_Z, arg_1_Z;
2324 std::string msg=
"Error - C_TensorBinaryOperation: arguments have incompatible function spaces.";
2333 arg_0_Z =
Data(arg_0);
2338 arg_1_Z =
Data(arg_1);
2341 arg_0_Z =
Data(arg_0);
2342 arg_1_Z =
Data(arg_1);
2354 if (shape0 == shape1) {
2388 DataTagged::DataMapType::const_iterator i;
2389 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2404 int sampleNo_1,dataPointNo_1;
2407 int offset_0 = tmp_0->getPointOffset(0,0);
2409 #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2410 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2411 for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2445 DataTagged::DataMapType::const_iterator i;
2446 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2474 DataTagged::DataMapType::const_iterator i;
2477 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2480 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2485 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2502 int sampleNo_0,dataPointNo_0;
2506 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2507 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2508 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
2510 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2526 int sampleNo_0,dataPointNo_0;
2531 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2532 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2533 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2534 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2554 int sampleNo_0,dataPointNo_0;
2558 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2559 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2562 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2563 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2579 int sampleNo_0,dataPointNo_0;
2583 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2584 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2587 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2599 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
2602 }
else if (0 == rank0) {
2634 DataTagged::DataMapType::const_iterator i;
2635 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2653 int offset_0 = tmp_0->getPointOffset(0,0);
2655 double ptr_0 = ptr_src[0];
2656 int size = size1*numDataPointsPerSample_1;
2658 #pragma omp parallel for private(sampleNo_1) schedule(static)
2659 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2698 DataTagged::DataMapType::const_iterator i;
2699 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2729 DataTagged::DataMapType::const_iterator i;
2732 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2735 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2740 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2757 int sampleNo_0,dataPointNo_0;
2761 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2762 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2763 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
2765 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2781 int sampleNo_0,dataPointNo_0;
2786 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2787 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2788 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2789 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2808 int sampleNo_0,dataPointNo_0;
2812 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2813 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2816 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2817 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2834 int sampleNo_0,dataPointNo_0;
2838 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2839 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2840 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2841 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2853 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
2856 }
else if (0 == rank1) {
2889 DataTagged::DataMapType::const_iterator i;
2890 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2904 int sampleNo_1,dataPointNo_1;
2907 int offset_0 = tmp_0->getPointOffset(0,0);
2909 #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2910 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2911 for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2945 DataTagged::DataMapType::const_iterator i;
2946 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2975 DataTagged::DataMapType::const_iterator i;
2978 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2981 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2986 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
3002 int sampleNo_0,dataPointNo_0;
3006 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3007 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3008 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
3010 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3031 double ptr_1 = ptr_src[0];
3032 int size = size0 * numDataPointsPerSample_0;
3034 #pragma omp parallel for private(sampleNo_0) schedule(static)
3035 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3037 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
3056 int sampleNo_0,dataPointNo_0;
3060 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3061 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3064 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3065 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3082 int sampleNo_0,dataPointNo_0;
3086 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3087 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3088 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3089 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3101 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
3105 throw DataException(
"Error - C_TensorBinaryOperation: arguments have incompatible shapes");
3111 template <
typename UnaryFunction>
3114 UnaryFunction operation)
3118 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
3122 throw DataException(
"Error - Operations not permitted on lazy data.");
3157 DataTagged::DataMapType::const_iterator i;
3158 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
3172 int sampleNo_0,dataPointNo_0;
3175 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3176 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3179 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3188 throw DataException(
"Error - C_TensorUnaryOperation: unknown combination of inputs");