Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions expui/BasisFactory.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "OrthoFunction.H"
#include "Coefficients.H"
#include "PseudoAccel.H"
#include "Covariance.H"
#include "YamlCheck.H"
#include "localmpi.H"
#include "exputils.H"
Expand Down Expand Up @@ -135,6 +136,32 @@ namespace BasisClasses
Eigen::MatrixXd p_accel;
//@}

//@{
//! Sample counts and masses for covariance computation
Eigen::VectorXi sampleCounts;
Eigen::VectorXd sampleMasses;
//@}

//! Covariance storage instance
std::shared_ptr<SubsampleCovariance> covarStore;

//! Coefficient variance computation enabled
bool pcavar = false;

//! Round time key to emulated fixed-point arithmetic
double roundTime(double time)
{
// Eight decimal places should be enough here...
const double multiplier = 1.0e+08; // std::pow(10.0, 8);
return std::floor(time * multiplier + 0.5) / multiplier;
}
Comment thread
The9Cat marked this conversation as resolved.

//! Store covariance matrix?
bool covar = true;

//! Store summed covariance only?
bool scovr = true;

//! Number of center points in acceleration estimator
int Naccel = 0;

Expand Down Expand Up @@ -291,6 +318,46 @@ namespace BasisClasses

//! Get the basis expansion center
RowMatrix3d getRotation() { return coefrot; }

//!! Sample counts, masses, coefficients, and covariance
virtual SubsampleCovariance::CovarData getCoefCovariance(double time)
{
if (!covarStore)
throw std::runtime_error("Basis::getCoefCovariance: covariance storage not initialized");
return covarStore->getCoefCovariance(time);
}

//! Write coefficient covariance data to an HDF5 file
virtual void writeCoefCovariance(const std::string& compname, const std::string& runtag,
double time=0.0)
{
// Must be overriden; base implementation throws error
throw std::runtime_error("Basis::writeCoefCovariance: "
"Not implemented for this basis");
}

//! Make covariance after accumulation
virtual void makeCoefCovariance(void) {}

//! Enable covariance computation with optional sample time
virtual void enableCoefCovariance(bool pcavar, int sampT_in, bool ftype, bool total, bool covar_in)
{
// Must be overriden; base implementation throws error
throw std::runtime_error("Basis::enableCoefCovariance: "
"Not implemented for this basis");
}

//! HDF5 compression settings
void setCovarH5Compress(unsigned level, unsigned chunksize, bool shuffle,
bool szip=false)
{
if (covarStore) {
covarStore->setCovarH5Compress(level, chunksize, shuffle, szip);
} else {
throw std::runtime_error("Basis::setCovarH5Compress: covariance storage not initialized");
}
}

};

using BasisPtr = std::shared_ptr<Basis>;
Expand Down
62 changes: 0 additions & 62 deletions expui/BiorthBasis.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "BiorthBess.H"
#include "BasisFactory.H"
#include "BiorthCube.H"
#include "Covariance.H"
#include "sltableMP2.H"
#include "SLGridMP2.H"
#include "YamlCheck.H"
Expand Down Expand Up @@ -104,32 +103,6 @@ namespace BasisClasses
RowMatrixXd varray;
//@}

//! Coefficient variance computation enabled
bool pcavar = false;

//@{
//! Sample counts and masses for covariance computation
Eigen::VectorXi sampleCounts;
Eigen::VectorXd sampleMasses;
//@}

//! Covariance storage instance
std::shared_ptr<SubsampleCovariance> covarStore;

//! Round time key to emulated fixed-point arithmetic
double roundTime(double time)
{
// Eight decimal places should be enough here...
const double multiplier = 1.0e+08; // std::pow(10.0, 8);
return std::floor(time * multiplier + 0.5) / multiplier;
}

//! Store covariance matrix?
bool covar = true;

//! Store summed covariance only?
bool scovr = true;

public:

//! Basis identifier string
Expand Down Expand Up @@ -273,41 +246,6 @@ namespace BasisClasses
return varray;
}

//!! Sample counts, masses, coefficients, and covariance
SubsampleCovariance::CovarData getCoefCovariance(double time)
{ return covarStore->getCoefCovariance(time); }

//! Write coefficient covariance data to an HDF5 file
virtual void writeCoefCovariance(const std::string& compname, const std::string& runtag,
double time=0.0)
{
// Must be overriden; base implementation throws error
throw std::runtime_error("BiorthBasis::writeCoefCovariance: "
"Not implemented for this basis");
}

//! Make covariance after accumulation
virtual void makeCoefCovariance(void) {}

//! Enable covariance computation with optional sample time
virtual void enableCoefCovariance(bool pcavar, int sampT_in, bool ftype, bool covar_in)
{
// Must be overriden; base implementation throws error
throw std::runtime_error("BiorthBasis::enableCoefCovariance: "
"Not implemented for this basis");
}

//! HDF5 compression settings
void setCovarH5Compress(unsigned level, unsigned chunksize, bool shuffle,
bool szip=false)
{
if (covarStore) {
covarStore->setCovarH5Compress(level, chunksize, shuffle, szip);
} else {
throw std::runtime_error("BiorthBasis::setCovarH5Compress: covariance storage not initialized");
}
}

//! Evaluate acceleration in Cartesian coordinates in centered
//! coordinate system for a collections of points
virtual RowMatrixXd& getAccel(Eigen::Ref<const RowMatrixXd> pos)
Expand Down
Loading
Loading