$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

globalDefs.h

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00028 #ifndef GLOBAL_DEFS_H
00029 #define GLOBAL_DEFS_H
00030 
00031 #ifdef PLB_MPI_PARALLEL
00032 #include "mpi.h"
00033 #endif
00034 
00035 #include <limits>
00036 #include <string>
00037 #include <cstddef>
00038 
00039 namespace plb {
00040 
00042 
00046 #ifdef PLB_BGP
00047 typedef long long int plint;
00048 #else
00049 typedef ptrdiff_t plint;
00050 #endif
00051 
00053 
00057 #ifdef PLB_BGP
00058 typedef unsigned long long int pluint;
00059 #else
00060 typedef size_t pluint;
00061 #endif
00062 
00064 typedef unsigned long id_t;
00065 
00070 enum Precision { FLT, DBL, LDBL };
00071 
00072 template<typename T>
00073 inline T getEpsilon(Precision precision)
00074 {
00075     T epsilon;
00076 
00077     switch (precision) {
00078     case FLT:
00079         epsilon = std::numeric_limits<float>::epsilon();
00080         break;
00081     case DBL:
00082         epsilon = std::numeric_limits<double>::epsilon();
00083         break;
00084     case LDBL: default:
00085         epsilon = std::numeric_limits<long double>::epsilon();
00086         break;
00087     }
00088 
00089     T coef = 10.0; // hack for better results
00090 
00091     return (coef * epsilon);
00092 }
00093 
00096 enum SurfaceGeometryFileFormat { STL };
00097 
00099 
00111 namespace IndexOrdering {
00112     enum OrderingT {forward, backward, memorySaving};
00113 }
00114 
00116 
00121 namespace BlockDomain {
00122 
00123     enum DomainT {bulk, envelope, bulkAndEnvelope};
00124     inline bool usesEnvelope(DomainT domain) {
00125         return domain==envelope || domain==bulkAndEnvelope;
00126     }
00127 
00128 }
00129 
00130 namespace modif {
00131 
00134     enum ModifT {
00135         nothing          =0,  //< No modification.
00136         staticVariables  =1,  //< Static cell content (populations+externals).
00137         dynamicVariables =2,  //< Only content of dynamics objects, but no static content.
00138         allVariables     =3,  //< Both the static and dynamic cell content.
00139         dataStructure    =4,  //< Recreate dynamics and copy both static and dynamic content.
00140         undefined        =5   //< Used for debugging purposes only.
00141     };
00142 
00143     enum { numConstants=5 };
00144 
00147     inline ModifT combine(ModifT type1, ModifT type2) {
00148         ModifT result = std::max(type1, type2);
00149         // Note: static+dynamic = all.
00150         if ( result==dynamicVariables &&
00151              (type1==staticVariables || type2==staticVariables) )
00152         {
00153             result = allVariables;
00154         }
00155         return result;
00156     }
00157 }
00158 
00159 namespace global {
00160 
00161 class IOpolicyClass {
00162 public:
00163     void setIndexOrderingForStreams(IndexOrdering::OrderingT streamOrdering_);
00164     IndexOrdering::OrderingT getIndexOrderingForStreams() const;
00165 
00166     void setEndianSwitchOnBase64out(bool doSwitch);
00167     bool getEndianSwitchOnBase64out();
00168 
00169     void setEndianSwitchOnBase64in(bool doSwitch);
00170     bool getEndianSwitchOnBase64in();
00171 
00172     void setStlFilesHaveLowerBound(bool flag);
00173     bool stlFilesHaveLowerBound() const;
00174 
00175     void setLowerBoundForStlFiles(double stlLowerBound_);
00176     double getLowerBoundForStlFiles() const;
00177 
00178     void activateParallelIO(bool activate);
00179     bool useParallelIO() const;
00180 private:
00181     IOpolicyClass();
00182 private:
00183     IndexOrdering::OrderingT streamOrdering;
00184     bool endianSwitchOnBase64out;
00185     bool endianSwitchOnBase64in;
00186     bool stlLowerBoundFlag;
00187     double stlLowerBound;
00188     bool parallelIOflag;
00189     friend IOpolicyClass& IOpolicy();
00190 };
00191     
00192 class Directories {
00193 public:
00195     void setOutputDir(std::string outputDir_);
00197     void setLogOutDir(std::string logOutDir_);
00199     void setImageOutDir(std::string imageOutDir_);
00201     void setVtkOutDir(std::string inputDir_);
00203     void setInputDir(std::string inputDir);
00204 
00206     std::string getLogOutDir() const;
00208     std::string getImageOutDir() const;
00210     std::string getVtkOutDir() const;
00212     std::string getInputDir() const;
00214     std::string getOutputDir() const;
00215 private:
00216     Directories();
00217 private:
00218     std::string logOutDir;
00219     std::string imageOutDir;
00220     std::string vtkOutDir;
00221     std::string inputDir;
00222     std::string outputDir;
00223 friend Directories& directories();
00224 };
00225 
00226 inline Directories& directories() {
00227     static Directories singleton;
00228     return singleton;
00229 }
00230 
00231 inline IOpolicyClass& IOpolicy() {
00232     static IOpolicyClass singleton;
00233     return singleton;
00234 }
00235 
00236 }  // namespace global
00237 
00238 }  // namespace plb
00239 
00240 #endif