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
00029
00038 #ifndef INTEGRALS_1EL_POTENTIAL_PREP_HEADER
00039 #define INTEGRALS_1EL_POTENTIAL_PREP_HEADER
00040
00041 #include "basisinfo.h"
00042 #include <algorithm>
00043
00044 struct DistributionSpecStructWithIndexes2 {
00045 DistributionSpecStruct distr;
00046 int basisFuncIdx1;
00047 int basisFuncIdx2;
00048 };
00049
00050 struct group_struct {
00051 int startIndex;
00052 int count;
00053 int maxNoOfMoments;
00054 int maxDegree;
00055 ergo_real maxExtent;
00056 };
00057
00058 struct maxMomentVectorNormStruct {
00059 ergo_real maxMomentVectorNormList[MAX_MULTIPOLE_DEGREE_BASIC+1];
00060 };
00061
00062 struct SetOfDistrsForVInfo {
00063 ergo_real maxExtentForAll;
00064 maxMomentVectorNormStruct maxMomentVectorNormForAll;
00065 ergo_real boundingCubeCenterCoords[3];
00066 ergo_real boundingCubeWidth;
00067 };
00068
00069 struct SetOfDistrsForV {
00070 std::vector<DistributionSpecStructWithIndexes2> distrList;
00071 std::vector<multipole_struct_small> multipoleList;
00072 std::vector<group_struct> groupList;
00073 std::vector<maxMomentVectorNormStruct> maxMomentVectorNormList;
00074 SetOfDistrsForVInfo info;
00075
00076 SetOfDistrsForV();
00077 SetOfDistrsForV(const SetOfDistrsForV & other);
00078 void write_to_buffer ( char * dataBuffer, size_t const bufferSize ) const;
00079 size_t get_size() const;
00080 void assign_from_buffer ( char const * dataBuffer, size_t const bufferSize);
00081 };
00082
00083 void
00084 organize_distrs_for_V(const IntegralInfo & integralInfo,
00085 SetOfDistrsForV & setOfDistrsForV,
00086 const std::vector<DistributionSpecStructWithIndexes2> & inputList,
00087 ergo_real threshold,
00088 ergo_real maxCharge);
00089
00090 template <typename DistributionSpecStructType>
00091 int
00092 compare_distrs(const void* p1, const void* p2) {
00093 DistributionSpecStructType* d1 = (DistributionSpecStructType*)p1;
00094 DistributionSpecStructType* d2 = (DistributionSpecStructType*)p2;
00095
00096 const ergo_real tolernance_dist = 1e-10;
00097 const ergo_real tolernance_exponent = 1e-11;
00098 ergo_real dx = d1->distr.centerCoords[0] - d2->distr.centerCoords[0];
00099 if(dx > tolernance_dist)
00100 return 1;
00101 if(dx < -tolernance_dist)
00102 return -1;
00103 ergo_real dy = d1->distr.centerCoords[1] - d2->distr.centerCoords[1];
00104 if(dy > tolernance_dist)
00105 return 1;
00106 if(dy < -tolernance_dist)
00107 return -1;
00108 ergo_real dz = d1->distr.centerCoords[2] - d2->distr.centerCoords[2];
00109 if(dz > tolernance_dist)
00110 return 1;
00111 if(dz < -tolernance_dist)
00112 return -1;
00113 ergo_real de = d1->distr.exponent - d2->distr.exponent;
00114 if(de > tolernance_exponent)
00115 return 1;
00116 if(de < -tolernance_exponent)
00117 return -1;
00118 return 0;
00119 }
00120
00121 template <typename DistributionSpecStructType>
00122 bool
00123 compare_distrs_bool(const DistributionSpecStructType & p1, const DistributionSpecStructType & p2) {
00124 int i = compare_distrs<DistributionSpecStructType>(&p1, &p2);
00125 return (i == 1);
00126 }
00127
00128 template <typename DistributionSpecStructType>
00129 int
00130 sort_distr_list(DistributionSpecStructType* list, int n) {
00131 std::sort(&list[0], &list[n], compare_distrs_bool<DistributionSpecStructType>);
00132 return 0;
00133 }
00134
00135 #endif