00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef QC_GLOBAL_SYSTEM_H_
00021 #define QC_GLOBAL_SYSTEM_H_
00022
00023
00024 #include "QCSystem.hpp"
00025 #include "QCModelMatrices.hpp"
00026 #include "QCEnergies.hpp"
00027
00028
00029
00030 template <class TPSystem> class QCPartitioner;
00031
00036 template <class TPSolver>
00037 class QCGlobalSystem : public QCSystem, public QCModelMatrices, public QCEnergies
00038 {
00039
00041 public:
00042
00046 class QCIterator;
00047
00048 typedef TPSolver TSolver;
00049
00053 QCGlobalSystem(void)
00054 {}
00058 QCGlobalSystem(int& , char **& ){
00059 QCGlobalSystem();
00060 }
00064 int getId (void) const { return -1; };
00065 int getGlobalIdx (int indx) const { return indx; }
00066
00070 QCIterator begin (void) { return QCIterator(this); }
00071
00072
00073
00077 QCIterator end (void) { return QCIterator(this, 1); }
00078
00079
00080
00084 QCSystem& getRootSystem (void) { return QCSystem::asBase(); }
00085
00086
00087
00091 QCSystem& getSystem (void) {
00092 return QCSystem::asBase();
00093 }
00094
00095
00096
00100 const QCSystem& getSystem (void) const {
00101 return QCSystem::asBase();
00102 }
00103
00104
00105
00109 QCModelMatrices& getMatrices (void) {
00110 return QCModelMatrices::asBase();
00111 }
00112
00113
00114
00118 template <class TPManager>
00119 inline void init (TPManager& manager, const string& path);
00120
00121
00125 bool checkData(const QCGeneralData& data);
00126
00127
00128
00129 template <class TPSystem>
00130 void buildPartitioner (QCPartitioner<TPSystem>*& ,
00131 const QCGeneralData& ,
00132 const QCFiles& ,
00133 const int * ,
00134 const int ) {}
00135
00136
00137
00141 template <class TPManager>
00142 void computeEnergyDerivatives (TPManager& manager);
00143
00144
00145
00150 template <class TPManager>
00151 inline void buildMatrices (TPManager& manager);
00152
00153
00154
00158 template <class TPManager>
00159 inline void prepareIterations (TPManager& manager);
00165 void writeDensityOnFileAscii(const QCFiles & files, const string& path);
00172 void writeDensityOnFileBinary(const QCFiles & files, const string& path);
00177 void readDensityFromFile(const QCFiles & files, const string& path);
00181 void readDensityFromFileBinary(const QCFiles & files, const string& path);
00185 void readDensityFromFileAscii(const QCFiles & files, const string& path);
00189 void writeSystemOnFile(const QCFiles & files, const string& path);
00190
00191
00193 protected:
00194
00195
00197 private:
00198
00199
00200
00203 public:
00204
00205
00211 class QCIterator
00212 {
00213
00215 public:
00216
00220 QCIterator (void) :
00221 idx(0),
00222 pointer(NULL)
00223 {}
00224
00225
00229 QCIterator (QCGlobalSystem * system) :
00230 idx(0),
00231 pointer(system)
00232 {}
00233
00234
00238 QCIterator (QCGlobalSystem * system,
00239 int end) :
00240 idx(end),
00241 pointer(system)
00242 {}
00243
00244
00248 bool operator ++ (void) {
00249 if (idx == 0) {
00250 idx++;
00251 return true;
00252 }
00253 return false;
00254 }
00255
00256
00260 bool operator ++ (int) {
00261 return operator ++ ();
00262 }
00263
00264
00268 QCGlobalSystem * operator -> (void) {
00269 return pointer;
00270 }
00271
00272
00276 bool operator == (const QCIterator& iter) const {
00277 return ( (iter.pointer == pointer) &&
00278 (iter.idx == idx) );
00279 }
00280
00281
00285 bool operator != (const QCIterator& iter) const {
00286 return !(operator == (iter));
00287 }
00288
00289
00290
00291
00293 private:
00294
00298 int idx;
00299
00303 QCGlobalSystem * pointer;
00304 };
00305
00306
00307 protected:
00308 private:
00309
00310 };
00311
00312
00313
00314
00315
00319 template <class TPSolver>
00320 template <class TPManager>
00321 inline void
00322 QCGlobalSystem<TPSolver>::init(TPManager& manager, const string& )
00323 {
00324 typedef typename TPManager::TParam TParam;
00325
00326 const QCGeneralData& data = manager.getGeneralData();
00327
00328 QCSystem::init(manager.getParameters(), manager.getNbAtomTypes());
00329 if (data.getComputationType() == QC_ENERGY_DERIV) {
00330 allocateDisps();
00331 }
00332 allocateMatrices(manager, getNbAtomicOrbitals());
00333 }
00334
00335
00336
00337
00338
00342 template <class TPSolver>
00343 template <class TPManager>
00344 inline void
00345 QCGlobalSystem<TPSolver>::buildMatrices (TPManager& manager)
00346 {
00347 QCIterator workingSystem = this->begin();
00348 if(manager.getGeneralData().getInitDensityMatrix() == QC_DENSITY_FROM_FILE ){
00349 workingSystem->readDensityFromFile(manager.getFiles(),".");
00350 }
00351 QCModelMatrices::buildMatrices(manager, workingSystem);
00352 }
00356 template <class TPSolver>
00357 template <class TPManager>
00358 inline void
00359 QCGlobalSystem<TPSolver>::prepareIterations (TPManager& manager)
00360 {
00361 QCModelMatrices::prepareIterations(manager);
00362 }
00363
00364
00365
00366
00367
00368 #endif // QC_GLOBAL_SYSTEM_H_