EscriptDataset.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 __WEIPA_ESCRIPTDATASET_H__
#define __WEIPA_ESCRIPTDATASET_H__
#include <weipa/weipa.h>
#include <ostream>
class DBfile;
namespace escript {
class AbstractDomain;
class Data;
}
namespace weipa {
typedef std::vector<DataVar_ptr> DataChunks;
typedef std::vector<DomainChunk_ptr> DomainChunks;
struct VarInfo {
std::string varName;
std::string units;
DataChunks dataChunks;
IntVec sampleDistribution;
bool valid;
};
typedef std::vector<VarInfo> VarVector;
//
class WEIPA_DLL_API EscriptDataset
{
public:
EscriptDataset();
#if WEIPA_HAVE_MPI
EscriptDataset(MPI_Comm comm);
#endif
~EscriptDataset();
bool setDomain(const escript::AbstractDomain* domain);
// setDomain(), otherwise you will get undefined behaviour later!
bool addData(escript::Data& data, const std::string name,
const std::string units = "");
bool loadNetCDF(const std::string domainFilePattern,
const StringVec& varFiles, const StringVec& varNames,
int nChunks);
bool loadNetCDF(const DomainChunks& domain, const StringVec& varFiles,
const StringVec& varNames);
void setCycleAndTime(int c, double t) { cycle=c; time=t; }
int getCycle() const { return cycle; }
double getTime() const { return time; }
void setMeshLabels(const std::string x, const std::string y, const std::string z="");
void setMeshUnits(const std::string x, const std::string y, const std::string z="");
void setMetadataSchemaString(const std::string schema,
const std::string metadata)
{ mdSchema=schema; mdString=metadata; }
void setSaveMeshData(bool flag) { wantsMeshVars=flag; }
bool saveSilo(const std::string fileName, bool useMultiMesh=true);
bool saveVTK(const std::string fileName);
DomainChunks getConvertedDomain() { return domainChunks; }
const VarVector& getVariables() const { return variables; }
const VarVector& getMeshVariables() const { return meshVariables; }
#if WEIPA_HAVE_MPI
MPI_Comm
#else
void*
#endif
getMPIComm() { return mpiComm; }
private:
bool loadDomain(const std::string filePattern, int nChunks);
bool setExternalDomain(const DomainChunks& domain);
bool loadData(const std::string filePattern, const std::string name,
const std::string units);
void convertMeshVariables();
void updateSampleDistribution(VarInfo& vi);
void putSiloMultiMesh(DBfile* dbfile, const std::string& meshName);
void putSiloMultiTensor(DBfile* dbfile, const VarInfo& vi);
void putSiloMultiVar(DBfile* dbfile, const VarInfo& vi,
bool useMeshFile = false);
bool saveVTKsingle(const std::string& fileName,
const std::string& meshName, const VarVector& vars);
void writeVarToVTK(const VarInfo& varInfo, std::ostream& os);
int cycle;
double time;
std::string mdSchema, mdString;
StringVec meshLabels, meshUnits;
bool externalDomain, wantsMeshVars;
DomainChunks domainChunks;
VarVector variables, meshVariables;
int mpiRank, mpiSize;
#if WEIPA_HAVE_MPI
MPI_Comm mpiComm;
#else
void* mpiComm;
#endif
};
} // namespace weipa
#endif // __WEIPA_ESCRIPTDATASET_H__
weipa::EscriptDataset::getMPIComm
void * getMPIComm()
Definition: EscriptDataset.h:155
weipa::EscriptDataset::getCycle
int getCycle() const
Returns the cycle number.
Definition: EscriptDataset.h:113
weipa::EscriptDataset::meshUnits
StringVec meshUnits
Definition: EscriptDataset.h:176
weipa::VarInfo::sampleDistribution
IntVec sampleDistribution
Definition: EscriptDataset.h:41
escript
Definition: AbstractContinuousDomain.cpp:22
weipa::EscriptDataset::getConvertedDomain
DomainChunks getConvertedDomain()
Returns the dataset&#39;s converted domain so it can be reused.
Definition: EscriptDataset.h:142
weipa::VarInfo::valid
bool valid
Definition: EscriptDataset.h:42
weipa::EscriptDataset::variables
VarVector variables
Definition: EscriptDataset.h:179
weipa::StringVec
std::vector< std::string > StringVec
Definition: weipa.h:60
weipa::EscriptDataset::mpiComm
void * mpiComm
Definition: EscriptDataset.h:184
weipa::DomainChunks
std::vector< DomainChunk_ptr > DomainChunks
Definition: EscriptDataset.h:35
weipa::VarInfo::units
std::string units
Definition: EscriptDataset.h:39
weipa::EscriptDataset::getMeshVariables
const VarVector & getMeshVariables() const
Returns a vector with the mesh variables.
Definition: EscriptDataset.h:148
weipa
Definition: DataVar.cpp:50
weipa::EscriptDataset::cycle
int cycle
Definition: EscriptDataset.h:173
weipa::IntVec
std::vector< int > IntVec
Definition: weipa.h:59
weipa::EscriptDataset::domainChunks
DomainChunks domainChunks
Definition: EscriptDataset.h:178
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:63
weipa::VarInfo::dataChunks
DataChunks dataChunks
Definition: EscriptDataset.h:40
weipa::EscriptDataset::mpiSize
int mpiSize
Definition: EscriptDataset.h:180
weipa::EscriptDataset::setSaveMeshData
void setSaveMeshData(bool flag)
Enables/Disables saving of mesh-related data.
Definition: EscriptDataset.h:133
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:41
weipa::VarInfo::varName
std::string varName
Definition: EscriptDataset.h:38
weipa::EscriptDataset
Represents an escript dataset including a domain and data variables for one timestep.
Definition: EscriptDataset.h:62
weipa::DataChunks
std::vector< DataVar_ptr > DataChunks
Definition: EscriptDataset.h:34
weipa::EscriptDataset::getVariables
const VarVector & getVariables() const
Returns a vector with the dataset&#39;s variables.
Definition: EscriptDataset.h:145
weipa::EscriptDataset::wantsMeshVars
bool wantsMeshVars
Definition: EscriptDataset.h:177
escript::AbstractDomain
Base class for all escript domains.
Definition: AbstractDomain.h:45
weipa::EscriptDataset::setCycleAndTime
void setCycleAndTime(int c, double t)
Sets the cycle number and time value for this dataset.
Definition: EscriptDataset.h:110
weipa::VarInfo
Definition: EscriptDataset.h:37
weipa::EscriptDataset::time
double time
Definition: EscriptDataset.h:174
WEIPA_DLL_API
#define WEIPA_DLL_API
Definition: weipa.h:37
weipa::VarVector
std::vector< VarInfo > VarVector
Definition: EscriptDataset.h:45
weipa::EscriptDataset::getTime
double getTime() const
Returns the time value.
Definition: EscriptDataset.h:116
weipa::EscriptDataset::setMetadataSchemaString
void setMetadataSchemaString(const std::string schema, const std::string metadata)
Sets a metadata schema and content.
Definition: EscriptDataset.h:128
weipa::EscriptDataset::mdString
std::string mdString
Definition: EscriptDataset.h:175