1 /* Ergo, version 3.8, a program for linear scaling electronic structure 2 * calculations. 3 * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 4 * and Anastasia Kruchinina. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * Primary academic reference: 20 * Ergo: An open-source program for linear-scaling electronic structure 21 * calculations, 22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 23 * Kruchinina, 24 * SoftwareX 7, 107 (2018), 25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 26 * 27 * For further information about Ergo, see <http://www.ergoscf.org>. 28 */ 29 30 /** @file box_system.h 31 32 @brief BoxSystem class representing a hierarchical data structure 33 of boxes in 3D space (an oct-tree). 34 35 @author: Elias Rudberg <em>responsible</em> 36 */ 37 38 #ifndef BOX_SYSTEM_HEADER 39 #define BOX_SYSTEM_HEADER 40 41 42 #include "realtype.h" 43 44 45 typedef struct 46 { 47 ergo_real centerCoords[3]; 48 int originalIndex; 49 } box_item_struct; 50 51 52 typedef struct 53 { 54 ergo_real centerCoords[3]; 55 ergo_real width; 56 int noOfItems; 57 int firstItemIndex; 58 int noOfChildBoxes; 59 int firstChildBoxIndex; 60 } box_struct_basic; 61 62 typedef struct 63 { 64 int noOfBoxes; 65 int startIndexInBoxList; 66 } box_level_struct; 67 68 #define MAX_NO_OF_BOX_LEVELS 30 69 70 class BoxSystem 71 { 72 public: 73 int totNoOfBoxes; 74 int noOfLevels; 75 box_level_struct levelList[MAX_NO_OF_BOX_LEVELS]; 76 box_struct_basic* boxList; 77 BoxSystem(); 78 ~BoxSystem(); 79 int create_box_system(box_item_struct* itemList, 80 int noOfItems, 81 ergo_real toplevelBoxSize); 82 int get_items_near_point(const box_item_struct* itemList, 83 const ergo_real* coords, 84 ergo_real distance, 85 int* resultOrgIndexList) const; 86 private: 87 int get_items_near_point_recursive(const box_item_struct* itemList, 88 const ergo_real* coords, 89 ergo_real distance, 90 int* resultOrgIndexList, 91 int level, 92 int boxIndex) const; 93 }; 94 95 ergo_real 96 get_min_distance_from_point_to_box(const ergo_real* boxCenterCoords, 97 ergo_real halfwidth, 98 const ergo_real* point); 99 100 101 102 #endif 103