Utils.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
**
*****************************************************************************/
#ifndef __ESCRIPT_UTILS_H__
#define __ESCRIPT_UTILS_H__
#include "system_dep.h"
#include <boost/python/dict.hpp>
#ifdef ESYS_HAVE_BOOST_NUMPY
#include <boost/python/numpy.hpp>
#endif
namespace escript {
ESCRIPT_DLL_API int getSvnVersion();
ESCRIPT_DLL_API void printParallelThreadCnt();
ESCRIPT_DLL_API void setNumberOfThreads(const int num_threads);
ESCRIPT_DLL_API int getNumberOfThreads();
ESCRIPT_DLL_API int getMPISizeWorld();
ESCRIPT_DLL_API int getMPIRankWorld();
ESCRIPT_DLL_API int getMPIWorldMax(const int val);
ESCRIPT_DLL_API int getMPIWorldSum(const int val);
ESCRIPT_DLL_API void MPIBarrierWorld();
ESCRIPT_DLL_API int runMPIProgram(const boost::python::list args);
ESCRIPT_DLL_API double getMachinePrecision();
/*
\brief
return largest positive float
*/
ESCRIPT_DLL_API double getMaxFloat();
ESCRIPT_DLL_API void saveDataCSV(const std::string& filename,
boost::python::dict arg,
const std::string& sep,
const std::string& csep,
bool refid=false,
bool append=false);
#ifdef ESYS_HAVE_BOOST_NUMPY
ESCRIPT_DLL_API boost::python::list getNumpy(boost::python::dict arg);
#else
ESCRIPT_DLL_API void getNumpy(boost::python::dict arg);
#endif
#ifdef ESYS_HAVE_BOOST_NUMPY
ESCRIPT_DLL_API boost::python::numpy::ndarray convertToNumpy(escript::Data data);
#else
ESCRIPT_DLL_API void convertToNumpy(escript::Data data);
#endif
ESCRIPT_DLL_API void resolveGroup(boost::python::object obj);
} // end of namespace
#endif // __ESCRIPT_UTILS_H__
escript::FunctionSpace::ownSample
bool ownSample(DataTypes::dim_t sampleNo) const
Does this process own the sample? For non-MPI builds will always return true.
Definition: FunctionSpace.h:146
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::Data::getNumDataPointsPerSample
int getNumDataPointsPerSample() const
Return the number of data points per sample.
Definition: Data.h:544
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1160
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:4621
escript::MPIBarrierWorld
void MPIBarrierWorld()
performs a barrier synchronization across all processors.
Definition: Utils.cpp:377
escript::getSvnVersion
int getSvnVersion()
some functions
Definition: Utils.cpp:43
escript::saveDataCSV
void saveDataCSV(const std::string &filename, bp::dict arg, const std::string &sep, const std::string &csep, bool refid, bool append)
Definition: Utils.cpp:388
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
escript::getNumpy
void getNumpy(bp::dict arg)
Definition: Utils.cpp:920
escript::getMaxFloat
double getMaxFloat()
Definition: Utils.cpp:372
escript::EsysException
The base class for escript exceptions.
Definition: EsysException.h:43
escript::Data::getDomain
const_Domain_ptr getDomain() const
Return the domain.
Definition: Data.h:487
escript::FunctionSpace::getReferenceIDOfSample
DataTypes::dim_t getReferenceIDOfSample(DataTypes::dim_t sampleNo) const
Returns the reference number associated with the given sample number. This function is not efficient....
Definition: FunctionSpace.h:137
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:1989
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:705
escript::resolveGroup
void resolveGroup(bp::object obj)
Definition: Utils.cpp:986
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:1311
escript::FileWriter
Definition: FileWriter.h:43
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:52
escript::getMPISizeWorld
int getMPISizeWorld()
returns the total number of available MPI processes for MPI_COMM_WORLD
Definition: Utils.cpp:94
escript::get_core_id
int get_core_id()
Definition: Utils.cpp:54
escript::FunctionSpace
Definition: FunctionSpace.h:49
CHILD_FAIL
#define CHILD_FAIL
Definition: Utils.cpp:164
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
escript::FileWriter::openFile
bool openFile(std::string filename, size_t initialSize=0, bool binary=false, bool append=false)
Definition: FileWriter.h:77
MPI_INT
#define MPI_INT
Definition: EsysMPI.h:46
weipa::VisItControl::initialize
bool initialize(const std::string &simFile, const std::string &comment)
Definition: VisItControl.cpp:206
MPI_MAX
#define MPI_MAX
Definition: EsysMPI.h:54
system_dep.h
escript::getNumberOfThreads
int getNumberOfThreads()
returns the number of threads
Definition: Utils.cpp:85
escript::Data::getNumSamples
int getNumSamples() const
Return the number of samples.
Definition: Data.h:533
MPI_COMM_WORLD
#define MPI_COMM_WORLD
Definition: EsysMPI.h:48
Utils.h
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::DataException
Definition: DataException.h:41
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:71
escript::runMPIProgram
int runMPIProgram(bp::list args)
Definition: Utils.cpp:312
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::DataTypes::pointToStream
void pointToStream(std::ostream &os, const RealVectorType::ElementType *data, const ShapeType &shape, int offset, bool needsep=true, const std::string &sep=",")
Display a single value (with the specified shape) from the data.
escript::getMPIWorldSum
int getMPIWorldSum(int val)
returns sum of an integer over all processors with MPI_COMM_WORLD
Definition: Utils.cpp:124
FileWriter.h
OVERLORDPATH
#define OVERLORDPATH
Definition: Utils.cpp:38
CHILD_COMPLETE
#define CHILD_COMPLETE
Definition: Utils.cpp:165
escript::printParallelThreadCnt
void printParallelThreadCnt()
print a message about how many MPI CPUs and OpenMP threads we're using
Definition: Utils.cpp:136
escript
Definition: AbstractContinuousDomain.cpp:23
DataVector.h
MPI_COMM_NULL
#define MPI_COMM_NULL
Definition: EsysMPI.h:49
DataTypes.h
escript::getMPIWorldMax
int getMPIWorldMax(int val)
returns the maximum value of an integer over all processors within MPI_COMM_WORLD
Definition: Utils.cpp:112
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:95
escript::Data::isLazy
bool isLazy() const
Return true if this Data is lazy.
Definition: Data.cpp:1146
escript::Data::getShapeProduct
long getShapeProduct() const
Returns the product of the data point shapes.
Definition: Data.cpp:745
escript::EsysException::what
virtual const char * what() const
Returns a description of the exception.
Definition: EsysException.h:75
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:42
Data.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:1118
escript::getMPIRankWorld
int getMPIRankWorld()
returns the MPI processor number within MPI_COMM_WORLD
Definition: Utils.cpp:103
escript::convertToNumpy
void convertToNumpy(escript::Data data)
Definition: Utils.cpp:981
escript::FileWriter::close
void close()
Definition: FileWriter.h:227
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:82
escript::setNumberOfThreads
void setNumberOfThreads(int num_threads)
set the number of threads
Definition: Utils.cpp:78
escript::getMachinePrecision
double getMachinePrecision()
returns the machine precision
Definition: Utils.cpp:367
escript::NoCOMM_WORLD::active
static bool active()
Definition: EsysMPI.cpp:251
escript::FileWriter::writeOrdered
bool writeOrdered(std::ostringstream &oss)
Definition: FileWriter.h:154
escript::Data::getDataPointRank
unsigned int getDataPointRank() const
Return the rank of the point data.
Definition: Data.h:512
escript::DataLazy
Wraps an expression tree of other DataObjects. The data will be evaluated when required.
Definition: DataLazy.h:62