UnitTests_DMRGBlock_InitializeFromDisk.cpp
1 static char help[] =
2  "Test code for DMRGBlock module which retrieves blocks from disk "
3  "";
4 
5 #include <slepceps.h>
6 #include "DMRGBlock.hpp"
7 #include "linalg_tools.hpp"
8 #include <iostream>
9 
10 PETSC_EXTERN PetscErrorCode SetRow(const Mat& A, const PetscInt& row, const std::vector<PetscInt>& idxn);
11 PETSC_EXTERN PetscErrorCode Makedir(const std::string& dir_name);
12 
13 PetscErrorCode RetrieveBlockFromDisk(Block::SpinBase& blk)
14 {
15  PetscErrorCode ierr;
16  char file[PETSC_MAX_PATH_LEN];
17  PetscBool flg;
18  ierr = PetscOptionsGetString(NULL,NULL,"-blockdir",file,PETSC_MAX_PATH_LEN,&flg); CHKERRQ(ierr);
19  if(!flg) SETERRQ(PETSC_COMM_WORLD,1,"-blockdir <str> must be specified.");
20  ierr = PetscPrintf(PETSC_COMM_WORLD,"Reading from: %s\n",file); CHKERRQ(ierr);
21  ierr = blk.InitializeFromDisk(PETSC_COMM_WORLD,std::string(file)); CHKERRQ(ierr);
22  ierr = blk.AssembleOperators(); CHKERRQ(ierr);
23  ierr = blk.CheckOperatorBlocks(); CHKERRQ(ierr);
24  return(0);
25 }
26 
27 int main(int argc, char **argv)
28 {
29  PetscErrorCode ierr = 0;
30  ierr = SlepcInitialize(&argc, &argv, (char*)0, help); CHKERRQ(ierr);
31  ierr = PetscOptionsSetValue(NULL,"-log_io","yes"); CHKERRQ(ierr);
32 
33  Block::SpinBase blk1;
34  ierr = RetrieveBlockFromDisk(blk1); CHKERRQ(ierr);
35  ierr = blk1.Destroy(); CHKERRQ(ierr);
36 
37  ierr = SlepcFinalize(); CHKERRQ(ierr);
38  return ierr;
39 }
PETSC_EXTERN PetscErrorCode Makedir(const std::string &dir_name)
Creates a directory named dir_name.
Definition: MiscTools.cpp:306
Base class for the implementation of a block of spin sites.
Definition: DMRGBlock.hpp:79
PetscErrorCode AssembleOperators()
Ensures that all operators are assembled.
Definition: DMRGBlock.cpp:825
PetscErrorCode CheckOperatorBlocks() const
Checks whether all matrix blocks follow the correct sector indices using MatCheckOperatorBlocks() ...
Definition: DMRGBlock.cpp:601
PetscErrorCode InitializeFromDisk(const MPI_Comm &comm_in, const std::string &block_path)
Initializes block object from data located in the directory block_path.
Definition: DMRGBlock.cpp:214
PetscErrorCode Destroy()
Destroys all operator matrices and frees memory.
Definition: DMRGBlock.cpp:655
This site was generated by Sphinx using Doxygen with a customized theme from doxygen-bootstrapped.