diff --git a/AMDiS/src/Global.cc b/AMDiS/src/Global.cc index 1b80f9f491ca333c7a3d8e8cf608386dccf69d28..ab243aa5d74f1793eda710cfa37fdf710225298f 100644 --- a/AMDiS/src/Global.cc +++ b/AMDiS/src/Global.cc @@ -24,7 +24,8 @@ namespace AMDiS { { NULL, NEW Line(NULL), NEW Triangle(NULL), - NEW Tetrahedron(NULL) }; + NEW Tetrahedron(NULL) + }; void Msg::wait(bool w) { @@ -43,7 +44,7 @@ namespace AMDiS { FUNCNAME("Msg::change_out()"); if (fp) { - if (out && *out != ::std::cout && *out != ::std::cerr) { + if (out && *out != ::std::cout && *out != ::std::cerr) { dynamic_cast< ::std::ofstream*>(out)->close(); delete out; } diff --git a/AMDiS/src/Global.h b/AMDiS/src/Global.h index 9cf7fae19035f85094d9087e779e2732cd968790..b189b114f3620a12a44e066f76438bca5a7edc69 100644 --- a/AMDiS/src/Global.h +++ b/AMDiS/src/Global.h @@ -444,7 +444,6 @@ namespace AMDiS { */ static const Element *getReferenceElement(int dim) { FUNCNAME("Global::getReferenceElement()"); - initTest(); TEST_EXIT((dim > 0) && (dim < 4))("invalid dim: %d\n", dim); return referenceElement[dim]; }; @@ -453,7 +452,6 @@ namespace AMDiS { * returns geometrical information. Currently this is only dimOfWorld. */ static inline int getGeo(GeoIndex p) { - initTest(); if (WORLD == p) return dimOfWorld; @@ -466,7 +464,6 @@ namespace AMDiS { * getGeo(VERTEX, 3) returns 4 because a Tetrahedron has 4 vertices. */ static inline int getGeo(GeoIndex p, int dim) { - initTest(); TEST_EXIT_DBG((p >= MINPART) && (p <= MAXPART)) ("Calling for invalid geometry value %d\n",p); TEST_EXIT_DBG((dim >= 0) && (dim < 4)) @@ -477,25 +474,17 @@ namespace AMDiS { return geoIndexTable[dim][p - MINPART]; } - private: - /** \brief - * Global is a pure static class. So the constructor is private to avoid - * instantiation. - */ - Global(); - /** \brief * inits the Global class with the help of Parameters. */ static void init(); + private: /** \brief - * calls init if Global is not yet initialized. + * Global is a pure static class. So the constructor is private to avoid + * instantiation. */ - static inline void initTest() { - if (dimOfWorld == 0) - init(); - }; + Global(); private: /** \brief @@ -512,6 +501,9 @@ namespace AMDiS { */ static Element *referenceElement[4]; + /** \brief + * Stores the precalculated results that should be returned by Global::getGeo. + */ static ::std::vector< ::std::vector< int > > geoIndexTable; }; diff --git a/AMDiS/src/Parameters.cc b/AMDiS/src/Parameters.cc index 217b0bc0de1d70ed5ebc4219d6dd30f10f103e80..e36a8e2e73a68b2189a93102f9f53bc87380cdbf 100644 --- a/AMDiS/src/Parameters.cc +++ b/AMDiS/src/Parameters.cc @@ -565,13 +565,14 @@ namespace AMDiS { initIntern(); if (0 == fn.size()) { + Global::init(); return; } if (NULL == flags) { singlett->read(fn); } else { - singlett->inputFile.open(fn.data(),::std::ios::in); + singlett->inputFile.open(fn.data(), ::std::ios::in); if (!(singlett->inputFile.rdstate())) { ERROR("can not read from file %s\n", fn.data()); return; @@ -676,6 +677,7 @@ namespace AMDiS { if (p && singlett->msgInfo) printParameters(); + Global::init(); return; }