| [f66195] | 1 | /** \file parser.hpp
 | 
|---|
| [14de469] | 2 |  *
 | 
|---|
 | 3 |  * Definitions of various class functions for the parsing of value files.
 | 
|---|
| [6ac7ee] | 4 |  *
 | 
|---|
| [14de469] | 5 |  */
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | 
 | 
|---|
| [f66195] | 8 | #ifndef PARSER_HPP_
 | 
|---|
 | 9 | #define PARSER_HPP_
 | 
|---|
| [14de469] | 10 | 
 | 
|---|
| [6dea43] | 11 | using namespace std;
 | 
|---|
 | 12 | 
 | 
|---|
| [f66195] | 13 | /*********************************************** includes ***********************************/
 | 
|---|
 | 14 | 
 | 
|---|
| [6dea43] | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [f66195] | 20 | /****************************************** forward declarations *****************************/
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | class EnergyMatrix;
 | 
|---|
 | 23 | class ForceMatrix;
 | 
|---|
 | 24 | class HessianMatrix;
 | 
|---|
 | 25 | class KeySetsContainer;
 | 
|---|
 | 26 | class MatrixContainer;
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | /********************************************** definitions *********************************/
 | 
|---|
| [14de469] | 29 | 
 | 
|---|
 | 30 | #define EnergySuffix ".energy.all"
 | 
|---|
| [85d278] | 31 | #define EnergyFragmentSuffix ".energyfragment.all"
 | 
|---|
| [14de469] | 32 | #define ForcesSuffix ".forces.all"
 | 
|---|
| [85d278] | 33 | #define ForceFragmentSuffix ".forcefragment.all"
 | 
|---|
 | 34 | #define HcorrectionSuffix ".Hcorrection.all"
 | 
|---|
 | 35 | #define HcorrectionFragmentSuffix ".Hcorrectionfragment.all"
 | 
|---|
 | 36 | #define HessianSuffix ".hessian_xx.all"
 | 
|---|
 | 37 | #define HessianFragmentSuffix ".hessianfragment_xx.all"
 | 
|---|
 | 38 | #define OrderSuffix ".Order"
 | 
|---|
| [68cb0f] | 39 | #define ShieldingSuffix ".sigma_all.csv"
 | 
|---|
 | 40 | #define ShieldingPASSuffix ".sigma_all_PAS.csv"
 | 
|---|
 | 41 | #define ShieldingFragmentSuffix ".sigma_all_fragment.all"
 | 
|---|
 | 42 | #define ShieldingPASFragmentSuffix ".sigma_all_PAS_fragment.all"
 | 
|---|
| [674220] | 43 | #define ChiSuffix ".chi_all.csv"
 | 
|---|
 | 44 | #define ChiPASSuffix ".chi_all_PAS.csv"
 | 
|---|
 | 45 | #define ChiFragmentSuffix ".chi_all_fragment.all"
 | 
|---|
 | 46 | #define ChiPASFragmentSuffix ".chi_all_PAS_fragment.all"
 | 
|---|
| [14de469] | 47 | #define TimeSuffix ".speed"
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | // ======================================= FUNCTIONS ==========================================
 | 
|---|
 | 50 | 
 | 
|---|
| [68cb0f] | 51 | bool FilePresent(const char *filename, bool test);
 | 
|---|
| [14de469] | 52 | bool TestParams(int argc, char **argv);
 | 
|---|
 | 53 | 
 | 
|---|
| [f66195] | 54 | // ======================================= CLASS KeySetsContainer =============================
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 | class KeySetsContainer {
 | 
|---|
 | 57 |   public:
 | 
|---|
 | 58 |     int **KeySets;
 | 
|---|
 | 59 |     int *AtomCounter;
 | 
|---|
 | 60 |     int FragmentCounter;
 | 
|---|
 | 61 |     int Order;
 | 
|---|
 | 62 |     int *FragmentsPerOrder;
 | 
|---|
 | 63 |     int **OrderSet;
 | 
|---|
 | 64 | 
 | 
|---|
 | 65 |   KeySetsContainer();
 | 
|---|
 | 66 |   ~KeySetsContainer();
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 |   bool ParseKeySets(const char *name, const int *ACounter, const int FCounter);
 | 
|---|
 | 69 |   bool ParseManyBodyTerms();
 | 
|---|
 | 70 |   bool Contains(const int GreaterSet, const int SmallerSet);
 | 
|---|
 | 71 | };
 | 
|---|
| [6dea43] | 72 | 
 | 
