39 #include "esysUtils/Esys_MPI.h"
44 #include <boost/shared_ptr.hpp>
45 #include <boost/python/object.hpp>
46 #include <boost/python/tuple.hpp>
118 bool expanded=
false);
135 bool expanded=
false);
159 Data(
const boost::python::object& value,
161 bool expanded=
false);
175 bool expanded=
false);
188 Data(
const boost::python::object& value,
197 const boost::python::tuple& shape=boost::python::make_tuple(),
199 bool expanded=
false);
279 const boost::python::object
310 const boost::python::object
462 return m_data->getFunctionSpace();
541 return m_data->getNumSamples();
553 return m_data->getNumDPPSample();
591 return m_data->getNoValues();
601 dump(
const std::string fileName)
const;
610 const boost::python::object
651 return m_data->getSampleDataByTag(tag);
686 return m_data->getPointOffset(sampleNo,dataPointNo);
698 return m_data->getShape();
706 const boost::python::tuple
748 const boost::python::object& value);
762 const boost::python::object& value);
818 double undef,
Data& B,
double Bmin,
double Bstep,
Data& C,
819 double Cmin,
double Cstep,
bool check_boundaries);
824 double undef,
Data& B,
double Bmin,
double Bstep,
bool check_boundaries);
829 double undef,
bool check_boundaries);
835 Data& B,
double Bmin,
double Bstep,
Data& C,
double Cmin,
double Cstep,
double undef,
bool check_boundaries);
841 Data& B,
double Bmin,
double Bstep,
double undef,
bool check_boundaries);
846 double undef,
bool check_boundaries);
850 nonuniforminterp(boost::python::object in, boost::python::object out,
bool check_boundaries);
854 nonuniformslope(boost::python::object in, boost::python::object out,
bool check_boundaries);
875 boost::python::object
884 boost::python::object
1047 const boost::python::tuple
1058 const boost::python::tuple
1098 trace(
int axis_offset)
const;
1129 const boost::python::tuple
1139 swapaxes(
const int axis0,
const int axis1)
const;
1333 powO(
const boost::python::object& right)
const;
1345 rpowO(
const boost::python::object& left)
const;
1420 boost::python::object
__add__(
const boost::python::object& right);
1428 boost::python::object
__sub__(
const boost::python::object& right);
1435 boost::python::object
__rsub__(
const boost::python::object& right);
1442 boost::python::object
__mul__(
const boost::python::object& right);
1449 boost::python::object
__div__(
const boost::python::object& right);
1456 boost::python::object
__rdiv__(
const boost::python::object& right);
1490 getItem(
const boost::python::object& key)
const;
1505 setItemD(
const boost::python::object& key,
1510 setItemO(
const boost::python::object& key,
1511 const boost::python::object& value);
1520 template <
class UnaryFunction>
1627 template <
class BinaryOp>
1644 boost::python::object
1681 template <
class BinaryFunction>
1685 double initial_value)
const;
1694 template <
class BinaryFunction>
1698 double initial_value)
const;
1708 template <
class BinaryFunction>
1712 BinaryFunction operation);
1823 if (omp_in_parallel())
1825 throw DataException(
"Please do not call forceResolve() in a parallel region.");
1839 if (omp_in_parallel())
1842 throw DataException(
"Programming error. Please do not run exclusiveWrite() in multi-threaded sections.");
1860 throw DataException(
"Programming error. ExclusiveWrite required - please call requireWrite()");
1874 #ifdef IKNOWWHATIMDOING
1883 #ifdef IKNOWWHATIMDOING
1922 EsysAssert((dr!=0),
"Error - casting to DataReady.");
1931 EsysAssert((dr!=0),
"Error - casting to DataReady.");
1943 EsysAssert((dr.get()!=0),
"Error - casting to DataReady.");
1953 EsysAssert((dr.get()!=0),
"Error - casting to DataReady.");
1963 throw DataException(
"Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
1977 return &((*res)[offset]);
1992 inline double rpow(
double x,
double y)
2121 return *
this / right;
2155 template <
class BinaryFunction>
2159 BinaryFunction operation)
2164 throw DataException(
"Error - attempt to update rank zero object with object with rank bigger than zero.");
2169 throw DataException(
"Programmer error - attempt to call binaryOp with Lazy Data.");
2173 Data tempRight(right);
2180 std::string msg=
"Error - attempt to combine incompatible FunctionSpaces.";
2189 tempRight=
Data(right,fsl);
2194 Data tempLeft(*
this,fsr);
2210 EsysAssert((leftC!=0),
"Programming error - casting to DataExpanded.");
2217 EsysAssert((leftC!=0),
"Programming error - casting to DataTagged.");
2220 EsysAssert((rightC!=0),
"Programming error - casting to DataTagged.");
2224 EsysAssert((rightC!=0),
"Programming error - casting to DataConstant.");
2230 EsysAssert((leftC!=0 && rightC!=0),
"Programming error - casting to DataConstant.");
2242 template <
class BinaryFunction>
2249 EsysAssert((leftC!=0),
"Programming error - casting to DataExpanded.");
2253 EsysAssert((leftC!=0),
"Programming error - casting to DataTagged.");
2257 EsysAssert((leftC!=0),
"Programming error - casting to DataConstant.");
2260 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2262 throw DataException(
"Error - Operations not permitted on instances of DataLazy.");
2264 throw DataException(
"Error - Data encapsulates an unknown type.");
2276 template <
class BinaryFunction>
2282 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2288 EsysAssert((dataE!=0),
"Programming error - casting data to DataExpanded.");
2289 EsysAssert((resultE!=0),
"Programming error - casting result to DataExpanded.");
2295 EsysAssert((dataT!=0),
"Programming error - casting data to DataTagged.");
2300 return Data(resultT);
2306 EsysAssert((dataC!=0),
"Programming error - casting data to DataConstant.");
2307 EsysAssert((resultC!=0),
"Programming error - casting result to DataConstant.");
2311 throw DataException(
"Error - Operations not permitted on instances of DataLazy.");
2313 throw DataException(
"Error - Data encapsulates an unknown type.");
2324 template <
typename BinaryFunction>
2329 BinaryFunction operation)
2333 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
2337 throw DataException(
"Error - Operations not permitted on lazy data.");
2340 Data arg_0_Z, arg_1_Z;
2347 std::string msg=
"Error - C_TensorBinaryOperation: arguments have incompatible function spaces.";
2356 arg_0_Z =
Data(arg_0);
2361 arg_1_Z =
Data(arg_1);
2364 arg_0_Z =
Data(arg_0);
2365 arg_1_Z =
Data(arg_1);
2377 if (shape0 == shape1) {
2411 DataTagged::DataMapType::const_iterator i;
2412 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2427 int sampleNo_1,dataPointNo_1;
2430 int offset_0 = tmp_0->getPointOffset(0,0);
2432 #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2433 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2434 for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2468 DataTagged::DataMapType::const_iterator i;
2469 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2497 DataTagged::DataMapType::const_iterator i;
2500 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2503 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2508 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2525 int sampleNo_0,dataPointNo_0;
2529 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2530 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2531 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
2533 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2549 int sampleNo_0,dataPointNo_0;
2554 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2555 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2556 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2557 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2577 int sampleNo_0,dataPointNo_0;
2581 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2582 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2585 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2586 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2602 int sampleNo_0,dataPointNo_0;
2606 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2607 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2610 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2622 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
2625 }
else if (0 == rank0) {
2657 DataTagged::DataMapType::const_iterator i;
2658 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2676 int offset_0 = tmp_0->getPointOffset(0,0);
2678 double ptr_0 = ptr_src[0];
2679 int size = size1*numDataPointsPerSample_1;
2681 #pragma omp parallel for private(sampleNo_1) schedule(static)
2682 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2721 DataTagged::DataMapType::const_iterator i;
2722 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2752 DataTagged::DataMapType::const_iterator i;
2755 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2758 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2763 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
2780 int sampleNo_0,dataPointNo_0;
2784 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2785 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2786 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
2788 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2804 int sampleNo_0,dataPointNo_0;
2809 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2810 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2811 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2812 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2831 int sampleNo_0,dataPointNo_0;
2835 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2836 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2839 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2840 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2857 int sampleNo_0,dataPointNo_0;
2861 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
2862 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
2863 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
2864 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
2876 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
2879 }
else if (0 == rank1) {
2912 DataTagged::DataMapType::const_iterator i;
2913 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
2927 int sampleNo_1,dataPointNo_1;
2930 int offset_0 = tmp_0->getPointOffset(0,0);
2932 #pragma omp parallel for private(sampleNo_1,dataPointNo_1) schedule(static)
2933 for (sampleNo_1 = 0; sampleNo_1 < numSamples_1; sampleNo_1++) {
2934 for (dataPointNo_1 = 0; dataPointNo_1 < numDataPointsPerSample_1; dataPointNo_1++) {
2968 DataTagged::DataMapType::const_iterator i;
2969 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
2998 DataTagged::DataMapType::const_iterator i;
3001 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
3004 for (i=lookup_1.begin();i!=lookup_1.end();i++) {
3009 for (i=lookup_2.begin();i!=lookup_2.end();i++) {
3025 int sampleNo_0,dataPointNo_0;
3029 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3030 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3031 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
3033 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3054 double ptr_1 = ptr_src[0];
3055 int size = size0 * numDataPointsPerSample_0;
3057 #pragma omp parallel for private(sampleNo_0) schedule(static)
3058 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3060 int offset_0 = tmp_0->getPointOffset(sampleNo_0,0);
3079 int sampleNo_0,dataPointNo_0;
3083 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3084 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3087 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3088 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3105 int sampleNo_0,dataPointNo_0;
3109 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3110 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3111 for (dataPointNo_0 = 0; dataPointNo_0 < numDataPointsPerSample_0; dataPointNo_0++) {
3112 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3124 throw DataException(
"Error - C_TensorBinaryOperation: unknown combination of inputs");
3128 throw DataException(
"Error - C_TensorBinaryOperation: arguments have incompatible shapes");
3134 template <
typename UnaryFunction>
3137 UnaryFunction operation)
3141 throw DataException(
"Error - Operations not permitted on instances of DataEmpty.");
3145 throw DataException(
"Error - Operations not permitted on lazy data.");
3180 DataTagged::DataMapType::const_iterator i;
3181 for (i=lookup_0.begin();i!=lookup_0.end();i++) {
3195 int sampleNo_0,dataPointNo_0;
3198 #pragma omp parallel for private(sampleNo_0,dataPointNo_0) schedule(static)
3199 for (sampleNo_0 = 0; sampleNo_0 < numSamples_0; sampleNo_0++) {
3202 int offset_0 = tmp_0->getPointOffset(sampleNo_0,dataPointNo_0);
3211 throw DataException(
"Error - C_TensorUnaryOperation: unknown combination of inputs");