00001 // expde: expression templates for partial differential equations. 00002 // Copyright (C) 2001 Christoph Pflaum 00003 // This program is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // SEE Notice1.doc made by 00014 // LAWRENCE LIVERMORE NATIONAL LABORATORY 00015 // 00016 00017 // ------------------------------------------------------------ 00018 // 00019 // sto_man.h 00020 // 00021 // ------------------------------------------------------------ 00022 00023 #ifndef STOMAN_H_ 00024 #define STOMAN_H_ 00025 00027 // Storage Manager 00029 00030 00031 //----------------------------------------- 00032 // storage structure of cell informations: 00033 // 1. cell variable -> begin with: 0 00034 // 2. stencils -> use: cell_number_of_stencil(int num) 00035 // 3. boundary sencils -> use: cell_number_of_bo_stencil(int num) 00036 00037 // A few member functions of the following class 00038 // are contained in labbo.cc 00039 00040 class Storage_manager { 00041 public: 00042 Storage_manager() : label_initialize(false), max_num_var(0), 00043 max_num_bo_stencil(0), max_num_stencil(0), 00044 max_num_coarse_stencil(0), 00045 max_num_var_cell(0), 00046 max_num_label(0) { 00047 for(int i=0;i<Max_label_number;++i) occupied[i] = false; 00048 }; 00049 00050 // Give a new storage number 00051 int Give_number_variable(); // storage number for points 00052 int Give_number_bo_stencil(); // |-> for a boundary stencil 00053 int Give_number_stencil(); // |-> for a stencil 00054 int Give_number_cell_variable(); // storage number for cell point 00055 00056 // Give or delete a label number 00057 int Give_number_label_bo(); // Erzeuge neue Labelnummer 00058 void Remove_number_label_bo(int num); // Streiche Labelnummer 00059 00060 // Was storage initialized? 00061 bool Is_storage_initialized(); 00062 00063 // transformation of the numbers 00064 int cell_number_of_bo_stencil(int num) const; 00065 int cell_number_of_stencil(int num) const; 00066 00067 protected: 00068 // Initialization is done 00069 void Storge_initialization_done(); 00070 00071 // Give maximal storage number 00072 int Give_max_num_var(); // for points 00073 int Give_max_num_cell_var(); // for cell variables 00074 int Give_max_num_coarse_int_cells(); // for coarse interior cells 00075 int Give_max_num_bo_cells(); // for coares boundary cells 00076 int Give_max_num_fine_all_cells(); // for all fine cells 00077 int Give_max_num_label(); // for labels 00078 int Give_max_num_matrices_bo(); // for boundary matrices 00079 bool Give_increase_max_num_label(); // for labels 00080 void No_increase_max_num_label(); // for labels 00081 00082 private: 00083 bool label_initialize; // Initialisierung dieser Speicher schon gemacht? 00084 00085 // Verwaltung der Datenspeicher: 00086 // Anzahl der double's die in einem Punkt oder Zelle oder so 00087 // gespeichert werden 00088 00089 // a) Number of storage for points (for Variable) 00090 int max_num_var; 00091 // b) Number of storage for a stencil near the boundary 00092 // (at coarse boundary cells) ( -> for Res_stencil_boundary) 00093 // each requires 64 doubles 00094 int max_num_bo_stencil; 00095 // c) Number of storage for a stencil near the boundary and coarse int cells 00096 // (at coarse boundary cells) ( -> for Res_stencil) 00097 // each requires 64 doubles 00098 int max_num_stencil; 00099 // d) Number of storage for a stencil on coarse cells 00100 int max_num_coarse_stencil; 00101 // e) Number of storage for cell variables 00102 int max_num_var_cell; 00103 // f) labels at the boundary. Which labes are occupied: 00104 bool occupied[Max_label_number]; 00105 int max_num_label; 00106 bool increase_max_num_label; 00107 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00108 }; 00109 00110 00111 inline int Storage_manager::Give_number_variable() { 00112 ++max_num_var; 00113 return max_num_var-1; 00114 } 00115 inline int Storage_manager::Give_number_cell_variable() { 00116 ++max_num_var_cell; 00117 return max_num_var_cell-1; 00118 } 00119 00120 00121 inline int Storage_manager::Give_number_bo_stencil() { 00122 ++max_num_bo_stencil; 00123 return max_num_bo_stencil-1; 00124 } 00125 00126 inline int Storage_manager::Give_number_stencil() { 00127 ++max_num_stencil; 00128 return max_num_stencil-1; 00129 } 00130 00131 inline bool Storage_manager::Give_increase_max_num_label() { 00132 return increase_max_num_label; 00133 } 00134 00135 inline void Storage_manager::No_increase_max_num_label() { 00136 increase_max_num_label = false; 00137 } 00138 00139 inline int Storage_manager::Give_max_num_label() { 00140 return max_num_label; 00141 } 00142 inline int Storage_manager::Give_max_num_var() { 00143 return max_num_var; 00144 } 00145 inline int Storage_manager::Give_max_num_cell_var() { 00146 return max_num_var_cell; 00147 } 00148 00149 inline int Storage_manager::Give_max_num_bo_cells() { 00150 return (max_num_bo_stencil+max_num_stencil) * 64 + max_num_var_cell; 00151 } 00152 00153 inline int Storage_manager::Give_max_num_matrices_bo() { 00154 return max_num_bo_stencil+max_num_stencil; 00155 } 00156 00157 inline int Storage_manager::Give_max_num_coarse_int_cells() { 00158 return max_num_stencil * 64 + max_num_var_cell; 00159 } 00160 00161 inline int Storage_manager::Give_max_num_fine_all_cells() { 00162 return max_num_var_cell; 00163 } 00164 00165 //----- 00166 // transformation of the numbers 00167 inline int Storage_manager::cell_number_of_bo_stencil(int num) const { 00168 return max_num_var_cell + (max_num_stencil+num) * 64; 00169 } 00170 00171 inline int Storage_manager::cell_number_of_stencil(int num) const { 00172 return max_num_var_cell + num * 64; 00173 } 00174 //----- 00175 00176 inline void Storage_manager::Storge_initialization_done() { 00177 label_initialize = true; 00178 } 00179 00180 inline bool Storage_manager::Is_storage_initialized() { 00181 return label_initialize; 00182 } 00183 00184 #endif 00185