DataConstant.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#if !defined escript_DataConstant_20040323_H
#define escript_DataConstant_20040323_H
#include "system_dep.h"
#include "DataReady.h"
#include "WrappedArray.h"
namespace escript {
class DataConstant : public DataReady {
typedef DataReady parent;
public:
ESCRIPT_DLL_API
explicit DataConstant(const WrappedArray& value,
const FunctionSpace& what);
ESCRIPT_DLL_API
DataConstant(const DataConstant& other);
ESCRIPT_DLL_API
explicit DataConstant(const DataConstant& other,
const DataTypes::RegionType& region);
ESCRIPT_DLL_API
explicit DataConstant(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const DataTypes::RealVectorType &data);
explicit DataConstant(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const DataTypes::CplxVectorType &data);
ESCRIPT_DLL_API
explicit DataConstant(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const DataTypes::real_t v);
explicit DataConstant(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const DataTypes::cplx_t v);
ESCRIPT_DLL_API
bool
isConstant() const
{
return true;
};
ESCRIPT_DLL_API
bool
hasNaN() const;
ESCRIPT_DLL_API
void
replaceNaN(DataTypes::real_t value);
ESCRIPT_DLL_API
void
replaceNaN(DataTypes::cplx_t value);
ESCRIPT_DLL_API
virtual bool
hasInf() const;
ESCRIPT_DLL_API
virtual void
replaceInf(DataTypes::real_t value);
ESCRIPT_DLL_API
virtual void
replaceInf(DataTypes::cplx_t value);
ESCRIPT_DLL_API
std::string
toString() const;
ESCRIPT_DLL_API
virtual
DataAbstract*
deepCopy() const;
ESCRIPT_DLL_API
virtual
DataAbstract*
zeroedCopy() const;
ESCRIPT_DLL_API
virtual
void
dump(const std::string fileName) const;
ESCRIPT_DLL_API
virtual
void
setToZero();
ESCRIPT_DLL_API
virtual
DataTypes::RealVectorType::size_type
getPointOffset(int sampleNo,
int dataPointNo) const;
ESCRIPT_DLL_API
virtual
DataTypes::RealVectorType::size_type
getPointOffset(int sampleNo,
int dataPointNo);
ESCRIPT_DLL_API
virtual
DataTypes::RealVectorType::size_type
getLength() const;
ESCRIPT_DLL_API
virtual
DataAbstract*
getSlice(const DataTypes::RegionType& region) const;
ESCRIPT_DLL_API
virtual
void
setSlice(const DataAbstract* value,
const DataTypes::RegionType& region);
ESCRIPT_DLL_API
virtual void
symmetric(DataAbstract* ev);
ESCRIPT_DLL_API
virtual void
antisymmetric(DataAbstract* ev);
ESCRIPT_DLL_API
virtual void
hermitian(DataAbstract* ev);
ESCRIPT_DLL_API
virtual void
antihermitian(DataAbstract* ev);
ESCRIPT_DLL_API
virtual void
trace(DataAbstract* ev, int axis_offset);
ESCRIPT_DLL_API
virtual void
transpose(DataAbstract* ev, int axis_offset);
ESCRIPT_DLL_API
virtual void
swapaxes(DataAbstract* ev, int axis0, int axis1);
ESCRIPT_DLL_API
virtual void
eigenvalues(DataAbstract* ev);
ESCRIPT_DLL_API
virtual void
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
ESCRIPT_DLL_API
virtual int
matrixInverse(DataAbstract* out) const;
ESCRIPT_DLL_API
DataTypes::RealVectorType&
getVectorRW();
ESCRIPT_DLL_API
const DataTypes::RealVectorType&
getVectorRO() const;
ESCRIPT_DLL_API
DataTypes::CplxVectorType&
getVectorRWC();
ESCRIPT_DLL_API
const DataTypes::CplxVectorType&
getVectorROC() const;
ESCRIPT_DLL_API
virtual DataTypes::RealVectorType&
getTypedVectorRW(DataTypes::real_t dummy);
ESCRIPT_DLL_API
virtual const DataTypes::RealVectorType&
getTypedVectorRO(DataTypes::real_t dummy) const;
ESCRIPT_DLL_API
virtual DataTypes::CplxVectorType&
getTypedVectorRW(DataTypes::cplx_t dummy);
ESCRIPT_DLL_API
virtual const DataTypes::CplxVectorType&
getTypedVectorRO(DataTypes::cplx_t dummy) const;
ESCRIPT_DLL_API
void complicate();
protected:
private:
//
// the actual data
DataTypes::RealVectorType m_data_r;
DataTypes::CplxVectorType m_data_c;
};
} // end of namespace
#endif
escript::DataTypes::maxRank
static const int maxRank
The maximum number of dimensions a datapoint can have.
Definition: DataTypes.h:74
escript::DataConstant::getLength
virtual DataTypes::RealVectorType::size_type getLength() const
Return the number of doubles stored for the Data object.
Definition: DataConstant.cpp:384
escript::DataConstant::hasInf
virtual bool hasInf() const
Return true if data contains Inf or -Inf.
Definition: DataConstant.cpp:237
MPI_Status
int MPI_Status
Definition: EsysMPI.h:45
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::DataConstant::hermitian
virtual void hermitian(DataAbstract *ev)
Computes an hermitian matrix (A + A*) / 2.
Definition: DataConstant.cpp:469
escript::DataConstant::symmetric
virtual void symmetric(DataAbstract *ev)
Computes a symmetric matrix (A + AT) / 2.
Definition: DataConstant.cpp:435
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
escript::DataConstant::swapaxes
virtual void swapaxes(DataAbstract *ev, int axis0, int axis1)
swaps components axis0 and axis1
Definition: DataConstant.cpp:516
escript::DataTypes::copySlice
void copySlice(VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType &region)
Copy a data slice specified by the given region and offset from the "other" vector into the "left" ve...
Definition: DataVector.h:174
escript::DataConstant::getVectorRWC
DataTypes::CplxVectorType & getVectorRWC()
Definition: DataConstant.cpp:852
escript::DataConstant::transpose
virtual void transpose(DataAbstract *ev, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition: DataConstant.cpp:533
escript::DataConstant::getTypedVectorRO
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const
Definition: DataConstant.cpp:872
escript::DataConstant::m_data_r
DataTypes::RealVectorType m_data_r
Definition: DataConstant.h:451
escript::DataConstant::getVectorRO
const DataTypes::RealVectorType & getVectorRO() const
Definition: DataConstant.cpp:846
escript::antihermitian
void antihermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::CplxVectorType::size_type evOffset)
computes a antihermitian matrix from your square matrix A: (A - adjoint(A)) / 2
Definition: DataVectorOps.cpp:963
escript::DataConstant::parent
DataReady parent
Definition: DataConstant.h:67
CHECK_FOR_EX_WRITE
#define CHECK_FOR_EX_WRITE
Definition: DataConstant.cpp:52
escript::DataConstant::setToZero
virtual void setToZero()
sets all values to zero
Definition: DataConstant.cpp:600
escript::DataConstant::replaceInf
virtual void replaceInf(DataTypes::real_t value)
replaces all (+/-)Inf values with value
Definition: DataConstant.cpp:272
escript::DataTypes::checkShape
bool checkShape(const ShapeType &s1, const ShapeType &s2)
Test if two shapes are equal.
Definition: DataTypes.h:333
escript::DataConstant::getVectorRW
DataTypes::RealVectorType & getVectorRW()
Return a reference to the underlying DataVector.
Definition: DataConstant.cpp:839
escript::DataConstant
DataConstant stores a single data point which represents the entire function space.
Definition: DataConstant.h:52
escript::eigenvalues
void eigenvalues(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::RealVectorType::size_type evOffset)
solves a local eigenvalue problem
Definition: DataVectorOps.h:639
escript::WrappedArray
Definition: WrappedArray.h:32
escript::DataTypes::DataVectorAlt::resize
void resize(const size_type newSize, const value_type newVal=0.0, const size_type newBlockSize=1)
Resize the DataVectorAlt to the given length "newSize". All current data is lost. All elements in the...
Definition: DataVectorAlt.h:319
escript::DataTypes::DataVectorAlt< cplx_t >::size_type
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:92
escript::DataConstant::trace
virtual void trace(DataAbstract *ev, int axis_offset)
Computes the trace of a matrix.
Definition: DataConstant.cpp:498
escript::WrappedArray::isComplex
bool isComplex() const
Definition: WrappedArray.h:71
escript::symmetric
void symmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
Definition: DataVectorOps.h:103
escript::DataTypes::DataVectorAlt< real_t >
escript::transpose
void transpose(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition: DataVectorOps.h:343
escript::DataAbstract::getRank
unsigned int getRank() const
Return the rank information for the point data.
Definition: DataAbstract.h:667
escript::FunctionSpace
Definition: FunctionSpace.h:49
escript::DataTypes::getSliceRegionLoopRange
DataTypes::RegionLoopRangeType getSliceRegionLoopRange(const DataTypes::RegionType &region)
Modify region to copy from in order to deal with the case where one range in the region contains iden...
Definition: DataTypes.cpp:188
escript::DataConstant::hasNaN
bool hasNaN() const
Return true if the value contains a NaN.
Definition: DataConstant.cpp:153
escript::DataReady
Definition: DataReady.h:50
escript::DataConstant::getVectorROC
const DataTypes::CplxVectorType & getVectorROC() const
Definition: DataConstant.cpp:859
MPI_INT
#define MPI_INT
Definition: EsysMPI.h:46
escript::DataConstant::eigenvalues_and_eigenvectors
virtual void eigenvalues_and_eigenvectors(DataAbstract *ev, DataAbstract *V, const double tol=1.e-13)
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
Definition: DataConstant.cpp:567
system_dep.h
escript::LapackInverseHelper
Definition: LapackInverseHelper.h:41
MPI_COMM_WORLD
#define MPI_COMM_WORLD
Definition: EsysMPI.h:48
escript::DataConstant::DataConstant
DataConstant(const WrappedArray &value, const FunctionSpace &what)
Constructor for DataConstant objects.
Definition: DataConstant.cpp:65
escript::DataException
Definition: DataException.h:41
escript::hermitian
void hermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::CplxVectorType::size_type evOffset)
computes an hermitian matrix from your square matrix A: (A + adjoint(A)) / 2
Definition: DataVectorOps.cpp:916
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:865
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:71
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
escript::DataTypes::fillComplexFromReal
void fillComplexFromReal(const RealVectorType &r, CplxVectorType &c)
copy data from a real vector to a complex vector The complex vector will be resized as needed and any...
escript::DataTypes::copySliceFrom
void copySliceFrom(VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType &region)
Copy data into a slice specified by the given region and offset in the left vector from the other vec...
Definition: DataVector.h:281
escript::DataConstant::deepCopy
virtual DataAbstract * deepCopy() const
Return a deep copy of the current object.
Definition: DataConstant.cpp:331
escript::DataTypes::RegionType
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:72
escript::DataTypes::noValues
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:91
escript::DataAbstract::getShape
const DataTypes::ShapeType & getShape() const
Return the shape information for the point data.
Definition: DataAbstract.h:656
escript::DataTypes::getResultSliceShape
DataTypes::ShapeType getResultSliceShape(const RegionType &region)
Determine the shape of the specified slice region.
Definition: DataTypes.cpp:173
escript::DataTypes::DataVectorAlt::copyFromArray
void copyFromArray(const WrappedArray &value, size_type copies)
Populates the vector with the data from value. This method currently throws an exception if the speci...
Definition: DataVectorAlt.h:510
escript::DataConstant::isConstant
bool isConstant() const
Definition: DataConstant.h:136
escript::DataConstant::zeroedCopy
virtual DataAbstract * zeroedCopy() const
Return an object with the same type, domain (and tags if appropriate) as this, but all values are zer...
Definition: DataConstant.cpp:337
escript::matrix_inverse
int matrix_inverse(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &out, const DataTypes::ShapeType &outShape, DataTypes::RealVectorType::size_type outOffset, int count, LapackInverseHelper &helper)
computes the inverses of square (up to 3x3) matricies
Definition: DataVectorOps.cpp:207
DataConstant.h
WrappedArray.h
escript::DataAbstract::m_iscompl
bool m_iscompl
Definition: DataAbstract.h:578
escript::DataConstant::m_data_c
DataTypes::CplxVectorType m_data_c
Definition: DataConstant.h:452
escript::DataConstant::toString
std::string toString() const
Write the data as a string.
Definition: DataConstant.cpp:322
escript::swapaxes
void swapaxes(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis0, int axis1)
swaps the components axis0 and axis1.
Definition: DataVectorOps.h:488
escript::DataTypes::RegionLoopRangeType
std::vector< std::pair< int, int > > RegionLoopRangeType
Definition: DataTypes.h:73
escript::DataConstant::matrixInverse
virtual int matrixInverse(DataAbstract *out) const
invert square matricies
Definition: DataConstant.cpp:583
V
#define V(_K_, _I_)
Definition: ShapeFunctions.cpp:139
escript::DataConstant::getSlice
virtual DataAbstract * getSlice(const DataTypes::RegionType &region) const
Factory method that returns a newly created DataConstant object sliced from the specified region of t...
Definition: DataConstant.cpp:390
escript::DataConstant::dump
virtual void dump(const std::string fileName) const
dumps the object into a netCDF file
Definition: DataConstant.cpp:758
escript::DataConstant::complicate
void complicate()
Convert from real data to complex data.
Definition: DataConstant.cpp:890
escript
Definition: AbstractContinuousDomain.cpp:23
escript::DataTypes::DataVectorAlt::size
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:243
escript::DataTypes::pointToString
std::string pointToString(const RealVectorType &data, const ShapeType &shape, int offset, const std::string &prefix)
Display a single value (with the specified shape) from the data.
escript::DataAbstract
Definition: DataAbstract.h:76
DataVectorOps.h
Describes binary operations performed on DataVector.
escript::DataConstant::setSlice
virtual void setSlice(const DataAbstract *value, const DataTypes::RegionType &region)
Copy the specified region from the given value.
Definition: DataConstant.cpp:396
escript::DataTypes::createShapeErrorMessage
std::string createShapeErrorMessage(const std::string &messagePrefix, const DataTypes::ShapeType &other, const DataTypes::ShapeType &thisShape)
Produce a string containing two shapes.
Definition: DataTypes.cpp:206
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:95
escript::DataConstant::eigenvalues
virtual void eigenvalues(DataAbstract *ev)
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
Definition: DataConstant.cpp:550
escript::DataReady::DataReady
DataReady(const FunctionSpace &what, const ShapeType &shape, bool isDataEmpty=false)
Definition: DataReady.cpp:37
escript::DataConstant::antisymmetric
virtual void antisymmetric(DataAbstract *ev)
Computes a nonsymmetric matrix (A - AT) / 2.
Definition: DataConstant.cpp:452
escript::DataConstant::antihermitian
virtual void antihermitian(DataAbstract *ev)
Computes an anti-hermitian matrix (A - A*) / 2.
Definition: DataConstant.cpp:483
escript::DataAbstract::isComplex
bool isComplex() const
true if the components of datapoints are complex
Definition: DataAbstract.cpp:70
escript::DataAbstract::getNoValues
unsigned int getNoValues() const
Return the number of values in the shape for this object.
Definition: DataAbstract.h:678
escript::DataConstant::replaceNaN
void replaceNaN(DataTypes::real_t value)
replaces all NaN values with value
Definition: DataConstant.cpp:188
Data.h
DataReady.h
escript::antisymmetric
void antisymmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a antisymmetric matrix from your square matrix A: (A - transpose(A)) / 2
Definition: DataVectorOps.h:152
escript::DataConstant::getPointOffset
virtual DataTypes::RealVectorType::size_type getPointOffset(int sampleNo, int dataPointNo) const
Return the offset for the given sample. This is a somewhat artificial notion but returns the offset i...
Definition: DataConstant.cpp:354
escript::DataAbstract::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space associated with this Data object.
Definition: DataAbstract.h:649
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:82
escript::DataAbstract::ShapeType
DataTypes::ShapeType ShapeType
Definition: DataAbstract.h:81
escript::trace
void trace(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
computes the trace of a matrix
Definition: DataVectorOps.h:242
DataException.h
escript::eigenvalues_and_eigenvectors
void eigenvalues_and_eigenvectors(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::RealVectorType::size_type evOffset, DataTypes::RealVectorType &V, const DataTypes::ShapeType &VShape, DataTypes::RealVectorType::size_type VOffset, const double tol=1.e-13)
solves a local eigenvalue problem
Definition: DataVectorOps.h:750