Data.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2017 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014 by Centre for Geoscience Computing (GeoComp)
*
*****************************************************************************/
#ifndef __ESCRIPT_DATA_H__
#define __ESCRIPT_DATA_H__
#include "system_dep.h"
#include "DataAbstract.h"
#include "DataException.h"
#include "DataTypes.h"
#include "EsysMPI.h"
#include "FunctionSpace.h"
#include "DataVectorOps.h"
#include <algorithm>
#include <string>
#include <sstream>
#include <boost/python/object.hpp>
#include <boost/python/tuple.hpp>
#include <boost/math/special_functions/bessel.hpp>
#ifndef ESCRIPT_MAX_DATA_RANK
#define ESCRIPT_MAX_DATA_RANK 4
#endif
namespace escript {
//
// Forward declaration for various implementations of Data.
class DataConstant;
class DataTagged;
class DataExpanded;
class DataLazy;
class Data {
public:
Data();
Data(const Data& inData);
Data(const Data& inData,
const FunctionSpace& what);
Data(const DataTypes::RealVectorType& value,
const DataTypes::ShapeType& shape,
const FunctionSpace& what,
bool expanded);
Data(DataTypes::real_t value,
const DataTypes::ShapeType& dataPointShape,
const FunctionSpace& what,
bool expanded);
explicit
Data(DataTypes::cplx_t value,
const DataTypes::ShapeType& dataPointShape,
const FunctionSpace& what,
bool expanded);
Data(const Data& inData,
const DataTypes::RegionType& region);
Data(const WrappedArray& w, const FunctionSpace& what,
bool expanded);
Data(const boost::python::object& value,
const Data& other);
Data(boost::python::object value,
boost::python::object par1=boost::python::object(),
boost::python::object par2=boost::python::object(),
boost::python::object par3=boost::python::object());
explicit Data(DataAbstract* underlyingdata);
explicit Data(DataAbstract_ptr underlyingdata);
~Data();
void
copy(const Data& other);
Data
copySelf() const;
Data
delay();
void
delaySelf();
void
setProtection();
bool
isProtected() const;
const boost::python::object
getValueOfDataPointAsTuple(int dataPointNo);
void
setValueOfDataPointToPyObject(int dataPointNo, const boost::python::object& py_object);
void
setValueOfDataPointToArray(int dataPointNo, const boost::python::object&);
void
setValueOfDataPoint(int dataPointNo, const DataTypes::real_t);
void
setValueOfDataPointC(int dataPointNo, const DataTypes::cplx_t);
const boost::python::object
getValueOfGlobalDataPointAsTuple(int procNo, int dataPointNo);
void
setTupleForGlobalDataPoint(int id, int proc, boost::python::object);
int
getTagNumber(int dpno);
std::string
toString() const;
void
expand();
void
tag();
void
resolve();
bool
hasNaN();
void
replaceNaN(DataTypes::real_t value);
void
replaceNaN(DataTypes::cplx_t value);
void
replaceNaNPython(boost::python::object obj);
void
requireWrite();
bool
isExpanded() const;
bool
actsExpanded() const;
bool
isTagged() const;
bool
isConstant() const;
bool
isLazy() const;
bool
isReady() const;
bool
isEmpty() const;
bool
isComplex() const;
inline
const FunctionSpace&
getFunctionSpace() const
{
return m_data->getFunctionSpace();
}
inline
// const AbstractDomain&
const_Domain_ptr
getDomain() const
{
return getFunctionSpace().getDomain();
}
inline
// const AbstractDomain&
Domain_ptr
getDomainPython() const
{
return getFunctionSpace().getDomainPython();
}
inline
unsigned int
getDataPointRank() const
{
return m_data->getRank();
}
inline
int
getNumDataPoints() const
{
return getNumSamples() * getNumDataPointsPerSample();
}
inline
int
getNumSamples() const
{
return m_data->getNumSamples();
}
inline
int
getNumDataPointsPerSample() const
{
return m_data->getNumDPPSample();
}
inline
bool numSamplesEqual(int numDataPointsPerSample, int numSamples) const
{
return (isEmpty() ||
(numDataPointsPerSample==getNumDataPointsPerSample() && numSamples==getNumSamples()));
}
inline
bool isDataPointShapeEqual(int rank, const int* dimensions) const
{
if (isEmpty())
return true;
const DataTypes::ShapeType givenShape(&dimensions[0],&dimensions[rank]);
return (getDataPointShape()==givenShape);
}
int
getNoValues() const
{
return m_data->getNoValues();
}
void
dump(const std::string fileName) const;
const boost::python::object
toListOfTuples(bool scalarastuple=true);
const DataTypes::real_t*
getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const;
const DataTypes::cplx_t*
getSampleDataRO(DataTypes::CplxVectorType::size_type sampleNo, DataTypes::cplx_t dummy) const;
DataTypes::real_t*
getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0);
DataTypes::cplx_t*
getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::cplx_t dummy);
const DataTypes::real_t*
getDataRO(DataTypes::real_t dummy=0) const;
const DataTypes::cplx_t*
getDataRO(DataTypes::cplx_t dummy) const;
inline
DataTypes::real_t*
getSampleDataByTag(int tag, DataTypes::real_t dummy=0)
{
return m_data->getSampleDataByTag(tag, dummy);
}
inline
DataTypes::cplx_t*
getSampleDataByTag(int tag, DataTypes::cplx_t dummy)
{
return m_data->getSampleDataByTag(tag, dummy);
}
DataTypes::RealVectorType::const_reference
getDataPointRO(int sampleNo, int dataPointNo);
DataTypes::RealVectorType::reference
getDataPointRW(int sampleNo, int dataPointNo);
inline
DataTypes::RealVectorType::size_type
getDataOffset(int sampleNo,
int dataPointNo)
{
return m_data->getPointOffset(sampleNo,dataPointNo);
}
inline
const DataTypes::ShapeType&
getDataPointShape() const
{
return m_data->getShape();
}
const boost::python::tuple
getShapeTuple() const;
int
getDataPointSize() const;
DataTypes::RealVectorType::size_type
getLength() const;
bool
hasNoSamples() const
{
return m_data->getNumSamples()==0;
}
void
setTaggedValueByName(std::string name,
const boost::python::object& value);
void
setTaggedValue(int tagKey,
const boost::python::object& value);
void
setTaggedValueFromCPP(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::RealVectorType& value,
int dataOffset=0);
void
setTaggedValueFromCPP(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::CplxVectorType& value,
int dataOffset=0);
void
copyWithMask(const Data& other,
const Data& mask);
void
setToZero();
Data
interpolate(const FunctionSpace& functionspace) const;
Data
interpolateFromTable3D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
DataTypes::real_t undef, Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, Data& C,
DataTypes::real_t Cmin, DataTypes::real_t Cstep, bool check_boundaries);
Data
interpolateFromTable2D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
DataTypes::real_t undef, Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep,bool check_boundaries);
Data
interpolateFromTable1D(const WrappedArray& table, DataTypes::real_t Amin, DataTypes::real_t Astep,
DataTypes::real_t undef,bool check_boundaries);
Data
interpolateFromTable3DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, Data& C, DataTypes::real_t Cmin, DataTypes::real_t Cstep, DataTypes::real_t undef,bool check_boundaries);
Data
interpolateFromTable2DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
Data& B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, DataTypes::real_t undef,bool check_boundaries);
Data
interpolateFromTable1DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep,
DataTypes::real_t undef,bool check_boundaries);
Data
nonuniforminterp(boost::python::object in, boost::python::object out, bool check_boundaries);
Data
nonuniformslope(boost::python::object in, boost::python::object out, bool check_boundaries);
Data
gradOn(const FunctionSpace& functionspace) const;
Data
grad() const;
boost::python::object
integrateToTuple_const() const;
boost::python::object
integrateToTuple();
Data
oneOver() const;
Data
wherePositive() const;
Data
whereNegative() const;
Data
whereNonNegative() const;
Data
whereNonPositive() const;
Data
whereZero(DataTypes::real_t tol=0.0) const;
Data
whereNonZero(DataTypes::real_t tol=0.0) const;
DataTypes::real_t
Lsup();
DataTypes::real_t
Lsup_const() const;
DataTypes::real_t
sup();
DataTypes::real_t
sup_const() const;
DataTypes::real_t
inf();
DataTypes::real_t
inf_const() const;
Data
abs() const;
Data
phase() const;
Data
maxval() const;
Data
minval() const;
const boost::python::tuple
minGlobalDataPoint() const;
const boost::python::tuple
maxGlobalDataPoint() const;
Data
sign() const;
Data
symmetric() const;
Data
antisymmetric() const;
Data
hermitian() const;
Data
antihermitian() const;
Data
trace(int axis_offset) const;
Data
transpose(int axis_offset) const;
Data
eigenvalues() const;
const boost::python::tuple
eigenvalues_and_eigenvectors(const DataTypes::real_t tol=1.e-12) const;
Data
swapaxes(const int axis0, const int axis1) const;
Data
erf() const;
Data
conjugate() const;
Data
real() const;
Data
imag() const;
Data
sin() const;
Data
cos() const;
Data
bessel(int order, DataTypes::real_t (*besselfunc) (int,DataTypes::real_t) );
Data
besselFirstKind(int order);
Data
besselSecondKind(int order);
Data
tan() const;
Data
asin() const;
Data
acos() const;
Data
atan() const;
Data
sinh() const;
Data
cosh() const;
Data
tanh() const;
Data
asinh() const;
Data
acosh() const;
Data
atanh() const;
Data
log10() const;
Data
log() const;
Data
exp() const;
Data
sqrt() const;
Data
neg() const;
Data
pos() const;
Data
powD(const Data& right) const;
Data
powO(const boost::python::object& right) const;
Data
rpowO(const boost::python::object& left) const;
Data& operator+=(const Data& right);
Data& operator+=(const boost::python::object& right);
Data& operator=(const Data& other);
Data& operator-=(const Data& right);
Data& operator-=(const boost::python::object& right);
Data& operator*=(const Data& right);
Data& operator*=(const boost::python::object& right);
Data& operator/=(const Data& right);
Data& operator/=(const boost::python::object& right);
Data truedivD(const Data& right);
Data truedivO(const boost::python::object& right);
Data rtruedivO(const boost::python::object& left);
boost::python::object __add__(const boost::python::object& right);
boost::python::object __sub__(const boost::python::object& right);
boost::python::object __rsub__(const boost::python::object& right);
boost::python::object __mul__(const boost::python::object& right);
boost::python::object __div__(const boost::python::object& right);
boost::python::object __rdiv__(const boost::python::object& right);
Data
matrixInverse() const;
bool
probeInterpolation(const FunctionSpace& functionspace) const;
Data
getItem(const boost::python::object& key) const;
void
setItemD(const boost::python::object& key,
const Data& value);
void
setItemO(const boost::python::object& key,
const boost::python::object& value);
// These following public methods should be treated as private.
template <class UnaryFunction>
inline
void
unaryOp2(UnaryFunction operation);
Data
getSlice(const DataTypes::RegionType& region) const;
void
setSlice(const Data& value,
const DataTypes::RegionType& region);
void
print(void);
int
get_MPIRank(void) const;
int
get_MPISize(void) const;
MPI_Comm
get_MPIComm(void) const;
DataAbstract*
borrowData(void) const;
DataAbstract_ptr
borrowDataPtr(void) const;
DataReady_ptr
borrowReadyPtr(void) const;
DataTypes::RealVectorType::const_reference
getDataAtOffsetRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy);
DataTypes::RealVectorType::reference
getDataAtOffsetRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy);
DataTypes::CplxVectorType::const_reference
getDataAtOffsetRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
DataTypes::CplxVectorType::reference
getDataAtOffsetRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
DataTypes::RealVectorType&
getExpandedVectorReference(DataTypes::real_t dummy=0);
DataTypes::CplxVectorType&
getExpandedVectorReference(DataTypes::cplx_t dummy);
size_t
getNumberOfTaggedValues() const;
/*
* \brief make the data complex
*/
void complicate();
protected:
private:
void init_from_data_and_fs(const Data& inData,
const FunctionSpace& functionspace);
template <typename S>
void
maskWorker(Data& other2, Data& mask2, S sentinel);
template <class BinaryOp>
DataTypes::real_t
#ifdef ESYS_MPI
lazyAlgWorker(DataTypes::real_t init, MPI_Op mpiop_type);
#else
lazyAlgWorker(DataTypes::real_t init);
#endif
DataTypes::real_t
LsupWorker() const;
DataTypes::real_t
supWorker() const;
DataTypes::real_t
infWorker() const;
template<typename Scalar>
boost::python::object
integrateWorker() const;
void
calc_minGlobalDataPoint(int& ProcNo, int& DataPointNo) const;
void
calc_maxGlobalDataPoint(int& ProcNo, int& DataPointNo) const;
// For internal use in Data.cpp only!
// other uses should call the main entry points and allow laziness
Data
minval_nonlazy() const;
// For internal use in Data.cpp only!
Data
maxval_nonlazy() const;
inline
void
operandCheck(const Data& right) const
{
return m_data->operandCheck(*(right.m_data.get()));
}
template <class BinaryFunction>
inline
DataTypes::real_t
reduction(BinaryFunction operation,
DataTypes::real_t initial_value) const;
template <class BinaryFunction>
inline
Data
dp_algorithm(BinaryFunction operation,
DataTypes::real_t initial_value) const;
void
typeMatchLeft(Data& right) const;
void
typeMatchRight(const Data& right);
void
initialise(const DataTypes::RealVectorType& value,
const DataTypes::ShapeType& shape,
const FunctionSpace& what,
bool expanded);
void
initialise(const DataTypes::CplxVectorType& value,
const DataTypes::ShapeType& shape,
const FunctionSpace& what,
bool expanded);
void
initialise(const WrappedArray& value,
const FunctionSpace& what,
bool expanded);
void
initialise(const DataTypes::real_t value,
const DataTypes::ShapeType& shape,
const FunctionSpace& what,
bool expanded);
void
initialise(const DataTypes::cplx_t value,
const DataTypes::ShapeType& shape,
const FunctionSpace& what,
bool expanded);
//
// flag to protect the data object against any update
bool m_protected;
bool m_lazy;
//
// pointer to the actual data object
// boost::shared_ptr<DataAbstract> m_data;
DataAbstract_ptr m_data;
// If possible please use getReadyPtr instead.
// But see warning below.
const DataReady*
getReady() const
{
const DataReady* dr=dynamic_cast<const DataReady*>(m_data.get());
ESYS_ASSERT(dr!=0, "error casting to DataReady.");
return dr;
}
DataReady*
getReady()
{
DataReady* dr=dynamic_cast<DataReady*>(m_data.get());
ESYS_ASSERT(dr!=0, "error casting to DataReady.");
return dr;
}
// Be wary of using this for local operations since it (temporarily) increases reference count.
// If you are just using this to call a method on DataReady instead of DataAbstract consider using
// getReady() instead
DataReady_ptr
getReadyPtr()
{
DataReady_ptr dr=REFCOUNTNS::dynamic_pointer_cast<DataReady>(m_data);
ESYS_ASSERT(dr.get()!=0, "error casting to DataReady.");
return dr;
}
const_DataReady_ptr
getReadyPtr() const
{
const_DataReady_ptr dr=REFCOUNTNS::dynamic_pointer_cast<const DataReady>(m_data);
ESYS_ASSERT(dr.get()!=0, "error casting to DataReady.");
return dr;
}
// In the isShared() method below:
// A problem would occur if m_data (the address pointed to) were being modified
// while the call m_data->is_shared is being executed.
//
// Q: So why do I think this code can be thread safe/correct?
// A: We need to make some assumptions.
// 1. We assume it is acceptable to return true under some conditions when we aren't shared.
// 2. We assume that no constructions or assignments which will share previously unshared
// will occur while this call is executing. This is consistent with the way Data:: and C are written.
//
// This means that the only transition we need to consider, is when a previously shared object is
// not shared anymore. ie. the other objects have been destroyed or a deep copy has been made.
// In those cases the m_shared flag changes to false after m_data has completed changing.
// For any threads executing before the flag switches they will assume the object is still shared.
bool isShared() const
{
#ifdef SLOWSHARECHECK
return m_data->isShared(); // single threadsafe check for this
#else
return !m_data.unique();
#endif
}
void forceResolve()
{
if (isLazy())
{
#ifdef _OPENMP
if (omp_in_parallel())
{ // Yes this is throwing an exception out of an omp thread which is forbidden.
throw DataException("Please do not call forceResolve() in a parallel region.");
}
#endif
resolve();
}
}
void exclusiveWrite()
{
#ifdef _OPENMP
if (omp_in_parallel())
{
throw DataException("Programming error. Please do not run exclusiveWrite() in multi-threaded sections.");
}
#endif
forceResolve();
if (isShared())
{
DataAbstract* t=m_data->deepCopy();
set_m_data(DataAbstract_ptr(t));
}
#ifdef EXWRITECHK
m_data->exclusivewritecalled=true;
#endif
}
void checkExclusiveWrite()
{
if (isLazy() || isShared())
{
std::ostringstream oss;
oss << "Programming error. ExclusiveWrite required - please call requireWrite() isLazy=" << isLazy() << " isShared()=" << isShared();
throw DataException(oss.str());
}
}
void set_m_data(DataAbstract_ptr p);
void TensorSelfUpdateBinaryOperation(const Data& right, escript::ES_optype operation);
friend class DataAbstract; // To allow calls to updateShareStatus
friend class TestDomain; // so its getX will work quickly
#ifdef IKNOWWHATIMDOING
friend Data applyBinaryCFunction(boost::python::object cfunc, boost::python::tuple shape, escript::Data& d, escript::Data& e);
#endif
template <typename S>
friend Data condEvalWorker(escript::Data& mask, escript::Data& trueval, escript::Data& falseval, S sentinel);
friend Data randomData(const boost::python::tuple& shape, const FunctionSpace& what, long seed, const boost::python::tuple& filter);
};
#ifdef IKNOWWHATIMDOING
Data
applyBinaryCFunction(boost::python::object func, boost::python::tuple shape, escript::Data& d, escript::Data& e);
#endif
Data
condEval(escript::Data& mask, escript::Data& trueval, escript::Data& falseval);
Data randomData(const boost::python::tuple& shape,
const FunctionSpace& what,
long seed, const boost::python::tuple& filter);
} // end namespace escript
// No, this is not supposed to be at the top of the file
// DataAbstact needs to be declared first, then DataReady needs to be fully declared
// so that I can dynamic cast between them below.
#include "DataReady.h"
#include "DataLazy.h"
#include "DataExpanded.h"
#include "DataConstant.h"
#include "DataTagged.h"
namespace escript
{
inline
DataTypes::real_t*
Data::getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy)
{
if (isLazy())
{
throw DataException("Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
}
#ifdef EXWRITECHK
if (!getReady()->exclusivewritecalled)
{
throw DataException("Error, call to Data::getSampleDataRW without a preceeding call to requireWrite/exclusiveWrite.");
}
#endif
return getReady()->getSampleDataRW(sampleNo, dummy);
}
inline
DataTypes::cplx_t*
Data::getSampleDataRW(DataTypes::CplxVectorType::size_type sampleNo, DataTypes::cplx_t dummy)
{
if (isLazy())
{
throw DataException("Error, attempt to acquire RW access to lazy data. Please call requireWrite() first.");
}
#ifdef EXWRITECHK
if (!getReady()->exclusivewritecalled)
{
throw DataException("Error, call to Data::getSampleDataRW without a preceeding call to requireWrite/exclusiveWrite.");
}
#endif
return getReady()->getSampleDataRW(sampleNo, dummy);
}
inline
const DataTypes::real_t*
Data::getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo,DataTypes::real_t dummy) const
{
DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());
if (l!=0)
{
size_t offset=0;
const DataTypes::RealVectorType* res=l->resolveSample(sampleNo,offset);
return &((*res)[offset]);
}
return getReady()->getSampleDataRO(sampleNo, dummy);
}
inline
const DataTypes::cplx_t*
Data::getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::cplx_t dummy) const
{
DataLazy* l=dynamic_cast<DataLazy*>(m_data.get());
if (l!=0)
{
throw DataException("Programming error: complex lazy objects are not supported.");
}
return getReady()->getSampleDataRO(sampleNo, dummy);
}
inline
const DataTypes::real_t*
Data::getDataRO(DataTypes::real_t dummy) const
{
if (isLazy())
{
throw DataException("Programmer error - getDataRO must not be called on Lazy Data.");
}
if (getNumSamples()==0)
{
return 0;
}
else
{
return &(getReady()->getTypedVectorRO(0)[0]);
}
}
inline
const DataTypes::cplx_t*
Data::getDataRO(DataTypes::cplx_t dummy) const
{
if (isLazy())
{
throw DataException("Programmer error - getDataRO must not be called on Lazy Data.");
}
if (getNumSamples()==0)
{
return 0;
}
else
{
return &(getReady()->getTypedVectorRO(dummy)[0]);
}
}
inline DataTypes::real_t rpow(DataTypes::real_t x,DataTypes::real_t y)
{
return pow(y,x);
}
Data operator+(const Data& left, const Data& right);
Data operator-(const Data& left, const Data& right);
Data operator*(const Data& left, const Data& right);
Data operator/(const Data& left, const Data& right);
Data operator+(const Data& left, const boost::python::object& right);
Data operator-(const Data& left, const boost::python::object& right);
Data operator*(const Data& left, const boost::python::object& right);
Data operator/(const Data& left, const boost::python::object& right);
Data operator+(const boost::python::object& left, const Data& right);
Data operator-(const boost::python::object& left, const Data& right);
Data operator*(const boost::python::object& left, const Data& right);
Data operator/(const boost::python::object& left, const Data& right);
std::ostream& operator<<(std::ostream& o, const Data& data);
Data
C_GeneralTensorProduct(Data& arg_0,
Data& arg_1,
int axis_offset=0,
int transpose=0);
inline
Data
Data::truedivD(const Data& right)
{
return *this / right;
}
inline
Data
Data::truedivO(const boost::python::object& right)
{
Data tmp(right, getFunctionSpace(), false);
return truedivD(tmp);
}
inline
Data
Data::rtruedivO(const boost::python::object& left)
{
Data tmp(left, getFunctionSpace(), false);
return tmp.truedivD(*this);
}
template <class BinaryFunction>
inline
DataTypes::real_t
Data::reduction(BinaryFunction operation, DataTypes::real_t initial_value) const
{
if (isExpanded()) {
DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
ESYS_ASSERT(leftC!=0, "Programming error - casting to DataExpanded.");
DataExpanded& data=*leftC;
int i,j;
int numDPPSample=data.getNumDPPSample();
int numSamples=data.getNumSamples();
DataTypes::real_t global_current_value=initial_value;
DataTypes::real_t local_current_value;
const auto& vec=data.getTypedVectorRO(typename BinaryFunction::first_argument_type(0));
const DataTypes::ShapeType& shape=data.getShape();
// calculate the reduction operation value for each data point
// reducing the result for each data-point into the current_value variables
#pragma omp parallel private(local_current_value)
{
local_current_value=initial_value;
#pragma omp for private(i,j) schedule(static)
for (i=0;i<numSamples;i++) {
for (j=0;j<numDPPSample;j++) {
local_current_value=operation(local_current_value,escript::reductionOpVector(vec,shape,data.getPointOffset(i,j),operation,initial_value));
}
}
#pragma omp critical
global_current_value=operation(global_current_value,local_current_value);
}
return global_current_value;
} else if (isTagged()) {
DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
ESYS_ASSERT(leftC!=0, "Programming error - casting to DataTagged.");
DataTagged& data=*leftC;
DataTypes::real_t current_value=initial_value;
const auto& vec=data.getTypedVectorRO(typename BinaryFunction::first_argument_type(0));
const DataTypes::ShapeType& shape=data.getShape();
const DataTagged::DataMapType& lookup=data.getTagLookup();
const std::list<int> used=data.getFunctionSpace().getListOfTagsSTL();
for (std::list<int>::const_iterator i=used.begin();i!=used.end();++i)
{
int tag=*i;
DataTagged::DataMapType::const_iterator it=lookup.find(tag);
if ((tag==0) || (it==lookup.end())) // check for the default tag
{
current_value=operation(current_value,escript::reductionOpVector(vec,shape,data.getDefaultOffset(),operation,initial_value));
}
else
{
current_value=operation(current_value,escript::reductionOpVector(vec,shape,it->second,operation,initial_value));
}
}
return current_value;
} else if (isConstant()) {
DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
ESYS_ASSERT(leftC!=0, "Programming error - casting to DataConstant.");
return escript::reductionOpVector(leftC->getTypedVectorRO(typename BinaryFunction::first_argument_type(0)),leftC->getShape(),0,operation,initial_value);
} else if (isEmpty()) {
throw DataException("Error - Operations (algorithm) not permitted on instances of DataEmpty.");
} else if (isLazy()) {
throw DataException("Error - Operations not permitted on instances of DataLazy.");
} else {
throw DataException("Error - Data encapsulates an unknown type.");
}
}
template <class BinaryFunction>
inline
Data
Data::dp_algorithm(BinaryFunction operation, DataTypes::real_t initial_value) const
{
if (isEmpty()) {
throw DataException("Error - Operations (dp_algorithm) not permitted on instances of DataEmpty.");
}
else if (isExpanded()) {
Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());
DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
ESYS_ASSERT(dataE!=0, "Programming error - casting data to DataExpanded.");
ESYS_ASSERT(resultE!=0, "Programming error - casting result to DataExpanded.");
int i,j;
int numSamples=dataE->getNumSamples();
int numDPPSample=dataE->getNumDPPSample();
// DataArrayView dataView=data.getPointDataView();
// DataArrayView resultView=result.getPointDataView();
const auto& dataVec=dataE->getTypedVectorRO(initial_value);
const DataTypes::ShapeType& shape=dataE->getShape();
auto& resultVec=resultE->getTypedVectorRW(initial_value);
// perform the operation on each data-point and assign
// this to the corresponding element in result
#pragma omp parallel for private(i,j) schedule(static)
for (i=0;i<numSamples;i++) {
for (j=0;j<numDPPSample;j++) {
resultVec[resultE->getPointOffset(i,j)] =
escript::reductionOpVector(dataVec, shape, dataE->getPointOffset(i,j),operation,initial_value);
}
}
//escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
return result;
}
else if (isTagged()) {
DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
ESYS_ASSERT(dataT!=0, "Programming error - casting data to DataTagged.");
DataTypes::RealVectorType defval(1);
defval[0]=0;
DataTagged* resultT=new DataTagged(getFunctionSpace(), DataTypes::scalarShape, defval, dataT);
const DataTypes::ShapeType& shape=dataT->getShape();
const auto& vec=dataT->getTypedVectorRO(initial_value);
const DataTagged::DataMapType& lookup=dataT->getTagLookup();
for (DataTagged::DataMapType::const_iterator i=lookup.begin(); i!=lookup.end(); i++) {
resultT->getDataByTagRW(i->first,0) =
escript::reductionOpVector(vec,shape,dataT->getOffsetForTag(i->first),operation,initial_value);
}
resultT->getTypedVectorRW(initial_value)[resultT->getDefaultOffset()] = escript::reductionOpVector(dataT->getTypedVectorRO(initial_value),dataT->getShape(),dataT->getDefaultOffset(),operation,initial_value);
//escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
return Data(resultT); // note: the Data object now owns the resultT pointer
}
else if (isConstant()) {
Data result(0,DataTypes::ShapeType(),getFunctionSpace(),isExpanded());
DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
ESYS_ASSERT(dataC!=0, "Programming error - casting data to DataConstant.");
ESYS_ASSERT(resultC!=0, "Programming error - casting result to DataConstant.");
DataConstant& data=*dataC;
resultC->getTypedVectorRW(initial_value)[0] =
escript::reductionOpVector(data.getTypedVectorRO(initial_value),data.getShape(),0,operation,initial_value);
//escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
return result;
} else if (isLazy()) {
throw DataException("Error - Operations not permitted on instances of DataLazy.");
} else {
throw DataException("Error - Data encapsulates an unknown type.");
}
}
Data
C_TensorBinaryOperation(Data const &arg_0,
Data const &arg_1,
ES_optype operation);
Data
C_TensorUnaryOperation(Data const &arg_0,
escript::ES_optype operation,
DataTypes::real_t tol=0);
} // namespace escript
#endif // __ESCRIPT_DATA_H__
escript::FunctionSpace
Definition: FunctionSpace.h:34
escript::operator<<
std::ostream & operator<<(std::ostream &o, const Data &data)
Output operator.
Definition: Data.cpp:3602
escript::Data::typeMatchLeft
void typeMatchLeft(Data &right) const
Convert the data type of the RHS to match this.
Definition: Data.cpp:3448
escript::Data::m_data
DataAbstract_ptr m_data
Definition: Data.h:1750
escript::Data::getLength
DataTypes::RealVectorType::size_type getLength() const
Return the number of doubles stored for this Data.
Definition: Data.cpp:1349
escript::Data::toListOfTuples
const boost::python::object toListOfTuples(bool scalarastuple=true)
returns the values of the object as a list of tuples (one for each datapoint).
Definition: Data.cpp:1360
escript::Data::getSampleDataByTag
DataTypes::real_t * getSampleDataByTag(int tag, DataTypes::real_t dummy=0)
Return the sample data for the given tag. If an attempt is made to access data that isn&#39;t tagged an e...
Definition: Data.h:631
escript::Data::sqrt
Data sqrt() const
Return the square root of each data point of this Data object.
Definition: Data.cpp:2162
DataConstant.h
escript::Data::setItemO
void setItemO(const boost::python::object &key, const boost::python::object &value)
Definition: Data.cpp:3409
escript::Data::antihermitian
Data antihermitian() const
Return the anti-hermitian part of a matrix which is half the matrix minus its hermitian.
Definition: Data.cpp:2727
escript::Data::interpolateFromTable1D
Data interpolateFromTable1D(const WrappedArray &table, DataTypes::real_t Amin, DataTypes::real_t Astep, DataTypes::real_t undef, bool check_boundaries)
Definition: Data.cpp:4684
escript::Data::__add__
boost::python::object __add__(const boost::python::object &right)
wrapper for python add operation
Definition: Data.cpp:5831
escript::Data::getReadyPtr
const_DataReady_ptr getReadyPtr() const
Definition: Data.h:1783
escript::Data::checkExclusiveWrite
void checkExclusiveWrite()
checks if caller can have exclusive write to the object
Definition: Data.h:1853
escript::Data::__rsub__
boost::python::object __rsub__(const boost::python::object &right)
wrapper for python reverse subtract operation
Definition: Data.cpp:5879
escript::Data::toString
std::string toString() const
Write the data as a string. For large amounts of data, a summary is printed.
Definition: Data.cpp:4562
escript::Data::setToZero
void setToZero()
set all values to zero
Definition: Data.cpp:797
escript::rpow
DataTypes::real_t rpow(DataTypes::real_t x, DataTypes::real_t y)
Definition: Data.h:2023
escript::DataTypes::DataVectorAlt< real_t >::reference
ElementType & reference
Definition: DataVectorAlt.h:50
escript::Data::inf
DataTypes::real_t inf()
Return the minimum value of this Data object.
Definition: Data.cpp:2267
escript::Data::replaceNaN
void replaceNaN(DataTypes::real_t value)
replaces all NaN values with value
Definition: Data.cpp:2364
escript::Data::getDataPointRank
unsigned int getDataPointRank() const
Return the rank of the point data.
Definition: Data.h:489
MPI_Op
int MPI_Op
Definition: EsysMPI.h:43
escript::Data::delay
Data delay()
produce a delayed evaluation version of this Data.
Definition: Data.cpp:768
escript::Data::operator*=
Data & operator*=(const Data &right)
Overloaded operator *=.
Definition: Data.cpp:3156
escript::Data::tag
void tag()
If possible convert this Data to DataTagged. This will only allow Constant data to be converted to ta...
Definition: Data.cpp:1186
escript::Data::isDataPointShapeEqual
bool isDataPointShapeEqual(int rank, const int *dimensions) const
Returns true if the shape matches the vector (dimensions[0],..., dimensions[rank-1]). DataEmpty always returns true.
Definition: Data.h:544
escript::Data::set_m_data
void set_m_data(DataAbstract_ptr p)
Modify the data abstract hosted by this Data object For internal use only. Passing a pointer to null ...
Definition: Data.cpp:612
escript::DataExpanded::getTypedVectorRW
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition: DataExpanded.cpp:1438
escript::Data::integrateToTuple
boost::python::object integrateToTuple()
Calculate the integral over the function space domain as a python tuple.
Definition: Data.cpp:1748
escript::Data::getSlice
Data getSlice(const DataTypes::RegionType &region) const
Return a Data object containing the specified slice of this Data object.
Definition: Data.cpp:3401
escript::Data::supWorker
DataTypes::real_t supWorker() const
Definition: Data.cpp:2456
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:36
escript::Data::sign
Data sign() const
Return the sign of each data point of this Data object. -1 for negative values, zero for zero values...
Definition: Data.cpp:2121
escript::DataReady
Definition: DataReady.h:35
escript::DataTypes::DataVectorAlt< real_t >::size_type
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:49
escript::DataTypes::RegionType
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:43
escript::Data::getDataPointSize
int getDataPointSize() const
Return the size of the data point. It is the product of the data point shape dimensions.
Definition: Data.cpp:1342
escript
Definition: AbstractContinuousDomain.cpp:22
escript::Data::imag
Data imag() const
Definition: Data.cpp:1967
escript::Data::atan
Data atan() const
Return the atan of each data point of this Data object.
Definition: Data.cpp:2046
escript::Data::log10
Data log10() const
Return the log to base 10 of each data point of this Data object.
Definition: Data.cpp:2107
escript::Data::pos
Data pos() const
Return the identity of each data point of this Data object. Simply returns this object unmodified...
Definition: Data.cpp:2143
escript::const_DataReady_ptr
boost::shared_ptr< const DataReady > const_DataReady_ptr
Definition: DataAbstract.h:59
escript::Data::setItemD
void setItemD(const boost::python::object &key, const Data &value)
Copies slice from value into this Data object.
Definition: Data.cpp:3417
escript::operator-
Data operator-(const Data &left, const Data &right)
Operator- Takes two Data objects.
Definition: Data.cpp:3278
escript::Data::get_MPIComm
MPI_Comm get_MPIComm(void) const
return the MPI rank number of the local data MPI_COMM_WORLD is assumed and returned.
Definition: Data.cpp:5382
escript::Data::sup_const
DataTypes::real_t sup_const() const
Definition: Data.cpp:2214
escript::Data::besselSecondKind
Data besselSecondKind(int order)
Return the Bessel function of the second kind for each data point of this Data object.
Definition: Data.cpp:1828
escript::Data::print
void print(void)
print the data values to stdout. Used for debugging
Definition: Data.cpp:5306
escript::Data::interpolateFromTable3DP
Data interpolateFromTable3DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep, Data &B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, Data &C, DataTypes::real_t Cmin, DataTypes::real_t Cstep, DataTypes::real_t undef, bool check_boundaries)
Definition: Data.cpp:4656
escript::Data::typeMatchRight
void typeMatchRight(const Data &right)
Convert the data type of this to match the RHS.
Definition: Data.cpp:3468
escript::Data::setSlice
void setSlice(const Data &value, const DataTypes::RegionType &region)
Copy the specified slice from the given value into this Data object.
Definition: Data.cpp:3433
escript::DataConstant
DataConstant stores a single data point which represents the entire function space.
Definition: DataConstant.h:37
escript::DataTypes::scalarShape
static const ShapeType scalarShape
Use this instead of creating empty shape objects for scalars.
Definition: DataTypes.h:46
escript::Data::setValueOfDataPointToPyObject
void setValueOfDataPointToPyObject(int dataPointNo, const boost::python::object &py_object)
sets the values of a data-point from a python object on this process
Definition: Data.cpp:1541
escript::Data::getDataPointRO
DataTypes::RealVectorType::const_reference getDataPointRO(int sampleNo, int dataPointNo)
Return a reference into the DataVector which points to the specified data point.
Definition: Data.cpp:4632
escript::Data::isLazy
bool isLazy() const
Return true if this Data is lazy.
Definition: Data.cpp:1128
escript::C_TensorUnaryOperation
Data C_TensorUnaryOperation(Data const &arg_0, escript::ES_optype operation, DataTypes::real_t tol=0)
Definition: Data.cpp:5998
escript::Data::borrowDataPtr
DataAbstract_ptr borrowDataPtr(void) const
Definition: Data.cpp:4547
escript::Data::real
Data real() const
Definition: Data.cpp:1948
escript::DataConstant::getTypedVectorRO
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition: DataConstant.cpp:786
escript::Data::setTaggedValueByName
void setTaggedValueByName(std::string name, const boost::python::object &value)
Assign the given value to the tag assocciated with name. Implicitly converts this object to type Data...
Definition: Data.cpp:3496
escript::DataExpanded
Give a short description of what DataExpanded does.
Definition: DataExpanded.h:43
escript::DataTagged::getTypedVectorRO
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition: DataTagged.cpp:1591
escript::Data::sinh
Data sinh() const
Return the sinh of each data point of this Data object.
Definition: Data.cpp:2053
escript::Data::atanh
Data atanh() const
Return the atanh of each data point of this Data object.
Definition: Data.cpp:2100
escript::Data::getReadyPtr
DataReady_ptr getReadyPtr()
Definition: Data.h:1775
escript::Data::TensorSelfUpdateBinaryOperation
void TensorSelfUpdateBinaryOperation(const Data &right, escript::ES_optype operation)
Definition: Data.cpp:6450
escript::DataTagged::getDataByTagRW
DataTypes::RealVectorType::reference getDataByTagRW(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0)
getDataByTag
Definition: DataTagged.cpp:932
escript::FunctionSpace::getDomain
const_Domain_ptr getDomain() const
Returns the function space domain.
Definition: FunctionSpace.cpp:102
escript::Data::rpowO
Data rpowO(const boost::python::object &left) const
Return the given power of each data point of this boost python object.
Definition: Data.cpp:3242
escript::Data::randomData
friend Data randomData(const boost::python::tuple &shape, const FunctionSpace &what, long seed, const boost::python::tuple &filter)
Create a new Expanded Data object filled with pseudo-random data.
escript::Data::lazyAlgWorker
DataTypes::real_t lazyAlgWorker(DataTypes::real_t init)
escript::Data::interpolateFromTable1DP
Data interpolateFromTable1DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep, DataTypes::real_t undef, bool check_boundaries)
Definition: Data.cpp:4675
escript::FunctionSpace::getListOfTagsSTL
std::list< int > getListOfTagsSTL() const
Returns an stl list of the tags used in this function space.
Definition: FunctionSpace.cpp:286
escript::TestDomain
(Testing use only) Provides a domain to wrap a collection of values.
Definition: TestDomain.h:41
escript::Data::setTaggedValueFromCPP
void setTaggedValueFromCPP(int tagKey, const DataTypes::ShapeType &pointshape, const DataTypes::RealVectorType &value, int dataOffset=0)
Assign the given value to the tag. Implicitly converts this object to type DataTagged if it is consta...
Definition: Data.cpp:3553
escript::Data::nonuniformslope
Data nonuniformslope(boost::python::object in, boost::python::object out, bool check_boundaries)
Definition: Data.cpp:5227
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:42
escript::Data::__sub__
boost::python::object __sub__(const boost::python::object &right)
wrapper for python subtract operation
Definition: Data.cpp:5855
escript::Data::interpolateFromTable2DP
Data interpolateFromTable2DP(boost::python::object table, DataTypes::real_t Amin, DataTypes::real_t Astep, Data &B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, DataTypes::real_t undef, bool check_boundaries)
Definition: Data.cpp:4666
DataLazy.h
escript::Data::acos
Data acos() const
Return the acos of each data point of this Data object.
Definition: Data.cpp:2038
escript::DataTagged
Simulates a full dataset accessible via sampleNo and dataPointNo.
Definition: DataTagged.h:44
escript::Data::probeInterpolation
bool probeInterpolation(const FunctionSpace &functionspace) const
Returns true if this can be interpolated to functionspace.
Definition: Data.cpp:1299
escript::DataAbstract_ptr
boost::shared_ptr< DataAbstract > DataAbstract_ptr
Definition: DataAbstract.h:51
DataReady.h
DataTagged.h
escript::Data::phase
Data phase() const
Return the phase/arg/angular-part of complex values.
Definition: Data.cpp:1987
escript::DataReady::getSampleDataRW
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample number.
Definition: DataReady.h:181
escript::Data::getItem
Data getItem(const boost::python::object &key) const
Returns a slice from this Data object.
Definition: Data.cpp:3387
escript::Data::initialise
void initialise(const DataTypes::RealVectorType &value, const DataTypes::ShapeType &shape, const FunctionSpace &what, bool expanded)
Construct a Data object of the appropriate type.
Definition: Data.cpp:641
escript::Data::maxval
Data maxval() const
Return the maximum value of each data point of this Data object.
Definition: Data.cpp:2566
escript::Data::setValueOfDataPointC
void setValueOfDataPointC(int dataPointNo, const DataTypes::cplx_t)
Definition: Data.cpp:1658
escript::Data::cos
Data cos() const
Return the cos of each data point of this Data object.
Definition: Data.cpp:2017
escript::Data::getDataRO
const DataTypes::real_t * getDataRO(DataTypes::real_t dummy=0) const
Return a pointer to the beginning of the underlying data.
Definition: Data.h:1985
system_dep.h
escript::C_GeneralTensorProduct
Data C_GeneralTensorProduct(Data &arg_0, Data &arg_1, int axis_offset=0, int transpose=0)
Compute a tensor product of two Data objects.
Definition: Data.cpp:3609
escript::Data::getDataAtOffsetRO
DataTypes::RealVectorType::const_reference getDataAtOffsetRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy)
Return a pointer to the beginning of the datapoint at the specified offset. TODO Eventually these sho...
Definition: Data.cpp:4609
escript::Data::m_protected
bool m_protected
Definition: Data.h:1744
escript::Data::cosh
Data cosh() const
Return the cosh of each data point of this Data object.
Definition: Data.cpp:2060
escript::Data::setValueOfDataPoint
void setValueOfDataPoint(int dataPointNo, const DataTypes::real_t)
sets the values of a data-point on this process
Definition: Data.cpp:1637
escript::Data::interpolate
Data interpolate(const FunctionSpace &functionspace) const
Interpolates this onto the given functionspace and returns the result as a Data object.
Definition: Data.cpp:1293
escript::Data::matrixInverse
Data matrixInverse() const
return inverse of matricies.
Definition: Data.cpp:3214
escript::Data::operator/=
Data & operator/=(const Data &right)
Overloaded operator /=.
Definition: Data.cpp:3183
escript::Data::getReady
DataReady * getReady()
Definition: Data.h:1763
escript::Data::copySelf
Data copySelf() const
Return a pointer to a deep copy of this object.
Definition: Data.cpp:752
escript::Data::resolve
void resolve()
If this data is lazy, then convert it to ready data. What type of ready data depends on the expressio...
Definition: Data.cpp:1212
escript::Data::isEmpty
bool isEmpty() const
Return true if this Data holds an instance of DataEmpty. This is _not_ the same as asking if the obj...
Definition: Data.cpp:1114
escript::Data::tanh
Data tanh() const
Return the tanh of each data point of this Data object.
Definition: Data.cpp:2067
escript::Data::calc_minGlobalDataPoint
void calc_minGlobalDataPoint(int &ProcNo, int &DataPointNo) const
Definition: Data.cpp:2916
DataException.h
escript::Data::operandCheck
void operandCheck(const Data &right) const
Check *this and the right operand are compatible. Throws an exception if they aren&#39;t.
Definition: Data.h:1664
escript::Data::borrowData
DataAbstract * borrowData(void) const
return the object produced by the factory, which is a DataConstant or DataExpanded TODO Ownership of ...
Definition: Data.cpp:4540
escript::Data::erf
Data erf() const
Return the error function erf of each data point of this Data object.
Definition: Data.cpp:2075
escript::DataAbstract::getShape
const DataTypes::ShapeType & getShape() const
Return the shape information for the point data.
Definition: DataAbstract.h:641
FunctionSpace.h
escript::DataAbstract::getNumSamples
int getNumSamples() const
Return the number of samples.
Definition: DataAbstract.h:622
escript::DataAbstract::getNumDPPSample
int getNumDPPSample() const
Return the number of data points per sample.
Definition: DataAbstract.h:611
escript::Data::infWorker
DataTypes::real_t infWorker() const
Definition: Data.cpp:2499
escript::Data::getNoValues
int getNoValues() const
Return the number of values in the shape for this object.
Definition: Data.h:557
DataVectorOps.h
Describes binary operations performed on DataVector.
escript::DataExpanded::getPointOffset
virtual DataTypes::RealVectorType::size_type getPointOffset(int sampleNo, int dataPointNo) const
Return the offset for the given given data point. This returns the offset in bytes for the given poin...
Definition: DataExpanded.cpp:534
escript::Data::integrateWorker
boost::python::object integrateWorker() const
escript::Data::rtruedivO
Data rtruedivO(const boost::python::object &left)
Newer style division operator for python.
Definition: Data.h:2174
escript::Data::maxGlobalDataPoint
const boost::python::tuple maxGlobalDataPoint() const
Return the (sample number, data-point number) of the data point with the minimum component value in t...
Definition: Data.cpp:3002
escript::Data::getSampleDataRO
const DataTypes::real_t * getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition: Data.h:1958
escript::DataTagged::DataMapType
std::map< int, int > DataMapType
Definition: DataTagged.h:57
escript::Data::powD
Data powD(const Data &right) const
Return the given power of each data point of this Data object.
Definition: Data.cpp:3256
escript::Data::replaceNaNPython
void replaceNaNPython(boost::python::object obj)
replaces all NaN values with value
Definition: Data.cpp:2384
escript::Data::trace
Data trace(int axis_offset) const
Return the trace of a matrix.
Definition: Data.cpp:2767
escript::DataTagged::getOffsetForTag
DataTypes::RealVectorType::size_type getOffsetForTag(int tag) const
getOffsetForTag
Definition: DataTagged.cpp:910
escript::Data::minGlobalDataPoint
const boost::python::tuple minGlobalDataPoint() const
Return the (sample number, data-point number) of the data point with the minimum component value in t...
Definition: Data.cpp:2899
escript::Data::minval_nonlazy
Data minval_nonlazy() const
Definition: Data.cpp:2544
escript::Data::get_MPISize
int get_MPISize(void) const
return the MPI rank number of the local data MPI_COMM_WORLD is assumed and the result of MPI_Comm_ran...
Definition: Data.cpp:5358
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:682
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:452
escript::Data::delaySelf
void delaySelf()
convert the current data into lazy data.
Definition: Data.cpp:779
escript::Data::transpose
Data transpose(int axis_offset) const
Transpose each data point of this Data object around the given axis.
Definition: Data.cpp:2822
escript::Data::get_MPIRank
int get_MPIRank(void) const
return the MPI rank number of the local data MPI_COMM_WORLD is assumed and the result of MPI_Comm_siz...
Definition: Data.cpp:5370
escript::Data::expand
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition: Data.cpp:1162
escript::Data::reduction
DataTypes::real_t reduction(BinaryFunction operation, DataTypes::real_t initial_value) const
Perform the specified reduction algorithm on every element of every data point in this Data object ac...
Definition: Data.h:2192
escript::operator+
Data operator+(const Data &left, const Data &right)
Operator+ Takes two Data objects.
Definition: Data.cpp:3268
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:63
escript::Data::whereZero
Data whereZero(DataTypes::real_t tol=0.0) const
Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.
Definition: Data.cpp:1279
escript::Data::getDataPointRW
DataTypes::RealVectorType::reference getDataPointRW(int sampleNo, int dataPointNo)
Return a reference into the DataVector which points to the specified data point.
Definition: Data.cpp:4648
escript::Data::asinh
Data asinh() const
Return the asinh of each data point of this Data object.
Definition: Data.cpp:2086
escript::Data::maskWorker
void maskWorker(Data &other2, Data &mask2, S sentinel)
Definition: Data.cpp:936
escript::DataTypes::DataVectorAlt< real_t >
escript::DataConstant::getTypedVectorRW
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition: DataConstant.cpp:779
escript::Data::getDataAtOffsetRW
DataTypes::RealVectorType::reference getDataAtOffsetRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy)
Definition: Data.cpp:4601
escript::ES_optype
ES_optype
Definition: ES_optype.h:26
escript::Data::asin
Data asin() const
Return the asin of each data point of this Data object.
Definition: Data.cpp:2031
escript::Data::isConstant
bool isConstant() const
Return true if this Data is constant.
Definition: Data.cpp:1121
escript::Data::setValueOfDataPointToArray
void setValueOfDataPointToArray(int dataPointNo, const boost::python::object &)
sets the values of a data-point from a array-like object on this process
Definition: Data.cpp:1594
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1142
escript::Data::isShared
bool isShared() const
Definition: Data.h:1804
escript::Data::numSamplesEqual
bool numSamplesEqual(int numDataPointsPerSample, int numSamples) const
Returns true if the number of data points per sample and the number of samples match the respective a...
Definition: Data.h:532
escript::DataLazy::resolveSample
const DataTypes::RealVectorType * resolveSample(int sampleNo, size_t &roffset) const
Compute the value of the expression for the given sample.
Definition: DataLazy.cpp:2334
escript::Data::borrowReadyPtr
DataReady_ptr borrowReadyPtr(void) const
Definition: Data.cpp:4554
escript::Data::acosh
Data acosh() const
Return the acosh of each data point of this Data object.
Definition: Data.cpp:2093
escript::Data::wherePositive
Data wherePositive() const
Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.
Definition: Data.cpp:1235
EsysMPI.h
escript::Data::actsExpanded
bool actsExpanded() const
Return true if this Data is expanded or resolves to expanded. That is, if it has a separate value for...
Definition: Data.cpp:1100
escript::Data::operator=
Data & operator=(const Data &other)
Definition: Data.cpp:3121
escript::Data::forceResolve
void forceResolve()
Definition: Data.h:1813
DataTypes.h
escript::Data::getSampleDataByTag
DataTypes::cplx_t * getSampleDataByTag(int tag, DataTypes::cplx_t dummy)
Definition: Data.h:638
escript::DataAbstract::deepCopy
virtual DataAbstract * deepCopy() const =0
Return a deep copy of the current object.
escript::Data::requireWrite
void requireWrite()
Ensures data is ready for write access. This means that the data will be resolved if lazy and will be...
Definition: Data.cpp:1221
escript::Data::Lsup_const
DataTypes::real_t Lsup_const() const
Definition: Data.cpp:2169
escript::Data::getNumDataPointsPerSample
int getNumDataPointsPerSample() const
Return the number of data points per sample.
Definition: Data.h:521
escript::Data::getReady
const DataReady * getReady() const
Definition: Data.h:1755
escript::DataTagged::getDefaultOffset
DataTypes::RealVectorType::size_type getDefaultOffset() const
Returns the offset in the structure which stores the default value.
Definition: DataTagged.h:703
escript::Data::getSampleDataRW
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition: Data.h:1923
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:41
escript::Data::hermitian
Data hermitian() const
Return the hermitian part of a matrix which is half the matrix plus its adjoint.
Definition: Data.cpp:2700
escript::Data::condEvalWorker
friend Data condEvalWorker(escript::Data &mask, escript::Data &trueval, escript::Data &falseval, S sentinel)
escript::Data::oneOver
Data oneOver() const
Returns 1./ Data object.
Definition: Data.cpp:1228
escript::DataTagged::getTypedVectorRW
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)
These versions use the type system rather than method name to determine return type.
Definition: DataTagged.cpp:1584
escript::Data::LsupWorker
DataTypes::real_t LsupWorker() const
Definition: Data.cpp:2399
escript::Data::minval
Data minval() const
Return the minimum value of each data point of this Data object.
Definition: Data.cpp:2575
escript::C_TensorBinaryOperation
Data C_TensorBinaryOperation(Data const &arg_0, Data const &arg_1, ES_optype operation)
Compute a tensor operation with two Data objects.
Definition: Data.cpp:6274
escript::Data::m_lazy
bool m_lazy
Definition: Data.h:1745
escript::Data::sup
DataTypes::real_t sup()
Return the maximum value of this Data object.
Definition: Data.cpp:2228
escript::Data::setTupleForGlobalDataPoint
void setTupleForGlobalDataPoint(int id, int proc, boost::python::object)
Set the value of a global data point.
Definition: Data.cpp:1549
escript::DataReady::getSampleDataRO
const DataTypes::real_t * getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const
Definition: DataReady.h:195
escript::Data::getNumSamples
int getNumSamples() const
Return the number of samples.
Definition: Data.h:510
escript::Data::__div__
boost::python::object __div__(const boost::python::object &right)
wrapper for python divide operation
Definition: Data.cpp:5928
escript::DataReady::getTypedVectorRO
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const =0
escript::Data::abs
Data abs() const
Return the absolute value of each data point of this Data object.
Definition: Data.cpp:2129
escript::Data::grad
Data grad() const
Definition: Data.cpp:1332
escript::Data::dp_algorithm
Data dp_algorithm(BinaryFunction operation, DataTypes::real_t initial_value) const
Reduce each data-point in this Data object using the given operation. Return a Data object with the s...
Definition: Data.h:2271
escript::Data::copy
void copy(const Data &other)
Make this object a deep copy of "other".
Definition: Data.cpp:759
escript::DataLazy
Wraps an expression tree of other DataObjects. The data will be evaluated when required.
Definition: DataLazy.h:47
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:53
DataAbstract.h
escript::Data::inf_const
DataTypes::real_t inf_const() const
Definition: Data.cpp:2253
escript::Data::eigenvalues_and_eigenvectors
const boost::python::tuple eigenvalues_and_eigenvectors(const DataTypes::real_t tol=1.e-12) const
Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of thi...
Definition: Data.cpp:2873
escript::Data::init_from_data_and_fs
void init_from_data_and_fs(const Data &inData, const FunctionSpace &functionspace)
Definition: Data.cpp:433
escript::Data::getTagNumber
int getTagNumber(int dpno)
Return the tag number associated with the given data-point.
Definition: Data.cpp:3592
escript::FunctionSpace::getDomainPython
Domain_ptr getDomainPython() const
Return the function space domain. Internal use only! This gets around some python difficulties by cas...
Definition: FunctionSpace.cpp:108
escript::DataException
Definition: DataException.h:26
escript::Data::complicate
void complicate()
Definition: Data.cpp:5976
escript::Data::nonuniforminterp
Data nonuniforminterp(boost::python::object in, boost::python::object out, bool check_boundaries)
Definition: Data.cpp:5151
escript::DataExpanded::getTypedVectorRO
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition: DataExpanded.cpp:1444
escript::Data::maxval_nonlazy
Data maxval_nonlazy() const
Definition: Data.cpp:2555
escript::reductionOpVector
DataTypes::real_t reductionOpVector(const DataTypes::RealVectorType &left, const DataTypes::ShapeType &leftShape, DataTypes::RealVectorType::size_type offset, BinaryFunction operation, DataTypes::real_t initial_value)
Perform the given data point reduction operation on the data point specified by the given offset into...
Definition: DataVectorOps.h:1393
escript::condEval
Data condEval(escript::Data &mask, escript::Data &trueval, escript::Data &falseval)
Definition: Data.cpp:5567
escript::Data::powO
Data powO(const boost::python::object &right) const
Return the given power of each data point of this boost python object.
Definition: Data.cpp:3249
escript::Data::whereNonNegative
Data whereNonNegative() const
Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.
Definition: Data.cpp:1257
escript::Data::exp
Data exp() const
Return the exponential function of each data point of this Data object.
Definition: Data.cpp:2155
escript::operator*
Data operator*(const AbstractSystemMatrix &left, const Data &right)
Definition: AbstractSystemMatrix.cpp:59
escript::Data::exclusiveWrite
void exclusiveWrite()
if another object is sharing out member data make a copy to work with instead. This code should only ...
Definition: Data.h:1831
escript::Data::whereNegative
Data whereNegative() const
Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.
Definition: Data.cpp:1246
escript::Data::isTagged
bool isTagged() const
Return true if this Data is tagged.
Definition: Data.cpp:1107
escript::DataAbstract
Definition: DataAbstract.h:61
escript::Data::hasNoSamples
bool hasNoSamples() const
Return true if this object contains no samples. This is not the same as isEmpty() ...
Definition: Data.h:714
escript::Data::conjugate
Data conjugate() const
For complex values return the conjugate values. For non-complex data return a copy.
Definition: Data.cpp:1928
escript::Data::getDomain
const_Domain_ptr getDomain() const
Return the domain.
Definition: Data.h:464
escript::Data::interpolateFromTable2D
Data interpolateFromTable2D(const WrappedArray &table, DataTypes::real_t Amin, DataTypes::real_t Astep, DataTypes::real_t undef, Data &B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, bool check_boundaries)
Definition: Data.cpp:4812
escript::DataTypes::DataVectorAlt< real_t >::const_reference
const ElementType & const_reference
Definition: DataVectorAlt.h:51
escript::Data::dump
void dump(const std::string fileName) const
dumps the object into a netCDF file
Definition: Data.cpp:5336
escript::Data::setProtection
void setProtection()
switches on update protection
Definition: Data.cpp:1148
escript::DataAbstract::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space associated with this Data object.
Definition: DataAbstract.h:634
escript::Data::besselFirstKind
Data besselFirstKind(int order)
Return the Bessel function of the first kind for each data point of this Data object.
Definition: Data.cpp:1821
escript::DataReady_ptr
boost::shared_ptr< DataReady > DataReady_ptr
Definition: DataAbstract.h:56
escript::Data::__rdiv__
boost::python::object __rdiv__(const boost::python::object &right)
wrapper for python reverse divide operation
Definition: Data.cpp:5952
escript::Data::hasNaN
bool hasNaN()
returns return true if data contains NaN.
Definition: Data.cpp:2353
DataExpanded.h
escript::Data::getDataOffset
DataTypes::RealVectorType::size_type getDataOffset(int sampleNo, int dataPointNo)
Return the offset for the given sample and point within the sample.
Definition: Data.h:670
escript::operator/
Data operator/(const Data &left, const Data &right)
Operator/ Takes two Data objects.
Definition: Data.cpp:3297
escript::Data::isExpanded
bool isExpanded() const
Return true if this Data is expanded.
Definition: Data.cpp:1093
escript::Data::whereNonPositive
Data whereNonPositive() const
Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.
Definition: Data.cpp:1268
escript::Data::Data
Data()
Default constructor. Creates a DataEmpty object.
Definition: Data.cpp:249
escript::Data::copyWithMask
void copyWithMask(const Data &other, const Data &mask)
Copy other Data object into this Data object where mask is positive.
Definition: Data.cpp:833
escript::Data::__mul__
boost::python::object __mul__(const boost::python::object &right)
wrapper for python multiply operation
Definition: Data.cpp:5904
escript::Data::getNumberOfTaggedValues
size_t getNumberOfTaggedValues() const
For tagged Data returns the number of tags with values. For non-tagged data will return 0 (even Data ...
Definition: Data.cpp:5778
escript::Data::neg
Data neg() const
Return the negation of each data point of this Data object.
Definition: Data.cpp:2136
escript::Data::getShapeTuple
const boost::python::tuple getShapeTuple() const
Return the data point shape as a tuple of integers.
Definition: Data.cpp:727
escript::DataTagged::getTagLookup
const DataMapType & getTagLookup() const
getTagLookup
Definition: DataTagged.h:741
escript::Data::truedivO
Data truedivO(const boost::python::object &right)
Newer style division operator for python.
Definition: Data.h:2161
escript::Data::isReady
bool isReady() const
Return true if this data is ready.
Definition: Data.cpp:1135
escript::Data::symmetric
Data symmetric() const
Return the symmetric part of a matrix which is half the matrix plus its transpose.
Definition: Data.cpp:2641
ESYS_ASSERT
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false...
Definition: Assert.h:78
escript::WrappedArray
Definition: WrappedArray.h:31
escript::Data::getExpandedVectorReference
DataTypes::RealVectorType & getExpandedVectorReference(DataTypes::real_t dummy=0)
Ensures that the Data is expanded and returns its underlying vector Does not check for exclusive writ...
Definition: Data.cpp:5760
escript::Data::getNumDataPoints
int getNumDataPoints() const
Return the number of data points.
Definition: Data.h:500
escript::Data::antisymmetric
Data antisymmetric() const
Return the antisymmetric part of a matrix which is half the matrix minus its transpose.
Definition: Data.cpp:2664
escript::Data::sin
Data sin() const
Return the sin of each data point of this Data object.
Definition: Data.cpp:2010
escript::Data::~Data
~Data()
Destructor.
Definition: Data.cpp:604
escript::Data::unaryOp2
void unaryOp2(UnaryFunction operation)
Perform the given unary operation on every element of every data point in this Data object...
escript::Data::gradOn
Data gradOn(const FunctionSpace &functionspace) const
Calculates the gradient of the data at the data points of functionspace. If functionspace is not pres...
Definition: Data.cpp:1305
escript::Data::getValueOfDataPointAsTuple
const boost::python::object getValueOfDataPointAsTuple(int dataPointNo)
Return the value of a data point as a python tuple.
Definition: Data.cpp:1502
S
#define S(_J_, _I_)
Definition: ShapeFunctions.cpp:121
escript::Data::interpolateFromTable3D
Data interpolateFromTable3D(const WrappedArray &table, DataTypes::real_t Amin, DataTypes::real_t Astep, DataTypes::real_t undef, Data &B, DataTypes::real_t Bmin, DataTypes::real_t Bstep, Data &C, DataTypes::real_t Cmin, DataTypes::real_t Cstep, bool check_boundaries)
Definition: Data.cpp:4968
escript::Data::isProtected
bool isProtected() const
Returns true, if the data object is protected against update.
Definition: Data.cpp:1154
escript::Data::log
Data log() const
Return the natural log of each data point of this Data object.
Definition: Data.cpp:2114
escript::Data::truedivD
Data truedivD(const Data &right)
Newer style division operator for python.
Definition: Data.h:2149
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:39
escript::Data::whereNonZero
Data whereNonZero(DataTypes::real_t tol=0.0) const
Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.
Definition: Data.cpp:1286
escript::Data::Lsup
DataTypes::real_t Lsup()
Return the maximum absolute value of this Data object.
Definition: Data.cpp:2179
escript::Data::operator-=
Data & operator-=(const Data &right)
Overloaded operator -=.
Definition: Data.cpp:3129
escript::Data::integrateToTuple_const
boost::python::object integrateToTuple_const() const
Calculate the integral over the function space domain as a python tuple.
Definition: Data.cpp:1734
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:50
escript::Data::calc_maxGlobalDataPoint
void calc_maxGlobalDataPoint(int &ProcNo, int &DataPointNo) const
Definition: Data.cpp:3012
escript::Data::eigenvalues
Data eigenvalues() const
Return the eigenvalues of the symmetric part at each data point of this Data object in increasing val...
Definition: Data.cpp:2846
escript::Data::bessel
Data bessel(int order, DataTypes::real_t(*besselfunc)(int, DataTypes::real_t))
Bessel worker function.
Definition: Data.cpp:1835
escript::Data::setTaggedValue
void setTaggedValue(int tagKey, const boost::python::object &value)
Assign the given value to the tag. Implicitly converts this object to type DataTagged if it is consta...
Definition: Data.cpp:3513
escript::Data::getValueOfGlobalDataPointAsTuple
const boost::python::object getValueOfGlobalDataPointAsTuple(int procNo, int dataPointNo)
Return a data point across all processors as a python tuple.
Definition: Data.cpp:1681
escript::Data::swapaxes
Data swapaxes(const int axis0, const int axis1) const
swaps the components axis0 and axis1
Definition: Data.cpp:2584
escript::Data::getDomainPython
Domain_ptr getDomainPython() const
Return the domain. TODO: For internal use only. This should be removed.
Definition: Data.h:478
escript::Data::tan
Data tan() const
Return the tan of each data point of this Data object.
Definition: Data.cpp:2024
escript::Data::operator+=
Data & operator+=(const Data &right)
Overloaded operator +=.
Definition: Data.cpp:3093