ergo
|
Write and read objects to/from file. More...
#include <FileWritable.h>
Classes | |
struct | Manager |
struct | Stats |
Public Member Functions | |
void | writeToFile () |
Write object to file if filewrite is active. | |
void | readFromFile () |
Read object from file if filewrite is active. | |
bool | isOnFile () |
Check if object is on file. | |
long int | fileSize () |
Return file size. |
Static Public Member Functions | |
static void | setPath (char const *const newPath) |
Set the path to which the objects will be written. | |
static void | activate () |
Activate the filewriting. | |
static std::string | getStatsFileSizes () |
static std::string | writeAndReadAll () |
static void | resetStats () |
static std::string | getStatsTimeWrite () |
static std::string | getStatsTimeRead () |
static std::string | getStatsTimeCopyAndAssign () |
static std::string | getStatsCountWrite () |
static std::string | getStatsCountRead () |
static std::string | getStatsCountCopyAndAssign () |
Protected Types | |
typedef std::map< std::string, double > | TypeTimeMap |
typedef std::map< std::string, int > | TypeCountMap |
typedef std::set< FileWritable * > | ObjPtrSet |
Protected Member Functions | |
virtual void | clear ()=0 |
Release memory for the information written to file. | |
virtual void | inMemorySet (bool)=0 |
Make object invalid (false) via this function when object is written to file and valid (true) when object is read from file. | |
virtual void | writeToFileProt (std::ofstream &) const =0 |
Write object to file. | |
virtual void | readFromFileProt (std::ifstream &)=0 |
Read object from file. | |
FileWritable () | |
Gives each object a unique ID-number and filename. | |
virtual | ~FileWritable () |
Removes file, if any. | |
FileWritable (FileWritable const &) | |
FileWritable & | operator= (FileWritable const &) |
virtual std::string | obj_type_id () const =0 |
Static Protected Member Functions | |
static std::string | getStatsTime (TypeTimeMap &theMap) |
static std::string | getStatsCount (TypeCountMap &theMap) |
static std::string | getStatsFileSizes (ObjPtrSet const &set) |
Private Attributes | |
unsigned int const | IDNumber |
Each object has its unique ID-number. | |
char * | fileName |
Each object has its unique filename. | |
bool | objectIsOnFile |
States whether the object is on file or not. |
Static Private Attributes | |
static unsigned int | nObjects = 0 |
The number of instantiated objects. | |
static char * | path = NULL |
The path to which files will be written. | |
static bool | active = false |
States whether the filewriting is active. |
Write and read objects to/from file.
This is an abstract class. Classes that are derived from this class must define the following pure virtual functions to be able to instantiate objects:
|
protected |
|
protected |
|
protected |
|
protected |
Gives each object a unique ID-number and filename.
References fileName, IDNumber, nObjects, path, and mat::FileWritable::Manager::registerObj().
|
protectedvirtual |
Removes file, if any.
References active, fileName, objectIsOnFile, and mat::FileWritable::Manager::unRegisterObj().
|
protected |
References active, mat::copy_file(), mat::FileWritable::Stats::countCopyAndAssign, fileName, IDNumber, mat::FileWritable::Stats::instance(), nObjects, obj_type_id(), objectIsOnFile, path, mat::FileWritable::Manager::registerObj(), mat::Time::tic(), mat::Time::toc(), and mat::FileWritable::Stats::wallTimeCopyAndAssign.
|
static |
|
protectedpure virtual |
Release memory for the information written to file.
Implemented in mat::MatrixBase< Treal, Tmatrix >, mat::MatrixBase< ergo_real, Matri >, mat::VectorGeneral< Treal, Tvector >, and mat::VectorGeneral< ergo_real, Vectorrr >.
Referenced by writeToFile().
long int mat::FileWritable::fileSize | ( | ) |
|
staticprotected |
Referenced by getStatsCountCopyAndAssign(), getStatsCountRead(), and getStatsCountWrite().
|
static |
References getStatsCount(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
References getStatsCount(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
References getStatsCount(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
References mat::FileWritable::Manager::instance().
Referenced by writeAndReadAll().
|
staticprotected |
|
staticprotected |
Referenced by getStatsTimeCopyAndAssign(), getStatsTimeRead(), and getStatsTimeWrite().
|
static |
References getStatsTime(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
References getStatsTime(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
References getStatsTime(), and mat::FileWritable::Stats::instance().
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
protectedpure virtual |
Make object invalid (false) via this function when object is written to file and valid (true) when object is read from file.
Implemented in mat::VectorGeneral< Treal, Tvector >, mat::VectorGeneral< ergo_real, Vectorrr >, mat::MatrixBase< Treal, Tmatrix >, and mat::MatrixBase< ergo_real, Matri >.
Referenced by readFromFile(), and writeToFile().
|
inline |
|
protectedpure virtual |
Implemented in mat::MatrixSymmetric< Treal, Tmatrix >, mat::MatrixSymmetric< ergo_real, Matri >, mat::MatrixGeneral< Treal, Tmatrix >, mat::MatrixGeneral< ergo_real, Matri >, mat::MatrixTriangular< Treal, Tmatrix >, mat::MatrixTriangular< ergo_real, Matri >, mat::MatrixBase< Treal, Tmatrix >, mat::MatrixBase< ergo_real, Matri >, mat::VectorGeneral< Treal, Tvector >, and mat::VectorGeneral< ergo_real, Vectorrr >.
Referenced by FileWritable(), operator=(), readFromFile(), and writeToFile().
|
protected |
void mat::FileWritable::readFromFile | ( | ) |
Read object from file if filewrite is active.
References active, mat::FileWritable::Stats::countRead, fileName, inMemorySet(), mat::FileWritable::Stats::instance(), obj_type_id(), objectIsOnFile, readFromFileProt(), mat::Time::tic(), mat::Time::toc(), and mat::FileWritable::Stats::wallTimeRead.
Referenced by SCF_restricted::add_random_disturbance_to_starting_guess(), SCF_unrestricted::add_random_disturbance_to_starting_guess(), SCF_restricted::add_to_DIIS_list(), SCF_unrestricted::add_to_DIIS_list(), DIISManagerRestricted::AddIterationToList(), DIISManagerUnrestricted::AddIterationToList(), SCF_restricted::calculate_energy(), SCF_unrestricted::calculate_energy(), SCF_restricted::combine_old_fock_matrices(), SCF_unrestricted::combine_old_fock_matrices(), SCF_restricted::compute_dipole_moment(), SCF_unrestricted::compute_dipole_moment(), compute_FDSminusSDF_sparse(), compute_h_core_matrix_sparse(), compute_K_by_boxes_sparse(), compute_K_by_boxes_sparse_nosymm(), compute_operator_matrix_sparse_symm(), compute_R_matrix_sparse(), SCF_restricted::create_mtx_files_D(), SCF_unrestricted::create_mtx_files_D(), SCF_restricted::create_mtx_files_F(), SCF_unrestricted::create_mtx_files_F(), SCF_restricted::disturb_dens_matrix(), SCF_restricted::disturb_dens_matrix_exact(), SCF_restricted::disturb_dens_matrix_exact_try(), SCF_restricted::disturb_fock_matrix(), do_acc_scan_J(), do_acc_scan_K(), do_acc_scan_Vxc(), SCF_restricted::do_electron_dynamics(), SCF_restricted::do_mulliken_pop_stuff(), SCF_unrestricted::do_mulliken_pop_stuff(), SCF_unrestricted::do_spin_flip(), SCF_restricted::get_2e_part_and_energy(), SCF_unrestricted::get_2e_part_and_energy(), get_dens_from_fock_general(), get_dens_from_fock_sparse(), SCF_restricted::get_FDSminusSDF(), SCF_unrestricted::get_FDSminusSDF(), SCF_unrestricted::get_Fock_matrices(), SCF_general::get_H_core_matrix(), SCF_restricted::get_new_density_matrix(), SCF_unrestricted::get_new_density_matrix(), SCF_general::get_overlap_matrix(), SCF_unrestricted::get_S2(), SCF_restricted::get_starting_guess_density(), SCF_unrestricted::get_starting_guess_density(), getAllEigsInterval(), DIISManagerUnrestricted::GetCombinedFockMatrices(), DIISManagerRestricted::GetCombinedFockMatrix(), mainFun(), SCF_restricted::output_csr_matrices_for_gao(), SCF_unrestricted::output_density_images(), SCF_restricted::output_sparsity_S_F_D(), SCF_unrestricted::output_sparsity_S_F_D(), SCF_restricted::report_density_difference(), SCF_unrestricted::report_density_difference(), SCF_restricted::save_current_fock_as_fprev(), SCF_unrestricted::save_current_fock_as_fprev(), SCF_restricted::save_density_as_prevdens(), SCF_unrestricted::save_density_as_prevdens(), SCF_restricted::save_full_matrices_for_matlab(), save_symmetric_matrix(), SCF_general::SCF_general(), SCF_restricted::transform_with_invChol(), SCF_restricted::transform_with_S(), SCF_restricted::update_best_fock_so_far(), SCF_unrestricted::update_best_fock_so_far(), SCF_restricted::update_subspace_diff(), SCF_restricted::use_diis_to_get_new_fock_matrix(), SCF_unrestricted::use_diis_to_get_new_fock_matrix(), SCF_restricted::write_density_to_file(), SCF_unrestricted::write_density_to_file(), SCF_restricted::write_diag_dens_to_file(), and SCF_unrestricted::write_diag_dens_to_file().
|
protectedpure virtual |
Read object from file.
Defined in derived class.
Implemented in mat::MatrixSymmetric< Treal, Tmatrix >, mat::MatrixSymmetric< ergo_real, Matri >, mat::MatrixGeneral< Treal, Tmatrix >, mat::MatrixGeneral< ergo_real, Matri >, mat::MatrixTriangular< Treal, Tmatrix >, mat::MatrixTriangular< ergo_real, Matri >, mat::VectorGeneral< Treal, Tvector >, and mat::VectorGeneral< ergo_real, Vectorrr >.
Referenced by readFromFile().
|
static |
References mat::FileWritable::Stats::countCopyAndAssign, mat::FileWritable::Stats::countRead, mat::FileWritable::Stats::countWrite, mat::FileWritable::Stats::instance(), mat::FileWritable::Stats::wallTimeCopyAndAssign, mat::FileWritable::Stats::wallTimeRead, and mat::FileWritable::Stats::wallTimeWrite.
Referenced by get_dens_from_fock_sparse(), and mainFun().
|
static |
|
static |
void mat::FileWritable::writeToFile | ( | ) |
Write object to file if filewrite is active.
Object is "cleared" in this call.
References active, clear(), mat::FileWritable::Stats::countWrite, fileName, inMemorySet(), mat::FileWritable::Stats::instance(), obj_type_id(), objectIsOnFile, mat::Time::tic(), mat::Time::toc(), mat::FileWritable::Stats::wallTimeWrite, and writeToFileProt().
Referenced by SCF_restricted::add_random_disturbance_to_starting_guess(), SCF_unrestricted::add_random_disturbance_to_starting_guess(), SCF_restricted::add_to_DIIS_list(), SCF_unrestricted::add_to_DIIS_list(), DIISManagerRestricted::AddIterationToList(), DIISManagerUnrestricted::AddIterationToList(), SCF_restricted::calculate_energy(), SCF_unrestricted::calculate_energy(), SCF_restricted::combine_old_fock_matrices(), SCF_unrestricted::combine_old_fock_matrices(), SCF_restricted::compute_dipole_moment(), SCF_unrestricted::compute_dipole_moment(), compute_FDSminusSDF_sparse(), compute_h_core_matrix_sparse(), compute_K_by_boxes_sparse(), compute_K_by_boxes_sparse_nosymm(), compute_operator_matrix_sparse_symm(), compute_R_matrix_sparse(), SCF_restricted::create_mtx_files_D(), SCF_unrestricted::create_mtx_files_D(), SCF_restricted::create_mtx_files_F(), SCF_unrestricted::create_mtx_files_F(), SCF_restricted::disturb_dens_matrix(), SCF_restricted::disturb_dens_matrix_exact(), SCF_restricted::disturb_dens_matrix_exact_try(), SCF_restricted::disturb_fock_matrix(), do_acc_scan_J(), do_acc_scan_K(), do_acc_scan_Vxc(), SCF_restricted::do_mulliken_pop_stuff(), SCF_unrestricted::do_mulliken_pop_stuff(), SCF_unrestricted::do_spin_flip(), SCF_restricted::get_2e_part_and_energy(), SCF_unrestricted::get_2e_part_and_energy(), get_dens_from_fock_general(), get_dens_from_fock_sparse(), SCF_restricted::get_FDSminusSDF(), SCF_unrestricted::get_FDSminusSDF(), SCF_unrestricted::get_Fock_matrices(), SCF_general::get_H_core_matrix(), SCF_restricted::get_new_density_matrix(), SCF_unrestricted::get_new_density_matrix(), SCF_general::get_overlap_matrix(), SCF_unrestricted::get_S2(), SCF_restricted::get_starting_guess_density(), SCF_unrestricted::get_starting_guess_density(), getAllEigsInterval(), DIISManagerUnrestricted::GetCombinedFockMatrices(), DIISManagerRestricted::GetCombinedFockMatrix(), load_density_and_project_sparse(), mainFun(), SCF_restricted::output_csr_matrices_for_gao(), SCF_unrestricted::output_density_images(), SCF_restricted::output_sparsity_S_F_D(), SCF_unrestricted::output_sparsity_S_F_D(), SCF_restricted::report_density_difference(), SCF_unrestricted::report_density_difference(), SCF_restricted::save_current_fock_as_fprev(), SCF_unrestricted::save_current_fock_as_fprev(), SCF_restricted::save_density_as_prevdens(), SCF_unrestricted::save_density_as_prevdens(), SCF_restricted::save_full_matrices_for_matlab(), save_symmetric_matrix(), SCF_general::SCF_general(), SCF_restricted::transform_with_invChol(), SCF_restricted::transform_with_S(), SCF_restricted::update_best_fock_so_far(), SCF_unrestricted::update_best_fock_so_far(), SCF_restricted::update_subspace_diff(), SCF_restricted::use_diis_to_get_new_fock_matrix(), SCF_unrestricted::use_diis_to_get_new_fock_matrix(), SCF_restricted::write_density_to_file(), SCF_unrestricted::write_density_to_file(), SCF_restricted::write_diag_dens_to_file(), SCF_unrestricted::write_diag_dens_to_file(), SCF_restricted::write_matrices_to_file(), and SCF_unrestricted::write_matrices_to_file().
|
protectedpure virtual |
Write object to file.
Defined in derived class.
Implemented in mat::MatrixSymmetric< Treal, Tmatrix >, mat::MatrixSymmetric< ergo_real, Matri >, mat::MatrixGeneral< Treal, Tmatrix >, mat::MatrixGeneral< ergo_real, Matri >, mat::MatrixTriangular< Treal, Tmatrix >, mat::MatrixTriangular< ergo_real, Matri >, mat::VectorGeneral< Treal, Tvector >, and mat::VectorGeneral< ergo_real, Vectorrr >.
Referenced by writeToFile().
|
staticprivate |
States whether the filewriting is active.
Referenced by activate(), fileSize(), FileWritable(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().
|
private |
Each object has its unique filename.
Referenced by fileSize(), FileWritable(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().
|
private |
Each object has its unique ID-number.
Referenced by FileWritable().
|
staticprivate |
The number of instantiated objects.
Note that the objects may be of different types derived from this base class.
Referenced by activate(), FileWritable(), and setPath().
|
private |
States whether the object is on file or not.
Referenced by FileWritable(), isOnFile(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().
|
staticprivate |
The path to which files will be written.
Referenced by FileWritable(), and setPath().