|---|
| [14de469] | 73 | // ======================================= CLASS MatrixContainer =============================
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 | class MatrixContainer {
 | 
|---|
| [042f82] | 76 |   public:
 | 
|---|
 | 77 |     double ***Matrix;
 | 
|---|
 | 78 |     int **Indices;
 | 
|---|
| [b12a35] | 79 |     char **Header;
 | 
|---|
| [042f82] | 80 |     int MatrixCounter;
 | 
|---|
 | 81 |     int *RowCounter;
 | 
|---|
| [f731ae] | 82 |     int *ColumnCounter;
 | 
|---|
| [14de469] | 83 |   
 | 
|---|
| [042f82] | 84 |   MatrixContainer();
 | 
|---|
| [ab1932] | 85 |   virtual ~MatrixContainer();
 | 
|---|
| [14de469] | 86 |   
 | 
|---|
| [f731ae] | 87 |   bool InitialiseIndices(class MatrixContainer *Matrix = NULL);
 | 
|---|
| [4e855e] | 88 |   bool ParseMatrix(std::istream &input, int skiplines, int skipcolumns, int MatrixNr);
 | 
|---|
| [042f82] | 89 |   virtual bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
 | 
|---|
| [b12a35] | 90 |   bool AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter);
 | 
|---|
| [042f82] | 91 |   bool ResetMatrix();
 | 
|---|
 | 92 |   double FindMinValue();
 | 
|---|
 | 93 |   double FindMaxValue();
 | 
|---|
 | 94 |   bool SetLastMatrix(double value, int skipcolumns);
 | 
|---|
 | 95 |   bool SetLastMatrix(double **values, int skipcolumns);
 | 
|---|
 | 96 |   //bool ParseIndices();
 | 
|---|
 | 97 |   //bool SumSubValues();
 | 
|---|
| [f66195] | 98 |   bool SumSubManyBodyTerms(class MatrixContainer &Matrix, class KeySetsContainer &KeySets, int Order);
 | 
|---|
| [042f82] | 99 |   bool WriteTotalFragments(const char *name, const char *prefix);
 | 
|---|
 | 100 |   bool WriteLastMatrix(const char *name, const char *prefix, const char *suffix);
 | 
|---|
| [6ac7ee] | 101 | };
 | 
|---|
| [14de469] | 102 | 
 | 
|---|
| [b23e26] | 103 | std::ostream & operator << (std::ostream &ost, const MatrixContainer &m);
 | 
|---|
 | 104 | 
 | 
|---|
| [14de469] | 105 | // ======================================= CLASS EnergyMatrix =============================
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 | class EnergyMatrix : public MatrixContainer {
 | 
|---|
| [042f82] | 108 |   public:
 | 
|---|
 | 109 |     bool ParseIndices();
 | 
|---|
| [f66195] | 110 |     bool SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySets, int Order, double sign);
 | 
|---|
| [042f82] | 111 |     bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
 | 
|---|
| [14de469] | 112 | };
 | 
|---|
 | 113 | 
 | 
|---|
 | 114 | // ======================================= CLASS ForceMatrix =============================
 | 
|---|
 | 115 | 
 | 
|---|
 | 116 | class ForceMatrix : public MatrixContainer {
 | 
|---|
| [042f82] | 117 |   public:
 | 
|---|
 | 118 |     bool ParseIndices(const char *name);
 | 
|---|
| [f66195] | 119 |     bool SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign);
 | 
|---|
| [042f82] | 120 |     bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
 | 
|---|
| [14de469] | 121 | };
 | 
|---|
 | 122 | 
 | 
|---|
| [85d278] | 123 | // ======================================= CLASS HessianMatrix =============================
 | 
|---|
 | 124 | 
 | 
|---|
| [b12a35] | 125 | class HessianMatrix : public MatrixContainer { 
 | 
|---|
| [85d278] | 126 |   public: 
 | 
|---|
| [b12a35] | 127 |     HessianMatrix();
 | 
|---|
 | 128 |     //~HessianMatrix();
 | 
|---|
| [85d278] | 129 |     bool ParseIndices(char *name);
 | 
|---|
| [f66195] | 130 |     bool SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order);
 | 
|---|
 | 131 |     bool SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign);
 | 
|---|
| [36ec71] | 132 |     bool ParseFragmentMatrix(const char *name, const char *prefix, string suffix, int skiplines, int skipcolumns);
 | 
|---|
| [b12a35] | 133 |   private:
 | 
|---|
 | 134 |     bool IsSymmetric;
 | 
|---|
| [85d278] | 135 | };
 | 
|---|
 | 136 | 
 | 
|---|
| [14de469] | 137 | 
 | 
|---|
 | 138 | // ======================================= END =============================================
 | 
|---|
 | 139 | 
 | 
|---|
| [f66195] | 140 | #endif /*PARSER_HPP_*/
 | 
|---|