diff --git a/package.cmake b/package.cmake index 40850b341..78851f012 100644 --- a/package.cmake +++ b/package.cmake @@ -1,76 +1,76 @@ #=============================================================================== # @file package.cmake # # # # @brief # # @section LICENSE # # Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # #=============================================================================== package_declare(traction-at-split-node-contact DESCRIPTION "The super contact of David" DEPENDS iohelper) package_declare_sources(traction-at-split-node-contact common/synchronized_array.cc common/parameter_reader.cc common/manual_restart.cc functions/boundary_functions.cc ntn_contact/ntn_base_contact.cc ntn_contact/ntn_contact.cc ntn_contact/ntrf_contact.cc ntn_contact/ntn_base_friction.cc ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc ntn_contact/ntn_initiation_function.cc common/ast_common.hh - akantu_simtools.hh + tasn_contact.hh # headers common/synchronized_array.hh common/parameter_reader.hh common/manual_restart.hh functions/boundary_functions.hh functions/node_filter.hh boundary_conditions/force_based_dirichlet.hh boundary_conditions/spring_bc.hh boundary_conditions/inclined_flat_dirichlet.hh ntn_contact/ntn_base_contact.hh ntn_contact/ntn_contact.hh ntn_contact/ntrf_contact.hh ntn_contact/ntn_base_friction.hh ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh ntn_contact/friction_laws/ntn_friclaw_coulomb.hh ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh ntn_contact/ntn_friction.hh ntn_contact/ntn_friction_tmpl.hh ntn_contact/ntrf_friction.hh ntn_contact/ntrf_friction_tmpl.hh ntn_contact/ntn_initiation_function.hh # inlines common/synchronized_array_inline_impl.cc ntn_contact/ntn_base_contact_inline_impl.cc ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index e55bc99cf..000000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,111 +0,0 @@ -#=============================================================================== -# @file CMakeLists.txt -# -# -# -# @brief -# -# @section LICENSE -# -# Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) -# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) -# -#=============================================================================== - -cmake_minimum_required(VERSION 2.6) -project(Akantu_SimTools) - -set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") - -set(AKANTU_SIMTOOLS_SRCS - - common/synchronized_array.cc - common/parameter_reader.cc - common/manual_restart.cc - - functions/boundary_functions.cc - - ntn_contact/ntn_base_contact.cc - ntn_contact/ntn_contact.cc - ntn_contact/ntrf_contact.cc - - ntn_contact/ntn_base_friction.cc - ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc - ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc - ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc - - ntn_contact/ntn_initiation_function.cc - ) - -set(AKANTU_SIMTOOLS_HDRS - common/ast_common.hh - akantu_simtools.hh - - # headers - common/synchronized_array.hh - common/parameter_reader.hh - common/manual_restart.hh - - functions/boundary_functions.hh - functions/node_filter.hh - - boundary_conditions/force_based_dirichlet.hh - boundary_conditions/spring_bc.hh - boundary_conditions/inclined_flat_dirichlet.hh - - ntn_contact/ntn_base_contact.hh - ntn_contact/ntn_contact.hh - ntn_contact/ntrf_contact.hh - ntn_contact/ntn_base_friction.hh - - ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh - ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh - ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh - - ntn_contact/friction_laws/ntn_friclaw_coulomb.hh - ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh - ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh - ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh - ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh - ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh - - ntn_contact/ntn_friction.hh - ntn_contact/ntn_friction_tmpl.hh - ntn_contact/ntrf_friction.hh - ntn_contact/ntrf_friction_tmpl.hh - - ntn_contact/ntn_initiation_function.hh - - # inlines - common/synchronized_array_inline_impl.cc - ntn_contact/ntn_base_contact_inline_impl.cc - ) - - -find_package(Akantu REQUIRED) -include_directories(${AKANTU_INCLUDE_DIR} - ${AKANTU_BOOST_INCLUDE_DIR} - ${AKANTU_IOHELPER_INCLUDE_DIR}) - - -add_library(akantu_simtools - ${AKANTU_SIMTOOLS_SRCS} - ) - -include_directories(common/) -include_directories(ntn_contact/) -include_directories(ntn_contact/friction_laws/) -include_directories(ntn_contact/friction_regularisations/) -include_directories(ntrf_contact/) -include_directories(ntrf_contact/friction_laws/) - -target_link_libraries(akantu_simtools akantu) -#target_link_libraries(akantu_simtools ${AKANTU_LIBRARIES}) -set_target_properties(akantu_simtools - PROPERTIES PUBLIC_HEADER "${AKANTU_SIMTOOLS_HDRS}") - -install(TARGETS akantu_simtools - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include/akantu_simtools - ) diff --git a/src/boundary_conditions/force_based_dirichlet.hh b/src/boundary_conditions/force_based_dirichlet.hh index 25b3ca215..2671dd131 100644 --- a/src/boundary_conditions/force_based_dirichlet.hh +++ b/src/boundary_conditions/force_based_dirichlet.hh @@ -1,128 +1,122 @@ /** * @file force_based_dirichlet.hh * * @author Dana Christen * @author David Simon Kammer * * * @brief dirichlet boundary condition that tries * to keep the force at a given value * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_FORCE_BASED_DIRICHLET_HH__ #define __AST_FORCE_BASED_DIRICHLET_HH__ // akantu #include "aka_common.hh" -// simtools -#include "ast_common.hh" - -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class ForceBasedDirichlet : public BC::Dirichlet::IncrementValue { protected: typedef const Array * RealArrayPtr; typedef const Array * IntArrayPtr; /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ForceBasedDirichlet(SolidMechanicsModel & model, BC::Axis ax, Real target_f, Real mass = 0.) : IncrementValue(0., ax), model(model), mass(mass), velocity(0.), target_force(target_f), total_residual(0.) {} virtual ~ForceBasedDirichlet() {} /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: void updateTotalResidual() { SubBoundarySet::iterator it = this->subboundaries.begin(); SubBoundarySet::iterator end = this->subboundaries.end(); this->total_residual = 0.; for (; it != end; ++it) { this->total_residual += integrateResidual(*it, this->model, this->axis); } } virtual Real update() { AKANTU_DEBUG_IN(); this->updateTotalResidual(); Real total_force = this->target_force + this->total_residual; Real a = total_force / this->mass; Real dt = model.getTimeStep(); this->velocity += 0.5*dt*a; this->value = this->velocity*dt + 0.5*dt*dt*a; // increment position dx this->velocity += 0.5*dt*a; AKANTU_DEBUG_OUT(); return this->total_residual; } Real applyYourself() { AKANTU_DEBUG_IN(); Real reaction = this->update(); SubBoundarySet::iterator it = this->subboundaries.begin(); SubBoundarySet::iterator end = this->subboundaries.end(); for (; it != end; ++it) { this->model.applyBC(*this,*it); } AKANTU_DEBUG_OUT(); return reaction; } /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_SET_MACRO(Mass, mass, Real); AKANTU_SET_MACRO(TargetForce, target_force, Real); void insertSubBoundary(const std::string & sb_name) { this->subboundaries.insert(sb_name); } /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ typedef std::set SubBoundarySet; protected: SolidMechanicsModel & model; SubBoundarySet subboundaries; Real mass; Real velocity; Real target_force; Real total_residual; }; -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_FORCE_BASED_DIRICHLET_HH__ */ diff --git a/src/boundary_conditions/inclined_flat_dirichlet.hh b/src/boundary_conditions/inclined_flat_dirichlet.hh index 369da797d..3cd0bc2a1 100644 --- a/src/boundary_conditions/inclined_flat_dirichlet.hh +++ b/src/boundary_conditions/inclined_flat_dirichlet.hh @@ -1,80 +1,74 @@ /** * @file inclined_flat_dirichlet.hh * * @author David Simon Kammer * * * @brief inclined dirichlet * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_INCLINED_FLAT_DIRICHLET_HH__ #define __AST_INCLINED_FLAT_DIRICHLET_HH__ // akantu #include "aka_common.hh" -// simtools -#include "ast_common.hh" - -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class InclinedFlatDirichlet : public BC::Dirichlet::DirichletFunctor { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: InclinedFlatDirichlet(Real val, BC::Axis ax, BC::Axis incl_ax, Real center_coord, Real tang) : DirichletFunctor(ax), value(val), incl_ax(incl_ax), center_coord(center_coord), tang(tang) {}; virtual ~InclinedFlatDirichlet() {} /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: inline void operator()(UInt node, Vector & flags, Vector & primal, const Vector & coord) const { AKANTU_DEBUG_IN(); Real dist = coord(incl_ax) - this->center_coord; flags(axis) = true; primal(axis) = this->value + this->tang * dist; AKANTU_DEBUG_OUT(); } /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: Real value; BC::Axis incl_ax; Real center_coord; Real tang; }; -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_INCLINED_FLAT_DIRICHLET_HH__ */ diff --git a/src/boundary_conditions/spring_bc.hh b/src/boundary_conditions/spring_bc.hh index 4c2822f66..241c62a9a 100644 --- a/src/boundary_conditions/spring_bc.hh +++ b/src/boundary_conditions/spring_bc.hh @@ -1,140 +1,137 @@ /** * @file spring_bc.hh * * @author Dana Christen * @author David Simon Kammer * * * @brief spring boundary condition * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_SPRING_BC_HH__ #define __AST_SPRING_BC_HH__ // simtools #include "force_based_dirichlet.hh" -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class SpringBC : public ForceBasedDirichlet { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: SpringBC(SolidMechanicsModel & model, BC::Axis ax, Real stiffness, Real mass = 0.) : ForceBasedDirichlet(model, ax, 0., mass), stiffness(stiffness), elongation(0.) {} virtual ~SpringBC() {} /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: virtual Real update() { AKANTU_DEBUG_IN(); this->target_force = - this->stiffness * this->elongation; Real reaction = ForceBasedDirichlet::update(); this->elongation += this->value; AKANTU_DEBUG_OUT(); return reaction; } /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(Elongation, elongation, Real); inline void setToEquilibrium() { AKANTU_DEBUG_IN(); this->updateTotalResidual(); this->target_force = - this->total_residual; this->elongation = - this->target_force / this->stiffness; AKANTU_DEBUG_OUT(); } /// change elongation /// dx > 0 -> target_force < 0 inline void incrementElongation(Real dx) { AKANTU_DEBUG_IN(); this->elongation += dx; AKANTU_DEBUG_OUT(); } //friend std::ostream& operator<<(std::ostream& out, const SpringBC & spring); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: Real stiffness; Real elongation; }; // class SpringBCRestricted : public SpringBC { // public: // SpringBCRestricted(BC::Axis ax, Real target_force, BC::Axis surface_axis, Real min, Real max) // :SpringBC(ax, target_force), surface_axis(surface_axis), min(min), max(max) {} // virtual ~SpringBCRestricted() {} // public: // inline void operator()(UInt node, Vector & flags, Vector & primal, const Vector & coord) const { // if(coord(surface_axis) > min && coord(surface_axis) < max) { // SpringBC::operator()(node, flags, primal, coord); // } // } // private: // BC::Axis surface_axis; // Real min; // Real max; // }; // std::ostream& operator<<(std::ostream& out, const SpringBC & spring) { // out << "Real total_residual: " << *spring.total_residual << std::endl; // out << "Real mass: " << spring.mass << std::endl; // out << "Real k: " << spring.k << std::endl; // out << "Real delta_x: " << spring.delta_x << std::endl; // out << "Real dt: " << spring.dt << std::endl; // out << "Real v: " << spring.v << std::endl; // out << "Real dx: " << spring.dx << std::endl; // out << "Real forcing_vel: " << spring.forcing_vel << std::endl; // return out; // } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_SPRING_BC_HH__ */ diff --git a/src/common/ast_common.hh b/src/common/ast_common.hh deleted file mode 100644 index fcb5da85c..000000000 --- a/src/common/ast_common.hh +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file ast_common.hh - * - * - * - * @brief - * - * @section LICENSE - * - * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) - * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) - * - */ - -#define __BEGIN_SIMTOOLS__ namespace akantu_simtools { -#define __END_SIMTOOLS__ } diff --git a/src/common/parameter_reader.cc b/src/common/parameter_reader.cc index 7113e6a3e..7b1612da7 100644 --- a/src/common/parameter_reader.cc +++ b/src/common/parameter_reader.cc @@ -1,447 +1,447 @@ /** * @file parameter_reader.cc * * @author David Simon Kammer * * * @brief implementation of parameter reader * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // std #include #include #include #include // simtools #include "parameter_reader.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ ParameterReader::ParameterReader() : data_types(), element_type_data(), string_data(), int_data(), uint_data(), real_data(), bool_data() { AKANTU_DEBUG_IN(); // setup of types of element data_types.insert("elementtype"); data_types.insert("string"); data_types.insert("uint"); data_types.insert("int"); data_types.insert("real"); data_types.insert("bool"); // data_types.insert("surface"); // define conversion maps _input_to_akantu_element_types["_segment_2"] = akantu::_segment_2; _input_to_akantu_element_types["_segment_3"] = akantu::_segment_3; _input_to_akantu_element_types["_triangle_3"] = akantu::_triangle_3; _input_to_akantu_element_types["_triangle_6"] = akantu::_triangle_6; _input_to_akantu_element_types["_tetrahedron_4"] = akantu::_tetrahedron_4; _input_to_akantu_element_types["_tetrahedron_10"] = akantu::_tetrahedron_10; _input_to_akantu_element_types["_quadrangle_4"] = akantu::_quadrangle_4; _input_to_akantu_element_types["_quadrangle_8"] = akantu::_quadrangle_8; _input_to_akantu_element_types["_hexahedron_8"] = akantu::_hexahedron_8; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ParameterReader::readInputFile(std::string file_name) { AKANTU_DEBUG_IN(); char comment_char = '#'; char equal_char = '='; // open a file called file name std::ifstream infile; infile.open(file_name.c_str()); if(!infile.good()) { std::cerr << "Cannot open file " << file_name << "!!!" << std::endl; exit(EXIT_FAILURE); } std::string line; std::string clean_line; while(infile.good()) { getline(infile, line); clean_line = line; // take out comments size_t found_comment; found_comment = line.find_first_of(comment_char); if (found_comment != std::string::npos) clean_line = line.substr(0,found_comment); if (clean_line.empty()) continue; std::stringstream sstr(clean_line); // check if data type exists std::string type; sstr >> type; std::transform(type.begin(),type.end(),type.begin(),::tolower); if (this->data_types.find(type) == this->data_types.end()) { std::cerr << " *** WARNING *** Data type " << type << " does not exist" << " in this input data structure. Ignore line: "; std::cerr << clean_line << std::endl; continue; } std::string keyword; std::string equal; std::string value; // get keyword sstr >> keyword; size_t equal_p = keyword.find_first_of(equal_char); if (equal_p != std::string::npos) { equal = keyword.substr(equal_p,std::string::npos); keyword = keyword.substr(0,equal_p); } // get equal if (equal.empty()) sstr >> equal; if (equal.length() != 1) { value = equal.substr(1,std::string::npos); equal = equal[0]; } if (equal[0] != equal_char) { std::cerr << " *** WARNING *** Unrespected convention! Ignore line: "; std::cerr << clean_line << std::endl; continue; } // get value if (value.empty()) sstr >> value; // no value if (value.empty()) { std::cerr << " *** WARNING *** No value given! Ignore line: "; std::cerr << clean_line << std::endl; continue; } // put value in map std::stringstream convert(value); if (type.compare("elementtype") == 0) { std::map::const_iterator it; it = this->_input_to_akantu_element_types.find(value); if (it != this->_input_to_akantu_element_types.end()) this->element_type_data.insert(std::make_pair(keyword,it->second)); else { std::cerr << " *** WARNING *** ElementType " << value << " does not exist. Ignore line: "; std::cerr << clean_line << std::endl; continue; } } else if (type.compare("string") == 0) { this->string_data.insert(std::make_pair(keyword,value)); } /* else if (type.compare("surface") == 0) { //Surface surf; UInt surf; convert >> surf; //this->surface_data.insert(std::make_pair(keyword,surf)); this->uint_data.insert(std::make_pair(keyword,surf)); } */ else if (type.compare("int") == 0) { Int i; convert >> i; this->int_data.insert(std::make_pair(keyword,i)); } else if (type.compare("uint") == 0) { UInt i; convert >> i; this->uint_data.insert(std::make_pair(keyword,i)); } else if (type.compare("real") == 0) { Real r; convert >> r; this->real_data.insert(std::make_pair(keyword,r)); } else if (type.compare("bool") == 0) { std::transform(value.begin(),value.end(),value.begin(),::tolower); bool b; if (value.compare("true") == 0) b = true; else if (value.compare("false") == 0) b = false; else { std::cerr << " *** WARNING *** boolean cannot be " << value << ". Ignore line: "; std::cerr << clean_line << std::endl; continue; } this->bool_data.insert(std::make_pair(keyword,b)); } else { std::cerr << " *** ERROR *** Could not add data to InputData for line: "; std::cerr << clean_line << std::endl; continue; exit(EXIT_FAILURE); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void ParameterReader::writeInputFile(std::string file_name) const { AKANTU_DEBUG_IN(); // open file to write input information std::ofstream outfile; outfile.open(file_name.c_str()); // element type for (std::map::const_iterator it = element_type_data.begin(); it != element_type_data.end(); ++it) { for (std::map::const_iterator et = _input_to_akantu_element_types.begin(); et != _input_to_akantu_element_types.end(); ++et) { if (it->second == et->second) { outfile << "ElementType " << it->first << " = " << et->first << std::endl; continue; } } } // string for (std::map::const_iterator it = string_data.begin(); it != string_data.end(); ++it) outfile << "string " << it->first << " = " << it->second << std::endl; // Surface /* for (std::map::const_iterator it = surface_data.begin(); it != surface_data.end(); ++it) outfile << "Surface " << it->first << " = " << it->second << std::endl; */ // Int for (std::map::const_iterator it = int_data.begin(); it != int_data.end(); ++it) outfile << "Int " << it->first << " = " << it->second << std::endl; // UInt for (std::map::const_iterator it = uint_data.begin(); it != uint_data.end(); ++it) outfile << "UInt " << it->first << " = " << it->second << std::endl; // Real for (std::map::const_iterator it = real_data.begin(); it != real_data.end(); ++it) outfile << "Real " << it->first << " = " << it->second << std::endl; // Bool for (std::map::const_iterator it = bool_data.begin(); it != bool_data.end(); ++it) { std::string b = "false"; if (it->second) b = "true"; outfile << "bool " << it->first << " = " << b << std::endl; } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template<> akantu::UInt ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->uint_data.find(key); // if not in map if (it == this->uint_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "UInt " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ template<> akantu::ElementType ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->element_type_data.find(key); // if not in map if (it == this->element_type_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "ElementType " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ template<> std::string ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->string_data.find(key); // if not in map if (it == this->string_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "string " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ /* template<> akantu::Surface ParameterData::get(std::string key) const { std::map::const_iterator it; it = this->surface_data.find(key); // if not in map if (it == this->surface_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "Surface " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } */ /* -------------------------------------------------------------------------- */ template<> akantu::Int ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->int_data.find(key); // if not in map if (it == this->int_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "Int " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ template<> akantu::Real ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->real_data.find(key); // if not in map if (it == this->real_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "Real " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ template<> bool ParameterReader::get(std::string key) const { std::map::const_iterator it; it = this->bool_data.find(key); // if not in map if (it == this->bool_data.end()) { std::cerr << " *** ERROR *** This data was not in input file. " << "You need the following line in your input file: "; std::cerr << "bool " << key << " = ???" << std::endl; exit(EXIT_FAILURE); } else return it->second; } /* -------------------------------------------------------------------------- */ template<> bool ParameterReader::has(std::string key) const { std::map::const_iterator it; it = this->bool_data.find(key); return (it != this->bool_data.end()); } template<> bool ParameterReader::has(std::string key) const { std::map::const_iterator it; it = this->string_data.find(key); return (it != this->string_data.end()); } template<> bool ParameterReader::has(std::string key) const { std::map::const_iterator it; it = this->int_data.find(key); return (it != this->int_data.end()); } template<> bool ParameterReader::has(std::string key) const { std::map::const_iterator it; it = this->uint_data.find(key); return (it != this->uint_data.end()); } template<> bool ParameterReader::has(std::string key) const { std::map::const_iterator it; it = this->real_data.find(key); return (it != this->real_data.end()); } /* -------------------------------------------------------------------------- */ void ParameterReader::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "ParameterReader [" << std::endl; /* stream << space << this->element_type_data << std::endl; stream << space << this->string_data << std::endl; stream << space << this->surface_data << std::endl; stream << space << this->int_data << std::endl; stream << space << this->uint_data << std::endl; stream << space << this->real_data << std::endl; stream << space << this->bool_data << std::endl; */ stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/common/parameter_reader.hh b/src/common/parameter_reader.hh index 7c41b5444..e75749bbe 100644 --- a/src/common/parameter_reader.hh +++ b/src/common/parameter_reader.hh @@ -1,105 +1,99 @@ /** * @file parameter_reader.hh * * @author David Simon Kammer * * * @brief for simulations to read parameters from an input file * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_PARAMETER_READER_HH__ #define __AST_PARAMETER_READER_HH__ /* -------------------------------------------------------------------------- */ // std #include #include // akantu #include "aka_common.hh" -// simtools -#include "ast_common.hh" - -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class ParameterReader { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ParameterReader(); virtual ~ParameterReader() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// read input file void readInputFile(std::string file_name); /// write input file void writeInputFile(std::string file_name) const; /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// template T get(std::string key) const; template bool has(std::string key) const; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// type of data available std::set data_types; /// data std::map element_type_data; std::map string_data; std::map int_data; std::map uint_data; std::map real_data; std::map bool_data; /// convert string to element type std::map _input_to_akantu_element_types; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "parameter_reader_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const ParameterReader & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_PARAMETER_READER_HH__ */ diff --git a/src/common/synchronized_array.cc b/src/common/synchronized_array.cc index 0374e0b94..efffb2de4 100644 --- a/src/common/synchronized_array.cc +++ b/src/common/synchronized_array.cc @@ -1,222 +1,222 @@ /** * @file synchronized_array.cc * * @author David Simon Kammer * * * @brief implementation of synchronized array function * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // std #include #include // simtools #include "synchronized_array.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template SynchronizedArray::SynchronizedArray(UInt size, UInt nb_component, SynchronizedArray::const_reference value, const ID & id, SynchronizedArray::const_reference default_value, const std::string restart_name) : SynchronizedArrayBase(), Array(size, nb_component, value, id), default_value(default_value), restart_name(restart_name), deleted_elements(0), nb_added_elements(size), depending_arrays(0) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void SynchronizedArray::syncElements(SyncChoice sync_choice) { AKANTU_DEBUG_IN(); if (sync_choice == _deleted) { std::vector::iterator it; for (it=depending_arrays.begin(); it != depending_arrays.end(); ++it) { UInt vec_size = (*it)->syncDeletedElements(this->deleted_elements); AKANTU_DEBUG_ASSERT(vec_size == this->size, "Synchronized arrays do not have the same length" << "(may be a double synchronization)"); } this->deleted_elements.clear(); } else if (sync_choice == _added) { std::vector::iterator it; for (it=depending_arrays.begin(); it != depending_arrays.end(); ++it) { UInt vec_size = (*it)->syncAddedElements(this->nb_added_elements); AKANTU_DEBUG_ASSERT(vec_size == this->size, "Synchronized arrays do not have the same length" << "(may be a double synchronization)"); } this->nb_added_elements = 0; } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template UInt SynchronizedArray::syncDeletedElements(std::vector & del_elements) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(nb_added_elements == 0 && deleted_elements.size() == 0, "Cannot sync with a SynchronizedArray if it has already been modified"); std::vector::const_iterator it; for (it = del_elements.begin(); it != del_elements.end(); ++it) { erase(*it); } syncElements(_deleted); AKANTU_DEBUG_OUT(); return this->size; } /* -------------------------------------------------------------------------- */ template UInt SynchronizedArray::syncAddedElements(UInt nb_add_elements) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(nb_added_elements == 0 && deleted_elements.size() == 0, "Cannot sync with a SynchronizedArray if it has already been modified"); for (UInt i=0; idefault_value); } syncElements(_added); AKANTU_DEBUG_OUT(); return this->size; } /* -------------------------------------------------------------------------- */ template void SynchronizedArray::registerDependingArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->depending_arrays.push_back(&array); array.syncAddedElements(this->size); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void SynchronizedArray::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "SynchronizedArray<" << debug::demangle(typeid(T).name()) << "> [" << std::endl; stream << space << " + default_value : " << this->default_value << std::endl; stream << space << " + nb_added_elements : " << this->nb_added_elements << std::endl; stream << space << " + deleted_elements : "; for(std::vector::const_iterator it = this->deleted_elements.begin(); it != this->deleted_elements.end(); ++it) stream << *it << " "; stream << std::endl; stream << space << " + depending_arrays : "; for (std::vector::const_iterator it = this->depending_arrays.begin(); it!=this->depending_arrays.end(); ++it) stream << (*it)->getID() << " "; stream << std::endl; Array::printself(stream, indent+1); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void SynchronizedArray::dumpRestartFile(std::string file_name) const { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(nb_added_elements == 0 && deleted_elements.size() == 0, "Restart File for SynchronizedArray " << this->id << " should not be dumped as it is not synchronized yet"); std::stringstream name; name << file_name << "-" << this->restart_name << ".rs"; std::ofstream out_restart; out_restart.open(name.str().c_str()); out_restart << this->size << " " << this->nb_component << std::endl; Real size_comp = this->size * this->nb_component; for (UInt i=0; ivalues[i] << " "; // out_restart << std::hex << std::setprecision(12) << this->values[i] << " "; out_restart << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void SynchronizedArray::readRestartFile(std::string file_name) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(nb_added_elements == 0 && deleted_elements.size() == 0, "Restart File for SynchronizedArray " << this->id << " should not be read as it is not synchronized yet"); std::stringstream name; name << file_name << "-" << this->restart_name << ".rs"; std::ifstream infile; infile.open(name.str().c_str()); std::string line; // get size and nb_component info AKANTU_DEBUG_ASSERT(infile.good(), "Could not read restart file for " << "SynchronizedArray " << this->id); getline(infile, line); std::stringstream size_comp(line); size_comp >> this->size; size_comp >> this->nb_component; // get elements in array getline(infile, line); std::stringstream data(line); for (UInt i=0; isize * this->nb_component; ++i) { AKANTU_DEBUG_ASSERT(!data.eof(), "Read SynchronizedArray " << this->id << " got to the end of the file before having read all data!"); data >> this->values[i]; // data >> std::hex >> this->values[i]; } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template class SynchronizedArray; template class SynchronizedArray; template class SynchronizedArray; template class SynchronizedArray; -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/common/synchronized_array.hh b/src/common/synchronized_array.hh index 8df0f9741..8e0edb5b9 100644 --- a/src/common/synchronized_array.hh +++ b/src/common/synchronized_array.hh @@ -1,195 +1,189 @@ /** * @file synchronized_array.hh * * @author David Simon Kammer * * * @brief synchronized array: a array can be registered to another (hereafter called top) array. If an element is added to or removed from the top array, the registered array removes or adds at the same position an element. The two arrays stay therefore synchronized. * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_SYNCHRONIZED_ARRAY_HH__ #define __AST_SYNCHRONIZED_ARRAY_HH__ /* -------------------------------------------------------------------------- */ // std #include // akantu #include "aka_array.hh" -// simtools -#include "ast_common.hh" - -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ enum SyncChoice {_added, _deleted}; /* -------------------------------------------------------------------------- */ class SynchronizedArrayBase { public: SynchronizedArrayBase() {}; ~SynchronizedArrayBase() {}; virtual ID getID() const { return "call should be virtual"; }; virtual UInt syncDeletedElements(std::vector & delete_el) = 0; virtual UInt syncAddedElements(UInt nb_added_el) = 0; }; /* -------------------------------------------------------------------------- */ template class SynchronizedArray : public SynchronizedArrayBase, protected Array { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: typedef typename Array::value_type value_type; typedef typename Array::reference reference; typedef typename Array::pointer_type pointer_type; typedef typename Array::const_reference const_reference; SynchronizedArray(UInt size, UInt nb_component, const_reference value, const ID & id, const_reference default_value, const std::string restart_name); virtual ~SynchronizedArray() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// push_back inline void push_back(const_reference value); inline void push_back(const value_type new_element[]); /// erase inline void erase(UInt i); //template //inline void erase(const iterator & it); /// synchronize elements void syncElements(SyncChoice sync_choice); /// dump restart file void dumpRestartFile(std::string file_name) const; /// read restart file void readRestartFile(std::string file_name); /// register depending array void registerDependingArray(SynchronizedArrayBase & array); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; /// find position of element Int find(const T & elem) const { return Array::find(elem); }; /// set values to zero inline void clear() { Array::clear(); }; // inline void clear() { memset(values, 0, size*nb_component*sizeof(T)); }; /// set all entries of the array to the value t /// @param t value to fill the array with inline void set(T t) { Array::set(t); } /// set template class C> inline void set(const C & vm) { Array::set(vm); }; /// set all entries of the array to value t and set default value inline void setAndChangeDefault(T t) { this->set(t); this->default_value = t; } /// copy the content of an other array void copy(const SynchronizedArray & vect) { Array::copy(vect); }; /// give the address of the memory allocated for this array T * storage() const { return Array::storage(); }; // T * storage() const { return this->values; }; // get nb component UInt getNbComponent() const { return Array::getNbComponent(); }; protected: UInt syncDeletedElements(std::vector & del_elements); UInt syncAddedElements(UInt nb_add_elements); /* ------------------------------------------------------------------------ */ /* Operators */ /* ------------------------------------------------------------------------ */ public: inline reference operator()(UInt i, UInt j = 0) { return Array::operator()(i,j); } inline const_reference operator()(UInt i, UInt j = 0) const { return Array::operator()(i,j); } /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_SET_MACRO(DefaultValue, default_value, T); UInt getSize() const{ return this->size; }; ID getID() const { return Array::getID(); }; const Array & getArray() const { const Array & a = *(dynamic_cast *>(this)); return a; }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// init value when new elements added T default_value; /// restart file_name const std::string restart_name; /// elements that have been deleted std::vector deleted_elements; /// number of elements to add UInt nb_added_elements; /// pointers to arrays to be updated std::vector depending_arrays; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "synchronized_array_inline_impl.cc" /// standard output stream operator template inline std::ostream & operator <<(std::ostream & stream, const SynchronizedArray & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_SYNCHRONIZED_ARRAY_HH__ */ diff --git a/src/functions/boundary_functions.cc b/src/functions/boundary_functions.cc index d942fded2..a27722761 100644 --- a/src/functions/boundary_functions.cc +++ b/src/functions/boundary_functions.cc @@ -1,63 +1,63 @@ /** * @file boundary_functions.cc * * * * @brief * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ #include "boundary_functions.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ Real integrateResidual(const std::string & sub_boundary_name, const SolidMechanicsModel & model, UInt dir) { Real int_res = 0.; const Mesh & mesh = model.getMesh(); const Array & residual = model.getResidual(); // do not need try catch, as all subboundaries should be everywhere. // try { const ElementGroup & boundary = mesh.getElementGroup(sub_boundary_name); ElementGroup::const_node_iterator nit = boundary.node_begin(); ElementGroup::const_node_iterator nend = boundary.node_end(); for (; nit != nend; ++nit) { bool is_local_node = mesh.isLocalOrMasterNode(*nit); if (is_local_node) { int_res += residual(*nit, dir); } } // } catch(debug::Exception e) { // // AKANTU_DEBUG_ERROR("Error computing integrateResidual. Cannot get SubBoundary: " // // << sub_boundary_name << " [" << e.what() << "]"); // } StaticCommunicator::getStaticCommunicator().allReduce(&int_res, 1, _so_sum); return int_res; } /* -------------------------------------------------------------------------- */ void boundaryFix(Mesh & mesh, const std::vector & sub_boundary_names) { std::vector::const_iterator it = sub_boundary_names.begin(); std::vector::const_iterator end = sub_boundary_names.end(); for (; it != end; ++it) { if (mesh.element_group_find(*it) == mesh.element_group_end()) { mesh.createElementGroup(*it,mesh.getSpatialDimension()-1); // empty element group } } } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/functions/boundary_functions.hh b/src/functions/boundary_functions.hh index bb007d5c8..cf882b8fa 100644 --- a/src/functions/boundary_functions.hh +++ b/src/functions/boundary_functions.hh @@ -1,36 +1,31 @@ /** * @file boundary_functions.hh * * @author David Simon Kammer * * * @brief functions for boundaries * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // akantu #include "aka_common.hh" #include "solid_mechanics_model.hh" -// simtools -#include "ast_common.hh" - -__BEGIN_SIMTOOLS__ - -using namespace akantu; +__BEGIN_AKANTU__ Real integrateResidual(const std::string & sub_boundary_name, const SolidMechanicsModel & model, UInt dir); /// this is a fix so that all subboundaries exist on all procs void boundaryFix(Mesh & mesh, const std::vector & sub_boundary_names); -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/functions/node_filter.hh b/src/functions/node_filter.hh index 54fb26562..eabff8efc 100644 --- a/src/functions/node_filter.hh +++ b/src/functions/node_filter.hh @@ -1,110 +1,106 @@ /** * @file node_filter.hh * * @author David Simon Kammer * * * @brief to filter nodes with functors * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NODE_FILTER_HH__ #define __AST_NODE_FILTER_HH__ /* -------------------------------------------------------------------------- */ // akantu #include "aka_common.hh" #include "mesh_filter.hh" -// simtools -#include "ast_common.hh" -__BEGIN_SIMTOOLS__ - -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class GeometryFilter : public NodeFilterFunctor { public: GeometryFilter(const Mesh & mesh, UInt dir, Real limit) : NodeFilterFunctor(), mesh(mesh), dir(dir), limit(limit) { this->positions = &(mesh.getNodes()); }; ~GeometryFilter() {}; bool operator() (UInt node) { AKANTU_DEBUG_TO_IMPLEMENT(); }; protected: const Mesh & mesh; UInt dir; Real limit; const Array * positions; }; /* -------------------------------------------------------------------------- */ class FilterPositionsGreaterThan : public GeometryFilter { public: FilterPositionsGreaterThan(const Mesh & mesh, UInt dir, Real limit) : GeometryFilter(mesh, dir, limit) {}; ~FilterPositionsGreaterThan() {}; bool operator() (UInt node) { AKANTU_DEBUG_IN(); bool to_filter = true; if((*this->positions)(node,this->dir) > this->limit) to_filter = false; AKANTU_DEBUG_OUT(); return to_filter; }; }; /* -------------------------------------------------------------------------- */ class FilterPositionsLessThan : public GeometryFilter { public: FilterPositionsLessThan(const Mesh & mesh, UInt dir, Real limit) : GeometryFilter(mesh, dir, limit) {}; ~FilterPositionsLessThan() {}; bool operator() (UInt node) { AKANTU_DEBUG_IN(); bool to_filter = true; if((*this->positions)(node,this->dir) < this->limit) to_filter = false; AKANTU_DEBUG_OUT(); return to_filter; }; }; /* -------------------------------------------------------------------------- */ // this filter is erase because the convention of filter has changed!! // filter == true -> keep node // template // void applyNodeFilter(Array & nodes, FilterType & filter) { // Array::iterator<> it = nodes.begin(); // for (; it != nodes.end(); ++it) { // if (filter(*it)) { // it = nodes.erase(it); // } // } // }; -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NODE_FILTER_HH__ */ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh b/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh index 064a08183..d1bdb1efc 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh @@ -1,97 +1,95 @@ /** * @file ntn_friclaw_coulomb.hh * * @author David Simon Kammer * * * @brief coulomb friction with \mu_s = \mu_k (constant) * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICLAW_COULOMB_HH__ #define __AST_NTN_FRICLAW_COULOMB_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_no_regularisation.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - template class NTNFricLawCoulomb : public Regularisation { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricLawCoulomb(NTNBaseContact * contact, const FrictionID & id = "coulomb", const MemoryID & memory_id = 0); virtual ~NTNFricLawCoulomb() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// register synchronizedarrays for sync virtual void registerSynchronizedArray(SynchronizedArrayBase & array); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// compute frictional strength according to friction law virtual void computeFrictionalStrength(); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: // friction coefficient SynchronizedArray mu; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator template inline std::ostream & operator <<(std::ostream & stream, const NTNFricLawCoulomb & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #include "ntn_friclaw_coulomb_tmpl.hh" #endif /* __AST_NTN_FRICLAW_COULOMB_HH__ */ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh b/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh index 532e07b3b..f00661ee5 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh @@ -1,147 +1,147 @@ /** * @file ntn_friclaw_coulomb_tmpl.hh * * @author David Simon Kammer * * * @brief implementation of coulomb friction * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template NTNFricLawCoulomb::NTNFricLawCoulomb(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : Regularisation(contact,id,memory_id), mu(0,1,0.,id+":mu",0.,"mu") { AKANTU_DEBUG_IN(); Regularisation::registerSynchronizedArray(this->mu); this->registerParam("mu", this->mu, _pat_parsmod, "friction coefficient"); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::computeFrictionalStrength() { AKANTU_DEBUG_IN(); // get contact arrays const SynchronizedArray & is_in_contact = this->internalGetIsInContact(); const SynchronizedArray & pressure = this->internalGetContactPressure(); // array to fill SynchronizedArray & strength = this->internalGetFrictionalStrength(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nmu(n) * pressure(n); } } Regularisation::computeFrictionalStrength(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->mu.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->mu.dumpRestartFile(file_name); Regularisation::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->mu.readRestartFile(file_name); Regularisation::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricLawCoulomb [" << std::endl; Regularisation::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawCoulomb::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if(field_id == "mu") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->mu.getArray())); } /* else if (field_id == "frictional_contact_pressure") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new DumperIOHelper::NodalField(this->frictional_contact_pressure.getArray())); } */ else { Regularisation::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh b/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh index 4dae2440e..bc51f045f 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh @@ -1,103 +1,101 @@ /** * @file ntn_friclaw_linear_cohesive.hh * * @author David Simon Kammer * * * @brief linear cohesive law * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__ #define __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_no_regularisation.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - template class NTNFricLawLinearCohesive : public Regularisation { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricLawLinearCohesive(NTNBaseContact * contact, const FrictionID & id = "linear_cohesive", const MemoryID & memory_id = 0); virtual ~NTNFricLawLinearCohesive() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// register synchronizedarrays for sync virtual void registerSynchronizedArray(SynchronizedArrayBase & array); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// compute frictional strength according to friction law virtual void computeFrictionalStrength(); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: // fracture energy SynchronizedArray G_c; // peak value of cohesive law SynchronizedArray tau_c; // residual value of cohesive law (for slip > d_c) SynchronizedArray tau_r; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator template inline std::ostream & operator <<(std::ostream & stream, const NTNFricLawLinearCohesive & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #include "ntn_friclaw_linear_cohesive_tmpl.hh" #endif /* __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__ */ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh b/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh index 59158a6ae..3dca6e87d 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh @@ -1,170 +1,170 @@ /** * @file ntn_friclaw_linear_cohesive_tmpl.hh * * @author David Simon Kammer * * * @brief implementation of linear cohesive law * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ //#include "dumper_text.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template NTNFricLawLinearCohesive::NTNFricLawLinearCohesive(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : Regularisation(contact,id,memory_id), G_c(0,1,0.,id+":G_c",0.,"G_c"), tau_c(0,1,0.,id+":tau_c",0.,"tau_c"), tau_r(0,1,0.,id+":tau_r",0.,"tau_r") { AKANTU_DEBUG_IN(); Regularisation::registerSynchronizedArray(this->G_c); Regularisation::registerSynchronizedArray(this->tau_c); Regularisation::registerSynchronizedArray(this->tau_r); this->registerParam("G_c", this->G_c, _pat_parsmod, "fracture energy"); this->registerParam("tau_c", this->tau_c, _pat_parsmod, "peak shear strength"); this->registerParam("tau_r", this->tau_r, _pat_parsmod, "residual shear strength"); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::computeFrictionalStrength() { AKANTU_DEBUG_IN(); // get arrays const SynchronizedArray & is_in_contact = this->internalGetIsInContact(); const SynchronizedArray & slip = this->internalGetSlip(); // array to fill SynchronizedArray & strength = this->internalGetFrictionalStrength(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nG_c(n) == 0.) { // strength(n) = 0.; strength(n) = this->tau_r(n); } else { Real slope = (this->tau_c(n) - this->tau_r(n)) * (this->tau_c(n) - this->tau_r(n)) / (2*this->G_c(n)); // no strength < tau_r strength(n) = std::max(this->tau_c(n) - slope * slip(n), this->tau_r(n)); // strength(n) = std::max(this->tau_c(n) - slope * slip(n), 0.); // no negative strength // if we want to keep strength loss after restick, // we need to do min between new strength and previous strength } } } Regularisation::computeFrictionalStrength(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->G_c.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->G_c.dumpRestartFile(file_name); this->tau_c.dumpRestartFile(file_name); this->tau_r.dumpRestartFile(file_name); Regularisation::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->G_c.readRestartFile(file_name); this->tau_c.readRestartFile(file_name); this->tau_r.readRestartFile(file_name); Regularisation::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricLawLinearCohesive [" << std::endl; Regularisation::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearCohesive::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if(field_id == "G_c") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->G_c.getArray())); } else if(field_id == "tau_c") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->tau_c.getArray())); } else if(field_id == "tau_r") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->tau_r.getArray())); } else { Regularisation::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh b/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh index f01a3ea8b..40e39c65a 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh @@ -1,105 +1,103 @@ /** * @file ntn_friclaw_linear_slip_weakening.hh * * @author David Simon Kammer * * * @brief linear slip weakening * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__ #define __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_friclaw_coulomb.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - template class NTNFricLawLinearSlipWeakening : public NTNFricLawCoulomb { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricLawLinearSlipWeakening(NTNBaseContact * contact, const FrictionID & id = "linear_slip_weakening", const MemoryID & memory_id = 0); virtual ~NTNFricLawLinearSlipWeakening() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// register synchronizedarrays for sync virtual void registerSynchronizedArray(SynchronizedArrayBase & array); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// compute frictional strength according to friction law virtual void computeFrictionalStrength(); /// computes the friction coefficient as a function of slip virtual void computeFrictionCoefficient(); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: // static coefficient of friction SynchronizedArray mu_s; // kinetic coefficient of friction SynchronizedArray mu_k; // Dc the length over which slip weakening happens SynchronizedArray d_c; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator template inline std::ostream & operator <<(std::ostream & stream, const NTNFricLawLinearSlipWeakening & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #include "ntn_friclaw_linear_slip_weakening_tmpl.hh" #endif /* __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__ */ diff --git a/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh b/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh index 783cf4a5e..71cde4c78 100644 --- a/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh +++ b/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh @@ -1,171 +1,171 @@ /** * @file ntn_friclaw_linear_slip_weakening_tmpl.hh * * @author David Simon Kammer * * * @brief implementation of linear slip weakening * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #include "dumper_text.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template NTNFricLawLinearSlipWeakening::NTNFricLawLinearSlipWeakening(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : NTNFricLawCoulomb(contact,id,memory_id), mu_s(0,1,0.,id+":mu_s",0.,"mu_s"), mu_k(0,1,0.,id+":mu_k",0.,"mu_k"), d_c(0,1,0.,id+":d_c",0.,"d_c") { AKANTU_DEBUG_IN(); NTNFricLawCoulomb::registerSynchronizedArray(this->mu_s); NTNFricLawCoulomb::registerSynchronizedArray(this->mu_k); NTNFricLawCoulomb::registerSynchronizedArray(this->d_c); this->registerParam("mu_s", this->mu_s, _pat_parsmod, "static friction coefficient"); this->registerParam("mu_k", this->mu_k, _pat_parsmod, "kinetic friction coefficient"); this->registerParam("d_c", this->d_c, _pat_parsmod, "slip weakening length"); this->setParamAccessType("mu", _pat_readable); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::computeFrictionalStrength() { AKANTU_DEBUG_IN(); computeFrictionCoefficient(); NTNFricLawCoulomb::computeFrictionalStrength(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::computeFrictionCoefficient() { AKANTU_DEBUG_IN(); // get arrays const SynchronizedArray & stick = this->internalGetIsSticking(); const SynchronizedArray & slip = this->internalGetSlip(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nmu(n) = this->mu_s(n); } else { if (slip(n) >= this->d_c(n)) { this->mu(n) = this->mu_k(n); } else { // mu = mu_k + (1 - slip / Dc) * (mu_s - mu_k) this->mu(n) = this->mu_k(n) + (1 - (slip(n) / this->d_c(n))) * (this->mu_s(n) - this->mu_k(n)); } } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->mu_s.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->mu_s.dumpRestartFile(file_name); this->mu_k.dumpRestartFile(file_name); this->d_c.dumpRestartFile(file_name); NTNFricLawCoulomb::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->mu_s.readRestartFile(file_name); this->mu_k.readRestartFile(file_name); this->d_c.readRestartFile(file_name); NTNFricLawCoulomb::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricLawLinearSlipWeakening [" << std::endl; NTNFricLawCoulomb::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void NTNFricLawLinearSlipWeakening::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if(field_id == "mu_s") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->mu_s.getArray())); } else if(field_id == "mu_k") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->mu_k.getArray())); } else if(field_id == "d_c") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->d_c.getArray())); } else { NTNFricLawCoulomb::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc b/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc index f52da7a40..5bc2c340f 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc @@ -1,147 +1,147 @@ /** * @file ntn_fricreg_no_regularisation.cc * * @author David Simon Kammer * * * @brief implementation of no regularisation * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_no_regularisation.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNFricRegNoRegularisation::NTNFricRegNoRegularisation(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : NTNBaseFriction(contact, id, memory_id), frictional_contact_pressure(0,1,0.,id+":frictional_contact_pressure",0., "frictional_contact_pressure") { AKANTU_DEBUG_IN(); NTNBaseFriction::registerSynchronizedArray(this->frictional_contact_pressure); this->registerParam("frictional_contact_pressure", this->frictional_contact_pressure, _pat_internal , "contact pressure used for friction law"); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ const SynchronizedArray & NTNFricRegNoRegularisation::internalGetContactPressure() { AKANTU_DEBUG_IN(); this->computeFrictionalContactPressure(); AKANTU_DEBUG_OUT(); return this->frictional_contact_pressure; } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::computeFrictionalContactPressure() { AKANTU_DEBUG_IN(); SolidMechanicsModel & model = this->contact->getModel(); UInt dim = model.getSpatialDimension(); // get contact arrays const SynchronizedArray & is_in_contact = this->internalGetIsInContact(); const Array & pressure = this->contact->getContactPressure().getArray(); Array::const_iterator< Vector > it = pressure.begin(dim); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nfrictional_contact_pressure(n) = 0.; // node pair is in contact else { // compute frictional contact pressure const Vector & pres = it[n]; this->frictional_contact_pressure(n) = pres.norm(); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->frictional_contact_pressure.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->frictional_contact_pressure.dumpRestartFile(file_name); NTNBaseFriction::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->frictional_contact_pressure.readRestartFile(file_name); NTNBaseFriction::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricRegNoRegularisation [" << std::endl; NTNBaseFriction::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegNoRegularisation::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if (field_id == "frictional_contact_pressure") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->frictional_contact_pressure.getArray())); } else { NTNBaseFriction::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh b/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh index f020378f5..8301e296a 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh @@ -1,122 +1,120 @@ /** * @file ntn_fricreg_no_regularisation.hh * * @author David Simon Kammer * * * @brief regularisation that does nothing * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICREG_NO_REGULARISATION_HH__ #define __AST_NTN_FRICREG_NO_REGULARISATION_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_base_friction.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - class NTNFricRegNoRegularisation : public NTNBaseFriction { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricRegNoRegularisation(NTNBaseContact * contact, const FrictionID & id = "no_regularisation", const MemoryID & memory_id = 0); virtual ~NTNFricRegNoRegularisation() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// set to steady state for no regularisation -> do nothing virtual void setToSteadyState() {}; virtual void registerSynchronizedArray(SynchronizedArrayBase & array); virtual void dumpRestart(const std::string & file_name) const; virtual void readRestart(const std::string & file_name); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: virtual void computeFrictionalContactPressure(); /// compute frictional strength according to friction law virtual void computeFrictionalStrength() {}; /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: protected: /// get the is_in_contact array virtual const SynchronizedArray & internalGetIsInContact() { return this->contact->getIsInContact(); }; /// get the contact pressure (the norm: scalar value) virtual const SynchronizedArray & internalGetContactPressure(); /// get the frictional strength array virtual SynchronizedArray & internalGetFrictionalStrength() { return this->frictional_strength; }; /// get the is_sticking array virtual SynchronizedArray & internalGetIsSticking() { return this->is_sticking; } /// get the slip array virtual SynchronizedArray & internalGetSlip() { return this->slip; } /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: // contact pressure (absolut value) for computation of friction SynchronizedArray frictional_contact_pressure; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "ntn_fricreg_no_regularisation_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNFricRegNoRegularisation & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_FRICREG_NO_REGULARISATION_HH__ */ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc b/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc index ed60f2dd6..a51ce0fc4 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc @@ -1,154 +1,154 @@ /** * @file ntn_fricreg_rubin_ampuero.cc * * @author David Simon Kammer * * * @brief implementation of no regularisation * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_rubin_ampuero.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNFricRegRubinAmpuero::NTNFricRegRubinAmpuero(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : NTNFricRegNoRegularisation(contact, id, memory_id), t_star(0,1,0.,id+":t_star",0.,"t_star") { AKANTU_DEBUG_IN(); NTNFricRegNoRegularisation::registerSynchronizedArray(this->t_star); this->registerParam("t_star", this->t_star, _pat_parsmod, "time scale of regularization"); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ const SynchronizedArray & NTNFricRegRubinAmpuero::internalGetContactPressure() { AKANTU_DEBUG_IN(); SolidMechanicsModel & model = this->contact->getModel(); UInt dim = model.getSpatialDimension(); Real delta_t = model.getTimeStep(); // get contact arrays const SynchronizedArray & is_in_contact = this->internalGetIsInContact(); const Array & pressure = this->contact->getContactPressure().getArray(); Array::const_iterator< Vector > it = pressure.begin(dim); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nfrictional_contact_pressure(n) = 0.; // if t_star is too small compute like Coulomb friction (without regularization) else if (Math::are_float_equal(this->t_star(n), 0.)) { const Vector & pres = it[n]; this->frictional_contact_pressure(n) = pres.norm(); } else { // compute frictional contact pressure // backward euler method: first order implicit numerical integration method // \reg_pres_n+1 = (\reg_pres_n + \delta_t / \t_star * \cur_pres) // / (1 + \delta_t / \t_star) Real alpha = delta_t / this->t_star(n); const Vector & pres = it[n]; this->frictional_contact_pressure(n) += alpha * pres.norm(); this->frictional_contact_pressure(n) /= 1 + alpha; } } AKANTU_DEBUG_OUT(); return this->frictional_contact_pressure; } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::setToSteadyState() { AKANTU_DEBUG_IN(); NTNFricRegNoRegularisation::computeFrictionalContactPressure(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->t_star.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->t_star.dumpRestartFile(file_name); NTNFricRegNoRegularisation::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->t_star.readRestartFile(file_name); NTNFricRegNoRegularisation::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricRegRubinAmpuero [" << std::endl; NTNFricRegNoRegularisation::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegRubinAmpuero::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if (field_id == "t_star") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->t_star.getArray())); } else { NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh b/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh index e0505d8d2..b6f3472de 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh @@ -1,93 +1,91 @@ /** * @file ntn_fricreg_rubin_ampuero.hh * * @author David Simon Kammer * * * @brief regularisation that regularizes the contact pressure * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__ #define __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_no_regularisation.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - class NTNFricRegRubinAmpuero : public NTNFricRegNoRegularisation { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricRegRubinAmpuero(NTNBaseContact * contact, const FrictionID & id = "rubin_ampuero", const MemoryID & memory_id = 0); virtual ~NTNFricRegRubinAmpuero() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: virtual void registerSynchronizedArray(SynchronizedArrayBase & array); virtual void dumpRestart(const std::string & file_name) const; virtual void readRestart(const std::string & file_name); virtual void setToSteadyState(); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: protected: /// get the contact pressure (the norm: scalar value) virtual const SynchronizedArray & internalGetContactPressure(); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: SynchronizedArray t_star; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "ntn_fricreg_rubin_ampuero_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNFricRegRubinAmpuero & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__ */ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc b/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc index db3f18e70..068ec3dd6 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc @@ -1,144 +1,144 @@ /** * @file ntn_fricreg_simplified_prakash_clifton.cc * * @author David Simon Kammer * * * @brief implementation of simplified prakash clifton with one parameter * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_simplified_prakash_clifton.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNFricRegSimplifiedPrakashClifton::NTNFricRegSimplifiedPrakashClifton(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : NTNFricRegNoRegularisation(contact, id, memory_id), t_star(0,1,0.,id+":t_star",0.,"t_star"), spc_internal(0,1,0.,id+":spc_internal",0.,"spc_internal") { AKANTU_DEBUG_IN(); NTNFricRegNoRegularisation::registerSynchronizedArray(this->t_star); NTNFricRegNoRegularisation::registerSynchronizedArray(this->spc_internal); this->registerParam("t_star", this->t_star, _pat_parsmod, "time scale of regularisation"); this->registerParam("spc_internal", this->spc_internal, _pat_internal, ""); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::computeFrictionalStrength() { AKANTU_DEBUG_IN(); SolidMechanicsModel & model = this->contact->getModel(); Real delta_t = model.getTimeStep(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nt_star(n); this->frictional_strength(n) += alpha * this->spc_internal(n); this->frictional_strength(n) /= 1 + alpha; } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::setToSteadyState() { AKANTU_DEBUG_IN(); /// fill the spc_internal array computeFrictionalStrength(); /// set strength without regularisation UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nfrictional_strength(n) = this->spc_internal(n); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->t_star.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->t_star.dumpRestartFile(file_name); this->spc_internal.dumpRestartFile(file_name); NTNFricRegNoRegularisation::dumpRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->t_star.readRestartFile(file_name); this->spc_internal.readRestartFile(file_name); NTNFricRegNoRegularisation::readRestart(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNFricRegSimplifiedPrakashClifton [" << std::endl; NTNFricRegNoRegularisation::printself(stream, ++indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNFricRegSimplifiedPrakashClifton::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if (field_id == "t_star") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->t_star.getArray())); } else { NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh b/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh index 13a898773..40e621670 100644 --- a/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh +++ b/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh @@ -1,102 +1,100 @@ /** * @file ntn_fricreg_simplified_prakash_clifton.hh * * @author David Simon Kammer * * * @brief regularisation that regularizes the frictional strength with one parameter * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__ #define __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_fricreg_no_regularisation.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ -using namespace akantu; - class NTNFricRegSimplifiedPrakashClifton : public NTNFricRegNoRegularisation { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFricRegSimplifiedPrakashClifton(NTNBaseContact * contact, const FrictionID & id = "simplified_prakash_clifton", const MemoryID & memory_id = 0); virtual ~NTNFricRegSimplifiedPrakashClifton() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: virtual void registerSynchronizedArray(SynchronizedArrayBase & array); virtual void dumpRestart(const std::string & file_name) const; virtual void readRestart(const std::string & file_name); virtual void setToSteadyState(); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// compute frictional strength according to friction law virtual void computeFrictionalStrength(); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: protected: /// get the frictional strength array virtual SynchronizedArray & internalGetFrictionalStrength() { return this->spc_internal; }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: SynchronizedArray t_star; // to get the incremental frictional strength SynchronizedArray spc_internal; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "ntn_fricreg_simplified_prakash_clifton_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNFricRegSimplifiedPrakashClifton & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__ */ diff --git a/src/ntn_contact/ntn_base_contact.cc b/src/ntn_contact/ntn_base_contact.cc index 7bf9d7690..d97df5cf4 100644 --- a/src/ntn_contact/ntn_base_contact.cc +++ b/src/ntn_contact/ntn_base_contact.cc @@ -1,556 +1,556 @@ /** * @file ntn_base_contact.cc * * @author David Simon Kammer * * * @brief implementation of ntn base contact * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_base_contact.hh" #include "dumpable_inline_impl.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNContactSynchElementFilter::NTNContactSynchElementFilter(NTNBaseContact * contact) : contact(contact), connectivity(contact->getModel().getMesh().getConnectivities()) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ bool NTNContactSynchElementFilter::operator()(const Element & e) { AKANTU_DEBUG_IN(); ElementType type = e.type; UInt element = e.element; GhostType ghost_type = e.ghost_type; // loop over all nodes of this element bool need_element = false; UInt nb_nodes = Mesh::getNbNodesPerElement(type); for (UInt n=0; nconnectivity(type, ghost_type)(element,n); // if one nodes is in this contact, we need this element if (this->contact->getNodeIndex(nn) >= 0) { need_element = true; break; } } AKANTU_DEBUG_OUT(); return need_element; } /* -------------------------------------------------------------------------- */ NTNBaseContact::NTNBaseContact(SolidMechanicsModel & model, const ContactID & id, const MemoryID & memory_id) : Memory(id,memory_id), Dumpable(), model(model), slaves(0,1,0,id+":slaves",std::numeric_limits::quiet_NaN(),"slaves"), normals(0,model.getSpatialDimension(),0,id+":normals", std::numeric_limits::quiet_NaN(),"normals"), contact_pressure(0,model.getSpatialDimension(),0,id+":contact_pressure", std::numeric_limits::quiet_NaN(),"contact_pressure"), is_in_contact(0,1,false,id+":is_in_contact",false,"is_in_contact"), lumped_boundary_slaves(0,1,0,id+":lumped_boundary_slaves", std::numeric_limits::quiet_NaN(),"lumped_boundary_slaves"), impedance(0,1,0,id+":impedance",std::numeric_limits::quiet_NaN(),"impedance"), contact_surfaces(), slave_elements("slave_elements", id, memory_id), node_to_elements(), synch_registry(NULL) { AKANTU_DEBUG_IN(); FEEngine & boundary_fem = this->model.getFEEngineBoundary(); for (ghost_type_t::iterator gt = ghost_type_t::begin(); gt != ghost_type_t::end(); ++gt) { boundary_fem.initShapeFunctions(*gt); } Mesh & mesh = this->model.getMesh(); UInt spatial_dimension = this->model.getSpatialDimension(); mesh.initElementTypeMapArray(this->slave_elements, 1, spatial_dimension - 1); MeshUtils::buildNode2Elements(mesh, this->node_to_elements, spatial_dimension - 1); this->registerDumper("text_all", id, true); this->addDumpFilteredMesh(mesh, slave_elements, slaves.getArray(), spatial_dimension - 1, _not_ghost, _ek_regular); // parallelisation this->synch_registry = new SynchronizerRegistry(*this); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ NTNBaseContact::~NTNBaseContact() { AKANTU_DEBUG_IN(); if(this->synch_registry) delete this->synch_registry; if(this->synchronizer) delete this->synchronizer; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::initParallel() { AKANTU_DEBUG_IN(); NTNContactSynchElementFilter elem_filter(this); this->synchronizer = FilteredSynchronizer:: createFilteredSynchronizer(this->model.getSynchronizer(), elem_filter); this->synch_registry->registerSynchronizer(*(this->synchronizer), _gst_cf_nodal); this->synch_registry->registerSynchronizer(*(this->synchronizer), _gst_cf_incr); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::findBoundaryElements(const Array & interface_nodes, ElementTypeMapArray & elements) { AKANTU_DEBUG_IN(); UInt nb_interface_nodes = interface_nodes.getSize(); const ElementTypeMapArray & connectivity = this->model.getMesh().getConnectivities(); // add connected boundary elements that have all nodes on this contact for (UInt i=0; i::iterator it = this->node_to_elements.begin(node); CSR::iterator it_e = this->node_to_elements.end(node); for (; it != it_e; ++it) { // loop over all elements connected to node ElementType type = it->type; UInt element = it->element; GhostType ghost_type = it->ghost_type; UInt nb_nodes = Mesh::getNbNodesPerElement(type); UInt nb_found_nodes = 0; for (UInt n=0; n= 0) nb_found_nodes++; else break; } // this is an element between all contact nodes // and is not already in the elements if ((nb_found_nodes == nb_nodes) && (elements(type,ghost_type).find(element) < 0)) { elements(type, ghost_type).push_back(element); } } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::addSplitNode(UInt node) { AKANTU_DEBUG_IN(); UInt dim = this->model.getSpatialDimension(); // add to node arrays this->slaves.push_back(node); // set contact as false this->is_in_contact.push_back(false); // before initializing // set contact pressure, normal, lumped_boundary to Nan this->contact_pressure.push_back(std::numeric_limits::quiet_NaN()); this->impedance.push_back(std::numeric_limits::quiet_NaN()); this->lumped_boundary_slaves.push_back(std::numeric_limits::quiet_NaN()); Real nan_normal[dim]; for (UInt d=0; d::quiet_NaN(); this->normals.push_back(nan_normal); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->slaves.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->slaves.dumpRestartFile(file_name); this->normals.dumpRestartFile(file_name); this->is_in_contact.dumpRestartFile(file_name); this->contact_pressure.dumpRestartFile(file_name); this->lumped_boundary_slaves.dumpRestartFile(file_name); this->impedance.dumpRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->slaves.readRestartFile(file_name); this->normals.readRestartFile(file_name); this->is_in_contact.readRestartFile(file_name); this->contact_pressure.readRestartFile(file_name); this->lumped_boundary_slaves.readRestartFile(file_name); this->impedance.readRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ UInt NTNBaseContact::getNbNodesInContact() const { AKANTU_DEBUG_IN(); UInt nb_contact = 0; UInt nb_nodes = this->getNbContactNodes(); const Mesh & mesh = this->model.getMesh(); for (UInt n = 0; n < nb_nodes; ++n) { bool is_local_node = mesh.isLocalOrMasterNode(this->slaves(n)); bool is_pbc_slave_node = this->model.isPBCSlaveNode(this->slaves(n)); if (is_local_node && !is_pbc_slave_node && this->is_in_contact(n)) { nb_contact++; } } StaticCommunicator::getStaticCommunicator().allReduce(&nb_contact, 1, _so_sum); AKANTU_DEBUG_OUT(); return nb_contact; } /* -------------------------------------------------------------------------- */ void NTNBaseContact::updateInternalData() { AKANTU_DEBUG_IN(); updateNormals(); updateLumpedBoundary(); updateImpedance(); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::updateLumpedBoundary() { AKANTU_DEBUG_IN(); this->internalUpdateLumpedBoundary(this->slaves.getArray(), this->slave_elements, this->lumped_boundary_slaves); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::internalUpdateLumpedBoundary(const Array & nodes, const ElementTypeMapArray & elements, SynchronizedArray & boundary) { AKANTU_DEBUG_IN(); // set all values in lumped_boundary to zero boundary.clear(); UInt dim = this->model.getSpatialDimension(); // UInt nb_contact_nodes = getNbContactNodes(); const FEEngine & boundary_fem = this->model.getFEEngineBoundary(); const Mesh & mesh = this->model.getMesh(); for (ghost_type_t::iterator gt = ghost_type_t::begin(); gt != ghost_type_t::end(); ++gt) { Mesh::type_iterator it = mesh.firstType(dim-1, *gt); Mesh::type_iterator last = mesh.lastType(dim-1, *gt); for (; it != last; ++it) { UInt nb_elements = mesh.getNbElement(*it, *gt); UInt nb_nodes_per_element = mesh.getNbNodesPerElement(*it); const Array & connectivity = mesh.getConnectivity(*it, *gt); // get shapes and compute integral const Array & shapes = boundary_fem.getShapes(*it, *gt); Array area(nb_elements,nb_nodes_per_element); boundary_fem.integrate(shapes,area,nb_nodes_per_element,*it, *gt); if (this->contact_surfaces.size() == 0) { AKANTU_DEBUG_WARNING("No surfaces in ntn base contact." << " You have to define the lumped boundary by yourself."); } Array::const_iterator elem_it = (elements)(*it, *gt).begin(); Array::const_iterator elem_it_end = (elements)(*it, *gt).end(); // loop over contact nodes for (; elem_it != elem_it_end; ++elem_it) { for (UInt q=0; qmodel.getSpatialDimension(); Real delta_t = this->model.getTimeStep(); UInt nb_contact_nodes = getNbContactNodes(); AKANTU_DEBUG_ASSERT(delta_t > 0., "Cannot compute contact pressure if no time step is set"); // synchronize data this->synch_registry->synchronize(_gst_cf_nodal); // pre-compute the acceleration // (not increment acceleration, because residual is still Kf) Array acceleration(this->model.getMesh().getNbNodes(), dim, 0.); this->model.solveLumped(acceleration, this->model.getMass(), this->model.getResidual(), this->model.getBlockedDOFs(), this->model.getF_M2A()); // compute relative normal fields of displacement, velocity and acceleration Array r_disp(0,1); Array r_velo(0,1); Array r_acce(0,1); Array r_old_acce(0,1); computeNormalGap(r_disp); // computeRelativeNormalField(this->model.getCurrentPosition(), r_disp); computeRelativeNormalField(this->model.getVelocity(), r_velo); computeRelativeNormalField(acceleration, r_acce); computeRelativeNormalField(this->model.getAcceleration(), r_old_acce); AKANTU_DEBUG_ASSERT(r_disp.getSize() == nb_contact_nodes, "computeRelativeNormalField does not give back arrays " << "size == nb_contact_nodes. nb_contact_nodes = " << nb_contact_nodes << " | array size = " << r_disp.getSize()); // compute gap array for all nodes Array gap(nb_contact_nodes, 1); Real * gap_p = gap.storage(); Real * r_disp_p = r_disp.storage(); Real * r_velo_p = r_velo.storage(); Real * r_acce_p = r_acce.storage(); Real * r_old_acce_p = r_old_acce.storage(); for (UInt i=0; i is in contact for (UInt n=0; ncontact_pressure(n,d) = this->impedance(n) * gap(n) / (2 * delta_t) * this->normals(n,d); } this->is_in_contact(n) = true; } else { for (UInt d=0; dcontact_pressure(n,d) = 0.; this->is_in_contact(n) = false; } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::applyContactPressure() { AKANTU_DEBUG_IN(); UInt nb_contact_nodes = getNbContactNodes(); UInt dim = this->model.getSpatialDimension(); Array & residual = this->model.getResidual(); for (UInt n=0; nslaves(n); for (UInt d=0; dlumped_boundary(n,0) * this->contact_pressure(n,d); residual(slave, d) -= this->lumped_boundary_slaves(n) * this->contact_pressure(n,d); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ Int NTNBaseContact::getNodeIndex(UInt node) const { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); return this->slaves.find(node); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNBaseContact [" << std::endl; stream << space << " + id : " << id << std::endl; stream << space << " + slaves : " << std::endl; this->slaves.printself(stream, indent + 2); stream << space << " + normals : " << std::endl; this->normals.printself(stream, indent + 2); stream << space << " + contact_pressure : " << std::endl; this->contact_pressure.printself(stream, indent + 2); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::syncArrays(SyncChoice sync_choice) { AKANTU_DEBUG_IN(); this->slaves.syncElements(sync_choice); this->normals.syncElements(sync_choice); this->is_in_contact.syncElements(sync_choice); this->contact_pressure.syncElements(sync_choice); this->lumped_boundary_slaves.syncElements(sync_choice); this->impedance.syncElements(sync_choice); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseContact::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER const Array & nodal_filter = this->slaves.getArray(); #define ADD_FIELD(field_id, field, type) \ internalAddDumpFieldToDumper(dumper_name, \ field_id, \ new dumper::NodalField< type, true, \ Array, \ Array >(field, 0, 0, &nodal_filter)) if(field_id == "displacement") { ADD_FIELD(field_id, this->model.getDisplacement(), Real); } else if(field_id == "mass") { ADD_FIELD(field_id, this->model.getMass(), Real); } else if(field_id == "velocity") { ADD_FIELD(field_id, this->model.getVelocity(), Real); } else if(field_id == "acceleration") { ADD_FIELD(field_id, this->model.getAcceleration(), Real); } else if(field_id == "force") { ADD_FIELD(field_id, this->model.getForce(), Real); } else if(field_id == "residual") { ADD_FIELD(field_id, this->model.getResidual(), Real); } else if(field_id == "blocked_dofs") { ADD_FIELD(field_id, this->model.getBlockedDOFs(), bool); } else if(field_id == "increment") { ADD_FIELD(field_id, this->model.getIncrement(), Real); } else if(field_id == "normal") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->normals.getArray())); } else if(field_id == "contact_pressure") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->contact_pressure.getArray())); } else if(field_id == "is_in_contact") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->is_in_contact.getArray())); } else if(field_id == "lumped_boundary_slave") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->lumped_boundary_slaves.getArray())); } else if(field_id == "impedance") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->impedance.getArray())); } else { std::cerr << "Could not add field '" << field_id << "' to the dumper. Just ignored it." << std::endl; } #undef ADD_FIELD #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/ntn_base_contact.hh b/src/ntn_contact/ntn_base_contact.hh index e4c663724..98d233552 100644 --- a/src/ntn_contact/ntn_base_contact.hh +++ b/src/ntn_contact/ntn_base_contact.hh @@ -1,232 +1,229 @@ /** * @file ntn_base_contact.hh * * @author David Simon Kammer * * * @brief base contact for ntn and ntrf contact * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_BASE_CONTACT_HH__ #define __AST_NTN_BASE_CONTACT_HH__ /* -------------------------------------------------------------------------- */ // akantu #include "solid_mechanics_model.hh" #include "filtered_synchronizer.hh" // simtools #include "synchronized_array.hh" -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ class NTNBaseContact; /* -------------------------------------------------------------------------- */ class NTNContactSynchElementFilter : public SynchElementFilter { public: // constructor NTNContactSynchElementFilter(NTNBaseContact * contact); // answer to: do we need this element ? virtual bool operator()(const Element & e); private: const NTNBaseContact * contact; const ElementTypeMapArray & connectivity; }; /* -------------------------------------------------------------------------- */ class NTNBaseContact : protected Memory, public DataAccessor, public Dumpable { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNBaseContact(SolidMechanicsModel & model, const ContactID & id = "contact", const MemoryID & memory_id = 0); virtual ~NTNBaseContact(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// initializes ntn contact parallel virtual void initParallel(); /// add split node virtual void addSplitNode(UInt node); /// update normals, lumped boundary, and impedance virtual void updateInternalData(); /// update (compute the normals) virtual void updateNormals() = 0; /// update the lumped boundary B matrix virtual void updateLumpedBoundary(); /// update the impedance matrix virtual void updateImpedance() = 0; /// compute the normal contact force virtual void computeContactPressure(); /// impose the normal contact force virtual void applyContactPressure(); /// register synchronizedarrays for sync virtual void registerSynchronizedArray(SynchronizedArrayBase & array); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// compute the normal gap virtual void computeNormalGap(Array & gap) const = 0; /// compute relative normal field (only value that has to be multiplied with the normal) /// relative to master nodes virtual void computeRelativeNormalField(const Array & field, Array & rel_normal_field) const = 0; /// compute relative tangential field (complet array) /// relative to master nodes virtual void computeRelativeTangentialField(const Array & field, Array & rel_tang_field) const = 0; /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// updateLumpedBoundary virtual void internalUpdateLumpedBoundary(const Array & nodes, const ElementTypeMapArray & elements, SynchronizedArray & boundary); // to find the slave_elements or master_elements virtual void findBoundaryElements(const Array & interface_nodes, ElementTypeMapArray & elements); /// synchronize arrays virtual void syncArrays(SyncChoice sync_choice); /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: inline virtual UInt getNbDataForElements(const Array & elements, SynchronizationTag tag) const; inline virtual void packElementData(CommunicationBuffer & buffer, const Array & elements, SynchronizationTag tag) const; inline virtual void unpackElementData(CommunicationBuffer & buffer, const Array & elements, SynchronizationTag tag); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(Model, model, SolidMechanicsModel &) AKANTU_GET_MACRO(Slaves, slaves, const SynchronizedArray &) AKANTU_GET_MACRO(Normals, normals, const SynchronizedArray &) AKANTU_GET_MACRO(ContactPressure, contact_pressure, const SynchronizedArray &) AKANTU_GET_MACRO(LumpedBoundarySlaves, lumped_boundary_slaves, const SynchronizedArray &) AKANTU_GET_MACRO(Impedance, impedance, const SynchronizedArray &) AKANTU_GET_MACRO(IsInContact, is_in_contact, const SynchronizedArray &) AKANTU_GET_MACRO(SlaveElements, slave_elements, const ElementTypeMapArray &) AKANTU_GET_MACRO(SynchronizerRegistry, synch_registry, SynchronizerRegistry *) /// get number of nodes that are in contact (globally, on all procs together) /// is_in_contact = true virtual UInt getNbNodesInContact() const; /// get index of node in either slaves or masters array /// if node is in neither of them, return -1 virtual Int getNodeIndex(UInt node) const; /// get number of contact nodes: nodes in the system locally (on this proc) /// is_in_contact = true and false, because just in the system virtual UInt getNbContactNodes() const { return this->slaves.getSize(); }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: typedef std::set SurfacePtrSet; SolidMechanicsModel & model; /// array of slave nodes SynchronizedArray slaves; /// array of normals SynchronizedArray normals; /// array indicating if nodes are in contact SynchronizedArray contact_pressure; /// array indicating if nodes are in contact SynchronizedArray is_in_contact; /// boundary matrix for slave nodes SynchronizedArray lumped_boundary_slaves; /// impedance matrix SynchronizedArray impedance; /// contact surface SurfacePtrSet contact_surfaces; /// element list for dump and lumped_boundary ElementTypeMapArray slave_elements; CSR node_to_elements; /// parallelisation SynchronizerRegistry * synch_registry; FilteredSynchronizer * synchronizer; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "ntn_base_contact_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNBaseContact & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_BASE_CONTACT_HH__ */ diff --git a/src/ntn_contact/ntn_base_friction.cc b/src/ntn_contact/ntn_base_friction.cc index b6b1798d9..811890ccd 100644 --- a/src/ntn_contact/ntn_base_friction.cc +++ b/src/ntn_contact/ntn_base_friction.cc @@ -1,374 +1,374 @@ /** * @file ntn_base_friction.cc * * @author David Simon Kammer * * * @brief implementation of ntn base friction * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_base_friction.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNBaseFriction::NTNBaseFriction(NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id) : Memory(id,memory_id), Parsable(_st_friction, id), Dumpable(), contact(contact), is_sticking(0,1,true,id+":is_sticking",true,"is_sticking"), frictional_strength(0,1,0.,id+":frictional_strength",0.,"frictional_strength"), friction_traction(0,contact->getModel().getSpatialDimension(), 0.,id+":friction_traction",0.,"friction_traction"), slip(0,1,0.,id+":slip",0.,"slip"), cumulative_slip(0,1,0.,id+":cumulative_slip",0.,"cumulative_slip"), slip_velocity(0,contact->getModel().getSpatialDimension(), 0.,id+":slip_velocity",0.,"slip_velocity") { AKANTU_DEBUG_IN(); this->contact->registerSynchronizedArray(this->is_sticking); this->contact->registerSynchronizedArray(this->frictional_strength); this->contact->registerSynchronizedArray(this->friction_traction); this->contact->registerSynchronizedArray(this->slip); this->contact->registerSynchronizedArray(this->cumulative_slip); this->contact->registerSynchronizedArray(this->slip_velocity); contact->getModel().setIncrementFlagOn(); this->registerExternalDumper(contact->getDumper(), contact->getDefaultDumperName(), true); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::updateSlip() { AKANTU_DEBUG_IN(); SolidMechanicsModel & model = this->contact->getModel(); UInt dim = model.getSpatialDimension(); // synchronize increment this->contact->getSynchronizerRegistry()->synchronize(_gst_cf_incr); Array rel_tan_incr(0,dim); this->contact->computeRelativeTangentialField(model.getIncrement(), rel_tan_incr); Array::const_iterator< Vector > it = rel_tan_incr.begin(dim); UInt nb_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nis_sticking(n)) { this->slip(n) = 0.; } else { const Vector & rti = it[n]; this->slip(n) += rti.norm(); this->cumulative_slip(n) += rti.norm(); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::computeFrictionTraction() { AKANTU_DEBUG_IN(); this->computeStickTraction(); this->computeFrictionalStrength(); SolidMechanicsModel & model = this->contact->getModel(); UInt dim = model.getSpatialDimension(); // get contact arrays const SynchronizedArray & is_in_contact = this->contact->getIsInContact(); Array & traction = const_cast< Array & >(this->friction_traction.getArray()); Array::iterator< Vector > it_fric_trac = traction.begin(dim); this->is_sticking.clear(); // set to not sticking UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; n fric_trac = it_fric_trac[n]; // check if it is larger than frictional strength Real abs_fric = fric_trac.norm(); if (abs_fric != 0.) { Real alpha = this->frictional_strength(n) / abs_fric; // larger -> sliding if (alpha < 1.) { fric_trac *= alpha; } else this->is_sticking(n) = true; } else { // frictional traction is already zero this->is_sticking(n) = true; } } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::computeStickTraction() { AKANTU_DEBUG_IN(); SolidMechanicsModel & model = this->contact->getModel(); UInt dim = model.getSpatialDimension(); Real delta_t = model.getTimeStep(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); // get contact arrays const SynchronizedArray & impedance = this->contact->getImpedance(); const SynchronizedArray & is_in_contact = this->contact->getIsInContact(); // pre-compute the acceleration // (not increment acceleration, because residual is still Kf) Array acceleration(model.getFEEngine().getMesh().getNbNodes(), dim, 0.); model.solveLumped(acceleration, model.getMass(), model.getResidual(), model.getBlockedDOFs(), model.getF_M2A()); // compute relative normal fields of velocity and acceleration Array r_velo(0,dim); Array r_acce(0,dim); Array r_old_acce(0,dim); this->contact->computeRelativeTangentialField(model.getVelocity(), r_velo); this->contact->computeRelativeTangentialField(acceleration, r_acce); this->contact->computeRelativeTangentialField(model.getAcceleration(), r_old_acce); AKANTU_DEBUG_ASSERT(r_velo.getSize() == nb_contact_nodes, "computeRelativeNormalField does not give back arrays " << "size == nb_contact_nodes. nb_contact_nodes = " << nb_contact_nodes << " | array size = " << r_velo.getSize()); // compute tangential gap_dot array for all nodes Array gap_dot(nb_contact_nodes, dim); Real * gap_dot_p = gap_dot.storage(); Real * r_velo_p = r_velo.storage(); Real * r_acce_p = r_acce.storage(); Real * r_old_acce_p = r_old_acce.storage(); for (UInt i=0; i & traction = const_cast< Array & >(this->friction_traction.getArray()); Array::vector_iterator it_fric_trac = traction.begin(dim); for (UInt n=0; n fric_trac = it_fric_trac[n]; // node pair is NOT in contact if (!is_in_contact(n)) { fric_trac.clear(); // set to zero } // node pair is in contact else { // compute friction traction for (UInt d=0; dcontact->getModel(); Array & residual = model.getResidual(); UInt dim = model.getSpatialDimension(); const SynchronizedArray & slaves = this->contact->getSlaves(); const SynchronizedArray & lumped_boundary_slaves = this->contact->getLumpedBoundarySlaves(); UInt nb_contact_nodes = this->contact->getNbContactNodes(); for (UInt n=0; nfriction_traction(n,d); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::registerSynchronizedArray(SynchronizedArrayBase & array) { AKANTU_DEBUG_IN(); this->frictional_strength.registerDependingArray(array); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); this->is_sticking.dumpRestartFile(file_name); this->frictional_strength.dumpRestartFile(file_name); this->friction_traction.dumpRestartFile(file_name); this->slip.dumpRestartFile(file_name); this->cumulative_slip.dumpRestartFile(file_name); this->slip_velocity.dumpRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); this->is_sticking.readRestartFile(file_name); this->frictional_strength.readRestartFile(file_name); this->friction_traction.readRestartFile(file_name); this->cumulative_slip.readRestartFile(file_name); this->slip_velocity.readRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::setParam(const std::string & name, UInt node, Real value) { AKANTU_DEBUG_IN(); SynchronizedArray & array = this->get< SynchronizedArray >(name); Int index = this->contact->getNodeIndex(node); if (index < 0) { AKANTU_DEBUG_WARNING("Node " << node << " is not a contact node. " << "Therefore, cannot set interface parameter!!"); } else { array(index) = value; // put value } AKANTU_DEBUG_OUT(); }; /* -------------------------------------------------------------------------- */ UInt NTNBaseFriction::getNbStickingNodes() const { AKANTU_DEBUG_IN(); UInt nb_stick = 0; UInt nb_nodes = this->contact->getNbContactNodes(); const SynchronizedArray & nodes = this->contact->getSlaves(); const SynchronizedArray & is_in_contact = this->contact->getIsInContact(); const Mesh & mesh = this->contact->getModel().getMesh(); for (UInt n = 0; n < nb_nodes; ++n) { bool is_local_node = mesh.isLocalOrMasterNode(nodes(n)); bool is_pbc_slave_node = this->contact->getModel().isPBCSlaveNode(nodes(n)); if (is_local_node && !is_pbc_slave_node && is_in_contact(n) && this->is_sticking(n)) { nb_stick++; } } StaticCommunicator::getStaticCommunicator().allReduce(&nb_stick, 1, _so_sum); AKANTU_DEBUG_OUT(); return nb_stick; } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNBaseFriction [" << std::endl; Parsable::printself(stream, indent); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNBaseFriction::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); #ifdef AKANTU_USE_IOHELPER // const SynchronizedArray * nodal_filter = &(this->contact->getSlaves()); if(field_id == "is_sticking") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->is_sticking.getArray())); } else if(field_id == "frictional_strength") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->frictional_strength.getArray())); } else if(field_id == "friction_traction") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->friction_traction.getArray())); } else if(field_id == "slip") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->slip.getArray())); } else if(field_id == "cumulative_slip") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->cumulative_slip.getArray())); } else if(field_id == "slip_velocity") { this->internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->slip_velocity.getArray())); } else { this->contact->addDumpFieldToDumper(dumper_name, field_id); } #endif AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/ntn_base_friction.hh b/src/ntn_contact/ntn_base_friction.hh index 29fb489e5..05168947c 100644 --- a/src/ntn_contact/ntn_base_friction.hh +++ b/src/ntn_contact/ntn_base_friction.hh @@ -1,166 +1,161 @@ /** * @file ntn_base_friction.hh * * @author David Simon Kammer * * * @brief base class for ntn and ntrf friction * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_BASE_FRICTION_HH__ #define __AST_NTN_BASE_FRICTION_HH__ /* -------------------------------------------------------------------------- */ // akantu #include "parsable.hh" // simtools #include "ntn_base_contact.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ + template<> -inline void ParsableParamTyped< akantu_simtools::SynchronizedArray >::parseParam(const ParserParameter & in_param) { +inline void ParsableParamTyped< akantu::SynchronizedArray >::parseParam(const ParserParameter & in_param) { ParsableParam::parseParam(in_param); Real tmp = in_param; param.setAndChangeDefault(tmp); } /* -------------------------------------------------------------------------- */ template<> template<> -inline void ParsableParamTyped< akantu_simtools::SynchronizedArray >::setTyped(const Real & value) { +inline void ParsableParamTyped< akantu::SynchronizedArray >::setTyped(const Real & value) { param.setAndChangeDefault(value); } -__END_AKANTU__ - -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; /* -------------------------------------------------------------------------- */ class NTNBaseFriction : protected Memory, public Parsable, public Dumpable { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNBaseFriction(NTNBaseContact * contact, const FrictionID & id = "friction", const MemoryID & memory_id = 0); virtual ~NTNBaseFriction() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// compute friction traction virtual void computeFrictionTraction(); /// compute stick traction (friction traction needed to stick the nodes) virtual void computeStickTraction(); /// apply the friction force virtual void applyFrictionTraction(); /// compute slip virtual void updateSlip(); /// register Syncronizedarrays for sync virtual void registerSynchronizedArray(SynchronizedArrayBase & array); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// set to steady state virtual void setToSteadyState() { AKANTU_DEBUG_TO_IMPLEMENT(); }; /// get the number of sticking nodes (in parallel) /// a node that is not in contact does not count as sticking virtual UInt getNbStickingNodes() const; /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// compute frictional strength according to friction law virtual void computeFrictionalStrength() = 0; /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(Contact, contact, const NTNBaseContact *) AKANTU_GET_MACRO(IsSticking, is_sticking, const SynchronizedArray &) AKANTU_GET_MACRO(FrictionalStrength, frictional_strength, const SynchronizedArray &) AKANTU_GET_MACRO(FrictionTraction, friction_traction, const SynchronizedArray &) AKANTU_GET_MACRO(Slip, slip, const SynchronizedArray &) AKANTU_GET_MACRO(CumulativeSlip, cumulative_slip, const SynchronizedArray &) AKANTU_GET_MACRO(SlipVelocity, slip_velocity, const SynchronizedArray &) /// set parameter of a given node /// (if you need to set to all: used the setMixed function of the Parsable). virtual void setParam(const std::string & name, UInt node, Real value); // replaced by the setMixed of the Parsable // virtual void setParam(const std::string & param, Real value) { // AKANTU_DEBUG_ERROR("Friction does not know the following parameter: " << param); // }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: NTNBaseContact * contact; // if node is sticking SynchronizedArray is_sticking; // frictional strength SynchronizedArray frictional_strength; // friction force SynchronizedArray friction_traction; // slip SynchronizedArray slip; SynchronizedArray cumulative_slip; // slip velocity (tangential vector) SynchronizedArray slip_velocity; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "ntn_base_friction_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNBaseFriction & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_BASE_FRICTION_HH__ */ diff --git a/src/ntn_contact/ntn_contact.cc b/src/ntn_contact/ntn_contact.cc index 162e0c2be..81f7c55d8 100644 --- a/src/ntn_contact/ntn_contact.cc +++ b/src/ntn_contact/ntn_contact.cc @@ -1,535 +1,535 @@ /** * @file ntn_contact.cc * * @author David Simon Kammer * * * @brief implementation of ntn_contact * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_contact.hh" #include "dumper_text.hh" #include "dumper_nodal_field.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ NTNContact::NTNContact(SolidMechanicsModel & model, const ContactID & id, const MemoryID & memory_id) : NTNBaseContact(model,id,memory_id), masters(0,1,0,id+":masters",std::numeric_limits::quiet_NaN(),"masters"), lumped_boundary_masters(0,1,0,id+":lumped_boundary_masters", std::numeric_limits::quiet_NaN(),"lumped_boundary_masters"), master_elements("master_elements", id, memory_id) { AKANTU_DEBUG_IN(); const Mesh & mesh = this->model.getMesh(); UInt spatial_dimension = this->model.getSpatialDimension(); mesh.initElementTypeMapArray(this->master_elements, 1, spatial_dimension - 1); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::pairInterfaceNodes(const ElementGroup & slave_boundary, const ElementGroup & master_boundary, UInt surface_normal_dir, const Mesh & mesh, Array & pairs) { AKANTU_DEBUG_IN(); pairs.resize(0); AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2, "Array of node pairs should have nb_component = 2," << " but has nb_component = " << pairs.getNbComponent()); UInt dim = mesh.getSpatialDimension(); AKANTU_DEBUG_ASSERT(surface_normal_dir < dim, "Mesh is of " << dim << " dimensions" << " and cannot have direction " << surface_normal_dir << " for surface normal"); // offset for projection computation UInt offset[dim-1]; for (UInt i=0, j=0; i & coordinates = mesh.getNodes(); // find slave nodes Array proj_slave_coord(slave_boundary.getNbNodes(),dim-1,0.); Array slave_nodes(slave_boundary.getNbNodes()); UInt n(0); for(ElementGroup::const_node_iterator nodes_it(slave_boundary.node_begin()); nodes_it!= slave_boundary.node_end(); ++nodes_it) { for (UInt d=0; d proj_master_coord(master_boundary.getNbNodes(),dim-1,0.); Array master_nodes(master_boundary.getNbNodes()); n=0; for(ElementGroup::const_node_iterator nodes_it(master_boundary.node_begin()); nodes_it!= master_boundary.node_end(); ++nodes_it) { for (UInt d=0; d::max(); for (UInt i=0; imodel.getMesh(); const ElementGroup & slave_boundary = mesh.getElementGroup(slave); const ElementGroup & master_boundary = mesh.getElementGroup(master); this->contact_surfaces.insert(&slave_boundary); this->contact_surfaces.insert(&master_boundary); Array pairs(0,2); NTNContact::pairInterfaceNodes(slave_boundary, master_boundary, surface_normal_dir, this->model.getMesh(), pairs); // eliminate pairs which contain a pbc slave node Array pairs_no_PBC_slaves(0,2); Array::const_vector_iterator it = pairs.begin(2); Array::const_vector_iterator end = pairs.end(2); for (; it!=end; ++it) { const Vector & pair = *it; if (!this->model.isPBCSlaveNode(pair(0)) && !this->model.isPBCSlaveNode(pair(1))) { pairs_no_PBC_slaves.push_back(pair); } } this->addNodePairs(pairs_no_PBC_slaves); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::addNodePairs(const Array & pairs) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2, "Array of node pairs should have nb_component = 2," << " but has nb_component = " << pairs.getNbComponent()); UInt nb_pairs = pairs.getSize(); for (UInt n=0; naddSplitNode(pairs(n,0), pairs(n,1)); } // synchronize with depending nodes findBoundaryElements(this->slaves.getArray(), this->slave_elements); findBoundaryElements(this->masters.getArray(), this->master_elements); updateInternalData(); syncArrays(_added); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::getNodePairs(Array & pairs) const { AKANTU_DEBUG_IN(); pairs.resize(0); AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2, "Array of node pairs should have nb_component = 2," << " but has nb_component = " << pairs.getNbComponent()); UInt nb_pairs = this->getNbContactNodes(); for (UInt n=0; nslaves(n); pair[1] = this->masters(n); pairs.push_back(pair); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::addSplitNode(UInt slave, UInt master) { AKANTU_DEBUG_IN(); NTNBaseContact::addSplitNode(slave); this->masters.push_back(master); this->lumped_boundary_masters.push_back(std::numeric_limits::quiet_NaN()); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ /* This function only works for surface elements with one quad point. For surface elements with more quad points, it computes still, but the result might not be what you are looking for. */ void NTNContact::updateNormals() { AKANTU_DEBUG_IN(); // set normals to zero this->normals.clear(); // contact information UInt dim = this->model.getSpatialDimension(); UInt nb_contact_nodes = this->getNbContactNodes(); this->synch_registry->synchronize(_gst_cf_nodal); // synchronize current pos const Array & cur_pos = this->model.getCurrentPosition(); FEEngine & boundary_fem = this->model.getFEEngineBoundary(); const Mesh & mesh = this->model.getMesh(); for (ghost_type_t::iterator gt = ghost_type_t::begin(); gt != ghost_type_t::end(); ++gt) { Mesh::type_iterator it = mesh.firstType(dim-1, *gt); Mesh::type_iterator last = mesh.lastType(dim-1, *gt); for (; it != last; ++it) { // get elements connected to each node CSR node_to_element; MeshUtils::buildNode2ElementsElementTypeMap(mesh, node_to_element, *it, *gt); // compute the normals Array quad_normals(0,dim); boundary_fem.computeNormalsOnControlPoints(cur_pos, quad_normals, *it, *gt); UInt nb_quad_points = boundary_fem.getNbQuadraturePoints(*it, *gt); // add up normals to all master nodes for (UInt n=0; nmasters(n); CSR::iterator elem = node_to_element.begin(master); // loop over all elements connected to this master node for (; elem != node_to_element.end(master); ++elem) { UInt e = *elem; // loop over all quad points of this element for (UInt q=0; qnormals(n,d) += quad_normals(e*nb_quad_points + q, d); } } } } } } Real * master_normals = this->normals.storage(); for (UInt n=0; n::iterator nit = this->normals.begin(); // Array::iterator nend = this->normals.end(); // for (; nit != nend; ++nit) { // nit->normalize(); // } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::dumpRestart(const std::string & file_name) const { AKANTU_DEBUG_IN(); NTNBaseContact::dumpRestart(file_name); this->masters.dumpRestartFile(file_name); this->lumped_boundary_masters.dumpRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::readRestart(const std::string & file_name) { AKANTU_DEBUG_IN(); NTNBaseContact::readRestart(file_name); this->masters.readRestartFile(file_name); this->lumped_boundary_masters.readRestartFile(file_name); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::updateImpedance() { AKANTU_DEBUG_IN(); UInt nb_contact_nodes = getNbContactNodes(); Real delta_t = this->model.getTimeStep(); AKANTU_DEBUG_ASSERT(delta_t != NAN, "Time step is NAN. Have you set it already?"); const Array & mass = this->model.getMass(); for (UInt n=0; nmasters(n); UInt slave = this->slaves(n); Real imp = (this->lumped_boundary_masters(n) / mass(master)) + (this->lumped_boundary_slaves(n) / mass(slave)); imp = 2 / delta_t / imp; this->impedance(n) = imp; } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::updateLumpedBoundary() { AKANTU_DEBUG_IN(); internalUpdateLumpedBoundary(this->slaves.getArray(), this->slave_elements, this->lumped_boundary_slaves); internalUpdateLumpedBoundary(this->masters.getArray(), this->master_elements, this->lumped_boundary_masters); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::applyContactPressure() { AKANTU_DEBUG_IN(); UInt nb_ntn_pairs = getNbContactNodes(); UInt dim = this->model.getSpatialDimension(); Array & residual = this->model.getResidual(); for (UInt n=0; nmasters(n); UInt slave = this->slaves(n); for (UInt d=0; dlumped_boundary_masters(n) * this->contact_pressure(n,d); residual(slave, d) -= this->lumped_boundary_slaves(n) * this->contact_pressure(n,d); } } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::computeRelativeTangentialField(const Array & field, Array & rel_tang_field) const { AKANTU_DEBUG_IN(); // resize arrays to zero rel_tang_field.resize(0); UInt dim = this->model.getSpatialDimension(); Array::const_vector_iterator it_field = field.begin(dim); Array::const_vector_iterator it_normal = this->normals.getArray().begin(dim); Vector rfv(dim); Vector np_rfv(dim); UInt nb_contact_nodes = this->slaves.getSize(); for (UInt n=0; nslaves(n); UInt master = this->masters(n); // relative field vector (slave - master) rfv = Vector(it_field[slave]); rfv -= Vector(it_field[master]); // normal projection of relative field const Vector normal_v = it_normal[n]; np_rfv = normal_v; np_rfv *= rfv.dot(normal_v); // subract normal projection from relative field to get the tangential projection rfv -= np_rfv; rel_tang_field.push_back(rfv); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::computeRelativeNormalField(const Array & field, Array & rel_normal_field) const { AKANTU_DEBUG_IN(); // resize arrays to zero rel_normal_field.resize(0); UInt dim = this->model.getSpatialDimension(); // Real * field_p = field.storage(); // Real * normals_p = this->normals.storage(); Array::const_iterator< Vector > it_field = field.begin(dim); Array::const_iterator< Vector > it_normal = this->normals.getArray().begin(dim); Vector rfv(dim); UInt nb_contact_nodes = this->getNbContactNodes(); for (UInt n=0; nslaves(n); UInt master = this->masters(n); // relative field vector (slave - master) rfv = Vector(it_field[slave]); rfv -= Vector(it_field[master]); // length of normal projection of relative field const Vector normal_v = it_normal[n]; rel_normal_field.push_back(rfv.dot(normal_v)); } AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ Int NTNContact::getNodeIndex(UInt node) const { AKANTU_DEBUG_IN(); Int slave_i = NTNBaseContact::getNodeIndex(node); Int master_i = this->masters.find(node); AKANTU_DEBUG_OUT(); return std::max(slave_i,master_i); } /* -------------------------------------------------------------------------- */ void NTNContact::printself(std::ostream & stream, int indent) const { AKANTU_DEBUG_IN(); std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "NTNContact [" << std::endl; NTNBaseContact::printself(stream, indent); stream << space << " + masters : " << std::endl; this->masters.printself(stream, indent + 2); stream << space << " + lumped_boundary_mastres : " << std::endl; this->lumped_boundary_masters.printself(stream, indent + 2); stream << space << "]" << std::endl; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::syncArrays(SyncChoice sync_choice) { AKANTU_DEBUG_IN(); NTNBaseContact::syncArrays(sync_choice); this->masters.syncElements(sync_choice); this->lumped_boundary_masters.syncElements(sync_choice); AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ void NTNContact::addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id) { AKANTU_DEBUG_IN(); /* #ifdef AKANTU_USE_IOHELPER const Array & nodal_filter = this->slaves.getArray(); #define ADD_FIELD(field_id, field, type) \ internalAddDumpFieldToDumper(dumper_name, \ field_id, \ new DumperIOHelper::NodalField< type, true, \ Array, \ Array >(field, 0, 0, &nodal_filter)) */ if(field_id == "lumped_boundary_master") { internalAddDumpFieldToDumper(dumper_name, field_id, new dumper::NodalField(this->lumped_boundary_masters.getArray())); } else { NTNBaseContact::addDumpFieldToDumper(dumper_name, field_id); } /* #undef ADD_FIELD #endif */ AKANTU_DEBUG_OUT(); } -__END_SIMTOOLS__ +__END_AKANTU__ diff --git a/src/ntn_contact/ntn_contact.hh b/src/ntn_contact/ntn_contact.hh index fd829f687..41bb5132a 100644 --- a/src/ntn_contact/ntn_contact.hh +++ b/src/ntn_contact/ntn_contact.hh @@ -1,156 +1,153 @@ /** * @file ntn_contact.hh * * @author David Simon Kammer * * * @brief contact for node to node discretization * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_CONTACT_HH__ #define __AST_NTN_CONTACT_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_base_contact.hh" -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ class NTNContact : public NTNBaseContact { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNContact(SolidMechanicsModel & model, const ContactID & id = "contact", const MemoryID & memory_id = 0); virtual ~NTNContact() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// add surface pair and pair nodes according to the surface normal void addSurfacePair(const Surface & slave, const Surface & master, UInt surface_normal_dir); /// fills the pairs vector with interface node pairs (*,0)=slaves, (*,1)=masters static void pairInterfaceNodes(const ElementGroup & slave_boundary, const ElementGroup & master_boundary, UInt surface_normal_dir, const Mesh & mesh, Array & pairs); // add node pairs from a list with pairs(*,0)=slaves and pairs(*,1)=masters void addNodePairs(const Array & pairs); /// add node pair virtual void addSplitNode(UInt slave, UInt master); /// update (compute the normals on the master nodes) virtual void updateNormals(); /// update the lumped boundary B matrix virtual void updateLumpedBoundary(); /// update the impedance matrix virtual void updateImpedance(); /// impose the normal contact force virtual void applyContactPressure(); /// dump restart file virtual void dumpRestart(const std::string & file_name) const; /// read restart file virtual void readRestart(const std::string & file_name); /// compute the normal gap virtual void computeNormalGap(Array & gap) const { this->computeRelativeNormalField(this->model.getCurrentPosition(), gap); }; /// compute relative normal field (only value that has to be multiplied with the normal) /// relative to master nodes virtual void computeRelativeNormalField(const Array & field, Array & rel_normal_field) const; /// compute relative tangential field (complet array) /// relative to master nodes virtual void computeRelativeTangentialField(const Array & field, Array & rel_tang_field) const; /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /// synchronize arrays virtual void syncArrays(SyncChoice sync_choice); /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: virtual void addDumpFieldToDumper(const std::string & dumper_name, const std::string & field_id); // virtual void addDumpFieldVector(const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(Masters, masters, const SynchronizedArray &) AKANTU_GET_MACRO(LumpedBoundaryMasters, lumped_boundary_masters, const SynchronizedArray &) /// get interface node pairs (*,0) are slaves, (*,1) are masters void getNodePairs(Array & pairs) const; /// get index of node in either slaves or masters array /// if node is in neither of them, return -1 Int getNodeIndex(UInt node) const; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// array of master nodes SynchronizedArray masters; /// lumped boundary of master nodes SynchronizedArray lumped_boundary_masters; // element list for dump and lumped_boundary ElementTypeMapArray master_elements; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "ntn_contact_inline_impl.cc" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const NTNContact & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #endif /* __AST_NTN_CONTACT_HH__ */ diff --git a/src/ntn_contact/ntn_friction.hh b/src/ntn_contact/ntn_friction.hh index a44ca3bce..fbbeb674d 100644 --- a/src/ntn_contact/ntn_friction.hh +++ b/src/ntn_contact/ntn_friction.hh @@ -1,94 +1,91 @@ /** * @file ntn_friction.hh * * @author David Simon Kammer * * * @brief implementation of friction for node to node contact * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ #ifndef __AST_NTN_FRICTION_HH__ #define __AST_NTN_FRICTION_HH__ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_base_friction.hh" #include "ntn_friclaw_coulomb.hh" -__BEGIN_SIMTOOLS__ - -/* -------------------------------------------------------------------------- */ -using namespace akantu; +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template class FrictionLaw = NTNFricLawCoulomb, class Regularisation = NTNFricRegNoRegularisation> class NTNFriction : public FrictionLaw { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: NTNFriction(NTNBaseContact * contact, const FrictionID & id = "friction", const MemoryID & memory_id = 0); virtual ~NTNFriction() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// apply the friction force virtual void applyFrictionTraction(); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; protected: /* ------------------------------------------------------------------------ */ /* Dumpable */ /* ------------------------------------------------------------------------ */ public: // virtual void addDumpFieldToDumper(const std::string & dumper_name, // const std::string & field_id); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator template class FrictionLaw, class Regularisation> inline std::ostream & operator <<(std::ostream & stream, const NTNFriction & _this) { _this.printself(stream); return stream; } -__END_SIMTOOLS__ +__END_AKANTU__ #include "ntn_friction_tmpl.hh" #endif /* __AST_NTN_FRICTION_HH__ */ diff --git a/src/ntn_contact/ntn_friction_tmpl.hh b/src/ntn_contact/ntn_friction_tmpl.hh index 02865c373..358453993 100644 --- a/src/ntn_contact/ntn_friction_tmpl.hh +++ b/src/ntn_contact/ntn_friction_tmpl.hh @@ -1,79 +1,79 @@ /** * @file ntn_friction_tmpl.hh * * @author David Simon Kammer * * * @brief * * @section LICENSE * * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * */ /* -------------------------------------------------------------------------- */ // simtools #include "ntn_contact.hh" -__BEGIN_SIMTOOLS__ +__BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template