The POD (Proper Orthogonal Decomposition) class provides an interface for defining POD object. More...
Public Types | |
enum class | ErrorMode { COMBINED , SINGLE , NONE } |
Mode of Error evaluation of a reconstructed fields by the POD basis. More... | |
enum class | MemoryMode { MEMORY_NORMAL , MEMORY_LIGHT } |
Memory Mode of the POD object. It defines the use of the memory resources. More... | |
enum class | MeshType { UNDEFINED , VOLOCTREE } |
Type of the Mesh used to compute the POD basis. More... | |
enum class | ReconstructionMode { PROJECTION , MINIMIZATION } |
Mode of Reconstruction of fields by using the POD basis. More... | |
enum class | RunMode { RESTORE , COMPUTE } |
Run Mode of the POD object. It defines if the POD basis has to be computed or restored. More... | |
enum class | WriteMode { DUMP , DEBUG , NONE } |
Output Write Mode of the POD object. It defines the amount of information written by the POD object. More... | |
Public Member Functions | |
POD (MPI_Comm comm=MPI_COMM_WORLD) | |
POD (POD &&other)=default | |
~POD () | |
void | adaptionAlter (const std::vector< adaption::Info > &info) |
void | adaptionCleanUp (const std::vector< adaption::Info > &info) |
void | adaptionPrepare (const std::vector< adaption::Info > &info) |
void | addReconstructionSnapshot (const pod::SnapshotFile &file) |
void | addReconstructionSnapshot (const std::string &directory, const std::string &name) |
void | addSnapshot (const pod::SnapshotFile &file) |
void | addSnapshot (const std::string &directory, const std::string &name) |
void | clear () |
void | computeMapper (const VolumeKernel *mesh) |
void | dump () |
void | dumpDecomposition () |
void | dumpField (const std::string &name, const pod::PODField &field) const |
void | evalCorrelation () |
void | evalDecomposition () |
void | evalEigen () |
void | evalErrorBoundingBox () |
void | evalMeanMesh () |
void | evalModes () |
void | evalReconstruction () |
std::vector< double > | fieldsl2norm (pod::PODField &snap) |
std::vector< double > | fieldsMax (pod::PODField &snap) |
void | fillListActiveIDs (const PiercedStorage< bool > &bfield) |
const std::string & | getDirectory () |
double | getEnergyLevel () |
ErrorMode | getErrorMode () |
double | getErrorThreshold () |
std::vector< std::string > | getFieldsNames () |
std::unique_ptr< PODKernel > & | getKernel () |
const std::unordered_set< long int > & | getListActiveIDs () |
std::size_t | getListIDInternalCount () |
const pod::PODMode & | getMean () |
MemoryMode | getMemoryMode () |
const VolumeKernel * | getMesh () |
MeshType | getMeshType () |
std::size_t | getModeCount () |
const std::vector< pod::PODMode > & | getModes () |
const std::string & | getName () |
std::vector< std::vector< double > > | getReconstructionCoeffs () |
ReconstructionMode | getReconstructionMode () |
RunMode | getRunMode () |
std::vector< std::string > | getScalarNames () |
std::size_t | getSnapshotCount () |
std::vector< std::array< std::string, 3 > > | getVectorNames () |
WriteMode | getWriteMode () |
void | leave1out () |
std::vector< std::vector< double > > | projectField (pod::PODField &field) |
void | readSnapshot (const pod::SnapshotFile &snap, pod::PODField &fieldr) |
void | reconstructFields (const std::vector< std::vector< double > > &coeffMatrix, pod::PODField &recon) |
void | reconstructFields (PiercedStorage< double > &fields, VolumeKernel *mesh, std::map< std::string, std::size_t > targetFields, const std::unordered_set< long > *targetCells) |
void | reconstructFields (pod::PODField &field, pod::PODField &recon) |
void | removeLeave1outSnapshot (const pod::SnapshotFile &file) |
void | removeLeave1outSnapshot (const std::string &directory, const std::string &name) |
void | restore () |
void | restoreDecomposition () |
void | run () |
void | setDirectory (const std::string &directory) |
void | setEnergyLevel (double energy) |
void | setErrorMode (ErrorMode mode) |
void | setErrorThreshold (double threshold) |
void | setExpert (bool mode=true) |
void | setMemoryMode (MemoryMode mode) |
void | setMesh (const pod::SnapshotFile &file) |
void | setMesh (const std::string &directory, const std::string &name) |
void | setMesh (std::unique_ptr< VolumeKernel > &&mesh) |
void | setMeshType (MeshType type) |
void | setModeCount (std::size_t nmodes) |
void | setName (const std::string &name) |
void | setReconstructionMode (ReconstructionMode mode) |
void | setRunMode (RunMode mode) |
void | setSensorMask (const PiercedStorage< bool > &mask, VolumeKernel *mesh=nullptr) |
void | setSnapshots (const std::vector< pod::SnapshotFile > &database) |
void | setStaticMesh (bool flag) |
void | setTargetErrorFields (std::vector< std::string > &namesf, std::vector< std::array< std::string, 3 > > &namevf) |
void | setUseMean (bool flag) |
void | setWriteMode (WriteMode mode) |
void | unsetLeave1outSnapshots () |
void | write (const pod::PODField &snap, std::string file_name) const |
void | write (int mode_index, std::string file_name) |
Public Member Functions inherited from bitpit::VTKBaseStreamer | |
virtual void | absorbData (std::fstream &, const std::string &, VTKFormat, uint64_t, uint8_t, VTKDataType) |
virtual void | flushData (std::fstream &, const std::string &, VTKFormat) |
template<typename T > | |
void | flushValue (std::fstream &, VTKFormat, const T &value) const |
template<typename T > | |
void | flushValue (std::fstream &, VTKFormat, const T *values, int nValues) const |
The POD (Proper Orthogonal Decomposition) class provides an interface for defining POD object.
POD is the base class for defining POD object.
This class provides the interface methods, as the base get/set methods.
To execute a pod work-flow of a POD object call the method run().
Note: in this version the only allowed mesh type is VolOctree. All the database fields and the reconstructed ones have to be defined on the same domain.
|
strong |
Mode of Error evaluation of a reconstructed fields by the POD basis.
Enumerator | |
---|---|
COMBINED | Maximum of reconstruction errors. |
SINGLE | Reconstruction errors one at a time. |
NONE | No error evaluation. |
|
strong |
|
strong |
|
strong |
Mode of Reconstruction of fields by using the POD basis.
Enumerator | |
---|---|
PROJECTION | Orthogonal projection of a field over the POD basis. Note: if the POD modes are not orthogonal on the active domain this is an approximation. |
MINIMIZATION | Non-orthogonal projection of a field over the POD basis.Note: if the POD modes are orthogonal on the active domain the result obtained by using PROJECTION is the same. |
|
strong |
|
strong |
Output Write Mode of the POD object. It defines the amount of information written by the POD object.
Enumerator | |
---|---|
DUMP | Write (dump) only the files needed to restore the POD instance. |
DEBUG | Write files to debug the run (POD dumping files, POD basis in .vtu format, database fields in .vtu format, reconstrucetd fields in .vtu format...) . |
NONE | Write none. |
bitpit::POD::POD | ( | MPI_Comm | comm = MPI_COMM_WORLD | ) |
|
default |
Default copy constructor.
[in] | other | Input POD object |
void bitpit::POD::adaptionAlter | ( | const std::vector< adaption::Info > & | info | ) |
void bitpit::POD::adaptionCleanUp | ( | const std::vector< adaption::Info > & | info | ) |
void bitpit::POD::adaptionPrepare | ( | const std::vector< adaption::Info > & | info | ) |
void bitpit::POD::addReconstructionSnapshot | ( | const pod::SnapshotFile & | file | ) |
void bitpit::POD::addReconstructionSnapshot | ( | const std::string & | directory, |
const std::string & | name ) |
Add a snapshot to the reconstruction database.
[in] | directory | is the directory that contains the snapshot. |
[in] | name | is the name of the snapshot. |
void bitpit::POD::addSnapshot | ( | const pod::SnapshotFile & | file | ) |
void bitpit::POD::addSnapshot | ( | const std::string & | directory, |
const std::string & | name ) |
Add a snapshot to the POD database.
[in] | directory | is the directory that contains the snapshot. |
[in] | name | is the name of the snapshot. |
void bitpit::POD::computeMapper | ( | const VolumeKernel * | mesh | ) |
void bitpit::POD::dump | ( | ) |
void bitpit::POD::dumpDecomposition | ( | ) |
void bitpit::POD::dumpField | ( | const std::string & | name, |
const pod::PODField & | field ) const |
void bitpit::POD::evalCorrelation | ( | ) |
void bitpit::POD::evalDecomposition | ( | ) |
Evaluate POD decomposition over a set of given snapshots.
void bitpit::POD::evalEigen | ( | ) |
void bitpit::POD::evalErrorBoundingBox | ( | ) |
Evaluation of error bounding box according to a certain threshold.
void bitpit::POD::evalMeanMesh | ( | ) |
void bitpit::POD::evalReconstruction | ( | ) |
std::vector< double > bitpit::POD::fieldsl2norm | ( | pod::PODField & | snap | ) |
Evaluate the l2-norm of a POD field.
[in] | snap | Field as POD object. |
std::vector< double > bitpit::POD::fieldsMax | ( | pod::PODField & | snap | ) |
Evaluate the maximum value of a POD field.
[in] | snap | Field as POD object. |
void bitpit::POD::fillListActiveIDs | ( | const PiercedStorage< bool > & | mask | ) |
const std::string & bitpit::POD::getDirectory | ( | ) |
double bitpit::POD::getEnergyLevel | ( | ) |
Get the percentage energy level of retained POD modes.
POD::ErrorMode bitpit::POD::getErrorMode | ( | ) |
Get the error mode of the POD object.
double bitpit::POD::getErrorThreshold | ( | ) |
Get the error threshold used in the subregion evaluation.
std::vector< std::string > bitpit::POD::getFieldsNames | ( | ) |
std::unique_ptr< PODKernel > & bitpit::POD::getKernel | ( | ) |
const std::unordered_set< long > & bitpit::POD::getListActiveIDs | ( | ) |
std::size_t bitpit::POD::getListIDInternalCount | ( | ) |
const pod::PODMode & bitpit::POD::getMean | ( | ) |
POD::MemoryMode bitpit::POD::getMemoryMode | ( | ) |
Get the memory mode of the POD object.
const VolumeKernel * bitpit::POD::getMesh | ( | ) |
POD::MeshType bitpit::POD::getMeshType | ( | ) |
std::size_t bitpit::POD::getModeCount | ( | ) |
Get the number of POD modes.
const std::vector< pod::PODMode > & bitpit::POD::getModes | ( | ) |
Get a reference to the POD modes.
const std::string & bitpit::POD::getName | ( | ) |
Get the name of the pod object.
std::vector< std::vector< double > > bitpit::POD::getReconstructionCoeffs | ( | ) |
Get the POD coefficients of the last reconstructed field.
POD::ReconstructionMode bitpit::POD::getReconstructionMode | ( | ) |
Get the reconstruction mode of the POD object.
POD::RunMode bitpit::POD::getRunMode | ( | ) |
Get the execution mode of the POD object.
std::vector< std::string > bitpit::POD::getScalarNames | ( | ) |
Get the names of the scalar fields involved in the POD.
std::size_t bitpit::POD::getSnapshotCount | ( | ) |
std::vector< std::array< std::string, 3 > > bitpit::POD::getVectorNames | ( | ) |
Get the names of the vector fields (three components) involved in the POD.
POD::WriteMode bitpit::POD::getWriteMode | ( | ) |
Get the write mode of the POD object.
void bitpit::POD::leave1out | ( | ) |
Execution of leave-one-out procedure.
std::vector< std::vector< double > > bitpit::POD::projectField | ( | pod::PODField & | field | ) |
Perform L2 projection of a filed over the POD space generated by the POD modes.
[in/out] | POD Field object. | |
[out] | matrix | of size N_fields x N_modes with the coefficients of the L2 projection. |
void bitpit::POD::readSnapshot | ( | const pod::SnapshotFile & | snap, |
pod::PODField & | fieldr ) |
Read a snapshot from file defined on a given mesh.
[in] | snap | Snapshot filename |
[out] | fieldr | Resulting POD field |
void bitpit::POD::reconstructFields | ( | const std::vector< std::vector< double > > & | reconstructionCoeffs, |
pod::PODField & | reconi ) |
void bitpit::POD::reconstructFields | ( | PiercedStorage< double > & | fields, |
VolumeKernel * | mesh, | ||
std::map< std::string, std::size_t > | targetFields, | ||
const std::unordered_set< long > * | targetCells ) |
Field reconstruction.
[in,out] | fields | Original field used in the reconstruction. Only the values of targetCells are updated. |
[in] | mesh | Pointer to snapshot field |
[in] | targetFields | Map of names/ids of fields in PiercedStorage to reconstruct |
[in] | targetCells | Pointer to list of cell to be updated with the reconstructed values (optional, default whole field). |
void bitpit::POD::reconstructFields | ( | pod::PODField & | field, |
pod::PODField & | reconi ) |
Field reconstruction.
[in] | field | Original field (Note: it has to be defined on POD mesh). |
[out] | reconi | Reconstructed field. |
void bitpit::POD::removeLeave1outSnapshot | ( | const pod::SnapshotFile & | file | ) |
void bitpit::POD::removeLeave1outSnapshot | ( | const std::string & | directory, |
const std::string & | name ) |
Remove a snapshot from the leave-1-out error computation.
[in] | directory | is the directory that contains the snapshot. |
[in] | name | is the name of the snapshot. |
void bitpit::POD::restore | ( | ) |
Restore the POD results.
void bitpit::POD::restoreDecomposition | ( | ) |
void bitpit::POD::run | ( | ) |
void bitpit::POD::setDirectory | ( | const std::string & | directory | ) |
Set the input/output directory.
[in] | directory | is the name of the directory. |
void bitpit::POD::setEnergyLevel | ( | double | energy | ) |
Set the energy percentage level (e%) used to retain a limited number of POD modes during POD evaluation. m_nModes such that sum(lambda[1:m_nModes])/etot >= e% and sum(lambda[1:m_nModes-1])/etot < e%.
[in] | energy | is the target energy percentage level. |
void bitpit::POD::setErrorMode | ( | POD::ErrorMode | mode | ) |
Set the error evaluation mode of the POD object.
[in] | mode | is the error mode. If set to COMBINED evaluates the maximum reconstruction errors, if set to SINGLE evaluates the reconstruction errors one at a time, if set to NONE does nothing. |
void bitpit::POD::setErrorThreshold | ( | double | threshold | ) |
Set the minimum error threshold used to identify a subregion of the original computational domain.
[in] | threshold | is the threshold value for the minimum error. |
void bitpit::POD::setExpert | ( | bool | mode = true | ) |
void bitpit::POD::setMemoryMode | ( | POD::MemoryMode | mode | ) |
Set the memory mode of the POD object.
[in] | mode | Memory mode. If set to MEMORY_LIGHT the POD modes if present are erased and then they are read from file if needed. If set to MEMORY_NORMAL, the POD modes are kept in memory when computed or read for the first time. |
void bitpit::POD::setMesh | ( | const pod::SnapshotFile & | file | ) |
void bitpit::POD::setMesh | ( | const std::string & | directory, |
const std::string & | name ) |
Set the POD mesh by reading it from file, where the fields and modes are defined. The POD mesh is not computed during POD run. The file has to be a snapshot file format (data file + mesh file).
[in] | directory | is the directory that contains the snapshot. |
[in] | name | is the name of the snapshot. |
void bitpit::POD::setMesh | ( | std::unique_ptr< VolumeKernel > && | mesh | ) |
void bitpit::POD::setMeshType | ( | POD::MeshType | type | ) |
Set the type of the POD mesh, where the fields and modes are defined. Note: even if the mesh is directly set by setMesh methods, the type MUST be set before call setMesh.
[in] | type | Type of the POD mesh. |
void bitpit::POD::setModeCount | ( | std::size_t | nmodes | ) |
Set the number of retained POD modes during POD evaluation.
[in] | nmodes | Number of retained modes. |
void bitpit::POD::setName | ( | const std::string & | name | ) |
Set the name of the pod object.
[in] | name | is the name that will be set. |
void bitpit::POD::setReconstructionMode | ( | POD::ReconstructionMode | mode | ) |
Set the reconstruction mode of the POD object.
[in] | mode | is the reconstruction mode. If set to MINIMIZATION solve the least-squares problem, if set to PROJECTION uses orthogonal projection. |
void bitpit::POD::setRunMode | ( | POD::RunMode | mode | ) |
void bitpit::POD::setSensorMask | ( | const PiercedStorage< bool > & | mask, |
VolumeKernel * | mesh = nullptr ) |
Set the boolean field used as mask for the POD reconstruction.
[in] | mask | Reference to boolean field used as mask to chose the active cells. |
[in] | mesh | Pointer to mesh related to input mask (used only if dynamic mesh active). If set to true, the corresponding cell is used during the minimization [or projection], otherwise it is discarded. |
void bitpit::POD::setSnapshots | ( | const std::vector< pod::SnapshotFile > & | database | ) |
void bitpit::POD::setStaticMesh | ( | bool | flag | ) |
Set if the mesh, where the fields are defined, is a static mesh, fixed for the whole database, or it is an AMR mesh, i.e. differently adapted for each field in the database or during reconstruction.
[in] | flag | if set to true the mesh is considered static. |
void bitpit::POD::setTargetErrorFields | ( | std::vector< std::string > & | namesf, |
std::vector< std::array< std::string, 3 > > & | namevf ) |
Set the target error fields used in the error bounding box evaluation.
[in] | namesf | is the vector of scalar fields names. |
[in] | namevf | is the vector of vector fields names, arranged in vector components. |
void bitpit::POD::setUseMean | ( | bool | flag | ) |
Set if the mean fields are used during the POD basis calculation or not.
[in] | flag | if set to true the mean is used. |
void bitpit::POD::setWriteMode | ( | POD::WriteMode | mode | ) |
Set the write mode of the POD object.
[in] | mode | is the write mode. |
void bitpit::POD::unsetLeave1outSnapshots | ( | ) |
void bitpit::POD::write | ( | const pod::PODField & | field, |
std::string | file_name ) const |
Write a POD Field as VTK files.
[in] | field,PODField | object. |
[in] | file_name,string | with the desired file name for the VTK file. |
void bitpit::POD::write | ( | int | mode_index, |
std::string | file_name ) |