00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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/intdescr.h>
00039 #include <chemistry/qc/basis/distshpair.h>
00040 #include <chemistry/qc/mbptr12/r12ia.h>
00041 #include <chemistry/qc/mbptr12/orbitalspace.h>
00042 #include <chemistry/qc/mbptr12/transform_factory.h>
00043
00044 using namespace std;
00045
00046 namespace sc {
00047
00048 class MOIntsTransformFactory;
00049
00053 class TwoBodyMOIntsTransform : virtual public SavableState {
00054 public:
00055 typedef MOIntsTransformFactory::StorageType StorageType;
00056
00057 private:
00058
00059
00060
00061 virtual void init_acc() = 0;
00062
00063
00064 virtual distsize_t compute_transform_dynamic_memory_(int ni) const = 0;
00065
00066 protected:
00069 static double zero_integral;
00071 typedef struct {
00072 enum {Space1, Space2, Space3, Space4};
00073 } MOSpaces;
00074
00075 std::string name_;
00076 Ref<MOIntsTransformFactory> factory_;
00077
00078 Ref<MolecularEnergy> top_mole_;
00079 Ref<MessageGrp> msg_;
00080 Ref<MemoryGrp> mem_;
00081
00082
00083 Ref<ThreadGrp> thr_;
00084 Ref<TwoBodyIntDescr> tbintdescr_;
00085
00086 Ref<R12IntsAcc> ints_acc_;
00087
00088 Ref<OrbitalSpace> space1_;
00089 Ref<OrbitalSpace> space2_;
00090 Ref<OrbitalSpace> space3_;
00091 Ref<OrbitalSpace> space4_;
00092
00093 int restart_orbital_;
00094 size_t peak_memory_;
00095 size_t memory_;
00096 bool dynamic_;
00097 double print_percent_;
00098 DistShellPair::SharedData spdata_;
00099 int debug_;
00100 MOIntsTransformFactory::StoreMethod::type ints_method_;
00101 std::string file_prefix_;
00102
00103
00104 size_t max_memory_;
00105 size_t static_memory_;
00106 int batchsize_;
00107 int npass_;
00108
00110 unsigned int restart_orbital() const;
00111
00112
00113 void init_vars();
00114
00115 void reinit_acc();
00116
00117 void alloc_mem(const size_t localmem);
00118
00119 void dealloc_mem();
00120
00121 void set_memgrp(const Ref<MemoryGrp>& new_mem);
00122
00123
00124
00125 int compute_transform_batchsize_(size_t mem_static, int rank_i);
00126
00127
00128 static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
00129
00133 void memory_report(std::ostream& os = ExEnv::out0()) const;
00137 void mospace_report(std::ostream& os = ExEnv::out0()) const;
00138
00141 void print_header(std::ostream& os = ExEnv::out0()) const;
00144 void print_footer(std::ostream& os = ExEnv::out0()) const;
00145
00146 #if 0
00147
00148 void check_tbint(const Ref<TwoBodyInt>& tbint) const;
00149 #endif
00150
00151 public:
00152
00153 TwoBodyMOIntsTransform(StateIn&);
00154 TwoBodyMOIntsTransform(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
00155 const Ref<TwoBodyIntDescr>& tbintdescr,
00156 const Ref<OrbitalSpace>& space1, const Ref<OrbitalSpace>& space2,
00157 const Ref<OrbitalSpace>& space3, const Ref<OrbitalSpace>& space4);
00158 virtual ~TwoBodyMOIntsTransform();
00159
00160 void save_data_state(StateOut&);
00161
00163 const Ref<MOIntsTransformFactory>& factory() const { return factory_; }
00165 std::string name() const {return name_;}
00167 virtual std::string type() const =0;
00169 const Ref<MemoryGrp>& mem() const;
00171 const Ref<MessageGrp>& msg() const;
00173 const Ref<TwoBodyIntDescr>& intdescr() const;
00175 const Ref<R12IntsAcc>& ints_acc();
00177 const Ref<OrbitalSpace>& space1() const;
00179 const Ref<OrbitalSpace>& space2() const;
00181 const Ref<OrbitalSpace>& space3() const;
00183 const Ref<OrbitalSpace>& space4() const;
00184
00186 virtual void partially_transformed_ints(const Ref<R12IntsAcc>&);
00187
00188
00190 size_t memory() const;
00192 size_t peak_memory() const;
00193
00195 double print_percent() const;
00197 int batchsize() const;
00199 int debug() const;
00201 bool dynamic() const;
00203 unsigned int num_te_types() const;
00207 virtual const size_t memgrp_blksize() const =0;
00208
00210 void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
00211
00212 void set_debug(int debug) { debug_ = debug; }
00213 void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
00214 void set_print_percent(double print_percent) { print_percent_ = print_percent; }
00215
00217 virtual void compute() = 0;
00219 virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) throw (ProgrammingError) =0;
00221 virtual void obsolete();
00222
00225 DistShellPair::SharedData *shell_pair_data() { return &spdata_; }
00226
00227 };
00228
00229 }
00230
00231 #endif
00232
00233
00234
00235
00236
00237
00238