Commit d8b47d8f authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Small changes

parent 639f286f
...@@ -24,7 +24,8 @@ namespace AMDiS { ...@@ -24,7 +24,8 @@ namespace AMDiS {
{ NULL, { NULL,
NEW Line(NULL), NEW Line(NULL),
NEW Triangle(NULL), NEW Triangle(NULL),
NEW Tetrahedron(NULL) }; NEW Tetrahedron(NULL)
};
void Msg::wait(bool w) void Msg::wait(bool w)
{ {
...@@ -43,7 +44,7 @@ namespace AMDiS { ...@@ -43,7 +44,7 @@ namespace AMDiS {
FUNCNAME("Msg::change_out()"); FUNCNAME("Msg::change_out()");
if (fp) { if (fp) {
if (out && *out != ::std::cout && *out != ::std::cerr) { if (out && *out != ::std::cout && *out != ::std::cerr) {
dynamic_cast< ::std::ofstream*>(out)->close(); dynamic_cast< ::std::ofstream*>(out)->close();
delete out; delete out;
} }
......
...@@ -444,7 +444,6 @@ namespace AMDiS { ...@@ -444,7 +444,6 @@ namespace AMDiS {
*/ */
static const Element *getReferenceElement(int dim) { static const Element *getReferenceElement(int dim) {
FUNCNAME("Global::getReferenceElement()"); FUNCNAME("Global::getReferenceElement()");
initTest();
TEST_EXIT((dim > 0) && (dim < 4))("invalid dim: %d\n", dim); TEST_EXIT((dim > 0) && (dim < 4))("invalid dim: %d\n", dim);
return referenceElement[dim]; return referenceElement[dim];
}; };
...@@ -453,7 +452,6 @@ namespace AMDiS { ...@@ -453,7 +452,6 @@ namespace AMDiS {
* returns geometrical information. Currently this is only dimOfWorld. * returns geometrical information. Currently this is only dimOfWorld.
*/ */
static inline int getGeo(GeoIndex p) { static inline int getGeo(GeoIndex p) {
initTest();
if (WORLD == p) if (WORLD == p)
return dimOfWorld; return dimOfWorld;
...@@ -466,7 +464,6 @@ namespace AMDiS { ...@@ -466,7 +464,6 @@ namespace AMDiS {
* getGeo(VERTEX, 3) returns 4 because a Tetrahedron has 4 vertices. * getGeo(VERTEX, 3) returns 4 because a Tetrahedron has 4 vertices.
*/ */
static inline int getGeo(GeoIndex p, int dim) { static inline int getGeo(GeoIndex p, int dim) {
initTest();
TEST_EXIT_DBG((p >= MINPART) && (p <= MAXPART)) TEST_EXIT_DBG((p >= MINPART) && (p <= MAXPART))
("Calling for invalid geometry value %d\n",p); ("Calling for invalid geometry value %d\n",p);
TEST_EXIT_DBG((dim >= 0) && (dim < 4)) TEST_EXIT_DBG((dim >= 0) && (dim < 4))
...@@ -477,25 +474,17 @@ namespace AMDiS { ...@@ -477,25 +474,17 @@ namespace AMDiS {
return geoIndexTable[dim][p - MINPART]; return geoIndexTable[dim][p - MINPART];
} }
private:
/** \brief
* Global is a pure static class. So the constructor is private to avoid
* instantiation.
*/
Global();
/** \brief /** \brief
* inits the Global class with the help of Parameters. * inits the Global class with the help of Parameters.
*/ */
static void init(); static void init();
private:
/** \brief /** \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() { Global();
if (dimOfWorld == 0)
init();
};
private: private:
/** \brief /** \brief
...@@ -512,6 +501,9 @@ namespace AMDiS { ...@@ -512,6 +501,9 @@ namespace AMDiS {
*/ */
static Element *referenceElement[4]; static Element *referenceElement[4];
/** \brief
* Stores the precalculated results that should be returned by Global::getGeo.
*/
static ::std::vector< ::std::vector< int > > geoIndexTable; static ::std::vector< ::std::vector< int > > geoIndexTable;
}; };
......
...@@ -565,13 +565,14 @@ namespace AMDiS { ...@@ -565,13 +565,14 @@ namespace AMDiS {
initIntern(); initIntern();
if (0 == fn.size()) { if (0 == fn.size()) {
Global::init();
return; return;
} }
if (NULL == flags) { if (NULL == flags) {
singlett->read(fn); singlett->read(fn);
} else { } else {
singlett->inputFile.open(fn.data(),::std::ios::in); singlett->inputFile.open(fn.data(), ::std::ios::in);
if (!(singlett->inputFile.rdstate())) { if (!(singlett->inputFile.rdstate())) {
ERROR("can not read from file %s\n", fn.data()); ERROR("can not read from file %s\n", fn.data());
return; return;
...@@ -676,6 +677,7 @@ namespace AMDiS { ...@@ -676,6 +677,7 @@ namespace AMDiS {
if (p && singlett->msgInfo) if (p && singlett->msgInfo)
printParameters(); printParameters();
Global::init();
return; return;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment