# transform_tbint.h

    00001 //
    00002 // transform_tbint.h
    00003 //
    00004 // Copyright (C) 2004 Edward Valeev
    00005 //
    00006 // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
    00007 // Maintainer: EV
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifdef __GNUG__
    00029 #pragma interface
    00030 #endif
    00031
    00032 #ifndef _chemistry_qc_mbptr12_transformtbint_h
    00033 #define _chemistry_qc_mbptr12_transformtbint_h
    00034
    00035 #include <string>
    00036 #include <util/ref/ref.h>
    00037 #include <util/class/scexception.h>
    00038 #include <chemistry/qc/basis/distshpair.h>
    00039 #include <chemistry/qc/mbptr12/r12ia.h>
    00040 #include <chemistry/qc/mbptr12/moindexspace.h>
    00041 #include <chemistry/qc/mbptr12/transform_factory.h>
    00042
    00043 using namespace std;
    00044
    00045 namespace sc {
    00046
    00047 class MOIntsTransformFactory;
    00048
    00052 class TwoBodyMOIntsTransform : virtual public SavableState {
    00053
    00054   // Construct the integrals accumulator object
    00055   // This function depends on the particulars of the transformation
    00056   virtual void init_acc() = 0;
    00057   // Compute required dynamic memory for a given batch size
    00058   // implementation depends on the particulars of the concrete type
    00059   virtual distsize_t compute_transform_dynamic_memory_(int ni) const = 0;
    00060
    00061 protected:
    00064   static const double zero_integral = 1.0e-12;
    00066   typedef struct {
    00067     enum {Space1, Space2, Space3, Space4};
    00068   } MOSpaces;
    00069
    00070   std::string name_;
    00071   Ref<MOIntsTransformFactory> factory_;
    00072
    00073   Ref<MolecularEnergy> top_mole_;   // Top-level molecular energy to enable checkpointing
    00074   Ref<MessageGrp> msg_;
    00075   Ref<MemoryGrp> mem_;
    00076   Ref<ThreadGrp> thr_;
    00077   // Integrals accumulator
    00078   Ref<R12IntsAcc> ints_acc_;
    00079
    00080   Ref<MOIndexSpace> space1_;
    00081   Ref<MOIndexSpace> space2_;
    00082   Ref<MOIndexSpace> space3_;
    00083   Ref<MOIndexSpace> space4_;
    00084
    00085   int num_te_types_;
    00086   size_t memory_;
    00087   bool dynamic_;
    00088   double print_percent_;
    00089   DistShellPair::SharedData spdata_;
    00090   int debug_;
    00091   MOIntsTransformFactory::StoreMethod ints_method_;
    00092   std::string file_prefix_;
    00093
    00094   // These variables are never saved but computed every time in case environment
    00095   // has changed or it's a restart
    00096   size_t mem_static_;
    00097   int batchsize_;
    00098   int npass_;
    00099
    00101   unsigned int restart_orbital() const;
    00102
    00103   // Compute used static memory and batch size
    00104   void init_vars();
    00105   // Re-construct the integrals accumulator object
    00106   void reinit_acc();
    00107   // Allocate distributed memory
    00108   void alloc_mem(const size_t localmem);
    00109   // Deallocate distributed memory
    00110   void dealloc_mem();
    00111
    00112   // Compute batchsize given the amount of used static memory and
    00113   // the number of i-orbitals
    00114   int compute_transform_batchsize_(size_t mem_static, int rank_i);
    00115
    00116   // Compute the number of ij-pairs per this task
    00117   static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
    00118
    00122   void memory_report(std::ostream& os = ExEnv::out0()) const;
    00126   void mospace_report(std::ostream& os = ExEnv::out0()) const;
    00127
    00130   void print_header(std::ostream& os = ExEnv::out0()) const;
    00133   void print_footer(std::ostream& os = ExEnv::out0()) const;
    00134
    00135 public:
    00136
    00137   TwoBodyMOIntsTransform(StateIn&);
    00138   TwoBodyMOIntsTransform(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
    00139                          const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
    00140                          const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4);
    00141   ~TwoBodyMOIntsTransform();
    00142
    00143   void save_data_state(StateOut&);
    00144
    00146   std::string name() const {return name_;}
    00148   virtual std::string type() const =0;
    00150   Ref<MemoryGrp> mem() const;
    00152   Ref<MessageGrp> msg() const;
    00154   Ref<R12IntsAcc> ints_acc() const;
    00156   Ref<MOIndexSpace> space1() const;
    00158   Ref<MOIndexSpace> space2() const;
    00160   Ref<MOIndexSpace> space3() const;
    00162   Ref<MOIndexSpace> space4() const;
    00163
    00165   double print_percent() const;
    00167   int batchsize() const;
    00169   int debug() const;
    00171   bool dynamic() const;
    00173   int num_te_types() const;
    00177   virtual const size_t memgrp_blksize() const =0;
    00178
    00180   void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
    00181
    00184   void set_num_te_types(const int num_te_types);
    00185   void set_memory(const size_t memory);
    00186   void set_debug(int debug) { debug_ = debug; }
    00187   void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
    00188   void set_print_percent(double print_percent) { print_percent_ = print_percent; }
    00189
    00191   virtual void compute() = 0;
    00193   virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) const throw (ProgrammingError) =0;
    00195   virtual void obsolete();
    00196
    00199   DistShellPair::SharedData *shell_pair_data() { return &spdata_; }
    00200
    00201 };
    00202
    00203 }
    00204
    00205 #endif
    00206
    00207 // Local Variables:
    00208 // mode: c++
    00209 // c-file-style: "CLJ"
    00210 // End:
    00211
    00212