ergo
mat::FileWritable Class Reference

Write and read objects to/from file. More...

#include <FileWritable.h>

Inheritance diagram for mat::FileWritable:
mat::MatrixBase< Treal, Tmatrix > mat::VectorGeneral< Treal, Tvector > mat::MatrixGeneral< Treal, Tmatrix > mat::MatrixSymmetric< Treal, Tmatrix > mat::MatrixTriangular< Treal, Tmatrix >

List of all members.

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 &)
FileWritableoperator= (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.

Detailed Description

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:

  • clear()
  • write_to_buffer_count(int&) const
  • write_to_buffer(void*, int const) const
  • read_from_buffer(void*, int const)

Member Typedef Documentation

typedef std::set<FileWritable*> mat::FileWritable::ObjPtrSet
protected
typedef std::map<std::string, int> mat::FileWritable::TypeCountMap
protected
typedef std::map<std::string, double> mat::FileWritable::TypeTimeMap
protected

Constructor & Destructor Documentation

mat::FileWritable::FileWritable ( )
protected

Gives each object a unique ID-number and filename.

References fileName, IDNumber, nObjects, path, and mat::FileWritable::Manager::registerObj().

mat::FileWritable::~FileWritable ( )
protectedvirtual

Member Function Documentation

void mat::FileWritable::activate ( )
static

Activate the filewriting.

Without calling this function no filewriting will occur. This function can only be called before instantiation of objects.

References active, and nObjects.

Referenced by es_run().

virtual void mat::FileWritable::clear ( )
protectedpure virtual
long int mat::FileWritable::fileSize ( )

Return file size.

Call only if obj is on file.

References active, fileName, and isOnFile().

std::string mat::FileWritable::getStatsCount ( TypeCountMap theMap)
staticprotected
std::string mat::FileWritable::getStatsCountCopyAndAssign ( )
static
std::string mat::FileWritable::getStatsCountRead ( )
static
std::string mat::FileWritable::getStatsCountWrite ( )
static
std::string mat::FileWritable::getStatsFileSizes ( )
static
std::string mat::FileWritable::getStatsFileSizes ( ObjPtrSet const &  set)
staticprotected
std::string mat::FileWritable::getStatsTime ( TypeTimeMap theMap)
staticprotected
std::string mat::FileWritable::getStatsTimeCopyAndAssign ( )
static
std::string mat::FileWritable::getStatsTimeRead ( )
static
std::string mat::FileWritable::getStatsTimeWrite ( )
static
virtual void mat::FileWritable::inMemorySet ( bool  )
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().

bool mat::FileWritable::isOnFile ( )
inline

Check if object is on file.

References objectIsOnFile.

Referenced by fileSize().

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().

void mat::FileWritable::setPath ( char const *const  newPath)
static

Set the path to which the objects will be written.

This function can only be called before instantiation of objects.

References nObjects, and path.

Referenced by es_run().

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().


Member Data Documentation

bool mat::FileWritable::active = false
staticprivate

States whether the filewriting is active.

Referenced by activate(), fileSize(), FileWritable(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().

char* mat::FileWritable::fileName
private

Each object has its unique filename.

Referenced by fileSize(), FileWritable(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().

unsigned int const mat::FileWritable::IDNumber
private

Each object has its unique ID-number.

Referenced by FileWritable().

unsigned int mat::FileWritable::nObjects = 0
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().

bool mat::FileWritable::objectIsOnFile
private

States whether the object is on file or not.

Referenced by FileWritable(), isOnFile(), operator=(), readFromFile(), writeToFile(), and ~FileWritable().

char * mat::FileWritable::path = NULL
staticprivate

The path to which files will be written.

Referenced by FileWritable(), and setPath().


The documentation for this class was generated from the following files: