diff --git a/CMakeLists.txt b/CMakeLists.txt index ff3dcc819..086de2b5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,241 +1,244 @@ #=============================================================================== # @file CMakeLists.txt # @author Nicolas Richart # @date Fri Jun 11 09:46:59 2010 # # @section LICENSE # # # # @section DESCRIPTION # #=============================================================================== #=============================================================================== # _ ,-, _ # ,--, /: :\/': :`\/: :\ # |`; ' `,' `.; `: | _ _ # | | | ' | |. | | | | # | : | F E | A S | T++ || __ _| | ____ _ _ __ | |_ _ _ # | :. | : | : | : | \ / _` | |/ / _` | '_ \| __| | | | # \__/: :.. : :.. | :.. | ) | (_| | < (_| | | | | |_| |_| | # `---',\___/,\___/ /' \__,_|_|\_\__,_|_| |_|\__|\__,_| # `==._ .. . /' # `-::-' #=============================================================================== #=============================================================================== # CMake Project #=============================================================================== cmake_minimum_required(VERSION 2.6) project(AKANTU) enable_language(CXX) #=============================================================================== # Misc. #=============================================================================== set(AKANTU_CMAKE_DIR "${AKANTU_SOURCE_DIR}/cmake") set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") #=============================================================================== # Version Number #=============================================================================== # 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 AKANTU_NO_LIBRARY_VERSION) set(AKANTU_LIBRARY_PROPERTIES ${AKANTU_LIBRARY_PROPERTIES} VERSION "${AKANTU_VERSION}" SOVERSION "${AKANTU_MAJOR_VERSION}.${AKANTU_MINOR_VERSION}" ) endif(NOT AKANTU_NO_LIBRARY_VERSION) #=============================================================================== # Options #=============================================================================== # Debug option(AKANTU_DEBUG "Compiles akantu with the debug messages" ON) if(NOT AKANTU_DEBUG) add_definitions(-DAKANTU_NDEBUG) endif(NOT AKANTU_DEBUG) # IOHelper option(AKANTU_USE_IOHELPER "Add IOHelper support in akantu" OFF) if(AKANTU_USE_IOHELPER) include(${AKANTU_CMAKE_DIR}/FindIOHelper.cmake) if(IOHELPER_FOUND) add_definitions(-DAKANTU_USE_IOHELPER) set(AKANTU_EXTERNAL_LIB_INCLUDE_PATH ${AKANTU_EXTERNAL_LIB_INCLUDE_PATH} ${IOHELPER_INCLUDE_PATH} ) set(AKANTU_EXTERNAL_LIBRARIES ${AKANTU_EXTERNAL_LIBRARIES} ${IOHELPER_LIBRARIES} ) endif(IOHELPER_FOUND) endif(AKANTU_USE_IOHELPER) # MPI set(AKANTU_MPI_ON FALSE) option(AKANTU_USE_MPI "Add MPI support in akantu" OFF) if(AKANTU_USE_MPI) find_package(MPI) if(MPI_FOUND) add_definitions(-DAKANTU_USE_MPI) set(AKANTU_EXTERNAL_LIB_INCLUDE_PATH ${AKANTU_EXTERNAL_LIB_INCLUDE_PATH} ${MPI_INCLUDE_PATH} ) set(AKANTU_EXTERNAL_LIBRARIES ${AKANTU_EXTERNAL_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY} ) set(AKANTU_MPI_ON TRUE) endif(MPI_FOUND) endif(AKANTU_USE_MPI) # Scotch set(AKANTU_SCOTCH_ON FALSE) option(AKANTU_USE_SCOTCH "Add Scotch support in akantu" OFF) if(AKANTU_USE_SCOTCH) include(${AKANTU_CMAKE_DIR}/FindScotch.cmake) if(SCOTCH_FOUND) add_definitions(-DAKANTU_USE_SCOTCH) set(AKANTU_EXTERNAL_LIB_INCLUDE_PATH ${AKANTU_EXTERNAL_LIB_INCLUDE_PATH} ${SCOTCH_INCLUDE_PATH} ) set(AKANTU_EXTERNAL_LIBRARIES ${AKANTU_EXTERNAL_LIBRARIES} ${SCOTCH_LIBRARIES} ) set(AKANTU_SCOTCH_ON TRUE) endif(SCOTCH_FOUND) endif(AKANTU_USE_SCOTCH) # Doxygen OPTION(AKANTU_DOCUMENTATION "Build source documentation using Doxygen." OFF) # BLAS set(AKANTU_BLAS_ON FALSE) option(AKANTU_USE_BLAS "Use BLAS for arithmetic operations" OFF) if(AKANTU_USE_BLAS) find_package(BLAS) if(BLAS_FOUND) add_definitions(-DAKANTU_USE_BLAS) set(AKANTU_EXTERNAL_LIBRARIES ${AKANTU_EXTERNAL_LIBRARIES} ${BLAS_LIBRARIES} ) set(AKANTU_BLAS_ON TRUE) endif(BLAS_FOUND) endif(AKANTU_USE_BLAS) #=============================================================================== # Library #=============================================================================== set(AKANTU_COMMON_SRC common/aka_common.cc common/aka_error.cc common/aka_extern.cc common/aka_static_memory.cc common/aka_memory.cc common/aka_vector.cc common/aka_math.cc fem/mesh.cc fem/fem.cc fem/element_class.cc # model/integration_scheme/central_difference.cc model/solid_mechanics/solid_mechanics_model.cc model/solid_mechanics/solid_mechanics_model_mass.cc model/solid_mechanics/material.cc model/solid_mechanics/materials/material_elastic.cc + model/solid_mechanics/contact.cc + model/solid_mechanics/contact_search.cc + model/solid_mechanics/contact_neighbor_structure.cc mesh_utils/mesh_io.cc mesh_utils/mesh_io/mesh_io_msh.cc mesh_utils/mesh_partition.cc mesh_utils/mesh_utils.cc synchronizer/ghost_synchronizer.cc synchronizer/synchronizer.cc synchronizer/communicator.cc synchronizer/static_communicator.cc ) if(AKANTU_USE_MPI AND MPI_FOUND) set(AKANTU_COMMON_SRC ${AKANTU_COMMON_SRC} synchronizer/static_communicator_mpi.cc ) endif(AKANTU_USE_MPI AND MPI_FOUND) if(AKANTU_SCOTCH_ON) set(AKANTU_COMMON_SRC ${AKANTU_COMMON_SRC} mesh_utils/mesh_partition/mesh_partition_scotch.cc ) endif(AKANTU_SCOTCH_ON) set(AKANTU_INCLUDE_DIRS common fem/ mesh_utils/ mesh_utils/mesh_io/ mesh_utils/mesh_partition/ model/ model/integration_scheme model/solid_mechanics model/solid_mechanics/materials model/solid_mechanics/contact synchronizer/ ) include_directories( ${AKANTU_INCLUDE_DIRS} ${AKANTU_EXTERNAL_LIB_INCLUDE_PATH} ) add_library(akantu ${AKANTU_COMMON_SRC}) set_target_properties(akantu PROPERTIES ${AKANTU_LIBRARY_PROPERTIES}) #=========================================================================== # Documentation #=========================================================================== if(AKANTU_DOCUMENTATION) find_package(Doxygen) if(DOXYGEN_FOUND) set(DOXYGEN_WARNINGS NO) set(DOXYGEN_QUIET YES) if(CMAKE_VERBOSE_MAKEFILE) set(DOXYGEN_WARNINGS YES) set(DOXYGEN_QUIET NO) endif(CMAKE_VERBOSE_MAKEFILE) add_subdirectory(doc/doxygen) endif(DOXYGEN_FOUND) endif(AKANTU_DOCUMENTATION) #=============================================================================== # Tests #=============================================================================== option(AKANTU_TESTS "Activate tests" OFF) if(AKANTU_TESTS) add_subdirectory(test) endif(AKANTU_TESTS) diff --git a/common/aka_common.hh b/common/aka_common.hh index 4cddd868b..b81c31587 100644 --- a/common/aka_common.hh +++ b/common/aka_common.hh @@ -1,229 +1,249 @@ /** * @file aka_common.hh * @author Nicolas Richart * @date Fri Jun 11 09:48:06 2010 * * @namespace akantu * * @section LICENSE * * * * @section DESCRIPTION * * All common things to be included in the projects files * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_COMMON_HH__ #define __AKANTU_COMMON_HH__ /* -------------------------------------------------------------------------- */ #include #include #include /* -------------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include /* -------------------------------------------------------------------------- */ #define __BEGIN_AKANTU__ namespace akantu { #define __END_AKANTU__ } /* -------------------------------------------------------------------------- */ #include "aka_error.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* Common types */ /* -------------------------------------------------------------------------- */ typedef double Real; typedef unsigned int UInt; typedef int Int; typedef std::string ID; #ifdef AKANTU_NDEBUG static const Real REAL_INIT_VALUE = 0; #else static const Real REAL_INIT_VALUE = std::numeric_limits::quiet_NaN(); #endif /* -------------------------------------------------------------------------- */ /* Memory types */ /* -------------------------------------------------------------------------- */ typedef UInt MemoryID; typedef ID VectorID; /* -------------------------------------------------------------------------- */ /* Mesh/FEM/Model types */ /* -------------------------------------------------------------------------- */ typedef ID MeshID; typedef ID FEMID; typedef ID ModelID; typedef ID MaterialID; -typedef ID ContactID; + +typedef UInt Surface; enum ElementType { _not_defined = 0, _line_1 = 1, // implemented - _line_2 = 2, - _triangle_1 = 3, - _triangle_2 = 4, - _tetrahedra_1 = 5, + _line_2 = 2, // implemented + _triangle_1 = 3, // implemented + _triangle_2 = 4, // implemented + _tetrahedra_1 = 5, // implemented _tetrahedra_2 = 6, _max_element_type, _point }; enum MaterialType { _elastic = 0, _max_material_type }; +/* -------------------------------------------------------------------------- */ +/* Contact */ +/* -------------------------------------------------------------------------- */ +typedef ID ContactID; +typedef ID ContactSearchID; +typedef ID ContactNeighborStructureID; + +enum ContactType { + _ct_not_defined = 0 +}; + +enum ContactSearchType { + _cst_not_defined = 0 +}; + +enum ContactNeighborStructureType { + _cnst_not_defined = 0 +}; + /* -------------------------------------------------------------------------- */ /* Ghosts handling */ /* -------------------------------------------------------------------------- */ typedef ID SynchronizerID; enum CommunicatorType { _communicator_mpi, _communicator_dummy }; enum GhostSynchronizationTag { /// SolidMechanicsModel tags _gst_smm_mass, _gst_smm_residual, _gst_smm_boundary, /// Test _gst_test }; enum GhostType { _not_ghost, _ghost, _casper // not used but a real cute ghost }; enum SynchronizerOperation { _so_sum, _so_min, _so_max, _so_null }; /* -------------------------------------------------------------------------- */ /* Global defines */ /* -------------------------------------------------------------------------- */ #define AKANTU_MIN_ALLOCATION 2000 #define AKANTU_INDENT " " /* -------------------------------------------------------------------------- */ #define AKANTU_SET_MACRO(name, variable, type) \ inline void set##name (type variable) { \ this->variable = variable; \ } #define AKANTU_GET_MACRO(name, variable, type) \ inline type get##name () const { \ return variable; \ } #define AKANTU_GET_MACRO_NOT_CONST(name, variable, type) \ inline type get##name () { \ return variable; \ } #define AKANTU_GET_MACRO_BY_ELEMENT_TYPE(name, variable, type) \ inline type get##name (const ::akantu::ElementType & el_type) const { \ AKANTU_DEBUG_IN(); \ AKANTU_DEBUG_ASSERT(variable[el_type] != NULL, \ "No " << #variable << " of type " \ << el_type << " in " << id); \ AKANTU_DEBUG_OUT(); \ return *variable[el_type]; \ } /* -------------------------------------------------------------------------- */ //! standard output stream operator for ElementType inline std::ostream & operator <<(std::ostream & stream, ElementType type) { switch(type) { case _line_1 : stream << "line_1" ; break; case _line_2 : stream << "line_2" ; break; case _triangle_1 : stream << "triangle_1" ; break; case _triangle_2 : stream << "triangle_2" ; break; case _tetrahedra_1 : stream << "tetrahedra_1"; break; case _tetrahedra_2 : stream << "tetrahedra_2"; break; case _not_defined : stream << "undefined" ; break; case _max_element_type : stream << "ElementType(" << (int) type << ")"; break; case _point : stream << "point"; break; } return stream; } /* -------------------------------------------------------------------------- */ void initialize(int * argc, char *** argv); /* -------------------------------------------------------------------------- */ void finalize (); /* -------------------------------------------------------------------------- */ /* * For intel compiler annoying remark */ #if defined(__INTEL_COMPILER) /// remark #981: operands are evaluated in unspecified order #pragma warning ( disable : 981 ) /// remark #383: value copied to temporary, reference to temporary used #pragma warning ( disable : 383 ) #endif //defined(__INTEL_COMPILER) /* -------------------------------------------------------------------------- */ /* string manipulation */ /* -------------------------------------------------------------------------- */ inline void to_lower(std::string & str) { std::transform(str.begin(), str.end(), str.begin(), (int(*)(int))std::tolower); } /* -------------------------------------------------------------------------- */ inline void trim(std::string & to_trim) { size_t first = to_trim.find_first_not_of(" \t"); if (first != std::string::npos) { size_t last = to_trim.find_last_not_of(" \t"); to_trim = to_trim.substr(first, last - first + 1); } else to_trim = ""; } __END_AKANTU__ #endif /* __AKANTU_COMMON_HH__ */ diff --git a/common/aka_error.hh b/common/aka_error.hh index 6e3bb23f3..06404a830 100644 --- a/common/aka_error.hh +++ b/common/aka_error.hh @@ -1,216 +1,218 @@ /** * @file aka_error.hh * @author Nicolas Richart * @date Mon Jun 14 11:43:22 2010 * * @brief error management and internal exceptions * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_ERROR_HH__ #define __AKANTU_ERROR_HH__ /* -------------------------------------------------------------------------- */ #include #include #ifdef AKANTU_USE_MPI #include #endif /* -------------------------------------------------------------------------- */ #include "aka_common.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ enum DebugLevel { dbl0 = 0, dblError = 0, dblAssert = 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, dblAccessory = 9, dbl10 = 10, dbl100 = 100, dblDump = 100 }; /* -------------------------------------------------------------------------- */ namespace debug { extern std::ostream & _akantu_cout; extern std::ostream & _akantu_debug_cout; extern DebugLevel _debug_level; extern std::string _parallel_context; void setDebugLevel(const DebugLevel & level); void setParallelContext(int rank, int size); void initSignalHandler(); void printBacktrace(int sig); } /* -------------------------------------------------------------------------- */ /// 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 << "akantu::Exception" << " : " << _info << " [" << _file << ":" << _line << "]"; return stream.str().c_str(); } virtual const char* info() const throw() { return _info.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; }; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ #define AKANTU_LOCATION "(" <<__FILE__ << ":" << __func__ << "():" << __LINE__ << ")" #ifndef AKANTU_USE_MPI #define AKANTU_EXIT(status) \ do { \ - akantu::debug::printBacktrace(15); \ + if (status != EXIT_SUCCESS) \ + akantu::debug::printBacktrace(15); \ exit(status); \ - } while(0) +} while(0) #else -#define AKANTU_EXIT(status) \ - do { \ - akantu::debug::printBacktrace(15); \ - MPI_Abort(MPI_COMM_WORLD, MPI_ERR_UNKNOWN); \ +#define AKANTU_EXIT(status) \ + do { \ + if (status != EXIT_SUCCESS) \ + akantu::debug::printBacktrace(15); \ + MPI_Abort(MPI_COMM_WORLD, MPI_ERR_UNKNOWN); \ } while(0) #endif /* -------------------------------------------------------------------------- */ #define AKANTU_EXCEPTION(info) \ do { \ AKANTU_DEBUG(akantu::dblError, "!!! " << info); \ std::stringstream s_info; \ s_info << info ; \ Exception ex(s_info.str(), __FILE__, __LINE__ ); \ throw ex; \ } while(0) /* -------------------------------------------------------------------------- */ #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) #define AKANTU_DEBUG_ERROR(info) AKANTU_EXCEPTION(info) /* -------------------------------------------------------------------------- */ #else #define AKANTU_DEBUG(level,info) \ ((::akantu::debug::_debug_level >= level) && \ (::akantu::debug::_akantu_debug_cout \ << ::akantu::debug::_parallel_context \ << info << " " \ << AKANTU_LOCATION \ << std::endl)) #define AKANTU_DEBUG_TEST(level) \ (::akantu::debug::_debug_level >= (level)) #define AKANTU_DEBUG_IN() \ AKANTU_DEBUG(::akantu::dblIn , "==> " << __func__ << "()") #define AKANTU_DEBUG_OUT() \ AKANTU_DEBUG(::akantu::dblOut , "<== " << __func__ << "()") #define AKANTU_DEBUG_INFO(info) \ AKANTU_DEBUG(::akantu::dblInfo , "--- " << info) #define AKANTU_DEBUG_WARNING(info) \ AKANTU_DEBUG(::akantu::dblWarning, "??? " << info) #define AKANTU_DEBUG_TRACE(info) \ AKANTU_DEBUG(::akantu::dblTrace , ">>> " << info) #define AKANTU_DEBUG_ASSERT(test,info) \ do { \ if (!(test)) { \ AKANTU_DEBUG(::akantu::dblAssert, "assert [" << #test << "] " \ << "!!! " << info); \ AKANTU_EXIT(EXIT_FAILURE); \ } \ } while(0) #define AKANTU_DEBUG_ERROR(info) \ do { \ AKANTU_DEBUG(::akantu::dblError, "!!! " << info); \ AKANTU_EXIT(EXIT_FAILURE); \ } while(0) #endif // AKANTU_NDEBUG /* -------------------------------------------------------------------------- */ __END_AKANTU__ #endif /* __AKANTU_ERROR_HH__ */ // LocalWords: acessory diff --git a/fem/element_classes/element_class_triangle_2.cc b/fem/element_classes/element_class_triangle_2.cc index 85bb1990c..016e19e6a 100644 --- a/fem/element_classes/element_class_triangle_2.cc +++ b/fem/element_classes/element_class_triangle_2.cc @@ -1,195 +1,195 @@ /** * @file element_class_triangle_2.cc * @author Nicolas Richart * @date Thu Jul 15 10:28:28 2010 * * @brief Specialization of the element_class class for the type _triangle_2 * * @section LICENSE * * * * @section DESCRIPTION * * @verbatim \eta ^ | x 2 | ` | ` | . ` | q2 ` 5 x x 4 | ` | ` | .q0 q1. ` | ` x---------x---------x-----> \xi 0 3 1 @endverbatim * * @subsection coords Nodes coordinates * * @f[ * \begin{array}{ll} * \xi_{0} = 0 & \eta_{0} = 0 \\ * \xi_{1} = 1 & \eta_{1} = 0 \\ * \xi_{2} = 0 & \eta_{2} = 1 \\ * \xi_{3} = 1/2 & \eta_{3} = 0 \\ * \xi_{4} = 1/2 & \eta_{4} = 1/2 \\ * \xi_{5} = 0 & \eta_{5} = 1/2 * \end{array} * @f] * * @subsection shapes Shape functions * @f[ * \begin{array}{lll} * N1 = -(1 - \xi - \eta) (1 - 2 (1 - \xi - \eta)) * & \frac{\partial N1}{\partial \xi} = 1 - 4(1 - \xi - \eta) * & \frac{\partial N1}{\partial \eta} = 1 - 4(1 - \xi - \eta) \\ * N2 = - \xi (1 - 2 \xi) * & \frac{\partial N1}{\partial \xi} = - 1 + 4 \xi * & \frac{\partial N1}{\partial \eta} = 0 \\ * N3 = - \eta (1 - 2 \eta) * & \frac{\partial N1}{\partial \xi} = 0 * & \frac{\partial N1}{\partial \eta} = - 1 + 4 \eta \\ * N4 = 4 \xi (1 - \xi - \eta) * & \frac{\partial N1}{\partial \xi} = 4 (1 - 2 \xi - \eta) * & \frac{\partial N1}{\partial \eta} = - 4 \eta \\ * N5 = 4 \xi \eta * & \frac{\partial N1}{\partial \xi} = 4 \xi * & \frac{\partial N1}{\partial \eta} = 4 \eta \\ * N6 = 4 \eta (1 - \xi - \eta) * & \frac{\partial N1}{\partial \xi} = - 4 \xi * & \frac{\partial N1}{\partial \eta} = 4 (1 - \xi - 2 \eta) * \end{array} * @f] * * @subsection quad_points Position of quadrature points * @f{eqnarray*}{ * \xi_{q0} &=& 1/6 \qquad \eta_{q0} = 1/6 \\ * \xi_{q1} &=& 2/3 \qquad \eta_{q1} = 1/6 \\ * \xi_{q2} &=& 1/6 \qquad \eta_{q2} = 2/3 * @f} */ /* -------------------------------------------------------------------------- */ template<> UInt ElementClass<_triangle_2>::nb_nodes_per_element; template<> UInt ElementClass<_triangle_2>::nb_quadrature_points; template<> UInt ElementClass<_triangle_2>::spatial_dimension; /* -------------------------------------------------------------------------- */ template<> inline void ElementClass<_triangle_2>::shapeFunctions(const Real * x, Real * shape, Real * shape_deriv, Real * jacobian) { Real weight = 1./6.; /// quadrature point position Real quad[spatial_dimension * nb_quadrature_points]; quad[0] = 1./6.; /// q0_{\xi} quad[1] = 1./6.; /// q0_{\eta} quad[2] = 2./3.; /// q1_{\xi} quad[3] = 1./6.; /// q1_{\eta} quad[4] = 1./6.; /// q2_{\xi} quad[5] = 2./3.; /// q2_{\eta} Real * cquad = quad; for (UInt q = 0; q < nb_quadrature_points; ++q) { /// Natural coordinates Real c0 = 1 - cquad[0] - cquad[1]; /// @f$ c0 = 1 - \xi - \eta @f$ - Real c1 = cquad[0]; /// @f$ c1 = \x1 @f$ + Real c1 = cquad[0]; /// @f$ c1 = \xi @f$ Real c2 = cquad[1]; /// @f$ c2 = \eta @f$ shape[0] = c0 * (2 * c0 - 1.); shape[1] = c1 * (2 * c1 - 1.); shape[2] = c2 * (2 * c2 - 1.); shape[3] = 4 * c0 * c1; shape[4] = 4 * c1 * c2; shape[5] = 4 * c2 * c0; /** * @f[ * dnds = \left( * \begin{array}{cccccc} * \frac{\partial N1}{\partial \xi} * & \frac{\partial N2}{\partial \xi} * & \frac{\partial N3}{\partial \xi} * & \frac{\partial N4}{\partial \xi} * & \frac{\partial N5}{\partial \xi} * & \frac{\partial N6}{\partial \xi} \\ * * \frac{\partial N1}{\partial \eta} * & \frac{\partial N2}{\partial \eta} * & \frac{\partial N3}{\partial \eta} * & \frac{\partial N4}{\partial \eta} * & \frac{\partial N5}{\partial \eta} * & \frac{\partial N6}{\partial \eta} * \end{array} * \right) @f] */ Real dnds[nb_nodes_per_element*spatial_dimension]; dnds[0] = 1 - 4 * c0; dnds[1] = 4 * c1 - 1.; dnds[2] = 0.; dnds[3] = 4 * (c0 - c1); dnds[4] = 4 * c2; dnds[5] = - 4 * c2; dnds[6] = 1 - 4 * c0; dnds[7] = 0.; dnds[8] = 4 * c2 - 1.; dnds[9] = - 4 * c1; dnds[10] = 4 * c1; dnds[11] = 4 * (c0 - c2); /// @f$ J = dxds = dnds * x @f$ Real dxds[spatial_dimension*spatial_dimension]; Math::matrix_matrix(spatial_dimension, spatial_dimension, nb_nodes_per_element, dnds, x, dxds); Real det_dxds = Math::det2(dxds); /// @f$ dxds = J^{-1} @f$ Real inv_dxds[spatial_dimension*spatial_dimension]; Math::inv2(dxds, inv_dxds); jacobian[0] = det_dxds * weight; AKANTU_DEBUG_ASSERT(jacobian[0] > 0, "Negative jacobian computed, possible problem in the element node order."); Math::matrixt_matrixt(nb_nodes_per_element, spatial_dimension, spatial_dimension, dnds, inv_dxds, shape_deriv); cquad += spatial_dimension; shape += nb_nodes_per_element; shape_deriv += nb_nodes_per_element * spatial_dimension; jacobian++; } } /* -------------------------------------------------------------------------- */ template<> inline Real ElementClass<_triangle_2>::getInradius(const Real * coord) { UInt triangles[4][3] = { {0, 3, 5}, {3, 1, 4}, {3, 4, 5}, {5, 4, 2} }; Real inradius = std::numeric_limits::max(); for (UInt t = 0; t < 4; t++) { Real ir = Math::triangle_inradius(coord + triangles[t][0] * 2, coord + triangles[t][1] * 2, coord + triangles[t][2] * 2); inradius = ir < inradius ? ir : inradius; } return inradius; } diff --git a/model/solid_mechanics/contact.cc b/model/solid_mechanics/contact.cc index d35c874c3..6965239d7 100644 --- a/model/solid_mechanics/contact.cc +++ b/model/solid_mechanics/contact.cc @@ -1,140 +1,140 @@ /** * @file contact.cc * @author David Kammer * @author Leonardo Snozzi * @author Nicolas Richart * @date Fri Oct 8 14:55:42 2010 * * @brief Common part of contact classes * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include "contact.hh" #include "contact_search.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ Contact::Contact(const SolidMechanicsModel & model, - const ContactSearch & contact_search, + ContactSearch & contact_search, const ContactID & id, const MemoryID & memory_id) : Memory(memory_id), id(id), model(model), contact_search(&contact_search) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); } Contact::~Contact() { AKANTU_DEBUG_IN(); delete contact_search; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void Contact::initContact() { AKANTU_DEBUG_IN(); contact_search->initSearch(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void Contact::checkAndUpdate() { AKANTU_DEBUG_IN(); std::vector::iterator it; - for (it = master_surface.begin(); it != master_surface.end(); ++it) { + for (it = master_surfaces.begin(); it != master_surfaces.end(); ++it) { if(contact_search->checkIfUpdateStructureNeeded(*it)) { contact_search->updateStructure(*it); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void Contact::updateContact() { AKANTU_DEBUG_IN(); std::vector::iterator it; - for (it = master_surface.begin(); it != master_surface.end(); ++it) { + for (it = master_surfaces.begin(); it != master_surfaces.end(); ++it) { contact_search->updateStructure(*it); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void Contact::addMasterSurface(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(std::find(master_surfaces.begin(), master_surfaces.end(), master_surface) == master_surfaces.end(), "Master surface already registered in the master surface list"); master_surfaces.push_back(master_surface); contact_search->addMasterSurface(master_surface); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void Contact::removeMasterSurface(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(std::find(master_surfaces.begin(), master_surfaces.end(), master_surface) != master_surfaces.end(), "Master surface not registered in the master surface list"); std::remove(master_surfaces.begin(), master_surfaces.end(), master_surface); contact_search->removeMasterSurface(master_surface); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ Contact * Contact::newContact(const SolidMechanicsModel & model, const ContactType & contact_type, const ContactSearchType & contact_search_type, const ContactNeighborStructureType & contact_neighbor_structure_type, const ContactID & id) { AKANTU_DEBUG_IN(); std::stringstream sstr; sstr << id << ":contact_search"; ContactSearch * tmp_search = NULL; switch(contact_search_type) { case _cst_not_defined: // tmp_search = new ContactSearch(this, contact_neighbor_structure_type, sstr.str()); AKANTU_DEBUG_ERROR("Not a valid contact search type : " << contact_search_type); break; } Contact * tmp_contact = NULL; switch(contact_search_type) { case _ct_not_defined: // tmp_contact = new Contact(model, tmp_search, id); AKANTU_DEBUG_ERROR("Not a valid contact type : " << contact_type); break; } AKANTU_DEBUG_OUT(); return tmp_contact; } __END_AKANTU__ diff --git a/model/solid_mechanics/contact.hh b/model/solid_mechanics/contact.hh index ea4032d3a..5e15aee3e 100644 --- a/model/solid_mechanics/contact.hh +++ b/model/solid_mechanics/contact.hh @@ -1,118 +1,114 @@ /** * @file contact.hh * @author Nicolas Richart * @author David Kammer * @author Leonardo Snozzi * @date Mon Sep 27 09:47:27 2010 * * @brief Interface for contact classes * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_CONTACT_HH__ #define __AKANTU_CONTACT_HH__ /* -------------------------------------------------------------------------- */ #include "solid_mechanics_model.hh" +#include "contact_search.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ -namespace akantu { - class ContactSearch; -} +// namespace akantu { +// class ContactSearch; +// } class Contact : public Memory { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ protected: Contact(const SolidMechanicsModel & model, - const ContactSearch & contact_search, + ContactSearch & contact_search, const ContactID & id = "contact", - const MemoryID & memory_id = 0) : - Memory(memory_id), id(id), model(model), contact_search(contact_search) { - AKANTU_DEBUG_IN(); - - AKANTU_DEBUG_OUT(); - }; + const MemoryID & memory_id = 0); public: virtual ~Contact(); static Contact * newContact(const SolidMechanicsModel & model, const ContactType & contact_type, const ContactSearchType & contact_search_type, const ContactNeighborStructureType & contact_neighbor_structure_type, const ContactID & id = "contact"); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// update the internal structures virtual void initContact(); /// check if the neighbor structure need an update virtual void checkAndUpdate(); /// update the internal structures virtual void updateContact(); /// solve the contact virtual void solveContact() = 0; /// add a new master surface void addMasterSurface(const Surface & master_surface); /// remove a master surface void removeMasterSurface(const Surface & master_surface); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: - AKANTU_GET_MACRO(ID, id, const ContactID & id); + AKANTU_GET_MACRO(ID, id, const ContactID &); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// id of the contact class ContactID id; /// associated model - SolidMechanicsModel & model; + const SolidMechanicsModel & model; /// contact search object ContactSearch * contact_search; /// list of master surfaces std::vector master_surfaces; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "contact_inline_impl.cc" /// standard output stream operator // inline std::ostream & operator <<(std::ostream & stream, const Contact & _this) // { // _this.printself(stream); // return stream; //} __END_AKANTU__ #endif /* __AKANTU_CONTACT_HH__ */ diff --git a/model/solid_mechanics/contact_neighbor_structure.cc b/model/solid_mechanics/contact_neighbor_structure.cc index 1f48e2295..0f5f0fc71 100644 --- a/model/solid_mechanics/contact_neighbor_structure.cc +++ b/model/solid_mechanics/contact_neighbor_structure.cc @@ -1,30 +1,39 @@ /** * @file contact_neighbor_structure.cc * @author David Kammer * @author Leonardo Snozzi * @author Nicolas Richart * @date Fri Oct 8 12:42:26 2010 * * @brief * * @section LICENSE * * * */ +/* -------------------------------------------------------------------------- */ +#include "contact_neighbor_structure.hh" + +/* -------------------------------------------------------------------------- */ + +__BEGIN_AKANTU__ + /* -------------------------------------------------------------------------- */ ContactNeighborStructure::ContactNeighborStructure(const ContactSearch & contact_search, const Surface & master_surface, const ContactNeighborStructureID & id) : id(id), contact_search(contact_search), master_surface(master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); } bool ContactNeighborStructure::check() { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ERROR("Check not implemented for this neighbors structure : " << id); AKANTU_DEBUG_OUT(); } + +__END_AKANTU__ diff --git a/model/solid_mechanics/contact_neighbor_structure.hh b/model/solid_mechanics/contact_neighbor_structure.hh index 93b044196..bd0013e4d 100644 --- a/model/solid_mechanics/contact_neighbor_structure.hh +++ b/model/solid_mechanics/contact_neighbor_structure.hh @@ -1,86 +1,94 @@ /** * @file contact_neighbor_structure.hh * @author David Kammer * @author Leonardo Snozzi * @author Nicolas Richart * @date Fri Oct 8 12:36:15 2010 * * @brief Interface of the structure handling the neighbor lists * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_CONTACT_NEIGHBOR_STRUCTURE_HH__ #define __AKANTU_CONTACT_NEIGHBOR_STRUCTURE_HH__ +/* -------------------------------------------------------------------------- */ +#include "aka_common.hh" +#include "aka_vector.hh" +#include "contact_search.hh" + +/* -------------------------------------------------------------------------- */ + __BEGIN_AKANTU__ class NeighborList { public: /// number of impactor nodes UInt nb_nodes; /// list of nodes of slave surfaces near the master one Vector impactor_nodes; /// neighbor facets (sparse storage) Vector facets_offset; Vector facets; }; /* -------------------------------------------------------------------------- */ class ContactNeighborStructure { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ContactNeighborStructure(const ContactSearch & contact_search, const Surface & master_surface, const ContactNeighborStructureID & id = "contact_neighbor_structure_id"); - virtual ~ContactNeighborStructure(); + + virtual ~ContactNeighborStructure() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// initialize the structure virtual void init() = 0; /// update the structure virtual void update() = 0; /// check if an update is needed virtual bool check(); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// get the neighbor list - virtual NeighborList * getNeighborList(); + virtual NeighborList * getNeighborList() = 0; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// id of the object ContactNeighborStructureID id; /// associated contact search class const ContactSearch & contact_search; /// associated master surface const Surface & master_surface; }; __END_AKANTU__ #endif /* __AKANTU_CONTACT_NEIGHBOR_STRUCTURE_HH__ */ diff --git a/model/solid_mechanics/contact_search.cc b/model/solid_mechanics/contact_search.cc index aad776c03..35560a1c4 100644 --- a/model/solid_mechanics/contact_search.cc +++ b/model/solid_mechanics/contact_search.cc @@ -1,124 +1,124 @@ /** * @file contact_search.cc * @author David Kammer * @author Leonardo Snozzi * @author Nicolas Richart * @date Fri Oct 8 11:46:34 2010 * * @brief * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #include "contact_search.hh" #include "contact.hh" #include "contact_neighbor_structure.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ ContactSearch::ContactSearch(const Contact & contact, const ContactNeighborStructureType & neighbors_structure_type, - const ContactSearchID & id = "search_contact") : + const ContactSearchID & id) : id(id), contact(contact), neighbors_structure_type(neighbors_structure_type) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); }; /* -------------------------------------------------------------------------- */ ContactSearch::~ContactSearch() { AKANTU_DEBUG_IN(); std::map::iterator it; for (it = neighbors_structure.begin(); it != neighbors_structure.end(); ++it) { delete it->second; } neighbors_structure.clear(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ContactSearch::initSearch() { AKANTU_DEBUG_IN(); std::map::iterator it; for (it = neighbors_structure.begin(); it != neighbors_structure.end(); ++it) { it->second->init(); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ContactSearch::addMasterSurface(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(neighbors_structure.find(master_surface) == neighbors_structure.end(), "Master surface already registered in the search object " << id); - ContactNeighborStructure * tmp_neighbors_structure; + ContactNeighborStructure * tmp_neighbors_structure = NULL; std::stringstream sstr; sstr << id << ":contact_neighbor_structure:" << neighbors_structure_type << ":" << master_surface; switch(neighbors_structure_type) { case _cnst_not_defined : // tmp_neighbors_structure = new ContactNeighborStructureGrid2d(this, master_surface, sstr.str()); AKANTU_DEBUG_ERROR("Not a valid neighbors structure type : " << neighbors_structure_type); break; } - neighbors_structure[master] = tmp_neighbors_structure; + neighbors_structure[master_surface] = tmp_neighbors_structure; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ContactSearch::removeMasterSurface(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(neighbors_structure.find(master_surface) != neighbors_structure.end(), "Master surface not registered in the search object " << id); delete neighbors_structure[master_surface]; - neighbors_structure.erase(master_surface) + neighbors_structure.erase(neighbors_structure.find(master_surface)); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ContactSearch::updateStructure(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(neighbors_structure.find(master_surface) != neighbors_structure.end(), "Master surface not registered in the search object " << id); neighbors_structure[master_surface]->update(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ bool ContactSearch::checkIfUpdateStructureNeeded(const Surface & master_surface) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(neighbors_structure.find(master_surface) != neighbors_structure.end(), "Master surface not registered in the search object " << id); bool check = neighbors_structure[master_surface]->check(); AKANTU_DEBUG_OUT(); return check; } __END_AKANTU__ diff --git a/model/solid_mechanics/contact_search.hh b/model/solid_mechanics/contact_search.hh index ce2fe4975..f5cab5cce 100644 --- a/model/solid_mechanics/contact_search.hh +++ b/model/solid_mechanics/contact_search.hh @@ -1,115 +1,116 @@ /** * @file contact_search.hh * @author David Kammer * @author Leonardo Snozzi * @author Nicolas Richart * @date Fri Oct 8 10:43:54 2010 * * @brief Interface of the search class for contact * * @section LICENSE * * * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_CONTACT_SEARCH_HH__ #define __AKANTU_CONTACT_SEARCH_HH__ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" +#include "aka_vector.hh" /* -------------------------------------------------------------------------- */ namespace akantu { class Contact; class ContactNeighborStructure; } __BEGIN_AKANTU__ class PenetrationList { public: /// number of penetrating nodes UInt nb_nodes; /// nodes who have penetrated the master surface Vector penetrating_nodes; /// list of penetrated facets Vector penetrated_facets_offset; Vector penetrated_facet; /// normal of the penetrated facets Vector facets_normals; /// gap between the penetrated facets and the node Vector gap; /// position of the node projected on the penetrated facets Vector projected_position; }; /* -------------------------------------------------------------------------- */ class ContactSearch { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ContactSearch(const Contact & contact, const ContactNeighborStructureType & neighbors_structure_type, const ContactSearchID & id = "search_contact"); virtual ~ContactSearch(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// initialize the needed structures virtual void initSearch(); /// build the penetration list virtual PenetrationList * findPenetration(const Surface & master_surface) = 0; /// update the neighbor structure virtual void updateStructure(const Surface & master_surface); /// check if the neighbor structure need an update virtual bool checkIfUpdateStructureNeeded(const Surface & master_surface); /// add a new master surface void addMasterSurface(const Surface & master_surface); /// remove a master surface void removeMasterSurface(const Surface & master_surface); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: - AKANTU_GET_MACRO(Contact, conact, const Contact &); + AKANTU_GET_MACRO(Contact, contact, const Contact &); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// id of the object ContactSearchID id; /// associated contact class const Contact & contact; /// type of the neighbors structure to create const ContactNeighborStructureType & neighbors_structure_type; /// structure used to handle neighbors lists std::map neighbors_structure; }; __END_AKANTU__ #endif /* __AKANTU_CONTACT_SEARCH_HH__ */