diff --git a/CMakeLists.txt b/CMakeLists.txt index c8310260e..a15044324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,87 +1,87 @@ #=========================================================================== # @file CMakeLists.txt # @author Nicolas Richart # @date Fri Jun 11 09:46:59 2010 # # @section LICENSE # # # # @section DESCRIPTION # #=========================================================================== #=========================================================================== # CMake Project #=========================================================================== cmake_minimum_required(VERSION 2.6) -project(MYFEM) +project(AKANTU) enable_language(CXX) #=========================================================================== # Misc. #=========================================================================== -set(MYFEM_CMAKE_DIR "${MYFEM_SOURCE_DIR}/cmake") +set(AKANTU_CMAKE_DIR "${AKANTU_SOURCE_DIR}/cmake") set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") #=========================================================================== # Version Number #=========================================================================== -# MYFEM version number. An even minor number corresponds to releases. -set(MYFEM_MAJOR_VERSION 0) -set(MYFEM_MINOR_VERSION 1) -set(MYFEM_BUILD_VERSION 0) -set(MYFEM_VERSION - "${MYFEM_MAJOR_VERSION}.${MYFEM_MINOR_VERSION}.${MYFEM_BUILD_VERSION}" +# AKANTU version number. An even minor number corresponds to releases. +set(AKANTU_MAJOR_VERSION 0) +set(AKANTU_MINOR_VERSION 1) +set(AKANTU_BUILD_VERSION 0) +set(AKANTU_VERSION + "${AKANTU_MAJOR_VERSION}.${AKANTU_MINOR_VERSION}.${AKANTU_BUILD_VERSION}" ) # Append the library version information to the library target properties -if(NOT MYFEM_NO_LIBRARY_VERSION) - set(MYFEM_LIBRARY_PROPERTIES ${MYFEM_LIBRARY_PROPERTIES} - VERSION "${MYFEM_VERSION}" - SOVERSION "${MYFEM_MAJOR_VERSION}.${MYFEM_MINOR_VERSION}" +if(NOT AKANTU_NO_LIBRARY_VERSION) + set(AKANTU_LIBRARY_PROPERTIES ${AKANTU_LIBRARY_PROPERTIES} + VERSION "${AKANTU_VERSION}" + SOVERSION "${AKANTU_MAJOR_VERSION}.${AKANTU_MINOR_VERSION}" ) -endif(NOT MYFEM_NO_LIBRARY_VERSION) +endif(NOT AKANTU_NO_LIBRARY_VERSION) #=========================================================================== # Library #=========================================================================== -#add_definitions(-DMYFEM_NDEBUG) +#add_definitions(-DAKANTU_NDEBUG) -set(MYFEM_COMMON_SRC +set(AKANTU_COMMON_SRC common/extern.cc common/static_memory.cc common/memory.cc fem/mesh.cc mesh_io/mesh_io_msh.cc ) include_directories( common fem/ mesh_io/ ) -add_library(myfem ${MYFEM_COMMON_SRC}) -set_target_properties(myfem PROPERTIES ${MYFEM_LIBRARY_PROPERTIES}) +add_library(akantu ${AKANTU_COMMON_SRC}) +set_target_properties(akantu PROPERTIES ${AKANTU_LIBRARY_PROPERTIES}) #=========================================================================== # Tests #=========================================================================== option(BUILD_UNIT_TEST "Build the unit test") if(BUILD_UNIT_TEST) add_executable(test_static_memory test/static_memory.cc) - target_link_libraries(test_static_memory myfem) + target_link_libraries(test_static_memory akantu) endif(BUILD_UNIT_TEST) \ No newline at end of file diff --git a/common/common.hh b/common/common.hh index 4662724f8..c8f807418 100644 --- a/common/common.hh +++ b/common/common.hh @@ -1,73 +1,73 @@ /** * @file common.hh * @author Nicolas Richart * @date Fri Jun 11 09:48:06 2010 * * @section LICENSE * * * * @section DESCRIPTION * * All common things to be included in the projects files * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_COMMON_HH__ -#define __MYFEM_COMMON_HH__ +#ifndef __AKANTU_COMMON_HH__ +#define __AKANTU_COMMON_HH__ /* -------------------------------------------------------------------------- */ #include #include #include #include /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ -#define __BEGIN_MYFEM__ namespace myfem { -#define __END_MYFEM__ }; +#define __BEGIN_AKANTU__ namespace akantu { +#define __END_AKANTU__ }; /* -------------------------------------------------------------------------- */ #include "error.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* Memory types */ /* -------------------------------------------------------------------------- */ typedef unsigned int MemoryID; typedef std::string VectorID; -__END_MYFEM__ +__END_AKANTU__ /* -------------------------------------------------------------------------- */ /* Global defines */ /* -------------------------------------------------------------------------- */ -#define MYFEM_MIN_ALLOCATION 2000 +#define AKANTU_MIN_ALLOCATION 2000 -#define MYFEM_INDENT " " +#define AKANTU_INDENT " " #define MAX_NUMBER_OF_NODE_PER_ELEMENT 10 // tetrahedron of second order /* -------------------------------------------------------------------------- */ -#define MYFEM_SET_MACRO(name, variable, type) \ +#define AKANTU_SET_MACRO(name, variable, type) \ inline void set##name (type variable) { \ this->variable = variable; \ } -#define MYFEM_GET_MACRO(name, variable, type) \ +#define AKANTU_GET_MACRO(name, variable, type) \ inline const type get##name () const { \ return this->variable; \ } -#endif /* __MYFEM_COMMON_HH__ */ +#endif /* __AKANTU_COMMON_HH__ */ diff --git a/common/error.hh b/common/error.hh index 992d6d1ae..662773889 100644 --- a/common/error.hh +++ b/common/error.hh @@ -1,178 +1,178 @@ /** * @file error.hh * @author Nicolas Richart * @date Mon Jun 14 11:43:22 2010 * * @brief error management and internal exceptions * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_ERROR_HH__ -#define __MYFEM_ERROR_HH__ +#ifndef __AKANTU_ERROR_HH__ +#define __AKANTU_ERROR_HH__ /* -------------------------------------------------------------------------- */ #include #include /* -------------------------------------------------------------------------- */ #include "common.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -extern std::ostream & _myfem_cout; +extern std::ostream & _akantu_cout; -extern std::ostream & _myfem_debug_cout; +extern std::ostream & _akantu_debug_cout; extern int _debug_level; /* -------------------------------------------------------------------------- */ -/// exception class that can be thrown by myfem +/// exception class that can be thrown by akantu class Exception : public std::exception { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: //! full constructor Exception(std::string info, std::string file, unsigned int line) : _info(info), _file(file), _line(line) { } //! destructor virtual ~Exception() throw() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: virtual const char* what() const throw() { std::stringstream stream; - stream << "myfem::Exception" + stream << "akantu::Exception" << " : " << _info << " [" << _file << ":" << _line << "]"; return stream.str().c_str(); } /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// exception description and additionals std::string _info; /// file it is thrown from std::string _file; /// ligne it is thrown from unsigned int _line; }; /* -------------------------------------------------------------------------- */ enum DebugLevel { dbl0 = 0, dblError = 0, dbl1 = 1, dblException = 1, dblCritical = 1, dbl2 = 2, dblMajor = 2, dbl3 = 3, dblCall = 3, dblSecondary = 3, dblHead = 3, dbl4 = 4, dblWarning = 4, dbl5 = 5, dblInfo = 5, dbl6 = 6, dblIn = 6, dblOut = 6, dbl7 = 7, dbl8 = 8, dblTrace = 8, dbl9 = 9, dbl10 = 10, dblDump = 100 }; -#define MYFEM_LOCATION "(" <<__FILE__ << ":" << __LINE__ << ") " -#ifndef MYFEM_MPI -#define MYFEM_EXIT(status) exit(status) +#define AKANTU_LOCATION "(" <<__FILE__ << ":" << __LINE__ << ") " +#ifndef AKANTU_MPI +#define AKANTU_EXIT(status) exit(status) #else -#define MYFEM_EXIT(status) \ +#define AKANTU_EXIT(status) \ do { \ MPI_Finalize(); \ exit(status); \ } while(0) #endif /* -------------------------------------------------------------------------- */ -#ifdef MYFEM_NDEBUG -#define MYFEM_DEBUG_TEST(level) (0) -#define MYFEM_DEBUG(level,info) -#define MYFEM_DEBUG_IN() -#define MYFEM_DEBUG_OUT() -#define MYFEM_DEBUG_INFO(info) -#define MYFEM_DEBUG_WARNING(info) -#define MYFEM_DEBUG_TRACE(info) -#define MYFEM_DEBUG_ASSERT(test,info) +#ifdef AKANTU_NDEBUG +#define AKANTU_DEBUG_TEST(level) (0) +#define AKANTU_DEBUG(level,info) +#define AKANTU_DEBUG_IN() +#define AKANTU_DEBUG_OUT() +#define AKANTU_DEBUG_INFO(info) +#define AKANTU_DEBUG_WARNING(info) +#define AKANTU_DEBUG_TRACE(info) +#define AKANTU_DEBUG_ASSERT(test,info) /* -------------------------------------------------------------------------- */ #else -#define MYFEM_DEBUG(level,info) \ - ((myfem::_debug_level >= level) && \ - (_myfem_debug_cout << info << " " << MYFEM_LOCATION << std::endl)) +#define AKANTU_DEBUG(level,info) \ + ((akantu::_debug_level >= level) && \ + (_akantu_debug_cout << info << " " << AKANTU_LOCATION << std::endl)) -#define MYFEM_DEBUG_TEST(level) \ - (myfem::_debug_level >= (level)) +#define AKANTU_DEBUG_TEST(level) \ + (akantu::_debug_level >= (level)) -#define MYFEM_DEBUG_IN() \ - MYFEM_DEBUG(myfem::dblIn , "==> " << __func__ << "()") +#define AKANTU_DEBUG_IN() \ + AKANTU_DEBUG(akantu::dblIn , "==> " << __func__ << "()") -#define MYFEM_DEBUG_OUT() \ - MYFEM_DEBUG(myfem::dblOut , "<== " << __func__ << "()") +#define AKANTU_DEBUG_OUT() \ + AKANTU_DEBUG(akantu::dblOut , "<== " << __func__ << "()") -#define MYFEM_DEBUG_INFO(info) \ - MYFEM_DEBUG(myfem::dblInfo , "--- " << info) +#define AKANTU_DEBUG_INFO(info) \ + AKANTU_DEBUG(akantu::dblInfo , "--- " << info) -#define MYFEM_DEBUG_WARNING(info) \ - MYFEM_DEBUG(myfem::dblWarning, "??? " << info) +#define AKANTU_DEBUG_WARNING(info) \ + AKANTU_DEBUG(akantu::dblWarning, "??? " << info) -#define MYFEM_DEBUG_TRACE(info) \ - MYFEM_DEBUG(myfem::dblTrace , ">>> " << info) +#define AKANTU_DEBUG_TRACE(info) \ + AKANTU_DEBUG(akantu::dblTrace , ">>> " << info) -#define MYFEM_DEBUG_ASSERT(test,info) \ +#define AKANTU_DEBUG_ASSERT(test,info) \ do { \ if (!(test)) { \ - _myfem_debug_cout << "(" <<__FILE__ << ":" << __LINE__ << ") " \ + _akantu_debug_cout << "(" <<__FILE__ << ":" << __LINE__ << ") " \ << "assert [" << #test << "] " \ << "!!! " << info \ << std::endl; \ - MYFEM_EXIT(EXIT_FAILURE); \ + AKANTU_EXIT(EXIT_FAILURE); \ } \ } while(0) #endif /* -------------------------------------------------------------------------- */ -#define MYFEM_DEBUG_ERROR(info) \ +#define AKANTU_DEBUG_ERROR(info) \ do { \ - MYFEM_DEBUG(myfem::dblError, "!!! " << info); \ + AKANTU_DEBUG(akantu::dblError, "!!! " << info); \ std::stringstream s_info; \ s_info << info ; \ Exception ex(s_info.str(), __FILE__, __LINE__ ); \ throw ex; \ } while(0) /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_ERROR_HH__ */ +#endif /* __AKANTU_ERROR_HH__ */ diff --git a/common/extern.cc b/common/extern.cc index ac354614e..2b85fd9d2 100644 --- a/common/extern.cc +++ b/common/extern.cc @@ -1,43 +1,43 @@ /** * @file extern.cpp * @author Nicolas Richart * @date Mon Jun 14 14:34:14 2010 * * @brief initialisation of all global variables * to insure the order of creation * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "common.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /** \todo write function to get this * values from the environment or a config file */ /* -------------------------------------------------------------------------- */ /* error.hpp variables */ /* -------------------------------------------------------------------------- */ /// standard output for debug messages -std::ostream & _myfem_debug_cout = std::cerr; +std::ostream & _akantu_debug_cout = std::cerr; /// standard output for normal messages -std::ostream & _myfem_cout = std::cout; +std::ostream & _akantu_cout = std::cout; /// debug level int _debug_level = 10; /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ diff --git a/common/memory.cc b/common/memory.cc index 6a0d2df30..d4320ba7b 100644 --- a/common/memory.cc +++ b/common/memory.cc @@ -1,31 +1,31 @@ /** * @file memory.cpp * @author Nicolas Richart * @date Tue Jun 15 11:15:53 2010 * * @brief static memory wrapper * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include "memory.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ Memory::Memory(MemoryID memory_id) { static_memory = StaticMemory::getStaticMemory(); this->memory_id = memory_id; } /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ diff --git a/common/memory.hh b/common/memory.hh index 8a69413e6..2ab156fb1 100644 --- a/common/memory.hh +++ b/common/memory.hh @@ -1,93 +1,93 @@ /** * @file memory.hh * @author Nicolas Richart * @date Tue Jun 15 09:30:23 2010 * * @brief wrapper for the static_memory, all object which wants * to access the ststic_memory as to inherit from the class memory * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_MEMORY_HH__ -#define __MYFEM_MEMORY_HH__ +#ifndef __AKANTU_MEMORY_HH__ +#define __AKANTU_MEMORY_HH__ /* -------------------------------------------------------------------------- */ #include "common.hh" #include "static_memory.hh" #include "vector.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ class Memory { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: Memory(MemoryID memory_id = 0); virtual ~Memory() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// malloc template inline Vector & malloc(const VectorID & name, unsigned int size, unsigned int nb_component); /* ------------------------------------------------------------------------ */ /// free an array inline void free(const VectorID & name); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// the static memory instance StaticMemory * static_memory; /// the id registred in the static memory MemoryID memory_id; }; /* -------------------------------------------------------------------------- */ /* Inline functions */ /* -------------------------------------------------------------------------- */ template inline Vector & Memory::malloc(const VectorID & name, unsigned int size, unsigned int nb_component) { return static_memory->smalloc(memory_id, name, size, nb_component); } /* -------------------------------------------------------------------------- */ inline void Memory::free(const VectorID & name) { static_memory->sfree(memory_id, name); } /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_MEMORY_HH__ */ +#endif /* __AKANTU_MEMORY_HH__ */ diff --git a/common/static_memory.cc b/common/static_memory.cc index 8c0e79c64..81d56bea5 100644 --- a/common/static_memory.cc +++ b/common/static_memory.cc @@ -1,92 +1,92 @@ /** * @file static_memory.cc * @author Nicolas Richart * @date Thu Jun 10 14:42:37 2010 * * @brief Memory management * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include #include /* -------------------------------------------------------------------------- */ #include "static_memory.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ StaticMemory* StaticMemory::single_static_memory = NULL; /* -------------------------------------------------------------------------- */ StaticMemory::~StaticMemory() { delete single_static_memory; } /* -------------------------------------------------------------------------- */ void StaticMemory::printself(std::ostream & stream, int indent) const{ std::string space = ""; - for(int i = 0; i < indent; i++, space += MYFEM_INDENT); + for(int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "StaticMemory [" << std::endl; stream << space << " + nb memories : " << memories.size() << std::endl; int tot_size = 0; MemoryMap::const_iterator memory_it; for(memory_it = memories.begin(); memory_it != memories.end(); ++memory_it) { int mem_size = 0; - stream << space << MYFEM_INDENT << "Memory [" << std::endl; - stream << space << MYFEM_INDENT << " + memory id : " << memory_it->first << std::endl; - stream << space << MYFEM_INDENT << " + nb vectors : " << (memory_it->second).size() << std::endl; + stream << space << AKANTU_INDENT << "Memory [" << std::endl; + stream << space << AKANTU_INDENT << " + memory id : " << memory_it->first << std::endl; + stream << space << AKANTU_INDENT << " + nb vectors : " << (memory_it->second).size() << std::endl; VectorMap::const_iterator vector_it; for(vector_it = (memory_it->second).begin(); vector_it != (memory_it->second).end(); ++vector_it) { (vector_it->second)->printself(stream, indent + 2); mem_size += (vector_it->second)->getMemorySize(); } - stream << space << MYFEM_INDENT << " + total size : " << mem_size<< std::endl; - stream << space << MYFEM_INDENT << "]" << std::endl; + stream << space << AKANTU_INDENT << " + total size : " << mem_size<< std::endl; + stream << space << AKANTU_INDENT << "]" << std::endl; tot_size += mem_size; } stream << space << " + total size : " << tot_size << std::endl; stream << space << "]" << std::endl; } /* -------------------------------------------------------------------------- */ StaticMemory * StaticMemory::getStaticMemory() { if(!single_static_memory) { single_static_memory = new StaticMemory(); } return single_static_memory; } /* -------------------------------------------------------------------------- */ void StaticMemory::sfree(const MemoryID & memory_id, const VectorID & name) { - MYFEM_DEBUG_IN(); + AKANTU_DEBUG_IN(); VectorMap & vectors = const_cast(getMemory(memory_id)); VectorMap::iterator vector_it; vector_it = vectors.find(name); if(vector_it == vectors.end()) { - MYFEM_DEBUG_ERROR("StaticMemory as no array named " << name + AKANTU_DEBUG_ERROR("StaticMemory as no array named " << name << " for the Memory " << memory_id); } vectors.erase(vector_it); - MYFEM_DEBUG_OUT(); + AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ diff --git a/common/static_memory.hh b/common/static_memory.hh index 642c06aa7..d8389e517 100644 --- a/common/static_memory.hh +++ b/common/static_memory.hh @@ -1,187 +1,187 @@ /** * @file static_memory.hh * @author Nicolas Richart * @date Thu Jun 10 14:19:25 2010 * * @brief Memory management * * @section LICENSE * * * * @section DESCRIPTION * * The class handling the memory, allocation/reallocation/desallocation * The objects can register their array and ask for allocation or realocation */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_STATIC_MEMORY_HH__ -#define __MYFEM_STATIC_MEMORY_HH__ +#ifndef __AKANTU_STATIC_MEMORY_HH__ +#define __AKANTU_STATIC_MEMORY_HH__ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "common.hh" #include "vector.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ typedef std::map VectorMap; typedef std::map MemoryMap; /** * @class StaticMemory * @brief Class for memory management common to all objects (this class as to * be accessed by an interface class memory) */ class StaticMemory { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ private: /// Default constructor StaticMemory() {}; public: ~StaticMemory(); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// Get the global instance of the StaticMemory static StaticMemory * getStaticMemory(); public: /// access to an Vector inline const VectorBase & getVector(const MemoryID & memory_id, const VectorID & name) const; /// get all vectors of a memory inline const VectorMap & getMemory(const MemoryID & memory_id) const; /* ------------------------------------------------------------------------ */ /* Class Methods */ /* ------------------------------------------------------------------------ */ public: /** * Allocation of an array of type * * @param memory_id the id of the memory accessing to the static memory * @param name name of the array (for example connectivity) * @param size number of size (for example number of nodes) * @param nb_component number of component (for example spatial dimention) * @param type the type code of the array to be allocated * * @return pointer to an array of size nb_tupes * nb_component * sizeof(T) */ template Vector & smalloc(const MemoryID & memory_id, const VectorID & name, unsigned int size, unsigned int nb_component); /** * free the memory associated to the array name * * @param memory_id the id of the memory accessing to the static memory * @param name the name of an existing array */ void sfree(const MemoryID & memory_id, const VectorID & name); /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// unique instance of the StaticMemory static StaticMemory * single_static_memory; /// map of all allocated arrays, indexed by their names MemoryMap memories; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ inline const VectorMap & StaticMemory::getMemory(const MemoryID & memory_id) const { - MYFEM_DEBUG_IN(); + AKANTU_DEBUG_IN(); MemoryMap::const_iterator memory_it; memory_it = memories.find(memory_id); if(memory_it == memories.end()) { - MYFEM_DEBUG_ERROR("StaticMemory as no memory with ID " << memory_id); + AKANTU_DEBUG_ERROR("StaticMemory as no memory with ID " << memory_id); } - MYFEM_DEBUG_OUT(); + AKANTU_DEBUG_OUT(); return memory_it->second; } /* -------------------------------------------------------------------------- */ inline const VectorBase & StaticMemory::getVector(const MemoryID & memory_id, const VectorID & name) const { - MYFEM_DEBUG_IN(); + AKANTU_DEBUG_IN(); const VectorMap & vectors = getMemory(memory_id); VectorMap::const_iterator vectors_it; vectors_it = vectors.find(name); if(vectors_it == vectors.end()) { - MYFEM_DEBUG_ERROR("StaticMemory as no array named " << name + AKANTU_DEBUG_ERROR("StaticMemory as no array named " << name << " for the Memory " << memory_id); } - MYFEM_DEBUG_OUT(); + AKANTU_DEBUG_OUT(); return *(vectors_it->second); } /* -------------------------------------------------------------------------- */ template Vector & StaticMemory::smalloc(const MemoryID & memory_id, const VectorID & name, unsigned int size, unsigned int nb_component) { - MYFEM_DEBUG_IN(); + AKANTU_DEBUG_IN(); MemoryMap::iterator memory_it; memory_it = memories.find(memory_id); if(memory_it == memories.end()){ memories[memory_id] = VectorMap(); memory_it = memories.find(memory_id); } if((memory_it->second).find(name) != (memory_it->second).end()) { - MYFEM_DEBUG_ERROR("The vector " << name << " is already registred in the memory " << memory_id); + AKANTU_DEBUG_ERROR("The vector " << name << " is already registred in the memory " << memory_id); } (memory_it->second)[name] = new Vector(size, nb_component, name); - MYFEM_DEBUG_OUT(); + AKANTU_DEBUG_OUT(); return static_cast &>(*(memory_it->second)[name]); } /* -------------------------------------------------------------------------- */ /// standard output stream operator inline std::ostream & operator<<(std::ostream & stream, const StaticMemory & _this) { _this.printself(stream); return stream; } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_STATIC_MEMORY_HH__ */ +#endif /* __AKANTU_STATIC_MEMORY_HH__ */ diff --git a/common/vector.cc b/common/vector.cc index d16f0c935..f73ef1976 100644 --- a/common/vector.cc +++ b/common/vector.cc @@ -1,32 +1,32 @@ /** * @file vector.cc * @author Nicolas Richart * @date Thu Jun 17 15:14:24 2010 * * @brief class vector * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include "common.hh" #include "vector.hh" /* -------------------------------------------------------------------------- */ void VectorBase::printself(std::ostream & stream, int indent) const { std::string space; - for(int i = 0; i < indent; i++, space += MYFEM_INDENT); + for(int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << indent << "VectorBase [" << std::endl; stream << indent << " + nb tuples : " << nb_tuples << std::endl; stream << indent << " + nb_component : " << nb_component << std::endl; stream << indent << " + nb allocated tuples : " << nb_allocated_tuples << std::endl; int size = nb_allocated_tuples * nb_component * size_of_type; stream << indent << " + size : " << size << "B" << std::endl; stream << indent << "]" << std::endl; } /* -------------------------------------------------------------------------- */ diff --git a/common/vector.hh b/common/vector.hh index c7ed39337..722f03293 100644 --- a/common/vector.hh +++ b/common/vector.hh @@ -1,230 +1,230 @@ /** * @file vector.hh * @author Nicolas Richart * @date Thu Jun 17 10:04:55 2010 * * @brief class of vectors * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_VECTOR_HH__ -#define __MYFEM_VECTOR_HH__ +#ifndef __AKANTU_VECTOR_HH__ +#define __AKANTU_VECTOR_HH__ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "common.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /// class that afford to store vectors in static memory class VectorBase { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: virtual ~VectorBase() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// get the amount of space allocated in bytes inline unsigned int getMemorySize() const; /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const {}; /* ------------------------------------------------------------------------ */ /* Accesors */ /* ------------------------------------------------------------------------ */ public: - MYFEM_GET_MACRO(AllocatedSize, allocated_size, unsigned int); + AKANTU_GET_MACRO(AllocatedSize, allocated_size, unsigned int); - MYFEM_GET_MACRO(Size, size, unsigned int); + AKANTU_GET_MACRO(Size, size, unsigned int); - MYFEM_GET_MACRO(NbComponent, nb_component, unsigned int); + AKANTU_GET_MACRO(NbComponent, nb_component, unsigned int); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: /// the size allocated unsigned int allocated_size; /// the size used unsigned int size; /// number of components unsigned int nb_component; /// size of the stored type unsigned int size_of_type; /// id of the vector VectorID id; }; /* -------------------------------------------------------------------------- */ template class Vector : public VectorBase { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: Vector(unsigned int size, unsigned int nb_component, const VectorID & id = ""); virtual ~Vector(); private: Vector(const Vector& vect) {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// get jth componemt of the ith tuple inline T & at(unsigned int i, unsigned int j = 0); void resize(unsigned int size); /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /* ------------------------------------------------------------------------ */ /* Accesors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ public: /// array of values T *values; // /!\ very dangerous }; /* -------------------------------------------------------------------------- */ /* Inline Functions Vector */ /* -------------------------------------------------------------------------- */ template Vector::Vector (unsigned int size, unsigned int nb_component, const VectorID & id) { this->id = id; values = static_cast(malloc(nb_component * size * sizeof(T))); - MYFEM_DEBUG_ASSERT(values != NULL, + AKANTU_DEBUG_ASSERT(values != NULL, "Cannot allocate " << nb_component * size * sizeof(T) << " bytes"); if (values == NULL) { this->size = this->allocated_size = 0; } else { - MYFEM_DEBUG_INFO("Allocated " << size * nb_component * sizeof(T) << " bytes"); + AKANTU_DEBUG_INFO("Allocated " << size * nb_component * sizeof(T) << " bytes"); this->size = this->allocated_size = size; } this->size_of_type = sizeof(T); this->nb_component = nb_component; } /* -------------------------------------------------------------------------- */ template Vector::~Vector () { free(values); size = allocated_size = 0; } /* -------------------------------------------------------------------------- */ template void Vector::resize (unsigned int new_size) { - MYFEM_DEBUG_IN(); + AKANTU_DEBUG_IN(); if(new_size <= allocated_size) { - if(allocated_size - new_size > MYFEM_MIN_ALLOCATION) { - MYFEM_DEBUG_INFO("Freeing " << (allocated_size - size)*nb_component*sizeof(T) << " bytes"); + if(allocated_size - new_size > AKANTU_MIN_ALLOCATION) { + AKANTU_DEBUG_INFO("Freeing " << (allocated_size - size)*nb_component*sizeof(T) << " bytes"); /// Normally there are no allocation problem when reducing an array values = static_cast(realloc(values, new_size * nb_component * sizeof(T))); allocated_size = size; } size = new_size; - MYFEM_DEBUG_OUT(); + AKANTU_DEBUG_OUT(); return; } - unsigned int size_to_alloc = (new_size - allocated_size < MYFEM_MIN_ALLOCATION) ? - allocated_size + MYFEM_MIN_ALLOCATION : new_size; + unsigned int size_to_alloc = (new_size - allocated_size < AKANTU_MIN_ALLOCATION) ? + allocated_size + AKANTU_MIN_ALLOCATION : new_size; T *tmp_ptr = static_cast(realloc(values, size_to_alloc * nb_component * sizeof(T))); - MYFEM_DEBUG_ASSERT(tmp_ptr != NULL, + AKANTU_DEBUG_ASSERT(tmp_ptr != NULL, "Cannot allocate " << size_to_alloc * nb_component * sizeof(T) << " bytes"); if (!tmp_ptr) return; - MYFEM_DEBUG_INFO("Allocating " << (size_to_alloc - allocated_size)*nb_component*sizeof(T) << " bytes"); + AKANTU_DEBUG_INFO("Allocating " << (size_to_alloc - allocated_size)*nb_component*sizeof(T) << " bytes"); allocated_size = size_to_alloc; size = new_size; } /* -------------------------------------------------------------------------- */ template void Vector::printself(std::ostream & stream, int indent) const { std::string space; - for(int i = 0; i < indent; i++, space += MYFEM_INDENT); + for(int i = 0; i < indent; i++, space += AKANTU_INDENT); int size = allocated_size * nb_component * size_of_type; stream << space << "Vector<" << typeid(T).name() << "> [" << std::endl; stream << space << " + id : " << id << std::endl; stream << space << " + size : " << size << std::endl; stream << space << " + nb_component : " << nb_component << std::endl; stream << space << " + allocated size : " << allocated_size << std::endl; stream << space << " + memory size : " << size << "B" << std::endl; stream << space << " + adresse : " << std::hex << values << std::dec << std::endl; stream << space << "]" << std::endl; } /* -------------------------------------------------------------------------- */ template inline std::ostream & operator<<(std::ostream & stream, const Vector & _this) { _this.printself(stream); return stream; } /* -------------------------------------------------------------------------- */ /* Inline Functions VectorBase */ /* -------------------------------------------------------------------------- */ inline unsigned int VectorBase::getMemorySize() const { return allocated_size * nb_component * size_of_type; } /* -------------------------------------------------------------------------- */ inline std::ostream & operator<<(std::ostream & stream, const VectorBase & _this) { _this.printself(stream); return stream; } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_VECTOR_HH__ */ +#endif /* __AKANTU_VECTOR_HH__ */ diff --git a/fem/element_class.hh b/fem/element_class.hh index 215915f3c..999aa308f 100644 --- a/fem/element_class.hh +++ b/fem/element_class.hh @@ -1,74 +1,74 @@ /** * @file element_class.hh * @author Nicolas Richart * @date Wed Jun 16 18:48:25 2010 * * @brief * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_ELEMENT_CLASS_HH__ -#define __MYFEM_ELEMENT_CLASS_HH__ +#ifndef __AKANTU_ELEMENT_CLASS_HH__ +#define __AKANTU_ELEMENT_CLASS_HH__ /* -------------------------------------------------------------------------- */ #include "common.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ template class ElementClass { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ElementClass(); virtual ~ElementClass(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /* ------------------------------------------------------------------------ */ /* Accesors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: unsigned int nb_nodes_per_element; unsigned int nb_quadrature_points; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const ElementClass & _this) { _this.printself(stream); } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_ELEMENT_CLASS_HH__ */ +#endif /* __AKANTU_ELEMENT_CLASS_HH__ */ diff --git a/fem/mesh.cc b/fem/mesh.cc index 6b4b609cc..5331485e4 100644 --- a/fem/mesh.cc +++ b/fem/mesh.cc @@ -1,28 +1,28 @@ /** * @file mesh.cc * @author Nicolas Richart * @date Wed Jun 16 12:02:26 2010 * * @brief class handling meshes * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include "mesh.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ Mesh::Mesh(unsigned int spatial_dimension, MemoryID memory_id) : Memory(memory_id) { this->spatial_dimension = spatial_dimension; nodes = NULL; } -__END_MYFEM__ +__END_AKANTU__ diff --git a/fem/mesh.hh b/fem/mesh.hh index 608c8593a..e49edc028 100644 --- a/fem/mesh.hh +++ b/fem/mesh.hh @@ -1,114 +1,114 @@ /** * @file mesh.hh * @author Nicolas Richart * @date Wed Jun 16 11:53:53 2010 * * @brief the class representing the meshes * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_MESH_HH__ -#define __MYFEM_MESH_HH__ +#ifndef __AKANTU_MESH_HH__ +#define __AKANTU_MESH_HH__ /* -------------------------------------------------------------------------- */ #include "common.hh" #include "memory.hh" #include "vector.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ enum ElementType { _not_defined = 0, _triangle_1 = 1, _triangle_2 = 2, _tetrahedra_1 = 3, _tetrahedra_2 = 4, _max_element_type }; /* -------------------------------------------------------------------------- */ class Mesh : protected Memory { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: /// constructor that create nodes coordinates array Mesh(unsigned int spatial_dimension, MemoryID memory_id = 0); /// constructor that use an existing nodes coordinates array, by knowing its ID Mesh(unsigned int spatial_dimension, const VectorID & nodes_id, MemoryID memory_id = 0); /** * constructor that use an existing nodes coordinates * array, by getting the vector of coordinates */ Mesh(unsigned int spatial_dimension, const Vector & nodes, MemoryID memory_id = 0); virtual ~Mesh() {}; typedef std::map *> ConnectivityMap; typedef std::map *>::iterator ConnectivityIterator; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: inline Vector & getNodes() const; inline Vector & createConnectivity(ElementType type, unsigned int nb_element); inline Vector & getConnectivity(ElementType type) const; inline ConnectivityMap & getConnectivityMap() const; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// id of the nodes coordinates array Vector * nodes; /// all class of elements present in this mesh (for heterogenous meshes) ConnectivityMap connectivities; /// the spatial dimension of this mesh unsigned int spatial_dimension; }; /* -------------------------------------------------------------------------- */ /* Inline functions */ /* -------------------------------------------------------------------------- */ //! standard output stream operator inline std::ostream & operator <<(std::ostream & stream, ElementType type) { switch(type) { case _triangle_1 : stream << "triangle 1st order" ; break; case _triangle_2 : stream << "triangle 2nd order" ; break; case _tetrahedra_1 : stream << "tetrahedra 1st order"; break; case _tetrahedra_2 : stream << "tetrahedra 2nd order"; break; default : stream << "unknown ElementType (" << type << ")"; break; } return stream; } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_MESH_HH__ */ +#endif /* __AKANTU_MESH_HH__ */ diff --git a/mesh_io/mesh_io.hh b/mesh_io/mesh_io.hh index 35a468a1a..76754bf6b 100644 --- a/mesh_io/mesh_io.hh +++ b/mesh_io/mesh_io.hh @@ -1,82 +1,82 @@ /** * @file mesh_io.hh * @author Nicolas Richart * @date Fri Jun 18 10:27:42 2010 * * @brief Interface of a mesh io class, reader and writer * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_MESH_IO_HH__ -#define __MYFEM_MESH_IO_HH__ +#ifndef __AKANTU_MESH_IO_HH__ +#define __AKANTU_MESH_IO_HH__ /* -------------------------------------------------------------------------- */ #include "common.hh" #include "mesh.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ class MeshIO { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: MeshIO(); virtual ~MeshIO(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /// read a mesh from the file virtual void read(const std::string & filename, const Mesh & mesh) = 0; /// write a mesh to a file virtual void write(const std::string & filename, const Mesh & mesh) = 0; /* ------------------------------------------------------------------------ */ /* Accesors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: bool canReadSurface; bool canReadExtendedData; std::string filename; Mesh & mesh; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const MeshIO & _this) { _this.printself(stream); } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_MESH_IO_HH__ */ +#endif /* __AKANTU_MESH_IO_HH__ */ diff --git a/mesh_io/mesh_io_msh.cc b/mesh_io/mesh_io_msh.cc index 6ce5f378d..29bbed660 100644 --- a/mesh_io/mesh_io_msh.cc +++ b/mesh_io/mesh_io_msh.cc @@ -1,379 +1,379 @@ /** * @file mesh_io_msh.cc * @author Nicolas Richart * @date Fri Jun 18 11:36:35 2010 * * @brief Read/Write for MSH files generated by gmsh * * @section LICENSE * * * */ /* ----------------------------------------------------------------------------- Version (Legacy) 1.0 $NOD number-of-nodes node-number x-coord y-coord z-coord ... $ENDNOD $ELM number-of-elements elm-number elm-type reg-phys reg-elem number-of-nodes node-number-list ... $ENDELM ----------------------------------------------------------------------------- Version 2.1 $MeshFormat version-number file-type data-size $EndMeshFormat $Nodes number-of-nodes node-number x-coord y-coord z-coord ... $EndNodes $Elements number-of-elements elm-number elm-type number-of-tags < tag > ... node-number-list ... $EndElements $PhysicalNames number-of-names physical-dimension physical-number "physical-name" ... $EndPhysicalNames $NodeData number-of-string-tags < "string-tag" > ... number-of-real-tags < real-tag > ... number-of-integer-tags < integer-tag > ... node-number value ... ... $EndNodeData $ElementData number-of-string-tags < "string-tag" > ... number-of-real-tags < real-tag > ... number-of-integer-tags < integer-tag > ... elm-number value ... ... $EndElementData $ElementNodeData number-of-string-tags < "string-tag" > ... number-of-real-tags < real-tag > ... number-of-integer-tags < integer-tag > ... elm-number number-of-nodes-per-element value ... ... $ElementEndNodeData ----------------------------------------------------------------------------- elem-type 1: 2-node line. 2: 3-node triangle. 3: 4-node quadrangle. 4: 4-node tetrahedron. 5: 8-node hexahedron. 6: 6-node prism. 7: 5-node pyramid. 8: 3-node second order line 9: 6-node second order triangle 10: 9-node second order quadrangle 11: 10-node second order tetrahedron 12: 27-node second order hexahedron 13: 18-node second order prism 14: 14-node second order pyramid 15: 1-node point. 16: 8-node second order quadrangle 17: 20-node second order hexahedron 18: 15-node second order prism 19: 13-node second order pyramid 20: 9-node third order incomplete triangle 21: 10-node third order triangle 22: 12-node fourth order incomplete triangle 23: 15-node fourth order triangle 24: 15-node fifth order incomplete triangle 25: 21-node fifth order complete triangle 26: 4-node third order edge 27: 5-node fourth order edge 28: 6-node fifth order edge 29: 20-node third order tetrahedron 30: 35-node fourth order tetrahedron 31: 56-node fifth order tetrahedron -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "mesh_io_msh.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ unsigned int MeshIOMSH::_read_order[_max_element_type][MAX_NUMBER_OF_NODE_PER_ELEMENT] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // _not_defined { 0, 1, 2, 0, 0, 0, 0, 0, 0, 0 }, // _triangle_1 { 0, 1, 2, 3, 4, 5, 6, 0, 0, 0 }, // _triangle_2 { 0, 1, 2, 3, 4, 0, 0, 0, 0, 0 }, // _tetrahedra_1 { 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 }, // _tetrahedra_2 }; unsigned int MeshIOMSH::_msh_nodes_per_elem[16] = { 0, // element types began at 1 2, 3, 4, 4, 8, 6, 5, // 1st order 3, 6, 9, 10, 27, 18, 14, // 2st order 1 }; -ElementType MeshIOMSH::_msh_to_myfem_element_types[16] = +ElementType MeshIOMSH::_msh_to_akantu_element_types[16] = { _not_defined, // element types began at 1 _not_defined, _triangle_1, _not_defined, _tetrahedra_1, _not_defined, _not_defined, _not_defined, // 1st order _not_defined, _triangle_2, _not_defined, _tetrahedra_2, _not_defined, _not_defined, _not_defined, // 2nd order _not_defined }; -MeshIOMSH::MSHElementType MeshIOMSH::_myfem_to_msh_element_types[_max_element_type +MeshIOMSH::MSHElementType MeshIOMSH::_akantu_to_msh_element_types[_max_element_type ] = { _msh_not_defined, // _not_defined _msh_triangle_1, // _triangle_1 _msh_triangle_2, // _triangle_2 _msh_tetrahedron_1, // _tetrahedra_1 _msh_tetrahedron_2 // _tetrahedra_2 }; /* -------------------------------------------------------------------------- */ void MeshIOMSH::read(const std::string & filename, const Mesh & mesh) { std::ifstream infile; infile.open(filename.c_str()); std::string line; unsigned int first_node_number = 0, last_node_number = 0, file_format = 1, current_line = 0; if(!infile.good()) { - MYFEM_DEBUG_ERROR("Canot open file " << filename); + AKANTU_DEBUG_ERROR("Canot open file " << filename); } while(infile.good()) { std::getline(infile, line); current_line++; /// read the header if(line == "$MeshFormat") { std::getline(infile, line); /// the format line std::getline(infile, line); /// the end of block line current_line += 2; file_format = 2; } /// read all nodes if(line == "$Nodes" || line == "$NOD") { int nb_nodes; std::getline(infile, line); std::stringstream sstr(line); sstr >> nb_nodes; current_line++; Vector & nodes = mesh.getNodes(); nodes.resize(nb_nodes); int index; double coord[3]; unsigned int spatial_dimension = nodes.getNbComponent(); /// for each node, read the coordinates for(unsigned int i = 0; i < nb_nodes; ++i) { int offset = i * spatial_dimension; std::getline(infile, line); std::stringstream sstr(line); sstr >> index >> coord[0] >> coord[1] >> coord[2]; current_line++; first_node_number = first_node_number < index ? first_node_number : index; last_node_number = last_node_number > index ? last_node_number : index; /// read the coordinates for(unsigned int j = 0; j < spatial_dimension; ++j) nodes.values[offset + j] = coord[j]; } std::getline(infile, line); /// the end of block line } /// read all elements if(line == "$Elements" || line == "$ELM") { int nb_elements; std::getline(infile, line); std::stringstream sstr(line); sstr >> nb_elements; current_line++; int index; unsigned int msh_type; - ElementType myfem_type, myfem_type_old = _not_defined; + ElementType akantu_type, akantu_type_old = _not_defined; Vector *connectivity = NULL; unsigned int nb_elements_read = 0; for(unsigned int i = 0; i < nb_elements; ++i) { std::getline(infile, line); std::stringstream sstr(line); current_line++; sstr >> index; sstr >> msh_type; /// get the connectivity vector depending on the element type - myfem_type = _msh_to_myfem_element_types[msh_type]; + akantu_type = _msh_to_akantu_element_types[msh_type]; - if(myfem_type == _not_defined) continue; + if(akantu_type == _not_defined) continue; - if(myfem_type != myfem_type_old) { + if(akantu_type != akantu_type_old) { if(connectivity) connectivity->resize(nb_elements_read); - connectivity = &(const_cast(mesh).createConnectivity(myfem_type, nb_elements)); + connectivity = &(const_cast(mesh).createConnectivity(akantu_type, nb_elements)); connectivity->resize(nb_elements); - myfem_type_old = myfem_type; + akantu_type_old = akantu_type; nb_elements_read = 0; } /// read tags informations if(file_format == 2) { int nb_tags; sstr >> nb_tags; for(unsigned int j = 0; j < nb_tags; ++j) { int tag; sstr >> tag; ///@todo read to get extended information on elements } } else if (file_format == 1) { int tag; sstr >> tag; //reg-phys sstr >> tag; //reg-elem sstr >> tag; //number-of-nodes } /// read the connectivities informations unsigned int offset = nb_elements_read * connectivity->getNbComponent(); for(unsigned int j; j < connectivity->getNbComponent(); ++j) { unsigned int index; sstr >> index; - MYFEM_DEBUG_ASSERT(index <= last_node_number, + AKANTU_DEBUG_ASSERT(index <= last_node_number, "Node number not in range : line " << current_line); index = index - first_node_number + 1; - connectivity->values[offset + _read_order[myfem_type][j]] = index; + connectivity->values[offset + _read_order[akantu_type][j]] = index; } nb_elements_read++; } connectivity->resize(nb_elements_read); std::getline(infile, line); /// the end of block line } if(line[0] == '$') { - MYFEM_DEBUG_WARNING("Unsuported block_kind " << line + AKANTU_DEBUG_WARNING("Unsuported block_kind " << line << " at line " << current_line); } } // if there is less element than predicted... infile.close(); } /* -------------------------------------------------------------------------- */ void MeshIOMSH::write(const std::string & filename, const Mesh & mesh) { std::ofstream outfile; Vector & nodes = mesh.getNodes(); outfile.open(filename.c_str()); outfile << "$MeshFormat" << std::endl; outfile << "2 0 8" << std::endl;; outfile << "$EndMeshFormat" << std::endl;; outfile << "$Nodes" << std::endl;; outfile << nodes.getSize() << std::endl;; outfile << std::uppercase; for(int i = 0; i < nodes.getSize(); ++i) { int offset = i * nodes.getNbComponent(); outfile << i+1; for(int j = 0; j < nodes.getNbComponent(); ++j) { outfile << " " << nodes.values[offset + j]; } if(nodes.getNbComponent() == 2) outfile << " " << 0.; outfile << std::endl;; } outfile << std::nouppercase; outfile << "$EndNodes" << std::endl;; outfile << "$Elements" << std::endl;; Mesh::ConnectivityMap & connectivity_map = mesh.getConnectivityMap(); Mesh::ConnectivityMap::const_iterator it; int nb_elements = 0; for(it = connectivity_map.begin(); it != connectivity_map.end(); ++it) { - MSHElementType type = _myfem_to_msh_element_types[it->first]; + MSHElementType type = _akantu_to_msh_element_types[it->first]; Vector & connectivity = *(it->second); nb_elements += connectivity.getSize(); } outfile << nb_elements << std::endl; unsigned int element_idx = 1; for(it = connectivity_map.begin(); it != connectivity_map.end(); ++it) { ElementType type = it->first; Vector & connectivity = *(it->second); for(int i = 0; i < connectivity.getSize(); ++i) { int offset = i * connectivity.getNbComponent(); outfile << element_idx << " " << type << " 3 0 0 0"; for(int j = 0; j < connectivity.getNbComponent(); ++j) { outfile << " " << connectivity.values[offset + j]; } outfile << std::endl; } element_idx++; } outfile << "$EndElements" << std::endl;; outfile.close(); } /* -------------------------------------------------------------------------- */ -__END_MYFEM__ +__END_AKANTU__ diff --git a/mesh_io/mesh_io_msh.hh b/mesh_io/mesh_io_msh.hh index 60c6375a1..a313813f9 100644 --- a/mesh_io/mesh_io_msh.hh +++ b/mesh_io/mesh_io_msh.hh @@ -1,109 +1,109 @@ /** * @file mesh_io_msh.hh * @author Nicolas Richart * @date Fri Jun 18 11:30:59 2010 * * @brief Read/Write for MSH files * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ -#ifndef __MYFEM_MESH_IO_MSH_HH__ -#define __MYFEM_MESH_IO_MSH_HH__ +#ifndef __AKANTU_MESH_IO_MSH_HH__ +#define __AKANTU_MESH_IO_MSH_HH__ /* -------------------------------------------------------------------------- */ #include "mesh_io.hh" /* -------------------------------------------------------------------------- */ -__BEGIN_MYFEM__ +__BEGIN_AKANTU__ class MeshIOMSH { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: MeshIOMSH(); virtual ~MeshIOMSH(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /// read a mesh from the file virtual void read(const std::string & filename, const Mesh & mesh); /// write a mesh to a file virtual void write(const std::string & filename, const Mesh & mesh); /* ------------------------------------------------------------------------ */ /* Accesors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// MSH element types enum MSHElementType { _msh_not_defined = 0, _msh_line_1 = 1, // 2-node line. _msh_triangle_1 = 2, // 3-node triangle. _msh_quadrangle_1 = 3, // 4-node quadrangle. _msh_tetrahedron_1 = 4, // 4-node tetrahedron. _msh_hexaedron_1 = 5, // 8-node hexahedron. _msh_prism_1 = 6, // 6-node prism. _msh_pyramid_1 = 7, // 5-node pyramid. _msh_line_2 = 8, // 3-node second order line _msh_triangle_2 = 9, // 6-node second order triangle _msh_quadrangle_2 = 10, // 9-node second order quadrangle _msh_tetrahedron_2 = 11, // 10-node second order tetrahedron _msh_hexaedron_2 = 12, // 27-node second order hexahedron _msh_prism_2 = 13, // 18-node second order prism _msh_pyramid_2 = 14, // 14-node second order pyramid _msh_point = 15 // 1-node point. }; /// order in witch element as to be read static unsigned int _read_order[_max_element_type][MAX_NUMBER_OF_NODE_PER_ELEMENT]; /// number of nodes per msh element static unsigned int _msh_nodes_per_elem[16]; // 16 = number of recognized // msh element types +1 (for 0) - /// correspondance between msh element types and myfem element types - static ElementType _msh_to_myfem_element_types[16]; + /// correspondance between msh element types and akantu element types + static ElementType _msh_to_akantu_element_types[16]; - /// correspondance between myfem element types and msh element types - static MSHElementType _myfem_to_msh_element_types[_max_element_type]; + /// correspondance between akantu element types and msh element types + static MSHElementType _akantu_to_msh_element_types[_max_element_type]; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const MeshIOMSH & _this) { _this.printself(stream); } -__END_MYFEM__ +__END_AKANTU__ -#endif /* __MYFEM_MESH_IO_MSH_HH__ */ +#endif /* __AKANTU_MESH_IO_MSH_HH__ */ diff --git a/test/static_memory.cc b/test/static_memory.cc index c41b70643..3432313ec 100644 --- a/test/static_memory.cc +++ b/test/static_memory.cc @@ -1,32 +1,32 @@ /** * @file test/static_memory.cc * @author Nicolas Richart * @date Fri Jun 11 11:55:54 2010 * * @brief unit test for the StaticMemory class * */ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "static_memory.hh" #include "vector.hh" /* -------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { - myfem::StaticMemory * st_mem = myfem::StaticMemory::getStaticMemory(); + akantu::StaticMemory * st_mem = akantu::StaticMemory::getStaticMemory(); - myfem::Vector & test_int = st_mem->smalloc(0, "test_int", 1000, 3); + akantu::Vector & test_int = st_mem->smalloc(0, "test_int", 1000, 3); test_int.resize(1050); test_int.resize(2000); std::cout << *st_mem << std::endl; st_mem->sfree(0, "test_int"); exit(EXIT_SUCCESS); }