diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ced2611c..c16cd8bf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,200 +1,201 @@ #=============================================================================== # @file CMakeLists.txt # @author Nicolas Richart <nicolas.richart@epfl.ch> # @date Fri Jun 11 09:46:59 2010 # # @section LICENSE # # <insert lisence here> # # @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) #=============================================================================== # 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/material.cc model/solid_mechanics/materials/material_elastic.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/integeration_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}) #=============================================================================== # Tests #=============================================================================== option(AKANTU_TESTS "Activate tests" OFF) if(AKANTU_TESTS) subdirs(test) endif(AKANTU_TESTS) diff --git a/common/aka_common.hh b/common/aka_common.hh index 472e91f39..ba26f81ff 100644 --- a/common/aka_common.hh +++ b/common/aka_common.hh @@ -1,228 +1,229 @@ /** * @file aka_common.hh * @author Nicolas Richart <nicolas.richart@epfl.ch> * @date Fri Jun 11 09:48:06 2010 * * @section LICENSE * * <insert license here> * * @section DESCRIPTION * * All common things to be included in the projects files * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_COMMON_HH__ #define __AKANTU_COMMON_HH__ /* -------------------------------------------------------------------------- */ #include <cmath> #include <cstdlib> #include <cstring> /* -------------------------------------------------------------------------- */ #include <iostream> #include <iomanip> #include <string> #include <exception> #include <vector> #include <map> #include <set> #include <list> #include <limits> #include <algorithm> /* -------------------------------------------------------------------------- */ #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<Real>::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; enum ElementType { _not_defined = 0, _line_1 = 1, // implemented _line_2 = 2, _triangle_1 = 3, _triangle_2 = 4, _tetrahedra_1 = 5, _tetrahedra_2 = 6, _max_element_type, _point }; enum MaterialType { _elastic = 0, _max_material_type }; /* -------------------------------------------------------------------------- */ /* 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 (); /* -------------------------------------------------------------------------- */ /* 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 = ""; } /* -------------------------------------------------------------------------- */ /* * 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) __END_AKANTU__ #endif /* __AKANTU_COMMON_HH__ */ diff --git a/model/solid_mechanics/contact.hh b/model/solid_mechanics/contact.hh new file mode 100644 index 000000000..066fdfb21 --- /dev/null +++ b/model/solid_mechanics/contact.hh @@ -0,0 +1,89 @@ +/** + * @file contact.hh + * @author Nicolas Richart <nicolas.richart@epfl.ch> + * @date Mon Sep 27 09:47:27 2010 + * + * @brief Interface for contact classes + * + * @section LICENSE + * + * <insert license here> + * + */ + +/* -------------------------------------------------------------------------- */ + +#ifndef __AKANTU_CONTACT_HH__ +#define __AKANTU_CONTACT_HH__ + +/* -------------------------------------------------------------------------- */ +#include "solid_mechanics_model.hh" + +/* -------------------------------------------------------------------------- */ + +__BEGIN_AKANTU__ + +class Contact : public Memory { + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ +public: + + Contact(const SolidMechanicsModel & model, const ContactID & id = "contact", const MemoryID & memory_id = 0) : + Memory(memory_id), id(id), model(model) { + AKANTU_DEBUG_IN(); + + AKANTU_DEBUG_OUT(); + }; + + virtual ~Contact(); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ +public: + + /// update the internal structures + virtual void updateContact() = 0; + + /// solve the contact + virtual void solveContact() = 0; + + /// function to print the contain of the class + // virtual void printself(std::ostream & stream, int indent = 0) const; + + /* ------------------------------------------------------------------------ */ + /* Accessors */ + /* ------------------------------------------------------------------------ */ +public: + AKANTU_GET_MACRO(ID, id, const ContactID & id); + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ +private: + /// id of the contact class + ContactID id; + + /// Associated model + SolidMechanicsModel & model; +}; + + +/* -------------------------------------------------------------------------- */ +/* 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/solid_mechanics_model.hh b/model/solid_mechanics/solid_mechanics_model.hh index 08b70dce0..99a6066f8 100644 --- a/model/solid_mechanics/solid_mechanics_model.hh +++ b/model/solid_mechanics/solid_mechanics_model.hh @@ -1,212 +1,218 @@ /** * @file solid_mechanics_model.hh * @author Nicolas Richart <nicolas.richart@epfl.ch> * @date Thu Jul 22 11:51:06 2010 * * @brief Model of Solid Mechanics * * @section LICENSE * * <insert license here> * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_SOLID_MECHANICS_MODEL_HH__ #define __AKANTU_SOLID_MECHANICS_MODEL_HH__ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" #include "model.hh" #include "material.hh" /* -------------------------------------------------------------------------- */ namespace akantu { // class Material; class IntegrationScheme2ndOrder; + class Contact; } __BEGIN_AKANTU__ class SolidMechanicsModel : public Model { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: SolidMechanicsModel(UInt spatial_dimension, const ModelID & id = "solid_mechanics_model", const MemoryID & memory_id = 0); SolidMechanicsModel(Mesh & mesh, UInt spatial_dimension = 0, const ModelID & id = "solid_mechanics_model", const MemoryID & memory_id = 0); virtual ~SolidMechanicsModel(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// allocate all vectors void initVectors(); /// read the material files to instantiate all the materials void readMaterials(const std::string & filename); /// initialize all internal arrays for materials void initMaterials(); /// initialize the model void initModel(); /// assemble the lumped mass matrix void assembleMass(); /// assemble the residual for the explicit scheme void updateResidual(); /// compute the acceleration from the residual void updateAcceleration(); /// explicit integration predictor void explicitPred(); /// explicit integration corrector void explicitCorr(); /// compute boundary forces from quadrature point force values void computeForcesFromQuadraturePointForceValues(); /// synchronize the ghost element boundaries values void synchronizeBoundaries(); /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; private: /// assemble the lumped mass matrix for local and ghost elements void assembleMass(GhostType ghost_type); /* ------------------------------------------------------------------------ */ /* Ghost Synchronizer inherited members */ /* ------------------------------------------------------------------------ */ public: inline virtual UInt getNbDataToPack(const Element & element, GhostSynchronizationTag tag) const; inline virtual UInt getNbDataToUnpack(const Element & element, GhostSynchronizationTag tag) const; inline virtual void packData(Real ** buffer, const Element & element, GhostSynchronizationTag tag) const; inline virtual void unpackData(Real ** buffer, const Element & element, GhostSynchronizationTag tag) const; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(TimeStep, time_step, Real); AKANTU_SET_MACRO(TimeStep, time_step, Real); AKANTU_GET_MACRO(F_M2A, f_m2a, Real); AKANTU_SET_MACRO(F_M2A, f_m2a, Real); AKANTU_GET_MACRO(Displacement, *displacement, Vector<Real> &); AKANTU_GET_MACRO(Mass, *mass, Vector<Real> &); AKANTU_GET_MACRO(Velocity, *velocity, Vector<Real> &); AKANTU_GET_MACRO(Acceleration, *acceleration, Vector<Real> &); AKANTU_GET_MACRO(Force, *force, Vector<Real> &); AKANTU_GET_MACRO(Residual, *residual, Vector<Real> &); AKANTU_GET_MACRO(Boundary, *boundary, Vector<bool> &); AKANTU_GET_MACRO_BY_ELEMENT_TYPE(ElementMaterial, element_material, Vector<UInt> &); inline Material & getMaterial(UInt mat_index); /// compute the stable time step Real getStableTimeStep(); void setPotentialEnergyFlagOn(); void setPotentialEnergyFlagOff(); Real getPotentialEnergy(); Real getKineticEnergy(); + AKANTU_SET_MACRO(Contact, contact, Contact *); + /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// time step Real time_step; /// conversion coefficient form force/mass to acceleration Real f_m2a; /// displacements array Vector<Real> * displacement; /// lumped mass array Vector<Real> * mass; /// velocities array Vector<Real> * velocity; /// accelerations array Vector<Real> * acceleration; /// forces array Vector<Real> * force; /// residuals array Vector<Real> * residual; /// boundaries array Vector<bool> * boundary; /// array of current position used during update residual Vector<Real> * current_position; /// materials of all elements ByElementTypeUInt element_material; /// materials of all ghost elements ByElementTypeUInt ghost_element_material; /// list of used materials std::vector<Material *> materials; /// integration scheme of second order used IntegrationScheme2ndOrder * integrator; + + /// object to resolve the contact + Contact * contact; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "solid_mechanics_model_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const SolidMechanicsModel & _this) { _this.printself(stream); return stream; } __END_AKANTU__ #endif /* __AKANTU_SOLID_MECHANICS_MODEL_HH__ */